feat: add headless agent management to CLI and both desktop clients

This commit is contained in:
tongtong committed 2026-11-12 21:17:44 +08:00
1 parent e91fa0235c
commit 6916dd54fb
50 files changed
+4837 -148

No files matched your search

@@ -0,0 +1,594 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'agent_models.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ManagedPhone {
String get id; String? get target; String? get adbSerial; bool get enabled; bool get connected; String? get lastError;
/// Create a copy of ManagedPhone
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ManagedPhoneCopyWith<ManagedPhone> get copyWith => _$ManagedPhoneCopyWithImpl<ManagedPhone>(this as ManagedPhone, _$identity);
@override
bool operator ==(Object other) {
final _this = this as ManagedPhone;
return identical(this, other) || (other.runtimeType == runtimeType&&other is ManagedPhone&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.target, _this.target) || other.target == _this.target)&&(identical(other.adbSerial, _this.adbSerial) || other.adbSerial == _this.adbSerial)&&(identical(other.enabled, _this.enabled) || other.enabled == _this.enabled)&&(identical(other.connected, _this.connected) || other.connected == _this.connected)&&(identical(other.lastError, _this.lastError) || other.lastError == _this.lastError));
}
@override
int get hashCode {
final _this = this as ManagedPhone;
return Object.hash(runtimeType,_this.id,_this.target,_this.adbSerial,_this.enabled,_this.connected,_this.lastError);
}
@override
String toString() {
final _this = this as ManagedPhone;
return 'ManagedPhone(id: ${_this.id}, target: ${_this.target}, adbSerial: ${_this.adbSerial}, enabled: ${_this.enabled}, connected: ${_this.connected}, lastError: ${_this.lastError})';
}
}
/// @nodoc
abstract mixin class $ManagedPhoneCopyWith<$Res> {
factory $ManagedPhoneCopyWith(ManagedPhone value, $Res Function(ManagedPhone) _then) = _$ManagedPhoneCopyWithImpl;
@useResult
$Res call({
String id, String? target, String? adbSerial, bool enabled, bool connected, String? lastError
});
}
/// @nodoc
class _$ManagedPhoneCopyWithImpl<$Res>
implements $ManagedPhoneCopyWith<$Res> {
_$ManagedPhoneCopyWithImpl(this._self, this._then);
final ManagedPhone _self;
final $Res Function(ManagedPhone) _then;
/// Create a copy of ManagedPhone
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? target = freezed,Object? adbSerial = freezed,Object? enabled = null,Object? connected = null,Object? lastError = freezed,}) {
return _then(ManagedPhone(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,target: freezed == target ? _self.target : target // ignore: cast_nullable_to_non_nullable
as String?,adbSerial: freezed == adbSerial ? _self.adbSerial : adbSerial // ignore: cast_nullable_to_non_nullable
as String?,enabled: null == enabled ? _self.enabled : enabled // ignore: cast_nullable_to_non_nullable
as bool,connected: null == connected ? _self.connected : connected // ignore: cast_nullable_to_non_nullable
as bool,lastError: freezed == lastError ? _self.lastError : lastError // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [ManagedPhone].
extension ManagedPhonePatterns on ManagedPhone {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ManagedPhone value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ManagedPhone() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ManagedPhone value) $default,){
final _that = this;
switch (_that) {
case _ManagedPhone():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ManagedPhone value)? $default,){
final _that = this;
switch (_that) {
case _ManagedPhone() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? target, String? adbSerial, bool enabled, bool connected, String? lastError)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ManagedPhone() when $default != null:
return $default(_that.id,_that.target,_that.adbSerial,_that.enabled,_that.connected,_that.lastError);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? target, String? adbSerial, bool enabled, bool connected, String? lastError) $default,) {final _that = this;
switch (_that) {
case _ManagedPhone():
return $default(_that.id,_that.target,_that.adbSerial,_that.enabled,_that.connected,_that.lastError);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? target, String? adbSerial, bool enabled, bool connected, String? lastError)? $default,) {final _that = this;
switch (_that) {
case _ManagedPhone() when $default != null:
return $default(_that.id,_that.target,_that.adbSerial,_that.enabled,_that.connected,_that.lastError);case _:
return null;
}
}
}
/// @nodoc
class _ManagedPhone extends ManagedPhone {
const _ManagedPhone({required this.id, this.target, this.adbSerial, required this.enabled, required this.connected, this.lastError}): super._();
@override final String id;
@override final String? target;
@override final String? adbSerial;
@override final bool enabled;
@override final bool connected;
@override final String? lastError;
/// Create a copy of ManagedPhone
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ManagedPhoneCopyWith<_ManagedPhone> get copyWith => __$ManagedPhoneCopyWithImpl<_ManagedPhone>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ManagedPhone&&(identical(other.id, id) || other.id == id)&&(identical(other.target, target) || other.target == target)&&(identical(other.adbSerial, adbSerial) || other.adbSerial == adbSerial)&&(identical(other.enabled, enabled) || other.enabled == enabled)&&(identical(other.connected, connected) || other.connected == connected)&&(identical(other.lastError, lastError) || other.lastError == lastError));
}
@override
int get hashCode {
return Object.hash(runtimeType,id,target,adbSerial,enabled,connected,lastError);
}
@override
String toString() {
return 'ManagedPhone(id: $id, target: $target, adbSerial: $adbSerial, enabled: $enabled, connected: $connected, lastError: $lastError)';
}
}
/// @nodoc
abstract mixin class _$ManagedPhoneCopyWith<$Res> implements $ManagedPhoneCopyWith<$Res> {
factory _$ManagedPhoneCopyWith(_ManagedPhone value, $Res Function(_ManagedPhone) _then) = __$ManagedPhoneCopyWithImpl;
@override @useResult
$Res call({
String id, String? target, String? adbSerial, bool enabled, bool connected, String? lastError
});
}
/// @nodoc
class __$ManagedPhoneCopyWithImpl<$Res>
implements _$ManagedPhoneCopyWith<$Res> {
__$ManagedPhoneCopyWithImpl(this._self, this._then);
final _ManagedPhone _self;
final $Res Function(_ManagedPhone) _then;
/// Create a copy of ManagedPhone
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? target = freezed,Object? adbSerial = freezed,Object? enabled = null,Object? connected = null,Object? lastError = freezed,}) {
return _then(_ManagedPhone(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,target: freezed == target ? _self.target : target // ignore: cast_nullable_to_non_nullable
as String?,adbSerial: freezed == adbSerial ? _self.adbSerial : adbSerial // ignore: cast_nullable_to_non_nullable
as String?,enabled: null == enabled ? _self.enabled : enabled // ignore: cast_nullable_to_non_nullable
as bool,connected: null == connected ? _self.connected : connected // ignore: cast_nullable_to_non_nullable
as bool,lastError: freezed == lastError ? _self.lastError : lastError // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
mixin _$ManagedAgent {
String get id; String get name; bool get online; String get hostname; String get os; String get arch; String get version; int get pid; int get revision; bool get supervised; List<ManagedPhone> get devices;
/// Create a copy of ManagedAgent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ManagedAgentCopyWith<ManagedAgent> get copyWith => _$ManagedAgentCopyWithImpl<ManagedAgent>(this as ManagedAgent, _$identity);
@override
bool operator ==(Object other) {
final _this = this as ManagedAgent;
return identical(this, other) || (other.runtimeType == runtimeType&&other is ManagedAgent&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.online, _this.online) || other.online == _this.online)&&(identical(other.hostname, _this.hostname) || other.hostname == _this.hostname)&&(identical(other.os, _this.os) || other.os == _this.os)&&(identical(other.arch, _this.arch) || other.arch == _this.arch)&&(identical(other.version, _this.version) || other.version == _this.version)&&(identical(other.pid, _this.pid) || other.pid == _this.pid)&&(identical(other.revision, _this.revision) || other.revision == _this.revision)&&(identical(other.supervised, _this.supervised) || other.supervised == _this.supervised)&&const DeepCollectionEquality().equals(other.devices, _this.devices));
}
@override
int get hashCode {
final _this = this as ManagedAgent;
return Object.hash(runtimeType,_this.id,_this.name,_this.online,_this.hostname,_this.os,_this.arch,_this.version,_this.pid,_this.revision,_this.supervised,const DeepCollectionEquality().hash(_this.devices));
}
@override
String toString() {
final _this = this as ManagedAgent;
return 'ManagedAgent(id: ${_this.id}, name: ${_this.name}, online: ${_this.online}, hostname: ${_this.hostname}, os: ${_this.os}, arch: ${_this.arch}, version: ${_this.version}, pid: ${_this.pid}, revision: ${_this.revision}, supervised: ${_this.supervised}, devices: ${_this.devices})';
}
}
/// @nodoc
abstract mixin class $ManagedAgentCopyWith<$Res> {
factory $ManagedAgentCopyWith(ManagedAgent value, $Res Function(ManagedAgent) _then) = _$ManagedAgentCopyWithImpl;
@useResult
$Res call({
String id, String name, bool online, String hostname, String os, String arch, String version, int pid, int revision, bool supervised, List<ManagedPhone> devices
});
}
/// @nodoc
class _$ManagedAgentCopyWithImpl<$Res>
implements $ManagedAgentCopyWith<$Res> {
_$ManagedAgentCopyWithImpl(this._self, this._then);
final ManagedAgent _self;
final $Res Function(ManagedAgent) _then;
/// Create a copy of ManagedAgent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? online = null,Object? hostname = null,Object? os = null,Object? arch = null,Object? version = null,Object? pid = null,Object? revision = null,Object? supervised = null,Object? devices = null,}) {
return _then(ManagedAgent(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,online: null == online ? _self.online : online // ignore: cast_nullable_to_non_nullable
as bool,hostname: null == hostname ? _self.hostname : hostname // ignore: cast_nullable_to_non_nullable
as String,os: null == os ? _self.os : os // ignore: cast_nullable_to_non_nullable
as String,arch: null == arch ? _self.arch : arch // ignore: cast_nullable_to_non_nullable
as String,version: null == version ? _self.version : version // ignore: cast_nullable_to_non_nullable
as String,pid: null == pid ? _self.pid : pid // ignore: cast_nullable_to_non_nullable
as int,revision: null == revision ? _self.revision : revision // ignore: cast_nullable_to_non_nullable
as int,supervised: null == supervised ? _self.supervised : supervised // ignore: cast_nullable_to_non_nullable
as bool,devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable
as List<ManagedPhone>,
));
}
}
/// Adds pattern-matching-related methods to [ManagedAgent].
extension ManagedAgentPatterns on ManagedAgent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ManagedAgent value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ManagedAgent() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ManagedAgent value) $default,){
final _that = this;
switch (_that) {
case _ManagedAgent():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ManagedAgent value)? $default,){
final _that = this;
switch (_that) {
case _ManagedAgent() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, bool online, String hostname, String os, String arch, String version, int pid, int revision, bool supervised, List<ManagedPhone> devices)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ManagedAgent() when $default != null:
return $default(_that.id,_that.name,_that.online,_that.hostname,_that.os,_that.arch,_that.version,_that.pid,_that.revision,_that.supervised,_that.devices);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String name, bool online, String hostname, String os, String arch, String version, int pid, int revision, bool supervised, List<ManagedPhone> devices) $default,) {final _that = this;
switch (_that) {
case _ManagedAgent():
return $default(_that.id,_that.name,_that.online,_that.hostname,_that.os,_that.arch,_that.version,_that.pid,_that.revision,_that.supervised,_that.devices);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String name, bool online, String hostname, String os, String arch, String version, int pid, int revision, bool supervised, List<ManagedPhone> devices)? $default,) {final _that = this;
switch (_that) {
case _ManagedAgent() when $default != null:
return $default(_that.id,_that.name,_that.online,_that.hostname,_that.os,_that.arch,_that.version,_that.pid,_that.revision,_that.supervised,_that.devices);case _:
return null;
}
}
}
/// @nodoc
class _ManagedAgent extends ManagedAgent {
const _ManagedAgent({required this.id, required this.name, required this.online, required this.hostname, required this.os, required this.arch, required this.version, required this.pid, required this.revision, required this.supervised, required List<ManagedPhone> devices}): _devices = devices,super._();
@override final String id;
@override final String name;
@override final bool online;
@override final String hostname;
@override final String os;
@override final String arch;
@override final String version;
@override final int pid;
@override final int revision;
@override final bool supervised;
final List<ManagedPhone> _devices;
@override List<ManagedPhone> get devices {
if (_devices is EqualUnmodifiableListView) return _devices;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_devices);
}
/// Create a copy of ManagedAgent
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ManagedAgentCopyWith<_ManagedAgent> get copyWith => __$ManagedAgentCopyWithImpl<_ManagedAgent>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ManagedAgent&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.online, online) || other.online == online)&&(identical(other.hostname, hostname) || other.hostname == hostname)&&(identical(other.os, os) || other.os == os)&&(identical(other.arch, arch) || other.arch == arch)&&(identical(other.version, version) || other.version == version)&&(identical(other.pid, pid) || other.pid == pid)&&(identical(other.revision, revision) || other.revision == revision)&&(identical(other.supervised, supervised) || other.supervised == supervised)&&const DeepCollectionEquality().equals(other.devices, _devices));
}
@override
int get hashCode {
return Object.hash(runtimeType,id,name,online,hostname,os,arch,version,pid,revision,supervised,const DeepCollectionEquality().hash(_devices));
}
@override
String toString() {
return 'ManagedAgent(id: $id, name: $name, online: $online, hostname: $hostname, os: $os, arch: $arch, version: $version, pid: $pid, revision: $revision, supervised: $supervised, devices: $devices)';
}
}
/// @nodoc
abstract mixin class _$ManagedAgentCopyWith<$Res> implements $ManagedAgentCopyWith<$Res> {
factory _$ManagedAgentCopyWith(_ManagedAgent value, $Res Function(_ManagedAgent) _then) = __$ManagedAgentCopyWithImpl;
@override @useResult
$Res call({
String id, String name, bool online, String hostname, String os, String arch, String version, int pid, int revision, bool supervised, List<ManagedPhone> devices
});
}
/// @nodoc
class __$ManagedAgentCopyWithImpl<$Res>
implements _$ManagedAgentCopyWith<$Res> {
__$ManagedAgentCopyWithImpl(this._self, this._then);
final _ManagedAgent _self;
final $Res Function(_ManagedAgent) _then;
/// Create a copy of ManagedAgent
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? online = null,Object? hostname = null,Object? os = null,Object? arch = null,Object? version = null,Object? pid = null,Object? revision = null,Object? supervised = null,Object? devices = null,}) {
return _then(_ManagedAgent(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,online: null == online ? _self.online : online // ignore: cast_nullable_to_non_nullable
as bool,hostname: null == hostname ? _self.hostname : hostname // ignore: cast_nullable_to_non_nullable
as String,os: null == os ? _self.os : os // ignore: cast_nullable_to_non_nullable
as String,arch: null == arch ? _self.arch : arch // ignore: cast_nullable_to_non_nullable
as String,version: null == version ? _self.version : version // ignore: cast_nullable_to_non_nullable
as String,pid: null == pid ? _self.pid : pid // ignore: cast_nullable_to_non_nullable
as int,revision: null == revision ? _self.revision : revision // ignore: cast_nullable_to_non_nullable
as int,supervised: null == supervised ? _self.supervised : supervised // ignore: cast_nullable_to_non_nullable
as bool,devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable
as List<ManagedPhone>,
));
}
}
// dart format on