Files
openclaw/apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift

3410 lines
84 KiB
Swift
Raw Normal View History

// Generated by scripts/protocol-gen-swift.ts do not edit by hand
// swiftlint:disable file_length
import Foundation
public let GATEWAY_PROTOCOL_VERSION = 3
public enum ErrorCode: String, Codable, Sendable {
case notLinked = "NOT_LINKED"
case notPaired = "NOT_PAIRED"
case agentTimeout = "AGENT_TIMEOUT"
case invalidRequest = "INVALID_REQUEST"
case unavailable = "UNAVAILABLE"
}
public struct ConnectParams: Codable, Sendable {
public let minprotocol: Int
public let maxprotocol: Int
public let client: [String: AnyCodable]
public let caps: [String]?
public let commands: [String]?
public let permissions: [String: AnyCodable]?
2026-01-21 22:57:56 +00:00
public let pathenv: String?
public let role: String?
public let scopes: [String]?
public let device: [String: AnyCodable]?
public let auth: [String: AnyCodable]?
public let locale: String?
public let useragent: String?
public init(
minprotocol: Int,
maxprotocol: Int,
client: [String: AnyCodable],
caps: [String]?,
commands: [String]?,
permissions: [String: AnyCodable]?,
2026-01-21 22:57:56 +00:00
pathenv: String?,
role: String?,
scopes: [String]?,
device: [String: AnyCodable]?,
auth: [String: AnyCodable]?,
locale: String?,
useragent: String?)
{
self.minprotocol = minprotocol
self.maxprotocol = maxprotocol
self.client = client
self.caps = caps
self.commands = commands
self.permissions = permissions
2026-01-21 22:57:56 +00:00
self.pathenv = pathenv
self.role = role
self.scopes = scopes
self.device = device
self.auth = auth
self.locale = locale
self.useragent = useragent
}
private enum CodingKeys: String, CodingKey {
case minprotocol = "minProtocol"
case maxprotocol = "maxProtocol"
case client
case caps
case commands
case permissions
2026-01-21 22:57:56 +00:00
case pathenv = "pathEnv"
case role
case scopes
case device
case auth
case locale
case useragent = "userAgent"
}
}
public struct HelloOk: Codable, Sendable {
public let type: String
public let _protocol: Int
public let server: [String: AnyCodable]
public let features: [String: AnyCodable]
public let snapshot: Snapshot
public let canvashosturl: String?
public let auth: [String: AnyCodable]?
public let policy: [String: AnyCodable]
public init(
type: String,
_protocol: Int,
server: [String: AnyCodable],
features: [String: AnyCodable],
snapshot: Snapshot,
canvashosturl: String?,
auth: [String: AnyCodable]?,
policy: [String: AnyCodable])
{
self.type = type
self._protocol = _protocol
self.server = server
self.features = features
self.snapshot = snapshot
self.canvashosturl = canvashosturl
self.auth = auth
self.policy = policy
}
private enum CodingKeys: String, CodingKey {
case type
case _protocol = "protocol"
case server
case features
case snapshot
case canvashosturl = "canvasHostUrl"
case auth
case policy
}
}
public struct RequestFrame: Codable, Sendable {
public let type: String
public let id: String
public let method: String
public let params: AnyCodable?
public init(
type: String,
id: String,
method: String,
params: AnyCodable?)
{
self.type = type
self.id = id
self.method = method
self.params = params
}
private enum CodingKeys: String, CodingKey {
case type
case id
case method
case params
}
}
public struct ResponseFrame: Codable, Sendable {
public let type: String
public let id: String
public let ok: Bool
public let payload: AnyCodable?
public let error: [String: AnyCodable]?
public init(
type: String,
id: String,
ok: Bool,
payload: AnyCodable?,
error: [String: AnyCodable]?)
{
self.type = type
self.id = id
self.ok = ok
self.payload = payload
self.error = error
}
private enum CodingKeys: String, CodingKey {
case type
case id
case ok
case payload
case error
}
}
public struct EventFrame: Codable, Sendable {
public let type: String
public let event: String
public let payload: AnyCodable?
public let seq: Int?
public let stateversion: [String: AnyCodable]?
public init(
type: String,
event: String,
payload: AnyCodable?,
seq: Int?,
stateversion: [String: AnyCodable]?)
{
self.type = type
self.event = event
self.payload = payload
self.seq = seq
self.stateversion = stateversion
}
private enum CodingKeys: String, CodingKey {
case type
case event
case payload
case seq
case stateversion = "stateVersion"
}
}
public struct PresenceEntry: Codable, Sendable {
public let host: String?
public let ip: String?
public let version: String?
public let platform: String?
public let devicefamily: String?
public let modelidentifier: String?
public let mode: String?
public let lastinputseconds: Int?
public let reason: String?
public let tags: [String]?
public let text: String?
public let ts: Int
2026-01-20 12:16:36 +00:00
public let deviceid: String?
public let roles: [String]?
public let scopes: [String]?
public let instanceid: String?
public init(
host: String?,
ip: String?,
version: String?,
platform: String?,
devicefamily: String?,
modelidentifier: String?,
mode: String?,
lastinputseconds: Int?,
reason: String?,
tags: [String]?,
text: String?,
ts: Int,
2026-01-20 12:16:36 +00:00
deviceid: String?,
roles: [String]?,
scopes: [String]?,
instanceid: String?)
{
self.host = host
self.ip = ip
self.version = version
self.platform = platform
self.devicefamily = devicefamily
self.modelidentifier = modelidentifier
self.mode = mode
self.lastinputseconds = lastinputseconds
self.reason = reason
self.tags = tags
self.text = text
self.ts = ts
2026-01-20 12:16:36 +00:00
self.deviceid = deviceid
self.roles = roles
self.scopes = scopes
self.instanceid = instanceid
}
private enum CodingKeys: String, CodingKey {
case host
case ip
case version
case platform
case devicefamily = "deviceFamily"
case modelidentifier = "modelIdentifier"
case mode
case lastinputseconds = "lastInputSeconds"
case reason
case tags
case text
case ts
2026-01-20 12:16:36 +00:00
case deviceid = "deviceId"
case roles
case scopes
case instanceid = "instanceId"
}
}
public struct StateVersion: Codable, Sendable {
public let presence: Int
public let health: Int
public init(
presence: Int,
health: Int)
{
self.presence = presence
self.health = health
}
private enum CodingKeys: String, CodingKey {
case presence
case health
}
}
public struct Snapshot: Codable, Sendable {
public let presence: [PresenceEntry]
public let health: AnyCodable
public let stateversion: StateVersion
public let uptimems: Int
public let configpath: String?
public let statedir: String?
public let sessiondefaults: [String: AnyCodable]?
public let authmode: AnyCodable?
public let updateavailable: [String: AnyCodable]?
public init(
presence: [PresenceEntry],
health: AnyCodable,
stateversion: StateVersion,
uptimems: Int,
configpath: String?,
statedir: String?,
sessiondefaults: [String: AnyCodable]?,
authmode: AnyCodable?,
updateavailable: [String: AnyCodable]?)
{
self.presence = presence
self.health = health
self.stateversion = stateversion
self.uptimems = uptimems
self.configpath = configpath
self.statedir = statedir
self.sessiondefaults = sessiondefaults
self.authmode = authmode
self.updateavailable = updateavailable
}
private enum CodingKeys: String, CodingKey {
case presence
case health
case stateversion = "stateVersion"
case uptimems = "uptimeMs"
case configpath = "configPath"
case statedir = "stateDir"
case sessiondefaults = "sessionDefaults"
case authmode = "authMode"
case updateavailable = "updateAvailable"
}
}
public struct ErrorShape: Codable, Sendable {
public let code: String
public let message: String
public let details: AnyCodable?
public let retryable: Bool?
public let retryafterms: Int?
public init(
code: String,
message: String,
details: AnyCodable?,
retryable: Bool?,
retryafterms: Int?)
{
self.code = code
self.message = message
self.details = details
self.retryable = retryable
self.retryafterms = retryafterms
}
private enum CodingKeys: String, CodingKey {
case code
case message
case details
case retryable
case retryafterms = "retryAfterMs"
}
}
public struct AgentEvent: Codable, Sendable {
public let runid: String
public let seq: Int
public let stream: String
public let ts: Int
public let data: [String: AnyCodable]
public init(
runid: String,
seq: Int,
stream: String,
ts: Int,
data: [String: AnyCodable])
{
self.runid = runid
self.seq = seq
self.stream = stream
self.ts = ts
self.data = data
}
private enum CodingKeys: String, CodingKey {
case runid = "runId"
case seq
case stream
case ts
case data
}
}
public struct SendParams: Codable, Sendable {
public let to: String
public let message: String?
public let mediaurl: String?
2026-01-24 05:40:49 +00:00
public let mediaurls: [String]?
public let gifplayback: Bool?
public let channel: String?
public let accountid: String?
public let agentid: String?
public let threadid: String?
public let sessionkey: String?
public let idempotencykey: String
public init(
to: String,
message: String?,
mediaurl: String?,
2026-01-24 05:40:49 +00:00
mediaurls: [String]?,
gifplayback: Bool?,
channel: String?,
accountid: String?,
agentid: String?,
threadid: String?,
sessionkey: String?,
idempotencykey: String)
{
self.to = to
self.message = message
self.mediaurl = mediaurl
2026-01-24 05:40:49 +00:00
self.mediaurls = mediaurls
self.gifplayback = gifplayback
self.channel = channel
self.accountid = accountid
self.agentid = agentid
self.threadid = threadid
self.sessionkey = sessionkey
self.idempotencykey = idempotencykey
}
private enum CodingKeys: String, CodingKey {
case to
case message
case mediaurl = "mediaUrl"
2026-01-24 05:40:49 +00:00
case mediaurls = "mediaUrls"
case gifplayback = "gifPlayback"
case channel
case accountid = "accountId"
case agentid = "agentId"
case threadid = "threadId"
case sessionkey = "sessionKey"
case idempotencykey = "idempotencyKey"
}
}
public struct PollParams: Codable, Sendable {
public let to: String
public let question: String
public let options: [String]
public let maxselections: Int?
public let durationseconds: Int?
public let durationhours: Int?
public let silent: Bool?
public let isanonymous: Bool?
public let threadid: String?
public let channel: String?
public let accountid: String?
public let idempotencykey: String
public init(
to: String,
question: String,
options: [String],
maxselections: Int?,
durationseconds: Int?,
durationhours: Int?,
silent: Bool?,
isanonymous: Bool?,
threadid: String?,
channel: String?,
accountid: String?,
idempotencykey: String)
{
self.to = to
self.question = question
self.options = options
self.maxselections = maxselections
self.durationseconds = durationseconds
self.durationhours = durationhours
self.silent = silent
self.isanonymous = isanonymous
self.threadid = threadid
self.channel = channel
self.accountid = accountid
self.idempotencykey = idempotencykey
}
private enum CodingKeys: String, CodingKey {
case to
case question
case options
case maxselections = "maxSelections"
case durationseconds = "durationSeconds"
case durationhours = "durationHours"
case silent
case isanonymous = "isAnonymous"
case threadid = "threadId"
case channel
case accountid = "accountId"
case idempotencykey = "idempotencyKey"
}
}
public struct AgentParams: Codable, Sendable {
public let message: String
public let agentid: String?
public let to: String?
public let replyto: String?
public let sessionid: String?
public let sessionkey: String?
public let thinking: String?
public let deliver: Bool?
public let attachments: [AnyCodable]?
public let channel: String?
public let replychannel: String?
public let accountid: String?
public let replyaccountid: String?
2026-01-21 00:19:39 +00:00
public let threadid: String?
2026-01-24 06:01:19 +00:00
public let groupid: String?
public let groupchannel: String?
public let groupspace: String?
public let timeout: Int?
public let besteffortdeliver: Bool?
public let lane: String?
public let extrasystemprompt: String?
public let internalevents: [[String: AnyCodable]]?
public let inputprovenance: [String: AnyCodable]?
public let idempotencykey: String
public let label: String?
public let spawnedby: String?
public init(
message: String,
agentid: String?,
to: String?,
replyto: String?,
sessionid: String?,
sessionkey: String?,
thinking: String?,
deliver: Bool?,
attachments: [AnyCodable]?,
channel: String?,
replychannel: String?,
accountid: String?,
replyaccountid: String?,
2026-01-21 00:19:39 +00:00
threadid: String?,
2026-01-24 06:01:19 +00:00
groupid: String?,
groupchannel: String?,
groupspace: String?,
timeout: Int?,
besteffortdeliver: Bool?,
lane: String?,
extrasystemprompt: String?,
internalevents: [[String: AnyCodable]]?,
inputprovenance: [String: AnyCodable]?,
idempotencykey: String,
label: String?,
spawnedby: String?)
{
self.message = message
self.agentid = agentid
self.to = to
self.replyto = replyto
self.sessionid = sessionid
self.sessionkey = sessionkey
self.thinking = thinking
self.deliver = deliver
self.attachments = attachments
self.channel = channel
self.replychannel = replychannel
self.accountid = accountid
self.replyaccountid = replyaccountid
2026-01-21 00:19:39 +00:00
self.threadid = threadid
2026-01-24 06:01:19 +00:00
self.groupid = groupid
self.groupchannel = groupchannel
self.groupspace = groupspace
self.timeout = timeout
self.besteffortdeliver = besteffortdeliver
self.lane = lane
self.extrasystemprompt = extrasystemprompt
self.internalevents = internalevents
self.inputprovenance = inputprovenance
self.idempotencykey = idempotencykey
self.label = label
self.spawnedby = spawnedby
}
private enum CodingKeys: String, CodingKey {
case message
case agentid = "agentId"
case to
case replyto = "replyTo"
case sessionid = "sessionId"
case sessionkey = "sessionKey"
case thinking
case deliver
case attachments
case channel
case replychannel = "replyChannel"
case accountid = "accountId"
case replyaccountid = "replyAccountId"
2026-01-21 00:19:39 +00:00
case threadid = "threadId"
2026-01-24 06:01:19 +00:00
case groupid = "groupId"
case groupchannel = "groupChannel"
case groupspace = "groupSpace"
case timeout
case besteffortdeliver = "bestEffortDeliver"
case lane
case extrasystemprompt = "extraSystemPrompt"
case internalevents = "internalEvents"
case inputprovenance = "inputProvenance"
case idempotencykey = "idempotencyKey"
case label
case spawnedby = "spawnedBy"
}
}
2026-01-22 07:22:56 +00:00
public struct AgentIdentityParams: Codable, Sendable {
public let agentid: String?
public let sessionkey: String?
public init(
agentid: String?,
sessionkey: String?)
{
2026-01-22 07:22:56 +00:00
self.agentid = agentid
self.sessionkey = sessionkey
}
2026-01-22 07:22:56 +00:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case sessionkey = "sessionKey"
}
}
public struct AgentIdentityResult: Codable, Sendable {
public let agentid: String
public let name: String?
public let avatar: String?
2026-02-02 21:44:31 -05:00
public let emoji: String?
2026-01-22 07:22:56 +00:00
public init(
agentid: String,
name: String?,
2026-02-02 21:44:31 -05:00
avatar: String?,
emoji: String?)
{
2026-01-22 07:22:56 +00:00
self.agentid = agentid
self.name = name
self.avatar = avatar
2026-02-02 21:44:31 -05:00
self.emoji = emoji
2026-01-22 07:22:56 +00:00
}
2026-01-22 07:22:56 +00:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case name
case avatar
2026-02-02 21:44:31 -05:00
case emoji
2026-01-22 07:22:56 +00:00
}
}
public struct AgentWaitParams: Codable, Sendable {
public let runid: String
public let timeoutms: Int?
public init(
runid: String,
timeoutms: Int?)
{
self.runid = runid
self.timeoutms = timeoutms
}
private enum CodingKeys: String, CodingKey {
case runid = "runId"
case timeoutms = "timeoutMs"
}
}
public struct WakeParams: Codable, Sendable {
public let mode: AnyCodable
public let text: String
public init(
mode: AnyCodable,
text: String)
{
self.mode = mode
self.text = text
}
private enum CodingKeys: String, CodingKey {
case mode
case text
}
}
public struct NodePairRequestParams: Codable, Sendable {
public let nodeid: String
public let displayname: String?
public let platform: String?
public let version: String?
public let coreversion: String?
public let uiversion: String?
public let devicefamily: String?
public let modelidentifier: String?
public let caps: [String]?
public let commands: [String]?
public let remoteip: String?
public let silent: Bool?
public init(
nodeid: String,
displayname: String?,
platform: String?,
version: String?,
coreversion: String?,
uiversion: String?,
devicefamily: String?,
modelidentifier: String?,
caps: [String]?,
commands: [String]?,
remoteip: String?,
silent: Bool?)
{
self.nodeid = nodeid
self.displayname = displayname
self.platform = platform
self.version = version
self.coreversion = coreversion
self.uiversion = uiversion
self.devicefamily = devicefamily
self.modelidentifier = modelidentifier
self.caps = caps
self.commands = commands
self.remoteip = remoteip
self.silent = silent
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case displayname = "displayName"
case platform
case version
case coreversion = "coreVersion"
case uiversion = "uiVersion"
case devicefamily = "deviceFamily"
case modelidentifier = "modelIdentifier"
case caps
case commands
case remoteip = "remoteIp"
case silent
}
}
public struct NodePairListParams: Codable, Sendable {}
public struct NodePairApproveParams: Codable, Sendable {
public let requestid: String
public init(
requestid: String)
{
self.requestid = requestid
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
}
}
public struct NodePairRejectParams: Codable, Sendable {
public let requestid: String
public init(
requestid: String)
{
self.requestid = requestid
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
}
}
public struct NodePairVerifyParams: Codable, Sendable {
public let nodeid: String
public let token: String
public init(
nodeid: String,
token: String)
{
self.nodeid = nodeid
self.token = token
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case token
}
}
public struct NodeRenameParams: Codable, Sendable {
public let nodeid: String
public let displayname: String
public init(
nodeid: String,
displayname: String)
{
self.nodeid = nodeid
self.displayname = displayname
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case displayname = "displayName"
}
}
public struct NodeListParams: Codable, Sendable {}
public struct NodeDescribeParams: Codable, Sendable {
public let nodeid: String
public init(
nodeid: String)
{
self.nodeid = nodeid
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
}
}
public struct NodeInvokeParams: Codable, Sendable {
public let nodeid: String
public let command: String
public let params: AnyCodable?
public let timeoutms: Int?
public let idempotencykey: String
public init(
nodeid: String,
command: String,
params: AnyCodable?,
timeoutms: Int?,
idempotencykey: String)
{
self.nodeid = nodeid
self.command = command
self.params = params
self.timeoutms = timeoutms
self.idempotencykey = idempotencykey
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case command
case params
case timeoutms = "timeoutMs"
case idempotencykey = "idempotencyKey"
}
}
public struct NodeInvokeResultParams: Codable, Sendable {
public let id: String
public let nodeid: String
public let ok: Bool
public let payload: AnyCodable?
public let payloadjson: String?
public let error: [String: AnyCodable]?
public init(
id: String,
nodeid: String,
ok: Bool,
payload: AnyCodable?,
payloadjson: String?,
error: [String: AnyCodable]?)
{
self.id = id
self.nodeid = nodeid
self.ok = ok
self.payload = payload
self.payloadjson = payloadjson
self.error = error
}
private enum CodingKeys: String, CodingKey {
case id
case nodeid = "nodeId"
case ok
case payload
case payloadjson = "payloadJSON"
case error
}
}
public struct NodeEventParams: Codable, Sendable {
public let event: String
public let payload: AnyCodable?
public let payloadjson: String?
public init(
event: String,
payload: AnyCodable?,
payloadjson: String?)
{
self.event = event
self.payload = payload
self.payloadjson = payloadjson
}
private enum CodingKeys: String, CodingKey {
case event
case payload
case payloadjson = "payloadJSON"
}
}
public struct NodeInvokeRequestEvent: Codable, Sendable {
public let id: String
public let nodeid: String
public let command: String
public let paramsjson: String?
public let timeoutms: Int?
public let idempotencykey: String?
public init(
id: String,
nodeid: String,
command: String,
paramsjson: String?,
timeoutms: Int?,
idempotencykey: String?)
{
self.id = id
self.nodeid = nodeid
self.command = command
self.paramsjson = paramsjson
self.timeoutms = timeoutms
self.idempotencykey = idempotencykey
}
private enum CodingKeys: String, CodingKey {
case id
case nodeid = "nodeId"
case command
case paramsjson = "paramsJSON"
case timeoutms = "timeoutMs"
case idempotencykey = "idempotencyKey"
}
}
public struct PushTestParams: Codable, Sendable {
public let nodeid: String
public let title: String?
public let body: String?
public let environment: String?
public init(
nodeid: String,
title: String?,
body: String?,
environment: String?)
{
self.nodeid = nodeid
self.title = title
self.body = body
self.environment = environment
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case title
case body
case environment
}
}
public struct PushTestResult: Codable, Sendable {
public let ok: Bool
public let status: Int
public let apnsid: String?
public let reason: String?
public let tokensuffix: String
public let topic: String
public let environment: String
public init(
ok: Bool,
status: Int,
apnsid: String?,
reason: String?,
tokensuffix: String,
topic: String,
environment: String)
{
self.ok = ok
self.status = status
self.apnsid = apnsid
self.reason = reason
self.tokensuffix = tokensuffix
self.topic = topic
self.environment = environment
}
private enum CodingKeys: String, CodingKey {
case ok
case status
case apnsid = "apnsId"
case reason
case tokensuffix = "tokenSuffix"
case topic
case environment
}
}
feat(secrets): expand SecretRef coverage across user-supplied credentials (#29580) * feat(secrets): expand secret target coverage and gateway tooling * docs(secrets): align gateway and CLI secret docs * chore(protocol): regenerate swift gateway models for secrets methods * fix(config): restore talk apiKey fallback and stabilize runner test * ci(windows): reduce test worker count for shard stability * ci(windows): raise node heap for test shard stability * test(feishu): make proxy env precedence assertion windows-safe * fix(gateway): resolve auth password SecretInput refs for clients * fix(gateway): resolve remote SecretInput credentials for clients * fix(secrets): skip inactive refs in command snapshot assignments * fix(secrets): scope gateway.remote refs to effective auth surfaces * fix(secrets): ignore memory defaults when enabled agents disable search * fix(secrets): honor Google Chat serviceAccountRef inheritance * fix(secrets): address tsgo errors in command and gateway collectors * fix(secrets): avoid auth-store load in providers-only configure * fix(gateway): defer local password ref resolution by precedence * fix(secrets): gate telegram webhook secret refs by webhook mode * fix(secrets): gate slack signing secret refs to http mode * fix(secrets): skip telegram botToken refs when tokenFile is set * fix(secrets): gate discord pluralkit refs by enabled flag * fix(secrets): gate discord voice tts refs by voice enabled * test(secrets): make runtime fixture modes explicit * fix(cli): resolve local qr password secret refs * fix(cli): fail when gateway leaves command refs unresolved * fix(gateway): fail when local password SecretRef is unresolved * fix(gateway): fail when required remote SecretRefs are unresolved * fix(gateway): resolve local password refs only when password can win * fix(cli): skip local password SecretRef resolution on qr token override * test(gateway): cast SecretRef fixtures to OpenClawConfig * test(secrets): activate mode-gated targets in runtime coverage fixture * fix(cron): support SecretInput webhook tokens safely * fix(bluebubbles): support SecretInput passwords across config paths * fix(msteams): make appPassword SecretInput-safe in onboarding/token paths * fix(bluebubbles): align SecretInput schema helper typing * fix(cli): clarify secrets.resolve version-skew errors * refactor(secrets): return structured inactive paths from secrets.resolve * refactor(gateway): type onboarding secret writes as SecretInput * chore(protocol): regenerate swift models for secrets.resolve * feat(secrets): expand extension credential secretref support * fix(secrets): gate web-search refs by active provider * fix(onboarding): detect SecretRef credentials in extension status * fix(onboarding): allow keeping existing ref in secret prompt * fix(onboarding): resolve gateway password SecretRefs for probe and tui * fix(onboarding): honor secret-input-mode for local gateway auth * fix(acp): resolve gateway SecretInput credentials * fix(secrets): gate gateway.remote refs to remote surfaces * test(secrets): cover pattern matching and inactive array refs * docs(secrets): clarify secrets.resolve and remote active surfaces * fix(bluebubbles): keep existing SecretRef during onboarding * fix(tests): resolve CI type errors in new SecretRef coverage * fix(extensions): replace raw fetch with SSRF-guarded fetch * test(secrets): mark gateway remote targets active in runtime coverage * test(infra): normalize home-prefix expectation across platforms * fix(cli): only resolve local qr password refs in password mode * test(cli): cover local qr token mode with unresolved password ref * docs(cli): clarify local qr password ref resolution behavior * refactor(extensions): reuse sdk SecretInput helpers * fix(wizard): resolve onboarding env-template secrets before plaintext * fix(cli): surface secrets.resolve diagnostics in memory and qr * test(secrets): repair post-rebase runtime and fixtures * fix(gateway): skip remote password ref resolution when token wins * fix(secrets): treat tailscale remote gateway refs as active * fix(gateway): allow remote password fallback when token ref is unresolved * fix(gateway): ignore stale local password refs for none and trusted-proxy * fix(gateway): skip remote secret ref resolution on local call paths * test(cli): cover qr remote tailscale secret ref resolution * fix(secrets): align gateway password active-surface with auth inference * fix(cli): resolve inferred local gateway password refs in qr * fix(gateway): prefer resolvable remote password over token ref pre-resolution * test(gateway): cover none and trusted-proxy stale password refs * docs(secrets): sync qr and gateway active-surface behavior * fix: restore stability blockers from pre-release audit * Secrets: fix collector/runtime precedence contradictions * docs: align secrets and web credential docs * fix(rebase): resolve integration regressions after main rebase * fix(node-host): resolve gateway secret refs for auth * fix(secrets): harden secretinput runtime readers * gateway: skip inactive auth secretref resolution * cli: avoid gateway preflight for inactive secret refs * extensions: allow unresolved refs in onboarding status * tests: fix qr-cli module mock hoist ordering * Security: align audit checks with SecretInput resolution * Gateway: resolve local-mode remote fallback secret refs * Node host: avoid resolving inactive password secret refs * Secrets runtime: mark Slack appToken inactive for HTTP mode * secrets: keep inactive gateway remote refs non-blocking * cli: include agent memory secret targets in runtime resolution * docs(secrets): sync docs with active-surface and web search behavior * fix(secrets): keep telegram top-level token refs active for blank account tokens * fix(daemon): resolve gateway password secret refs for probe auth * fix(secrets): skip IRC NickServ ref resolution when NickServ is disabled * fix(secrets): align token inheritance and exec timeout defaults * docs(secrets): clarify active-surface notes in cli docs * cli: require secrets.resolve gateway capability * gateway: log auth secret surface diagnostics * secrets: remove dead provider resolver module * fix(secrets): restore gateway auth precedence and fallback resolution * fix(tests): align plugin runtime mock typings --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-03-02 20:58:20 -06:00
public struct SecretsReloadParams: Codable, Sendable {}
public struct SecretsResolveParams: Codable, Sendable {
public let commandname: String
public let targetids: [String]
public init(
commandname: String,
targetids: [String])
{
self.commandname = commandname
self.targetids = targetids
}
private enum CodingKeys: String, CodingKey {
case commandname = "commandName"
case targetids = "targetIds"
}
}
public struct SecretsResolveAssignment: Codable, Sendable {
public let path: String?
public let pathsegments: [String]
public let value: AnyCodable
public init(
path: String?,
pathsegments: [String],
value: AnyCodable)
{
self.path = path
self.pathsegments = pathsegments
self.value = value
}
private enum CodingKeys: String, CodingKey {
case path
case pathsegments = "pathSegments"
case value
}
}
public struct SecretsResolveResult: Codable, Sendable {
public let ok: Bool?
public let assignments: [SecretsResolveAssignment]?
public let diagnostics: [String]?
public let inactiverefpaths: [String]?
public init(
ok: Bool?,
assignments: [SecretsResolveAssignment]?,
diagnostics: [String]?,
inactiverefpaths: [String]?)
{
self.ok = ok
self.assignments = assignments
self.diagnostics = diagnostics
self.inactiverefpaths = inactiverefpaths
}
private enum CodingKeys: String, CodingKey {
case ok
case assignments
case diagnostics
case inactiverefpaths = "inactiveRefPaths"
}
}
public struct SessionsListParams: Codable, Sendable {
public let limit: Int?
public let activeminutes: Int?
public let includeglobal: Bool?
public let includeunknown: Bool?
2026-01-21 00:19:39 +00:00
public let includederivedtitles: Bool?
public let includelastmessage: Bool?
public let label: String?
public let spawnedby: String?
public let agentid: String?
2026-01-21 00:19:39 +00:00
public let search: String?
public init(
limit: Int?,
activeminutes: Int?,
includeglobal: Bool?,
includeunknown: Bool?,
2026-01-21 00:19:39 +00:00
includederivedtitles: Bool?,
includelastmessage: Bool?,
label: String?,
spawnedby: String?,
2026-01-21 00:19:39 +00:00
agentid: String?,
search: String?)
{
self.limit = limit
self.activeminutes = activeminutes
self.includeglobal = includeglobal
self.includeunknown = includeunknown
2026-01-21 00:19:39 +00:00
self.includederivedtitles = includederivedtitles
self.includelastmessage = includelastmessage
self.label = label
self.spawnedby = spawnedby
self.agentid = agentid
2026-01-21 00:19:39 +00:00
self.search = search
}
private enum CodingKeys: String, CodingKey {
case limit
case activeminutes = "activeMinutes"
case includeglobal = "includeGlobal"
case includeunknown = "includeUnknown"
2026-01-21 00:19:39 +00:00
case includederivedtitles = "includeDerivedTitles"
case includelastmessage = "includeLastMessage"
case label
case spawnedby = "spawnedBy"
case agentid = "agentId"
2026-01-21 00:19:39 +00:00
case search
}
}
2026-01-22 11:02:03 +00:00
public struct SessionsPreviewParams: Codable, Sendable {
public let keys: [String]
public let limit: Int?
public let maxchars: Int?
public init(
keys: [String],
limit: Int?,
maxchars: Int?)
{
2026-01-22 11:02:03 +00:00
self.keys = keys
self.limit = limit
self.maxchars = maxchars
}
2026-01-22 11:02:03 +00:00
private enum CodingKeys: String, CodingKey {
case keys
case limit
case maxchars = "maxChars"
}
}
public struct SessionsResolveParams: Codable, Sendable {
public let key: String?
2026-01-24 11:27:55 +00:00
public let sessionid: String?
public let label: String?
public let agentid: String?
public let spawnedby: String?
public let includeglobal: Bool?
public let includeunknown: Bool?
public init(
key: String?,
2026-01-24 11:27:55 +00:00
sessionid: String?,
label: String?,
agentid: String?,
spawnedby: String?,
includeglobal: Bool?,
includeunknown: Bool?)
{
self.key = key
2026-01-24 11:27:55 +00:00
self.sessionid = sessionid
self.label = label
self.agentid = agentid
self.spawnedby = spawnedby
self.includeglobal = includeglobal
self.includeunknown = includeunknown
}
private enum CodingKeys: String, CodingKey {
case key
2026-01-24 11:27:55 +00:00
case sessionid = "sessionId"
case label
case agentid = "agentId"
case spawnedby = "spawnedBy"
case includeglobal = "includeGlobal"
case includeunknown = "includeUnknown"
}
}
public struct SessionsPatchParams: Codable, Sendable {
public let key: String
public let label: AnyCodable?
public let thinkinglevel: AnyCodable?
public let verboselevel: AnyCodable?
public let reasoninglevel: AnyCodable?
public let responseusage: AnyCodable?
public let elevatedlevel: AnyCodable?
public let exechost: AnyCodable?
public let execsecurity: AnyCodable?
public let execask: AnyCodable?
public let execnode: AnyCodable?
public let model: AnyCodable?
public let spawnedby: AnyCodable?
public let spawndepth: AnyCodable?
public let sendpolicy: AnyCodable?
public let groupactivation: AnyCodable?
public init(
key: String,
label: AnyCodable?,
thinkinglevel: AnyCodable?,
verboselevel: AnyCodable?,
reasoninglevel: AnyCodable?,
responseusage: AnyCodable?,
elevatedlevel: AnyCodable?,
exechost: AnyCodable?,
execsecurity: AnyCodable?,
execask: AnyCodable?,
execnode: AnyCodable?,
model: AnyCodable?,
spawnedby: AnyCodable?,
spawndepth: AnyCodable?,
sendpolicy: AnyCodable?,
groupactivation: AnyCodable?)
{
self.key = key
self.label = label
self.thinkinglevel = thinkinglevel
self.verboselevel = verboselevel
self.reasoninglevel = reasoninglevel
self.responseusage = responseusage
self.elevatedlevel = elevatedlevel
self.exechost = exechost
self.execsecurity = execsecurity
self.execask = execask
self.execnode = execnode
self.model = model
self.spawnedby = spawnedby
self.spawndepth = spawndepth
self.sendpolicy = sendpolicy
self.groupactivation = groupactivation
}
private enum CodingKeys: String, CodingKey {
case key
case label
case thinkinglevel = "thinkingLevel"
case verboselevel = "verboseLevel"
case reasoninglevel = "reasoningLevel"
case responseusage = "responseUsage"
case elevatedlevel = "elevatedLevel"
case exechost = "execHost"
case execsecurity = "execSecurity"
case execask = "execAsk"
case execnode = "execNode"
case model
case spawnedby = "spawnedBy"
case spawndepth = "spawnDepth"
case sendpolicy = "sendPolicy"
case groupactivation = "groupActivation"
}
}
public struct SessionsResetParams: Codable, Sendable {
public let key: String
public let reason: AnyCodable?
public init(
key: String,
reason: AnyCodable?)
{
self.key = key
self.reason = reason
}
private enum CodingKeys: String, CodingKey {
case key
case reason
}
}
public struct SessionsDeleteParams: Codable, Sendable {
public let key: String
public let deletetranscript: Bool?
feat: thread-bound subagents on Discord (#21805) * docs: thread-bound subagents plan * docs: add exact thread-bound subagent implementation touchpoints * Docs: prioritize auto thread-bound subagent flow * Docs: add ACP harness thread-binding extensions * Discord: add thread-bound session routing and auto-bind spawn flow * Subagents: add focus commands and ACP/session binding lifecycle hooks * Tests: cover thread bindings, focus commands, and ACP unbind hooks * Docs: add plugin-hook appendix for thread-bound subagents * Plugins: add subagent lifecycle hook events * Core: emit subagent lifecycle hooks and decouple Discord bindings * Discord: handle subagent bind lifecycle via plugin hooks * Subagents: unify completion finalizer and split registry modules * Add subagent lifecycle events module * Hooks: fix subagent ended context key * Discord: share thread bindings across ESM and Jiti * Subagents: add persistent sessions_spawn mode for thread-bound sessions * Subagents: clarify thread intro and persistent completion copy * test(subagents): stabilize sessions_spawn lifecycle cleanup assertions * Discord: add thread-bound session TTL with auto-unfocus * Subagents: fail session spawns when thread bind fails * Subagents: cover thread session failure cleanup paths * Session: add thread binding TTL config and /session ttl controls * Tests: align discord reaction expectations * Agent: persist sessionFile for keyed subagent sessions * Discord: normalize imports after conflict resolution * Sessions: centralize sessionFile resolve/persist helper * Discord: harden thread-bound subagent session routing * Rebase: resolve upstream/main conflicts * Subagents: move thread binding into hooks and split bindings modules * Docs: add channel-agnostic subagent routing hook plan * Agents: decouple subagent routing from Discord * Discord: refactor thread-bound subagent flows * Subagents: prevent duplicate end hooks and orphaned failed sessions * Refactor: split subagent command and provider phases * Subagents: honor hook delivery target overrides * Discord: add thread binding kill switches and refresh plan doc * Discord: fix thread bind channel resolution * Routing: centralize account id normalization * Discord: clean up thread bindings on startup failures * Discord: add startup cleanup regression tests * Docs: add long-term thread-bound subagent architecture * Docs: split session binding plan and dedupe thread-bound doc * Subagents: add channel-agnostic session binding routing * Subagents: stabilize announce completion routing tests * Subagents: cover multi-bound completion routing * Subagents: suppress lifecycle hooks on failed thread bind * tests: fix discord provider mock typing regressions * docs/protocol: sync slash command aliases and delete param models * fix: add changelog entry for Discord thread-bound subagents (#21805) (thanks @onutc) --------- Co-authored-by: Shadow <hi@shadowing.dev>
2026-02-21 16:14:55 +01:00
public let emitlifecyclehooks: Bool?
public init(
key: String,
feat: thread-bound subagents on Discord (#21805) * docs: thread-bound subagents plan * docs: add exact thread-bound subagent implementation touchpoints * Docs: prioritize auto thread-bound subagent flow * Docs: add ACP harness thread-binding extensions * Discord: add thread-bound session routing and auto-bind spawn flow * Subagents: add focus commands and ACP/session binding lifecycle hooks * Tests: cover thread bindings, focus commands, and ACP unbind hooks * Docs: add plugin-hook appendix for thread-bound subagents * Plugins: add subagent lifecycle hook events * Core: emit subagent lifecycle hooks and decouple Discord bindings * Discord: handle subagent bind lifecycle via plugin hooks * Subagents: unify completion finalizer and split registry modules * Add subagent lifecycle events module * Hooks: fix subagent ended context key * Discord: share thread bindings across ESM and Jiti * Subagents: add persistent sessions_spawn mode for thread-bound sessions * Subagents: clarify thread intro and persistent completion copy * test(subagents): stabilize sessions_spawn lifecycle cleanup assertions * Discord: add thread-bound session TTL with auto-unfocus * Subagents: fail session spawns when thread bind fails * Subagents: cover thread session failure cleanup paths * Session: add thread binding TTL config and /session ttl controls * Tests: align discord reaction expectations * Agent: persist sessionFile for keyed subagent sessions * Discord: normalize imports after conflict resolution * Sessions: centralize sessionFile resolve/persist helper * Discord: harden thread-bound subagent session routing * Rebase: resolve upstream/main conflicts * Subagents: move thread binding into hooks and split bindings modules * Docs: add channel-agnostic subagent routing hook plan * Agents: decouple subagent routing from Discord * Discord: refactor thread-bound subagent flows * Subagents: prevent duplicate end hooks and orphaned failed sessions * Refactor: split subagent command and provider phases * Subagents: honor hook delivery target overrides * Discord: add thread binding kill switches and refresh plan doc * Discord: fix thread bind channel resolution * Routing: centralize account id normalization * Discord: clean up thread bindings on startup failures * Discord: add startup cleanup regression tests * Docs: add long-term thread-bound subagent architecture * Docs: split session binding plan and dedupe thread-bound doc * Subagents: add channel-agnostic session binding routing * Subagents: stabilize announce completion routing tests * Subagents: cover multi-bound completion routing * Subagents: suppress lifecycle hooks on failed thread bind * tests: fix discord provider mock typing regressions * docs/protocol: sync slash command aliases and delete param models * fix: add changelog entry for Discord thread-bound subagents (#21805) (thanks @onutc) --------- Co-authored-by: Shadow <hi@shadowing.dev>
2026-02-21 16:14:55 +01:00
deletetranscript: Bool?,
emitlifecyclehooks: Bool?)
{
self.key = key
self.deletetranscript = deletetranscript
feat: thread-bound subagents on Discord (#21805) * docs: thread-bound subagents plan * docs: add exact thread-bound subagent implementation touchpoints * Docs: prioritize auto thread-bound subagent flow * Docs: add ACP harness thread-binding extensions * Discord: add thread-bound session routing and auto-bind spawn flow * Subagents: add focus commands and ACP/session binding lifecycle hooks * Tests: cover thread bindings, focus commands, and ACP unbind hooks * Docs: add plugin-hook appendix for thread-bound subagents * Plugins: add subagent lifecycle hook events * Core: emit subagent lifecycle hooks and decouple Discord bindings * Discord: handle subagent bind lifecycle via plugin hooks * Subagents: unify completion finalizer and split registry modules * Add subagent lifecycle events module * Hooks: fix subagent ended context key * Discord: share thread bindings across ESM and Jiti * Subagents: add persistent sessions_spawn mode for thread-bound sessions * Subagents: clarify thread intro and persistent completion copy * test(subagents): stabilize sessions_spawn lifecycle cleanup assertions * Discord: add thread-bound session TTL with auto-unfocus * Subagents: fail session spawns when thread bind fails * Subagents: cover thread session failure cleanup paths * Session: add thread binding TTL config and /session ttl controls * Tests: align discord reaction expectations * Agent: persist sessionFile for keyed subagent sessions * Discord: normalize imports after conflict resolution * Sessions: centralize sessionFile resolve/persist helper * Discord: harden thread-bound subagent session routing * Rebase: resolve upstream/main conflicts * Subagents: move thread binding into hooks and split bindings modules * Docs: add channel-agnostic subagent routing hook plan * Agents: decouple subagent routing from Discord * Discord: refactor thread-bound subagent flows * Subagents: prevent duplicate end hooks and orphaned failed sessions * Refactor: split subagent command and provider phases * Subagents: honor hook delivery target overrides * Discord: add thread binding kill switches and refresh plan doc * Discord: fix thread bind channel resolution * Routing: centralize account id normalization * Discord: clean up thread bindings on startup failures * Discord: add startup cleanup regression tests * Docs: add long-term thread-bound subagent architecture * Docs: split session binding plan and dedupe thread-bound doc * Subagents: add channel-agnostic session binding routing * Subagents: stabilize announce completion routing tests * Subagents: cover multi-bound completion routing * Subagents: suppress lifecycle hooks on failed thread bind * tests: fix discord provider mock typing regressions * docs/protocol: sync slash command aliases and delete param models * fix: add changelog entry for Discord thread-bound subagents (#21805) (thanks @onutc) --------- Co-authored-by: Shadow <hi@shadowing.dev>
2026-02-21 16:14:55 +01:00
self.emitlifecyclehooks = emitlifecyclehooks
}
private enum CodingKeys: String, CodingKey {
case key
case deletetranscript = "deleteTranscript"
feat: thread-bound subagents on Discord (#21805) * docs: thread-bound subagents plan * docs: add exact thread-bound subagent implementation touchpoints * Docs: prioritize auto thread-bound subagent flow * Docs: add ACP harness thread-binding extensions * Discord: add thread-bound session routing and auto-bind spawn flow * Subagents: add focus commands and ACP/session binding lifecycle hooks * Tests: cover thread bindings, focus commands, and ACP unbind hooks * Docs: add plugin-hook appendix for thread-bound subagents * Plugins: add subagent lifecycle hook events * Core: emit subagent lifecycle hooks and decouple Discord bindings * Discord: handle subagent bind lifecycle via plugin hooks * Subagents: unify completion finalizer and split registry modules * Add subagent lifecycle events module * Hooks: fix subagent ended context key * Discord: share thread bindings across ESM and Jiti * Subagents: add persistent sessions_spawn mode for thread-bound sessions * Subagents: clarify thread intro and persistent completion copy * test(subagents): stabilize sessions_spawn lifecycle cleanup assertions * Discord: add thread-bound session TTL with auto-unfocus * Subagents: fail session spawns when thread bind fails * Subagents: cover thread session failure cleanup paths * Session: add thread binding TTL config and /session ttl controls * Tests: align discord reaction expectations * Agent: persist sessionFile for keyed subagent sessions * Discord: normalize imports after conflict resolution * Sessions: centralize sessionFile resolve/persist helper * Discord: harden thread-bound subagent session routing * Rebase: resolve upstream/main conflicts * Subagents: move thread binding into hooks and split bindings modules * Docs: add channel-agnostic subagent routing hook plan * Agents: decouple subagent routing from Discord * Discord: refactor thread-bound subagent flows * Subagents: prevent duplicate end hooks and orphaned failed sessions * Refactor: split subagent command and provider phases * Subagents: honor hook delivery target overrides * Discord: add thread binding kill switches and refresh plan doc * Discord: fix thread bind channel resolution * Routing: centralize account id normalization * Discord: clean up thread bindings on startup failures * Discord: add startup cleanup regression tests * Docs: add long-term thread-bound subagent architecture * Docs: split session binding plan and dedupe thread-bound doc * Subagents: add channel-agnostic session binding routing * Subagents: stabilize announce completion routing tests * Subagents: cover multi-bound completion routing * Subagents: suppress lifecycle hooks on failed thread bind * tests: fix discord provider mock typing regressions * docs/protocol: sync slash command aliases and delete param models * fix: add changelog entry for Discord thread-bound subagents (#21805) (thanks @onutc) --------- Co-authored-by: Shadow <hi@shadowing.dev>
2026-02-21 16:14:55 +01:00
case emitlifecyclehooks = "emitLifecycleHooks"
}
}
public struct SessionsCompactParams: Codable, Sendable {
public let key: String
public let maxlines: Int?
public init(
key: String,
maxlines: Int?)
{
self.key = key
self.maxlines = maxlines
}
private enum CodingKeys: String, CodingKey {
case key
case maxlines = "maxLines"
}
}
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
public struct SessionsUsageParams: Codable, Sendable {
public let key: String?
public let startdate: String?
public let enddate: String?
public let mode: AnyCodable?
public let utcoffset: String?
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
public let limit: Int?
public let includecontextweight: Bool?
public init(
key: String?,
startdate: String?,
enddate: String?,
mode: AnyCodable?,
utcoffset: String?,
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
limit: Int?,
includecontextweight: Bool?)
{
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
self.key = key
self.startdate = startdate
self.enddate = enddate
self.mode = mode
self.utcoffset = utcoffset
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
self.limit = limit
self.includecontextweight = includecontextweight
}
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
private enum CodingKeys: String, CodingKey {
case key
case startdate = "startDate"
case enddate = "endDate"
case mode
case utcoffset = "utcOffset"
Web UI: add token usage dashboard (#10072) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature - Restore normalizeGatewayUrl() to validate ws:/wss: protocol - Restore isTopLevelWindow() guard for iframe security - Revert syncUrlWithSessionKey signature (host param was unused) * feat(ui): Token Usage dashboard with session analytics Adds a comprehensive Token Usage view to the dashboard: Backend: - Extended session-cost-usage.ts with per-session daily breakdown - Added date range filtering (startMs/endMs) to API endpoints - New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints - Cost breakdown by token type (input/output/cache read/write) Frontend: - Two-column layout: Daily chart + breakdown | Sessions list - Interactive daily bar chart with click-to-filter and shift-click range select - Session detail panel with usage timeline, conversation logs, context weight - Filter chips for active day/session selections - Toggle between tokens/cost view modes (default: cost) - Responsive design for smaller screens UX improvements: - 21-day default date range - Debounced date input (400ms) - Session list shows filtered totals when days selected - Context weight breakdown shows skills, tools, files contribution * fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj) * Usage: enrich metrics dashboard * Usage: add latency + model trends * Gateway: improve usage log parsing * UI: add usage query helpers * UI: client-side usage filter + debounce * Build: harden write-cli-compat timing * UI: add conversation log filters * UI: fix usage dashboard lint + state * Web UI: default usage dates to local day * Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman) --------- Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
case limit
case includecontextweight = "includeContextWeight"
}
}
public struct ConfigGetParams: Codable, Sendable {}
public struct ConfigSetParams: Codable, Sendable {
public let raw: String
public let basehash: String?
public init(
raw: String,
basehash: String?)
{
self.raw = raw
self.basehash = basehash
}
private enum CodingKeys: String, CodingKey {
case raw
case basehash = "baseHash"
}
}
public struct ConfigApplyParams: Codable, Sendable {
public let raw: String
public let basehash: String?
public let sessionkey: String?
public let note: String?
public let restartdelayms: Int?
public init(
raw: String,
basehash: String?,
sessionkey: String?,
note: String?,
restartdelayms: Int?)
{
self.raw = raw
self.basehash = basehash
self.sessionkey = sessionkey
self.note = note
self.restartdelayms = restartdelayms
}
private enum CodingKeys: String, CodingKey {
case raw
case basehash = "baseHash"
case sessionkey = "sessionKey"
case note
case restartdelayms = "restartDelayMs"
}
}
public struct ConfigPatchParams: Codable, Sendable {
public let raw: String
public let basehash: String?
2026-01-25 00:57:42 +00:00
public let sessionkey: String?
public let note: String?
public let restartdelayms: Int?
public init(
raw: String,
2026-01-25 00:57:42 +00:00
basehash: String?,
sessionkey: String?,
note: String?,
restartdelayms: Int?)
{
self.raw = raw
self.basehash = basehash
2026-01-25 00:57:42 +00:00
self.sessionkey = sessionkey
self.note = note
self.restartdelayms = restartdelayms
}
private enum CodingKeys: String, CodingKey {
case raw
case basehash = "baseHash"
2026-01-25 00:57:42 +00:00
case sessionkey = "sessionKey"
case note
case restartdelayms = "restartDelayMs"
}
}
public struct ConfigSchemaParams: Codable, Sendable {}
public struct ConfigSchemaResponse: Codable, Sendable {
public let schema: AnyCodable
public let uihints: [String: AnyCodable]
public let version: String
public let generatedat: String
public init(
schema: AnyCodable,
uihints: [String: AnyCodable],
version: String,
generatedat: String)
{
self.schema = schema
self.uihints = uihints
self.version = version
self.generatedat = generatedat
}
private enum CodingKeys: String, CodingKey {
case schema
case uihints = "uiHints"
case version
case generatedat = "generatedAt"
}
}
public struct WizardStartParams: Codable, Sendable {
public let mode: AnyCodable?
public let workspace: String?
public init(
mode: AnyCodable?,
workspace: String?)
{
self.mode = mode
self.workspace = workspace
}
private enum CodingKeys: String, CodingKey {
case mode
case workspace
}
}
public struct WizardNextParams: Codable, Sendable {
public let sessionid: String
public let answer: [String: AnyCodable]?
public init(
sessionid: String,
answer: [String: AnyCodable]?)
{
self.sessionid = sessionid
self.answer = answer
}
private enum CodingKeys: String, CodingKey {
case sessionid = "sessionId"
case answer
}
}
public struct WizardCancelParams: Codable, Sendable {
public let sessionid: String
public init(
sessionid: String)
{
self.sessionid = sessionid
}
private enum CodingKeys: String, CodingKey {
case sessionid = "sessionId"
}
}
public struct WizardStatusParams: Codable, Sendable {
public let sessionid: String
public init(
sessionid: String)
{
self.sessionid = sessionid
}
private enum CodingKeys: String, CodingKey {
case sessionid = "sessionId"
}
}
public struct WizardStep: Codable, Sendable {
public let id: String
public let type: AnyCodable
public let title: String?
public let message: String?
public let options: [[String: AnyCodable]]?
public let initialvalue: AnyCodable?
public let placeholder: String?
public let sensitive: Bool?
public let executor: AnyCodable?
public init(
id: String,
type: AnyCodable,
title: String?,
message: String?,
options: [[String: AnyCodable]]?,
initialvalue: AnyCodable?,
placeholder: String?,
sensitive: Bool?,
executor: AnyCodable?)
{
self.id = id
self.type = type
self.title = title
self.message = message
self.options = options
self.initialvalue = initialvalue
self.placeholder = placeholder
self.sensitive = sensitive
self.executor = executor
}
private enum CodingKeys: String, CodingKey {
case id
case type
case title
case message
case options
case initialvalue = "initialValue"
case placeholder
case sensitive
case executor
}
}
public struct WizardNextResult: Codable, Sendable {
public let done: Bool
public let step: [String: AnyCodable]?
public let status: AnyCodable?
public let error: String?
public init(
done: Bool,
step: [String: AnyCodable]?,
status: AnyCodable?,
error: String?)
{
self.done = done
self.step = step
self.status = status
self.error = error
}
private enum CodingKeys: String, CodingKey {
case done
case step
case status
case error
}
}
public struct WizardStartResult: Codable, Sendable {
public let sessionid: String
public let done: Bool
public let step: [String: AnyCodable]?
public let status: AnyCodable?
public let error: String?
public init(
sessionid: String,
done: Bool,
step: [String: AnyCodable]?,
status: AnyCodable?,
error: String?)
{
self.sessionid = sessionid
self.done = done
self.step = step
self.status = status
self.error = error
}
private enum CodingKeys: String, CodingKey {
case sessionid = "sessionId"
case done
case step
case status
case error
}
}
public struct WizardStatusResult: Codable, Sendable {
public let status: AnyCodable
public let error: String?
public init(
status: AnyCodable,
error: String?)
{
self.status = status
self.error = error
}
private enum CodingKeys: String, CodingKey {
case status
case error
}
}
public struct TalkModeParams: Codable, Sendable {
public let enabled: Bool
public let phase: String?
public init(
enabled: Bool,
phase: String?)
{
self.enabled = enabled
self.phase = phase
}
private enum CodingKeys: String, CodingKey {
case enabled
case phase
}
}
public struct TalkConfigParams: Codable, Sendable {
public let includesecrets: Bool?
public init(
includesecrets: Bool?)
{
self.includesecrets = includesecrets
}
private enum CodingKeys: String, CodingKey {
case includesecrets = "includeSecrets"
}
}
public struct TalkConfigResult: Codable, Sendable {
public let config: [String: AnyCodable]
public init(
config: [String: AnyCodable])
{
self.config = config
}
private enum CodingKeys: String, CodingKey {
case config
}
}
public struct ChannelsStatusParams: Codable, Sendable {
public let probe: Bool?
public let timeoutms: Int?
public init(
probe: Bool?,
timeoutms: Int?)
{
self.probe = probe
self.timeoutms = timeoutms
}
private enum CodingKeys: String, CodingKey {
case probe
case timeoutms = "timeoutMs"
}
}
public struct ChannelsStatusResult: Codable, Sendable {
public let ts: Int
public let channelorder: [String]
public let channellabels: [String: AnyCodable]
public let channeldetaillabels: [String: AnyCodable]?
public let channelsystemimages: [String: AnyCodable]?
public let channelmeta: [[String: AnyCodable]]?
public let channels: [String: AnyCodable]
public let channelaccounts: [String: AnyCodable]
public let channeldefaultaccountid: [String: AnyCodable]
public init(
ts: Int,
channelorder: [String],
channellabels: [String: AnyCodable],
channeldetaillabels: [String: AnyCodable]?,
channelsystemimages: [String: AnyCodable]?,
channelmeta: [[String: AnyCodable]]?,
channels: [String: AnyCodable],
channelaccounts: [String: AnyCodable],
channeldefaultaccountid: [String: AnyCodable])
{
self.ts = ts
self.channelorder = channelorder
self.channellabels = channellabels
self.channeldetaillabels = channeldetaillabels
self.channelsystemimages = channelsystemimages
self.channelmeta = channelmeta
self.channels = channels
self.channelaccounts = channelaccounts
self.channeldefaultaccountid = channeldefaultaccountid
}
private enum CodingKeys: String, CodingKey {
case ts
case channelorder = "channelOrder"
case channellabels = "channelLabels"
case channeldetaillabels = "channelDetailLabels"
case channelsystemimages = "channelSystemImages"
case channelmeta = "channelMeta"
case channels
case channelaccounts = "channelAccounts"
case channeldefaultaccountid = "channelDefaultAccountId"
}
}
public struct ChannelsLogoutParams: Codable, Sendable {
public let channel: String
public let accountid: String?
public init(
channel: String,
accountid: String?)
{
self.channel = channel
self.accountid = accountid
}
private enum CodingKeys: String, CodingKey {
case channel
case accountid = "accountId"
}
}
public struct WebLoginStartParams: Codable, Sendable {
public let force: Bool?
public let timeoutms: Int?
public let verbose: Bool?
public let accountid: String?
public init(
force: Bool?,
timeoutms: Int?,
verbose: Bool?,
accountid: String?)
{
self.force = force
self.timeoutms = timeoutms
self.verbose = verbose
self.accountid = accountid
}
private enum CodingKeys: String, CodingKey {
case force
case timeoutms = "timeoutMs"
case verbose
case accountid = "accountId"
}
}
public struct WebLoginWaitParams: Codable, Sendable {
public let timeoutms: Int?
public let accountid: String?
public init(
timeoutms: Int?,
accountid: String?)
{
self.timeoutms = timeoutms
self.accountid = accountid
}
private enum CodingKeys: String, CodingKey {
case timeoutms = "timeoutMs"
case accountid = "accountId"
}
}
public struct AgentSummary: Codable, Sendable {
public let id: String
public let name: String?
2026-01-22 07:22:56 +00:00
public let identity: [String: AnyCodable]?
public init(
id: String,
2026-01-22 07:22:56 +00:00
name: String?,
identity: [String: AnyCodable]?)
{
self.id = id
self.name = name
2026-01-22 07:22:56 +00:00
self.identity = identity
}
private enum CodingKeys: String, CodingKey {
case id
case name
2026-01-22 07:22:56 +00:00
case identity
}
}
public struct AgentsCreateParams: Codable, Sendable {
public let name: String
public let workspace: String
public let emoji: String?
public let avatar: String?
public init(
name: String,
workspace: String,
emoji: String?,
avatar: String?)
{
self.name = name
self.workspace = workspace
self.emoji = emoji
self.avatar = avatar
}
private enum CodingKeys: String, CodingKey {
case name
case workspace
case emoji
case avatar
}
}
public struct AgentsCreateResult: Codable, Sendable {
public let ok: Bool
public let agentid: String
public let name: String
public let workspace: String
public init(
ok: Bool,
agentid: String,
name: String,
workspace: String)
{
self.ok = ok
self.agentid = agentid
self.name = name
self.workspace = workspace
}
private enum CodingKeys: String, CodingKey {
case ok
case agentid = "agentId"
case name
case workspace
}
}
public struct AgentsUpdateParams: Codable, Sendable {
public let agentid: String
public let name: String?
public let workspace: String?
public let model: String?
public let avatar: String?
public init(
agentid: String,
name: String?,
workspace: String?,
model: String?,
avatar: String?)
{
self.agentid = agentid
self.name = name
self.workspace = workspace
self.model = model
self.avatar = avatar
}
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case name
case workspace
case model
case avatar
}
}
public struct AgentsUpdateResult: Codable, Sendable {
public let ok: Bool
public let agentid: String
public init(
ok: Bool,
agentid: String)
{
self.ok = ok
self.agentid = agentid
}
private enum CodingKeys: String, CodingKey {
case ok
case agentid = "agentId"
}
}
public struct AgentsDeleteParams: Codable, Sendable {
public let agentid: String
public let deletefiles: Bool?
public init(
agentid: String,
deletefiles: Bool?)
{
self.agentid = agentid
self.deletefiles = deletefiles
}
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case deletefiles = "deleteFiles"
}
}
public struct AgentsDeleteResult: Codable, Sendable {
public let ok: Bool
public let agentid: String
public let removedbindings: Int
public init(
ok: Bool,
agentid: String,
removedbindings: Int)
{
self.ok = ok
self.agentid = agentid
self.removedbindings = removedbindings
}
private enum CodingKeys: String, CodingKey {
case ok
case agentid = "agentId"
case removedbindings = "removedBindings"
}
}
2026-02-02 21:44:31 -05:00
public struct AgentsFileEntry: Codable, Sendable {
public let name: String
public let path: String
public let missing: Bool
public let size: Int?
public let updatedatms: Int?
public let content: String?
public init(
name: String,
path: String,
missing: Bool,
size: Int?,
updatedatms: Int?,
content: String?)
{
2026-02-02 21:44:31 -05:00
self.name = name
self.path = path
self.missing = missing
self.size = size
self.updatedatms = updatedatms
self.content = content
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case name
case path
case missing
case size
case updatedatms = "updatedAtMs"
case content
}
}
public struct AgentsFilesListParams: Codable, Sendable {
public let agentid: String
public init(
agentid: String)
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
}
}
public struct AgentsFilesListResult: Codable, Sendable {
public let agentid: String
public let workspace: String
public let files: [AgentsFileEntry]
public init(
agentid: String,
workspace: String,
files: [AgentsFileEntry])
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
self.workspace = workspace
self.files = files
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case workspace
case files
}
}
public struct AgentsFilesGetParams: Codable, Sendable {
public let agentid: String
public let name: String
public init(
agentid: String,
name: String)
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
self.name = name
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case name
}
}
public struct AgentsFilesGetResult: Codable, Sendable {
public let agentid: String
public let workspace: String
public let file: AgentsFileEntry
public init(
agentid: String,
workspace: String,
file: AgentsFileEntry)
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
self.workspace = workspace
self.file = file
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case workspace
case file
}
}
public struct AgentsFilesSetParams: Codable, Sendable {
public let agentid: String
public let name: String
public let content: String
public init(
agentid: String,
name: String,
content: String)
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
self.name = name
self.content = content
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case name
case content
}
}
public struct AgentsFilesSetResult: Codable, Sendable {
public let ok: Bool
public let agentid: String
public let workspace: String
public let file: AgentsFileEntry
public init(
ok: Bool,
agentid: String,
workspace: String,
file: AgentsFileEntry)
{
2026-02-02 21:44:31 -05:00
self.ok = ok
self.agentid = agentid
self.workspace = workspace
self.file = file
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case ok
case agentid = "agentId"
case workspace
case file
}
}
public struct AgentsListParams: Codable, Sendable {}
public struct AgentsListResult: Codable, Sendable {
public let defaultid: String
public let mainkey: String
public let scope: AnyCodable
public let agents: [AgentSummary]
public init(
defaultid: String,
mainkey: String,
scope: AnyCodable,
agents: [AgentSummary])
{
self.defaultid = defaultid
self.mainkey = mainkey
self.scope = scope
self.agents = agents
}
private enum CodingKeys: String, CodingKey {
case defaultid = "defaultId"
case mainkey = "mainKey"
case scope
case agents
}
}
public struct ModelChoice: Codable, Sendable {
public let id: String
public let name: String
public let provider: String
public let contextwindow: Int?
public let reasoning: Bool?
public init(
id: String,
name: String,
provider: String,
contextwindow: Int?,
reasoning: Bool?)
{
self.id = id
self.name = name
self.provider = provider
self.contextwindow = contextwindow
self.reasoning = reasoning
}
private enum CodingKeys: String, CodingKey {
case id
case name
case provider
case contextwindow = "contextWindow"
case reasoning
}
}
public struct ModelsListParams: Codable, Sendable {}
public struct ModelsListResult: Codable, Sendable {
public let models: [ModelChoice]
public init(
models: [ModelChoice])
{
self.models = models
}
private enum CodingKeys: String, CodingKey {
case models
}
}
public struct SkillsStatusParams: Codable, Sendable {
2026-02-02 21:44:31 -05:00
public let agentid: String?
public init(
agentid: String?)
{
2026-02-02 21:44:31 -05:00
self.agentid = agentid
}
2026-02-02 21:44:31 -05:00
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
}
}
public struct ToolsCatalogParams: Codable, Sendable {
public let agentid: String?
public let includeplugins: Bool?
public init(
agentid: String?,
includeplugins: Bool?)
{
self.agentid = agentid
self.includeplugins = includeplugins
}
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case includeplugins = "includePlugins"
}
}
public struct ToolCatalogProfile: Codable, Sendable {
public let id: AnyCodable
public let label: String
public init(
id: AnyCodable,
label: String)
{
self.id = id
self.label = label
}
private enum CodingKeys: String, CodingKey {
case id
case label
}
}
public struct ToolCatalogEntry: Codable, Sendable {
public let id: String
public let label: String
public let description: String
public let source: AnyCodable
public let pluginid: String?
public let optional: Bool?
public let defaultprofiles: [AnyCodable]
public init(
id: String,
label: String,
description: String,
source: AnyCodable,
pluginid: String?,
optional: Bool?,
defaultprofiles: [AnyCodable])
{
self.id = id
self.label = label
self.description = description
self.source = source
self.pluginid = pluginid
self.optional = optional
self.defaultprofiles = defaultprofiles
}
private enum CodingKeys: String, CodingKey {
case id
case label
case description
case source
case pluginid = "pluginId"
case optional
case defaultprofiles = "defaultProfiles"
}
}
public struct ToolCatalogGroup: Codable, Sendable {
public let id: String
public let label: String
public let source: AnyCodable
public let pluginid: String?
public let tools: [ToolCatalogEntry]
public init(
id: String,
label: String,
source: AnyCodable,
pluginid: String?,
tools: [ToolCatalogEntry])
{
self.id = id
self.label = label
self.source = source
self.pluginid = pluginid
self.tools = tools
}
private enum CodingKeys: String, CodingKey {
case id
case label
case source
case pluginid = "pluginId"
case tools
}
}
public struct ToolsCatalogResult: Codable, Sendable {
public let agentid: String
public let profiles: [ToolCatalogProfile]
public let groups: [ToolCatalogGroup]
public init(
agentid: String,
profiles: [ToolCatalogProfile],
groups: [ToolCatalogGroup])
{
self.agentid = agentid
self.profiles = profiles
self.groups = groups
}
private enum CodingKeys: String, CodingKey {
case agentid = "agentId"
case profiles
case groups
}
}
public struct SkillsBinsParams: Codable, Sendable {}
public struct SkillsBinsResult: Codable, Sendable {
public let bins: [String]
public init(
bins: [String])
{
self.bins = bins
}
private enum CodingKeys: String, CodingKey {
case bins
}
}
public struct SkillsInstallParams: Codable, Sendable {
public let name: String
public let installid: String
public let timeoutms: Int?
public init(
name: String,
installid: String,
timeoutms: Int?)
{
self.name = name
self.installid = installid
self.timeoutms = timeoutms
}
private enum CodingKeys: String, CodingKey {
case name
case installid = "installId"
case timeoutms = "timeoutMs"
}
}
public struct SkillsUpdateParams: Codable, Sendable {
public let skillkey: String
public let enabled: Bool?
public let apikey: String?
public let env: [String: AnyCodable]?
public init(
skillkey: String,
enabled: Bool?,
apikey: String?,
env: [String: AnyCodable]?)
{
self.skillkey = skillkey
self.enabled = enabled
self.apikey = apikey
self.env = env
}
private enum CodingKeys: String, CodingKey {
case skillkey = "skillKey"
case enabled
case apikey = "apiKey"
case env
}
}
public struct CronJob: Codable, Sendable {
public let id: String
public let agentid: String?
2026-02-16 14:49:52 -08:00
public let sessionkey: String?
public let name: String
public let description: String?
public let enabled: Bool
public let deleteafterrun: Bool?
public let createdatms: Int
public let updatedatms: Int
public let schedule: AnyCodable
public let sessiontarget: AnyCodable
public let wakemode: AnyCodable
public let payload: AnyCodable
public let delivery: AnyCodable?
public let failurealert: AnyCodable?
public let state: [String: AnyCodable]
public init(
id: String,
agentid: String?,
2026-02-16 14:49:52 -08:00
sessionkey: String?,
name: String,
description: String?,
enabled: Bool,
deleteafterrun: Bool?,
createdatms: Int,
updatedatms: Int,
schedule: AnyCodable,
sessiontarget: AnyCodable,
wakemode: AnyCodable,
payload: AnyCodable,
delivery: AnyCodable?,
failurealert: AnyCodable?,
state: [String: AnyCodable])
{
self.id = id
self.agentid = agentid
2026-02-16 14:49:52 -08:00
self.sessionkey = sessionkey
self.name = name
self.description = description
self.enabled = enabled
self.deleteafterrun = deleteafterrun
self.createdatms = createdatms
self.updatedatms = updatedatms
self.schedule = schedule
self.sessiontarget = sessiontarget
self.wakemode = wakemode
self.payload = payload
self.delivery = delivery
self.failurealert = failurealert
self.state = state
}
private enum CodingKeys: String, CodingKey {
case id
case agentid = "agentId"
2026-02-16 14:49:52 -08:00
case sessionkey = "sessionKey"
case name
case description
case enabled
case deleteafterrun = "deleteAfterRun"
case createdatms = "createdAtMs"
case updatedatms = "updatedAtMs"
case schedule
case sessiontarget = "sessionTarget"
case wakemode = "wakeMode"
case payload
case delivery
case failurealert = "failureAlert"
case state
}
}
public struct CronListParams: Codable, Sendable {
public let includedisabled: Bool?
public let limit: Int?
public let offset: Int?
public let query: String?
public let enabled: AnyCodable?
public let sortby: AnyCodable?
public let sortdir: AnyCodable?
public init(
includedisabled: Bool?,
limit: Int?,
offset: Int?,
query: String?,
enabled: AnyCodable?,
sortby: AnyCodable?,
sortdir: AnyCodable?)
{
self.includedisabled = includedisabled
self.limit = limit
self.offset = offset
self.query = query
self.enabled = enabled
self.sortby = sortby
self.sortdir = sortdir
}
private enum CodingKeys: String, CodingKey {
case includedisabled = "includeDisabled"
case limit
case offset
case query
case enabled
case sortby = "sortBy"
case sortdir = "sortDir"
}
}
public struct CronStatusParams: Codable, Sendable {}
public struct CronAddParams: Codable, Sendable {
public let name: String
public let agentid: AnyCodable?
2026-02-16 14:49:52 -08:00
public let sessionkey: AnyCodable?
public let description: String?
public let enabled: Bool?
public let deleteafterrun: Bool?
public let schedule: AnyCodable
public let sessiontarget: AnyCodable
public let wakemode: AnyCodable
public let payload: AnyCodable
public let delivery: AnyCodable?
public let failurealert: AnyCodable?
public init(
name: String,
agentid: AnyCodable?,
2026-02-16 14:49:52 -08:00
sessionkey: AnyCodable?,
description: String?,
enabled: Bool?,
deleteafterrun: Bool?,
schedule: AnyCodable,
sessiontarget: AnyCodable,
wakemode: AnyCodable,
payload: AnyCodable,
delivery: AnyCodable?,
failurealert: AnyCodable?)
{
self.name = name
self.agentid = agentid
2026-02-16 14:49:52 -08:00
self.sessionkey = sessionkey
self.description = description
self.enabled = enabled
self.deleteafterrun = deleteafterrun
self.schedule = schedule
self.sessiontarget = sessiontarget
self.wakemode = wakemode
self.payload = payload
self.delivery = delivery
self.failurealert = failurealert
}
private enum CodingKeys: String, CodingKey {
case name
case agentid = "agentId"
2026-02-16 14:49:52 -08:00
case sessionkey = "sessionKey"
case description
case enabled
case deleteafterrun = "deleteAfterRun"
case schedule
case sessiontarget = "sessionTarget"
case wakemode = "wakeMode"
case payload
case delivery
case failurealert = "failureAlert"
}
}
public struct CronRunsParams: Codable, Sendable {
public let scope: AnyCodable?
public let id: String?
public let jobid: String?
public let limit: Int?
public let offset: Int?
public let statuses: [AnyCodable]?
public let status: AnyCodable?
public let deliverystatuses: [AnyCodable]?
public let deliverystatus: AnyCodable?
public let query: String?
public let sortdir: AnyCodable?
public init(
scope: AnyCodable?,
id: String?,
jobid: String?,
limit: Int?,
offset: Int?,
statuses: [AnyCodable]?,
status: AnyCodable?,
deliverystatuses: [AnyCodable]?,
deliverystatus: AnyCodable?,
query: String?,
sortdir: AnyCodable?)
{
self.scope = scope
self.id = id
self.jobid = jobid
self.limit = limit
self.offset = offset
self.statuses = statuses
self.status = status
self.deliverystatuses = deliverystatuses
self.deliverystatus = deliverystatus
self.query = query
self.sortdir = sortdir
}
private enum CodingKeys: String, CodingKey {
case scope
case id
case jobid = "jobId"
case limit
case offset
case statuses
case status
case deliverystatuses = "deliveryStatuses"
case deliverystatus = "deliveryStatus"
case query
case sortdir = "sortDir"
}
}
public struct CronRunLogEntry: Codable, Sendable {
public let ts: Int
public let jobid: String
public let action: String
public let status: AnyCodable?
public let error: String?
public let summary: String?
public let delivered: Bool?
public let deliverystatus: AnyCodable?
public let deliveryerror: String?
fix: cron scheduler reliability, store hardening, and UX improvements (#10776) * refactor: update cron job wake mode and run mode handling - Changed default wake mode from 'next-heartbeat' to 'now' in CronJobEditor and related CLI commands. - Updated cron-tool tests to reflect changes in run mode, introducing 'due' and 'force' options. - Enhanced cron-tool logic to handle new run modes and ensure compatibility with existing job structures. - Added new tests for delivery plan consistency and job execution behavior under various conditions. - Improved normalization functions to handle wake mode and session target casing. This refactor aims to streamline cron job configurations and enhance the overall user experience with clearer defaults and improved functionality. * test: enhance cron job functionality and UI - Added tests to ensure the isolated agent correctly announces the final payload text when delivering messages via Telegram. - Implemented a new function to pick the last deliverable payload from a list of delivery payloads. - Enhanced the cron service to maintain legacy "every" jobs while minute cron jobs recompute schedules. - Updated the cron store migration tests to verify the addition of anchorMs to legacy every schedules. - Improved the UI for displaying cron job details, including job state and delivery information, with new styles and layout adjustments. These changes aim to improve the reliability and user experience of the cron job system. * test: enhance sessions thinking level handling - Added tests to verify that the correct thinking levels are applied during session spawning. - Updated the sessions-spawn-tool to include a new parameter for overriding thinking levels. - Enhanced the UI to support additional thinking levels, including "xhigh" and "full", and improved the handling of current options in dropdowns. These changes aim to improve the flexibility and accuracy of thinking level configurations in session management. * feat: enhance session management and cron job functionality - Introduced passthrough arguments in the test-parallel script to allow for flexible command-line options. - Updated session handling to hide cron run alias session keys from the sessions list, improving clarity. - Enhanced the cron service to accurately record job start times and durations, ensuring better tracking of job execution. - Added tests to verify the correct behavior of the cron service under various conditions, including zero-delay timers. These changes aim to improve the usability and reliability of session and cron job management. * feat: implement job running state checks in cron service - Added functionality to prevent manual job runs if a job is already in progress, enhancing job management. - Updated the `isJobDue` function to include checks for running jobs, ensuring accurate scheduling. - Enhanced the `run` function to return a specific reason when a job is already running. - Introduced a new test case to verify the behavior of forced manual runs during active job execution. These changes aim to improve the reliability and clarity of cron job execution and management. * feat: add session ID and key to CronRunLogEntry model - Introduced `sessionid` and `sessionkey` properties to the `CronRunLogEntry` struct for enhanced tracking of session-related information. - Updated the initializer and Codable conformance to accommodate the new properties, ensuring proper serialization and deserialization. These changes aim to improve the granularity of logging and session management within the cron job system. * fix: improve session display name resolution - Updated the `resolveSessionDisplayName` function to ensure that both label and displayName are trimmed and default to an empty string if not present. - Enhanced the logic to prevent returning the key if it matches the label or displayName, improving clarity in session naming. These changes aim to enhance the accuracy and usability of session display names in the UI. * perf: skip cron store persist when idle timer tick produces no changes recomputeNextRuns now returns a boolean indicating whether any job state was mutated. The idle path in onTimer only persists when the return value is true, eliminating unnecessary file writes every 60s for far-future or idle schedules. * fix: prep for merge - explicit delivery mode migration, docs + changelog (#10776) (thanks @tyler6204)
2026-02-06 18:03:03 -08:00
public let sessionid: String?
public let sessionkey: String?
public let runatms: Int?
public let durationms: Int?
public let nextrunatms: Int?
public let model: String?
public let provider: String?
public let usage: [String: AnyCodable]?
public let jobname: String?
public init(
ts: Int,
jobid: String,
action: String,
status: AnyCodable?,
error: String?,
summary: String?,
delivered: Bool?,
deliverystatus: AnyCodable?,
deliveryerror: String?,
fix: cron scheduler reliability, store hardening, and UX improvements (#10776) * refactor: update cron job wake mode and run mode handling - Changed default wake mode from 'next-heartbeat' to 'now' in CronJobEditor and related CLI commands. - Updated cron-tool tests to reflect changes in run mode, introducing 'due' and 'force' options. - Enhanced cron-tool logic to handle new run modes and ensure compatibility with existing job structures. - Added new tests for delivery plan consistency and job execution behavior under various conditions. - Improved normalization functions to handle wake mode and session target casing. This refactor aims to streamline cron job configurations and enhance the overall user experience with clearer defaults and improved functionality. * test: enhance cron job functionality and UI - Added tests to ensure the isolated agent correctly announces the final payload text when delivering messages via Telegram. - Implemented a new function to pick the last deliverable payload from a list of delivery payloads. - Enhanced the cron service to maintain legacy "every" jobs while minute cron jobs recompute schedules. - Updated the cron store migration tests to verify the addition of anchorMs to legacy every schedules. - Improved the UI for displaying cron job details, including job state and delivery information, with new styles and layout adjustments. These changes aim to improve the reliability and user experience of the cron job system. * test: enhance sessions thinking level handling - Added tests to verify that the correct thinking levels are applied during session spawning. - Updated the sessions-spawn-tool to include a new parameter for overriding thinking levels. - Enhanced the UI to support additional thinking levels, including "xhigh" and "full", and improved the handling of current options in dropdowns. These changes aim to improve the flexibility and accuracy of thinking level configurations in session management. * feat: enhance session management and cron job functionality - Introduced passthrough arguments in the test-parallel script to allow for flexible command-line options. - Updated session handling to hide cron run alias session keys from the sessions list, improving clarity. - Enhanced the cron service to accurately record job start times and durations, ensuring better tracking of job execution. - Added tests to verify the correct behavior of the cron service under various conditions, including zero-delay timers. These changes aim to improve the usability and reliability of session and cron job management. * feat: implement job running state checks in cron service - Added functionality to prevent manual job runs if a job is already in progress, enhancing job management. - Updated the `isJobDue` function to include checks for running jobs, ensuring accurate scheduling. - Enhanced the `run` function to return a specific reason when a job is already running. - Introduced a new test case to verify the behavior of forced manual runs during active job execution. These changes aim to improve the reliability and clarity of cron job execution and management. * feat: add session ID and key to CronRunLogEntry model - Introduced `sessionid` and `sessionkey` properties to the `CronRunLogEntry` struct for enhanced tracking of session-related information. - Updated the initializer and Codable conformance to accommodate the new properties, ensuring proper serialization and deserialization. These changes aim to improve the granularity of logging and session management within the cron job system. * fix: improve session display name resolution - Updated the `resolveSessionDisplayName` function to ensure that both label and displayName are trimmed and default to an empty string if not present. - Enhanced the logic to prevent returning the key if it matches the label or displayName, improving clarity in session naming. These changes aim to enhance the accuracy and usability of session display names in the UI. * perf: skip cron store persist when idle timer tick produces no changes recomputeNextRuns now returns a boolean indicating whether any job state was mutated. The idle path in onTimer only persists when the return value is true, eliminating unnecessary file writes every 60s for far-future or idle schedules. * fix: prep for merge - explicit delivery mode migration, docs + changelog (#10776) (thanks @tyler6204)
2026-02-06 18:03:03 -08:00
sessionid: String?,
sessionkey: String?,
runatms: Int?,
durationms: Int?,
nextrunatms: Int?,
model: String?,
provider: String?,
usage: [String: AnyCodable]?,
jobname: String?)
{
self.ts = ts
self.jobid = jobid
self.action = action
self.status = status
self.error = error
self.summary = summary
self.delivered = delivered
self.deliverystatus = deliverystatus
self.deliveryerror = deliveryerror
fix: cron scheduler reliability, store hardening, and UX improvements (#10776) * refactor: update cron job wake mode and run mode handling - Changed default wake mode from 'next-heartbeat' to 'now' in CronJobEditor and related CLI commands. - Updated cron-tool tests to reflect changes in run mode, introducing 'due' and 'force' options. - Enhanced cron-tool logic to handle new run modes and ensure compatibility with existing job structures. - Added new tests for delivery plan consistency and job execution behavior under various conditions. - Improved normalization functions to handle wake mode and session target casing. This refactor aims to streamline cron job configurations and enhance the overall user experience with clearer defaults and improved functionality. * test: enhance cron job functionality and UI - Added tests to ensure the isolated agent correctly announces the final payload text when delivering messages via Telegram. - Implemented a new function to pick the last deliverable payload from a list of delivery payloads. - Enhanced the cron service to maintain legacy "every" jobs while minute cron jobs recompute schedules. - Updated the cron store migration tests to verify the addition of anchorMs to legacy every schedules. - Improved the UI for displaying cron job details, including job state and delivery information, with new styles and layout adjustments. These changes aim to improve the reliability and user experience of the cron job system. * test: enhance sessions thinking level handling - Added tests to verify that the correct thinking levels are applied during session spawning. - Updated the sessions-spawn-tool to include a new parameter for overriding thinking levels. - Enhanced the UI to support additional thinking levels, including "xhigh" and "full", and improved the handling of current options in dropdowns. These changes aim to improve the flexibility and accuracy of thinking level configurations in session management. * feat: enhance session management and cron job functionality - Introduced passthrough arguments in the test-parallel script to allow for flexible command-line options. - Updated session handling to hide cron run alias session keys from the sessions list, improving clarity. - Enhanced the cron service to accurately record job start times and durations, ensuring better tracking of job execution. - Added tests to verify the correct behavior of the cron service under various conditions, including zero-delay timers. These changes aim to improve the usability and reliability of session and cron job management. * feat: implement job running state checks in cron service - Added functionality to prevent manual job runs if a job is already in progress, enhancing job management. - Updated the `isJobDue` function to include checks for running jobs, ensuring accurate scheduling. - Enhanced the `run` function to return a specific reason when a job is already running. - Introduced a new test case to verify the behavior of forced manual runs during active job execution. These changes aim to improve the reliability and clarity of cron job execution and management. * feat: add session ID and key to CronRunLogEntry model - Introduced `sessionid` and `sessionkey` properties to the `CronRunLogEntry` struct for enhanced tracking of session-related information. - Updated the initializer and Codable conformance to accommodate the new properties, ensuring proper serialization and deserialization. These changes aim to improve the granularity of logging and session management within the cron job system. * fix: improve session display name resolution - Updated the `resolveSessionDisplayName` function to ensure that both label and displayName are trimmed and default to an empty string if not present. - Enhanced the logic to prevent returning the key if it matches the label or displayName, improving clarity in session naming. These changes aim to enhance the accuracy and usability of session display names in the UI. * perf: skip cron store persist when idle timer tick produces no changes recomputeNextRuns now returns a boolean indicating whether any job state was mutated. The idle path in onTimer only persists when the return value is true, eliminating unnecessary file writes every 60s for far-future or idle schedules. * fix: prep for merge - explicit delivery mode migration, docs + changelog (#10776) (thanks @tyler6204)
2026-02-06 18:03:03 -08:00
self.sessionid = sessionid
self.sessionkey = sessionkey
self.runatms = runatms
self.durationms = durationms
self.nextrunatms = nextrunatms
self.model = model
self.provider = provider
self.usage = usage
self.jobname = jobname
}
private enum CodingKeys: String, CodingKey {
case ts
case jobid = "jobId"
case action
case status
case error
case summary
case delivered
case deliverystatus = "deliveryStatus"
case deliveryerror = "deliveryError"
fix: cron scheduler reliability, store hardening, and UX improvements (#10776) * refactor: update cron job wake mode and run mode handling - Changed default wake mode from 'next-heartbeat' to 'now' in CronJobEditor and related CLI commands. - Updated cron-tool tests to reflect changes in run mode, introducing 'due' and 'force' options. - Enhanced cron-tool logic to handle new run modes and ensure compatibility with existing job structures. - Added new tests for delivery plan consistency and job execution behavior under various conditions. - Improved normalization functions to handle wake mode and session target casing. This refactor aims to streamline cron job configurations and enhance the overall user experience with clearer defaults and improved functionality. * test: enhance cron job functionality and UI - Added tests to ensure the isolated agent correctly announces the final payload text when delivering messages via Telegram. - Implemented a new function to pick the last deliverable payload from a list of delivery payloads. - Enhanced the cron service to maintain legacy "every" jobs while minute cron jobs recompute schedules. - Updated the cron store migration tests to verify the addition of anchorMs to legacy every schedules. - Improved the UI for displaying cron job details, including job state and delivery information, with new styles and layout adjustments. These changes aim to improve the reliability and user experience of the cron job system. * test: enhance sessions thinking level handling - Added tests to verify that the correct thinking levels are applied during session spawning. - Updated the sessions-spawn-tool to include a new parameter for overriding thinking levels. - Enhanced the UI to support additional thinking levels, including "xhigh" and "full", and improved the handling of current options in dropdowns. These changes aim to improve the flexibility and accuracy of thinking level configurations in session management. * feat: enhance session management and cron job functionality - Introduced passthrough arguments in the test-parallel script to allow for flexible command-line options. - Updated session handling to hide cron run alias session keys from the sessions list, improving clarity. - Enhanced the cron service to accurately record job start times and durations, ensuring better tracking of job execution. - Added tests to verify the correct behavior of the cron service under various conditions, including zero-delay timers. These changes aim to improve the usability and reliability of session and cron job management. * feat: implement job running state checks in cron service - Added functionality to prevent manual job runs if a job is already in progress, enhancing job management. - Updated the `isJobDue` function to include checks for running jobs, ensuring accurate scheduling. - Enhanced the `run` function to return a specific reason when a job is already running. - Introduced a new test case to verify the behavior of forced manual runs during active job execution. These changes aim to improve the reliability and clarity of cron job execution and management. * feat: add session ID and key to CronRunLogEntry model - Introduced `sessionid` and `sessionkey` properties to the `CronRunLogEntry` struct for enhanced tracking of session-related information. - Updated the initializer and Codable conformance to accommodate the new properties, ensuring proper serialization and deserialization. These changes aim to improve the granularity of logging and session management within the cron job system. * fix: improve session display name resolution - Updated the `resolveSessionDisplayName` function to ensure that both label and displayName are trimmed and default to an empty string if not present. - Enhanced the logic to prevent returning the key if it matches the label or displayName, improving clarity in session naming. These changes aim to enhance the accuracy and usability of session display names in the UI. * perf: skip cron store persist when idle timer tick produces no changes recomputeNextRuns now returns a boolean indicating whether any job state was mutated. The idle path in onTimer only persists when the return value is true, eliminating unnecessary file writes every 60s for far-future or idle schedules. * fix: prep for merge - explicit delivery mode migration, docs + changelog (#10776) (thanks @tyler6204)
2026-02-06 18:03:03 -08:00
case sessionid = "sessionId"
case sessionkey = "sessionKey"
case runatms = "runAtMs"
case durationms = "durationMs"
case nextrunatms = "nextRunAtMs"
case model
case provider
case usage
case jobname = "jobName"
}
}
public struct LogsTailParams: Codable, Sendable {
public let cursor: Int?
public let limit: Int?
public let maxbytes: Int?
public init(
cursor: Int?,
limit: Int?,
maxbytes: Int?)
{
self.cursor = cursor
self.limit = limit
self.maxbytes = maxbytes
}
private enum CodingKeys: String, CodingKey {
case cursor
case limit
case maxbytes = "maxBytes"
}
}
public struct LogsTailResult: Codable, Sendable {
public let file: String
public let cursor: Int
public let size: Int
public let lines: [String]
public let truncated: Bool?
public let reset: Bool?
public init(
file: String,
cursor: Int,
size: Int,
lines: [String],
truncated: Bool?,
reset: Bool?)
{
self.file = file
self.cursor = cursor
self.size = size
self.lines = lines
self.truncated = truncated
self.reset = reset
}
private enum CodingKeys: String, CodingKey {
case file
case cursor
case size
case lines
case truncated
case reset
}
}
public struct ExecApprovalsGetParams: Codable, Sendable {}
public struct ExecApprovalsSetParams: Codable, Sendable {
public let file: [String: AnyCodable]
public let basehash: String?
public init(
file: [String: AnyCodable],
basehash: String?)
{
self.file = file
self.basehash = basehash
}
private enum CodingKeys: String, CodingKey {
case file
case basehash = "baseHash"
}
}
public struct ExecApprovalsNodeGetParams: Codable, Sendable {
public let nodeid: String
public init(
nodeid: String)
{
self.nodeid = nodeid
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
}
}
public struct ExecApprovalsNodeSetParams: Codable, Sendable {
public let nodeid: String
public let file: [String: AnyCodable]
public let basehash: String?
public init(
nodeid: String,
file: [String: AnyCodable],
basehash: String?)
{
self.nodeid = nodeid
self.file = file
self.basehash = basehash
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case file
case basehash = "baseHash"
}
}
public struct ExecApprovalsSnapshot: Codable, Sendable {
public let path: String
public let exists: Bool
public let hash: String
public let file: [String: AnyCodable]
public init(
path: String,
exists: Bool,
hash: String,
file: [String: AnyCodable])
{
self.path = path
self.exists = exists
self.hash = hash
self.file = file
}
private enum CodingKeys: String, CodingKey {
case path
case exists
case hash
case file
}
}
public struct ExecApprovalRequestParams: Codable, Sendable {
2026-01-22 01:30:06 +00:00
public let id: String?
public let command: String
public let commandargv: [String]?
public let systemrunplan: [String: AnyCodable]?
public let env: [String: AnyCodable]?
public let cwd: AnyCodable?
public let nodeid: AnyCodable?
public let host: AnyCodable?
public let security: AnyCodable?
public let ask: AnyCodable?
public let agentid: AnyCodable?
public let resolvedpath: AnyCodable?
public let sessionkey: AnyCodable?
2026-02-26 07:37:09 -05:00
public let turnsourcechannel: AnyCodable?
public let turnsourceto: AnyCodable?
public let turnsourceaccountid: AnyCodable?
public let turnsourcethreadid: AnyCodable?
public let timeoutms: Int?
fix: ensure exec approval is registered before returning (#2402) (#3357) * feat(gateway): add register and awaitDecision methods to ExecApprovalManager Separates registration (synchronous) from waiting (async) to allow callers to confirm registration before the decision is made. Adds grace period for resolved entries to prevent race conditions. * feat(gateway): add two-phase response and waitDecision handler for exec approvals Send immediate 'accepted' response after registration so callers can confirm the approval ID is valid. Add exec.approval.waitDecision endpoint to wait for decision on already-registered approvals. * fix(exec): await approval registration before returning approval-pending Ensures the approval ID is registered in the gateway before the tool returns. Uses exec.approval.request with expectFinal:false for registration, then fire-and-forget exec.approval.waitDecision for the decision phase. Fixes #2402 * test(gateway): update exec-approval test for two-phase response Add assertion for immediate 'accepted' response before final decision. * test(exec): update approval-id test mocks for new two-phase flow Mock both exec.approval.request (registration) and exec.approval.waitDecision (decision) calls to match the new internal implementation. * fix(lint): add cause to errors, use generics instead of type assertions * fix(exec-approval): guard register() against duplicate IDs * fix: remove unused timeoutMs param, guard register() against duplicates * fix(exec-approval): throw on duplicate ID, capture entry in closure * fix: return error on timeout, remove stale test mock branch * fix: wrap register() in try/catch, make timeout handling consistent * fix: update snapshot on timeout, make two-phase response opt-in * fix: extend grace period to 15s, return 'expired' status * fix: prevent double-resolve after timeout * fix: make register() idempotent, capture snapshot before await * fix(gateway): complete two-phase exec approval wiring * fix: finalize exec approval race fix (openclaw#3357) thanks @ramin-shirali * fix(protocol): regenerate exec approval request models (openclaw#3357) thanks @ramin-shirali * fix(test): remove unused callCount in discord threading test --------- Co-authored-by: rshirali <rshirali@rshirali-haga.local> Co-authored-by: rshirali <rshirali@rshirali-haga-1.home> Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 19:57:02 +01:00
public let twophase: Bool?
public init(
2026-01-22 01:30:06 +00:00
id: String?,
command: String,
commandargv: [String]?,
systemrunplan: [String: AnyCodable]?,
env: [String: AnyCodable]?,
cwd: AnyCodable?,
nodeid: AnyCodable?,
host: AnyCodable?,
security: AnyCodable?,
ask: AnyCodable?,
agentid: AnyCodable?,
resolvedpath: AnyCodable?,
sessionkey: AnyCodable?,
2026-02-26 07:37:09 -05:00
turnsourcechannel: AnyCodable?,
turnsourceto: AnyCodable?,
turnsourceaccountid: AnyCodable?,
turnsourcethreadid: AnyCodable?,
fix: ensure exec approval is registered before returning (#2402) (#3357) * feat(gateway): add register and awaitDecision methods to ExecApprovalManager Separates registration (synchronous) from waiting (async) to allow callers to confirm registration before the decision is made. Adds grace period for resolved entries to prevent race conditions. * feat(gateway): add two-phase response and waitDecision handler for exec approvals Send immediate 'accepted' response after registration so callers can confirm the approval ID is valid. Add exec.approval.waitDecision endpoint to wait for decision on already-registered approvals. * fix(exec): await approval registration before returning approval-pending Ensures the approval ID is registered in the gateway before the tool returns. Uses exec.approval.request with expectFinal:false for registration, then fire-and-forget exec.approval.waitDecision for the decision phase. Fixes #2402 * test(gateway): update exec-approval test for two-phase response Add assertion for immediate 'accepted' response before final decision. * test(exec): update approval-id test mocks for new two-phase flow Mock both exec.approval.request (registration) and exec.approval.waitDecision (decision) calls to match the new internal implementation. * fix(lint): add cause to errors, use generics instead of type assertions * fix(exec-approval): guard register() against duplicate IDs * fix: remove unused timeoutMs param, guard register() against duplicates * fix(exec-approval): throw on duplicate ID, capture entry in closure * fix: return error on timeout, remove stale test mock branch * fix: wrap register() in try/catch, make timeout handling consistent * fix: update snapshot on timeout, make two-phase response opt-in * fix: extend grace period to 15s, return 'expired' status * fix: prevent double-resolve after timeout * fix: make register() idempotent, capture snapshot before await * fix(gateway): complete two-phase exec approval wiring * fix: finalize exec approval race fix (openclaw#3357) thanks @ramin-shirali * fix(protocol): regenerate exec approval request models (openclaw#3357) thanks @ramin-shirali * fix(test): remove unused callCount in discord threading test --------- Co-authored-by: rshirali <rshirali@rshirali-haga.local> Co-authored-by: rshirali <rshirali@rshirali-haga-1.home> Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 19:57:02 +01:00
timeoutms: Int?,
twophase: Bool?)
{
2026-01-22 01:30:06 +00:00
self.id = id
self.command = command
self.commandargv = commandargv
self.systemrunplan = systemrunplan
self.env = env
self.cwd = cwd
self.nodeid = nodeid
self.host = host
self.security = security
self.ask = ask
self.agentid = agentid
self.resolvedpath = resolvedpath
self.sessionkey = sessionkey
2026-02-26 07:37:09 -05:00
self.turnsourcechannel = turnsourcechannel
self.turnsourceto = turnsourceto
self.turnsourceaccountid = turnsourceaccountid
self.turnsourcethreadid = turnsourcethreadid
self.timeoutms = timeoutms
fix: ensure exec approval is registered before returning (#2402) (#3357) * feat(gateway): add register and awaitDecision methods to ExecApprovalManager Separates registration (synchronous) from waiting (async) to allow callers to confirm registration before the decision is made. Adds grace period for resolved entries to prevent race conditions. * feat(gateway): add two-phase response and waitDecision handler for exec approvals Send immediate 'accepted' response after registration so callers can confirm the approval ID is valid. Add exec.approval.waitDecision endpoint to wait for decision on already-registered approvals. * fix(exec): await approval registration before returning approval-pending Ensures the approval ID is registered in the gateway before the tool returns. Uses exec.approval.request with expectFinal:false for registration, then fire-and-forget exec.approval.waitDecision for the decision phase. Fixes #2402 * test(gateway): update exec-approval test for two-phase response Add assertion for immediate 'accepted' response before final decision. * test(exec): update approval-id test mocks for new two-phase flow Mock both exec.approval.request (registration) and exec.approval.waitDecision (decision) calls to match the new internal implementation. * fix(lint): add cause to errors, use generics instead of type assertions * fix(exec-approval): guard register() against duplicate IDs * fix: remove unused timeoutMs param, guard register() against duplicates * fix(exec-approval): throw on duplicate ID, capture entry in closure * fix: return error on timeout, remove stale test mock branch * fix: wrap register() in try/catch, make timeout handling consistent * fix: update snapshot on timeout, make two-phase response opt-in * fix: extend grace period to 15s, return 'expired' status * fix: prevent double-resolve after timeout * fix: make register() idempotent, capture snapshot before await * fix(gateway): complete two-phase exec approval wiring * fix: finalize exec approval race fix (openclaw#3357) thanks @ramin-shirali * fix(protocol): regenerate exec approval request models (openclaw#3357) thanks @ramin-shirali * fix(test): remove unused callCount in discord threading test --------- Co-authored-by: rshirali <rshirali@rshirali-haga.local> Co-authored-by: rshirali <rshirali@rshirali-haga-1.home> Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 19:57:02 +01:00
self.twophase = twophase
}
private enum CodingKeys: String, CodingKey {
2026-01-22 01:30:06 +00:00
case id
case command
case commandargv = "commandArgv"
case systemrunplan = "systemRunPlan"
case env
case cwd
case nodeid = "nodeId"
case host
case security
case ask
case agentid = "agentId"
case resolvedpath = "resolvedPath"
case sessionkey = "sessionKey"
2026-02-26 07:37:09 -05:00
case turnsourcechannel = "turnSourceChannel"
case turnsourceto = "turnSourceTo"
case turnsourceaccountid = "turnSourceAccountId"
case turnsourcethreadid = "turnSourceThreadId"
case timeoutms = "timeoutMs"
fix: ensure exec approval is registered before returning (#2402) (#3357) * feat(gateway): add register and awaitDecision methods to ExecApprovalManager Separates registration (synchronous) from waiting (async) to allow callers to confirm registration before the decision is made. Adds grace period for resolved entries to prevent race conditions. * feat(gateway): add two-phase response and waitDecision handler for exec approvals Send immediate 'accepted' response after registration so callers can confirm the approval ID is valid. Add exec.approval.waitDecision endpoint to wait for decision on already-registered approvals. * fix(exec): await approval registration before returning approval-pending Ensures the approval ID is registered in the gateway before the tool returns. Uses exec.approval.request with expectFinal:false for registration, then fire-and-forget exec.approval.waitDecision for the decision phase. Fixes #2402 * test(gateway): update exec-approval test for two-phase response Add assertion for immediate 'accepted' response before final decision. * test(exec): update approval-id test mocks for new two-phase flow Mock both exec.approval.request (registration) and exec.approval.waitDecision (decision) calls to match the new internal implementation. * fix(lint): add cause to errors, use generics instead of type assertions * fix(exec-approval): guard register() against duplicate IDs * fix: remove unused timeoutMs param, guard register() against duplicates * fix(exec-approval): throw on duplicate ID, capture entry in closure * fix: return error on timeout, remove stale test mock branch * fix: wrap register() in try/catch, make timeout handling consistent * fix: update snapshot on timeout, make two-phase response opt-in * fix: extend grace period to 15s, return 'expired' status * fix: prevent double-resolve after timeout * fix: make register() idempotent, capture snapshot before await * fix(gateway): complete two-phase exec approval wiring * fix: finalize exec approval race fix (openclaw#3357) thanks @ramin-shirali * fix(protocol): regenerate exec approval request models (openclaw#3357) thanks @ramin-shirali * fix(test): remove unused callCount in discord threading test --------- Co-authored-by: rshirali <rshirali@rshirali-haga.local> Co-authored-by: rshirali <rshirali@rshirali-haga-1.home> Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 19:57:02 +01:00
case twophase = "twoPhase"
}
}
public struct ExecApprovalResolveParams: Codable, Sendable {
public let id: String
public let decision: String
public init(
id: String,
decision: String)
{
self.id = id
self.decision = decision
}
private enum CodingKeys: String, CodingKey {
case id
case decision
}
}
public struct DevicePairListParams: Codable, Sendable {}
public struct DevicePairApproveParams: Codable, Sendable {
public let requestid: String
public init(
requestid: String)
{
self.requestid = requestid
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
}
}
public struct DevicePairRejectParams: Codable, Sendable {
public let requestid: String
public init(
requestid: String)
{
self.requestid = requestid
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
}
}
public struct DevicePairRemoveParams: Codable, Sendable {
public let deviceid: String
public init(
deviceid: String)
{
self.deviceid = deviceid
}
private enum CodingKeys: String, CodingKey {
case deviceid = "deviceId"
}
}
public struct DeviceTokenRotateParams: Codable, Sendable {
public let deviceid: String
public let role: String
public let scopes: [String]?
public init(
deviceid: String,
role: String,
scopes: [String]?)
{
self.deviceid = deviceid
self.role = role
self.scopes = scopes
}
private enum CodingKeys: String, CodingKey {
case deviceid = "deviceId"
case role
case scopes
}
}
public struct DeviceTokenRevokeParams: Codable, Sendable {
public let deviceid: String
public let role: String
public init(
deviceid: String,
role: String)
{
self.deviceid = deviceid
self.role = role
}
private enum CodingKeys: String, CodingKey {
case deviceid = "deviceId"
case role
}
}
public struct DevicePairRequestedEvent: Codable, Sendable {
public let requestid: String
public let deviceid: String
public let publickey: String
public let displayname: String?
public let platform: String?
2026-02-26 08:46:39 -05:00
public let devicefamily: String?
public let clientid: String?
public let clientmode: String?
public let role: String?
public let roles: [String]?
public let scopes: [String]?
public let remoteip: String?
public let silent: Bool?
public let isrepair: Bool?
public let ts: Int
public init(
requestid: String,
deviceid: String,
publickey: String,
displayname: String?,
platform: String?,
2026-02-26 08:46:39 -05:00
devicefamily: String?,
clientid: String?,
clientmode: String?,
role: String?,
roles: [String]?,
scopes: [String]?,
remoteip: String?,
silent: Bool?,
isrepair: Bool?,
ts: Int)
{
self.requestid = requestid
self.deviceid = deviceid
self.publickey = publickey
self.displayname = displayname
self.platform = platform
2026-02-26 08:46:39 -05:00
self.devicefamily = devicefamily
self.clientid = clientid
self.clientmode = clientmode
self.role = role
self.roles = roles
self.scopes = scopes
self.remoteip = remoteip
self.silent = silent
self.isrepair = isrepair
self.ts = ts
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
case deviceid = "deviceId"
case publickey = "publicKey"
case displayname = "displayName"
case platform
2026-02-26 08:46:39 -05:00
case devicefamily = "deviceFamily"
case clientid = "clientId"
case clientmode = "clientMode"
case role
case roles
case scopes
case remoteip = "remoteIp"
case silent
case isrepair = "isRepair"
case ts
}
}
public struct DevicePairResolvedEvent: Codable, Sendable {
public let requestid: String
public let deviceid: String
public let decision: String
public let ts: Int
public init(
requestid: String,
deviceid: String,
decision: String,
ts: Int)
{
self.requestid = requestid
self.deviceid = deviceid
self.decision = decision
self.ts = ts
}
private enum CodingKeys: String, CodingKey {
case requestid = "requestId"
case deviceid = "deviceId"
case decision
case ts
}
}
public struct ChatHistoryParams: Codable, Sendable {
public let sessionkey: String
public let limit: Int?
public init(
sessionkey: String,
limit: Int?)
{
self.sessionkey = sessionkey
self.limit = limit
}
private enum CodingKeys: String, CodingKey {
case sessionkey = "sessionKey"
case limit
}
}
public struct ChatSendParams: Codable, Sendable {
public let sessionkey: String
public let message: String
public let thinking: String?
public let deliver: Bool?
public let attachments: [AnyCodable]?
public let timeoutms: Int?
public let idempotencykey: String
public init(
sessionkey: String,
message: String,
thinking: String?,
deliver: Bool?,
attachments: [AnyCodable]?,
timeoutms: Int?,
idempotencykey: String)
{
self.sessionkey = sessionkey
self.message = message
self.thinking = thinking
self.deliver = deliver
self.attachments = attachments
self.timeoutms = timeoutms
self.idempotencykey = idempotencykey
}
private enum CodingKeys: String, CodingKey {
case sessionkey = "sessionKey"
case message
case thinking
case deliver
case attachments
case timeoutms = "timeoutMs"
case idempotencykey = "idempotencyKey"
}
}
public struct ChatAbortParams: Codable, Sendable {
public let sessionkey: String
public let runid: String?
public init(
sessionkey: String,
runid: String?)
{
self.sessionkey = sessionkey
self.runid = runid
}
private enum CodingKeys: String, CodingKey {
case sessionkey = "sessionKey"
case runid = "runId"
}
}
public struct ChatInjectParams: Codable, Sendable {
public let sessionkey: String
public let message: String
public let label: String?
public init(
sessionkey: String,
message: String,
label: String?)
{
self.sessionkey = sessionkey
self.message = message
self.label = label
}
private enum CodingKeys: String, CodingKey {
case sessionkey = "sessionKey"
case message
case label
}
}
public struct ChatEvent: Codable, Sendable {
public let runid: String
public let sessionkey: String
public let seq: Int
public let state: AnyCodable
public let message: AnyCodable?
public let errormessage: String?
public let usage: AnyCodable?
public let stopreason: String?
public init(
runid: String,
sessionkey: String,
seq: Int,
state: AnyCodable,
message: AnyCodable?,
errormessage: String?,
usage: AnyCodable?,
stopreason: String?)
{
self.runid = runid
self.sessionkey = sessionkey
self.seq = seq
self.state = state
self.message = message
self.errormessage = errormessage
self.usage = usage
self.stopreason = stopreason
}
private enum CodingKeys: String, CodingKey {
case runid = "runId"
case sessionkey = "sessionKey"
case seq
case state
case message
case errormessage = "errorMessage"
case usage
case stopreason = "stopReason"
}
}
public struct UpdateRunParams: Codable, Sendable {
public let sessionkey: String?
public let note: String?
public let restartdelayms: Int?
public let timeoutms: Int?
public init(
sessionkey: String?,
note: String?,
restartdelayms: Int?,
timeoutms: Int?)
{
self.sessionkey = sessionkey
self.note = note
self.restartdelayms = restartdelayms
self.timeoutms = timeoutms
}
private enum CodingKeys: String, CodingKey {
case sessionkey = "sessionKey"
case note
case restartdelayms = "restartDelayMs"
case timeoutms = "timeoutMs"
}
}
public struct TickEvent: Codable, Sendable {
public let ts: Int
public init(
ts: Int)
{
self.ts = ts
}
private enum CodingKeys: String, CodingKey {
case ts
}
}
public struct ShutdownEvent: Codable, Sendable {
public let reason: String
public let restartexpectedms: Int?
public init(
reason: String,
restartexpectedms: Int?)
{
self.reason = reason
self.restartexpectedms = restartexpectedms
}
private enum CodingKeys: String, CodingKey {
case reason
case restartexpectedms = "restartExpectedMs"
}
}
public enum GatewayFrame: Codable, Sendable {
case req(RequestFrame)
case res(ResponseFrame)
case event(EventFrame)
case unknown(type: String, raw: [String: AnyCodable])
private enum CodingKeys: String, CodingKey {
case type
}
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
let type = try typeContainer.decode(String.self, forKey: .type)
switch type {
case "req":
self = try .req(RequestFrame(from: decoder))
case "res":
self = try .res(ResponseFrame(from: decoder))
case "event":
self = try .event(EventFrame(from: decoder))
default:
let container = try decoder.singleValueContainer()
let raw = try container.decode([String: AnyCodable].self)
self = .unknown(type: type, raw: raw)
}
}
public func encode(to encoder: Encoder) throws {
switch self {
case let .req(v):
try v.encode(to: encoder)
case let .res(v):
try v.encode(to: encoder)
case let .event(v):
try v.encode(to: encoder)
case let .unknown(_, raw):
var container = encoder.singleValueContainer()
try container.encode(raw)
}
}
}