handle method

  1. @override
Future<StructuredResponse> handle(
  1. GlintSession session,
  2. CallToolRequest request
)
override

Implementation

@override
Future<StructuredResponse> handle(GlintSession session, CallToolRequest request) async {
  final args = request.arguments ?? const <String, Object?>{};
  final showTouches = argBool(args, 'showTouches');
  final observe = argBool(args, 'observe') ?? false;
  var response = await _attach(session, request);
  if (!response.isError && argBool(args, 'dryRun') != true) {
    if (observe) {
      response = await _armObserve(session, response);
      if (showTouches != null) {
        response =
            response.addWarnings(['showTouches is ignored with observe:true: an observed app is never changed']);
      }
    } else {
      response = await _showTouches(session, showTouches, response);
      response = _disarmObserve(session, response);
    }
  }
  if (response.isError || session.updateNoticeShown) return response;
  final notice = updateNotice();
  if (notice == null) return response;
  session.updateNoticeShown = true;
  return response.addWarnings([notice]);
}