browser.ts 23.7 KB
Newer Older
Rayyyyy's avatar
Rayyyyy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { JSDOM } from 'jsdom';
import TurndownService from 'turndown';

import config from './config';
import { Message, ToolObservation } from './types';
import { logger, withTimeout } from './utils';

// represent a quote from a display
interface Quote {
  text: string;
  metadata: Metadata[];
}

interface ActionResult {
  contentType: string;
  metadataList?: TetherQuoteMetadata[];
  metadata?: any;
  roleMetadata: string;
  message: string;
}

// represent a piece of metadata to be marked in the final answer
interface Metadata {
  type: string;
  title: string;
  url: string;
  lines: string[];
}

interface TetherQuoteExtra {
  cited_message_idx: number;
  evidence_text: string;
}

interface TetherQuoteMetadata {
  type: string;
  title: string;
  url: string;
  text: string;
  pub_date?: string;
  extra?: TetherQuoteExtra;
}

interface Citation {
  citation_format_type: string;
  start_ix: number;
  end_ix: number;
  metadata?: TetherQuoteMetadata;
  invalid_reason?: string;
}

interface PageState {
  aCounter: number;
  imgCounter: number;

  url: URL;
  url_string: string;
  hostname: string;
  links: string[];
  links_meta: TetherQuoteMetadata[];
  lines: string[];
  line_source: Record<string, Metadata>; // string representation of number interval
  title?: string;
}

interface BrowserState {
  pageStack: PageState[];
  quoteCounter: number;
  quotes: Record<string, Quote>;
}

function removeDenseLinks(document: Document, ratioThreshold: number = 0.5) {
  // Remove nav elements
  const navs = document.querySelectorAll('nav');
  navs.forEach(nav => {
    if (nav.parentNode) {
      nav.parentNode.removeChild(nav);
    }
  });

  // Query for lists, divs, spans, tables, and paragraphs
  const elements = document.querySelectorAll('ul, ol, div, span, nav, table, p');
  elements.forEach(element => {
    if (element === null) return;

    const children = Array.from(element.childNodes);
    const links = element.querySelectorAll('a');

    if (children.length <= 1) return;

    const allText = element.textContent ? element.textContent.trim().replace(/\s+/g, '') : '';
    const linksText = Array.from(links)
      .map(link => (link.textContent ? link.textContent.trim() : ''))
      .join('')
      .replace(/\s+/g, '');

    if (allText.length === 0 || linksText.length === 0) return;

    let ratio = linksText.length / allText.length;
    if (ratio > ratioThreshold && element.parentNode) {
      element.parentNode.removeChild(element);
    }
  });
}

abstract class BaseBrowser {
  public static toolName = 'browser' as const;
  public description = 'BaseBrowser';

  private turndownService = new TurndownService({
    headingStyle: 'atx',
  });

  private state: BrowserState;

  private transform(dom: JSDOM): string {
    let state = this.lastPageState();
    state.aCounter = 0;
    state.imgCounter = 0;
    state.links = [];

    return this.turndownService.turndown(dom.window.document);
  }

  private formatPage(state: PageState): string {
    let formatted_lines = state.lines.join('\n');
    let formatted_title = state.title ? `TITLE: ${state.title}\n\n` : '';
    let formatted_range = `\nVisible: 0% - 100%`;
    let formatted_message = formatted_title + formatted_lines + formatted_range;
    return formatted_message;
  }

  private newPageState(): PageState {
    return {
      aCounter: 0,
      imgCounter: 0,

      url: new URL('about:blank'),
      url_string: 'about:blank',
      hostname: '',
      title: '',
      links: [],
      links_meta: [],
      lines: [],
      line_source: {},
    };
  }

  private pushPageState(): PageState {
    let state = this.newPageState();
    this.state.pageStack.push(state);
    return state;
  }

  private lastPageState(): PageState {
    if (this.state.pageStack.length === 0) {
      throw new Error('No page state');
    }
    return this.state.pageStack[this.state.pageStack.length - 1];
  }

  private formatErrorUrl(url: string): string {
    let TRUNCATION_LIMIT = 80;
    if (url.length <= TRUNCATION_LIMIT) {
      return url;
    }
    return url.slice(0, TRUNCATION_LIMIT) + `... (URL truncated at ${TRUNCATION_LIMIT} chars)`;
  }

  protected functions = {
    search: async (query: string, recency_days: number = -1) => {
      logger.debug(`Searching for: ${query}`);
      const search = new URLSearchParams({ q: query });
      recency_days > 0 && search.append('recency_days', recency_days.toString());
Rayyyyy's avatar
Rayyyyy committed
175
176
177
178
179
180
      if (config.CUSTOM_CONFIG_ID) {
    search.append('customconfig', config.CUSTOM_CONFIG_ID.toString());
}
      const url = `${config.BING_SEARCH_API_URL}/search?${search.toString()}`;
      console.log('Full URL:', url); // 输出完整的 URL查看是否正确

Rayyyyy's avatar
Rayyyyy committed
181
182
      return withTimeout(
        config.BROWSER_TIMEOUT,
Rayyyyy's avatar
Rayyyyy committed
183
        fetch(url, {
Rayyyyy's avatar
Rayyyyy committed
184
185
186
          headers: {
            'Ocp-Apim-Subscription-Key': config.BING_SEARCH_API_KEY,
          }
Rayyyyy's avatar
Rayyyyy committed
187
188
        })
            .then(
Rayyyyy's avatar
Rayyyyy committed
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
          res =>
            res.json() as Promise<{
              queryContext: {
                originalQuery: string;
              };
              webPages: {
                webSearchUrl: string;
                totalEstimatedMatches: number;
                value: {
                  id: string;
                  name: string;
                  url: string;
                  datePublished: string; // 2018-05-18T08:00:00.0000000
                  datePublishedDisplayText: string;
                  isFamilyFriendly: boolean;
                  displayUrl: string;
                  snippet: string;
                  dateLastCrawled: string;
                  cachedPageUrl: string;
                  language: string;
                  isNavigational: boolean;
                }[];
              };
              rankingResponse: {
                mainline: {
                  items: {
                    answerType: 'WebPages';
                    resultIndex: number;
                    value: {
                      id: string;
                    };
                  }[];
                };
              };
            }>,
        ),
      )
        .then(async ({ value: res }) => {
          try {
            let state = this.pushPageState();
            let metadataList: TetherQuoteMetadata[] = [];
            for (const [i, entry] of res.webPages.value.entries()) {
              const url = new URL(entry.url);
              const hostname = url.hostname;
              state.lines.push(` # 【${i}${entry.name}${hostname}】`);
              state.lines.push(entry.snippet);
              const quoteMetadata: Metadata = {
                type: 'webpage',
                title: entry.name,
                url: entry.url,
                lines: state.lines.slice(2 * i, 2 * i + 2),
              };
              state.line_source[`${2 * i}-${2 * i + 1}`] = quoteMetadata;
              state.links[i] = entry.url;

              const returnMetadata: TetherQuoteMetadata = {
                type: quoteMetadata.type,
                title: quoteMetadata.title,
                url: quoteMetadata.url,
                text: state.lines[2 * i + 1], // only content, not link
                pub_date: entry.datePublished,
              };
              metadataList.push(returnMetadata);
            }
            const returnContentType = 'browser_result';
            return {
              contentType: returnContentType,
              roleMetadata: returnContentType,
              message: this.formatPage(state),
              metadataList,
            };
          } catch (err) {
            throw new Error(`parse error: ${err}`);
          }
        })
        .catch(err => {
Rayyyyy's avatar
Rayyyyy committed
265
          logger.error(`搜索请求失败:${query},错误信息:${err.message}`);
Rayyyyy's avatar
Rayyyyy committed
266
267
268
          if (err.code === 'ECONNABORTED') {
            throw new Error(`Timeout while executing search for: ${query}`);
          }
Rayyyyy's avatar
Rayyyyy committed
269
          throw new Error(`网络或服务器发生错误,请检查URL: ${url}`);
Rayyyyy's avatar
Rayyyyy committed
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
        });
    },
    open_url: (url: string) => {
      logger.debug(`Opening ${url}`);

      return withTimeout(
        config.BROWSER_TIMEOUT,
        fetch(url).then(res => res.text()),
      )
        .then(async ({ value: res, time }) => {
          try {
            const state = this.pushPageState();
            state.url = new URL(url);
            state.url_string = url;
            state.hostname = state.url.hostname;

            const html = res;
            const dom = new JSDOM(html);
            const title = dom.window.document.title;
            const markdown = this.transform(dom);

            state.title = title;

            // Remove first line, because it will be served as the title
            const lines = markdown.split('\n');
            lines.shift();
            // Remove consequent empty lines
            let i = 0;
            while (i < lines.length - 1) {
              if (lines[i].trim() === '' && lines[i + 1].trim() === '') {
                lines.splice(i, 1);
              } else {
                i++;
              }
            }

            let page = lines.join('\n');

            // The first line feed is not a typo
            let text_result = `\nURL: ${url}\n${page}`;
            state.lines = text_result.split('\n');

            // all lines has only one source
            state.line_source = {};
            state.line_source[`0-${state.lines.length - 1}`] = {
              type: 'webpage',
              title: title,
              url: url,
              lines: state.lines,
            };

            let message = this.formatPage(state);

            const returnContentType = 'browser_result';
            return {
              contentType: returnContentType,
              roleMetadata: returnContentType,
              message,
              metadataList: state.links_meta,
            };
          } catch (err) {
            throw new Error(`parse error: ${err}`);
          }
        })
        .catch(err => {
          logger.error(err.message);
          if (err.code === 'ECONNABORTED') {
            throw new Error(`Timeout while loading page w/ URL: ${url}`);
          }
          throw new Error(`Failed to load page w/ URL: ${url}`);
        });
    },
    mclick: (ids: number[]) => {
      logger.info('Entering mclick', ids);
      let promises: Promise<ActionResult>[] = [];
      let state = this.lastPageState();
      for (let id of ids) {
        if (isNaN(id) || id >= state.links.length) {
          promises.push(
            Promise.reject(
              new Error(
                `recorded='click(${id})' temporary=None permanent=None new_state=None final=None success=False feedback='Error parsing ID ${id}' metadata={}`,
              ),
            ),
          );
          continue;
        }

        let url: string;
        try {
          url = new URL(state.links[id], state.url).href;
        } catch (err) {
          logger.error(`Failed in getting ${state.links[id]}, ${state.url}`);
          promises.push(
            Promise.reject(
              new Error(
                `recorded='click(${id})' temporary=None permanent='${err}' new_state=None final=None success=False feedback='Error parsing URL for ID ${id}' metadata={}`,
              ),
            ),
          );
          continue;
        }

        const quoteIndex = this.state.quoteCounter++; // ascending in final results
        promises.push(
          withTimeout(
            config.BROWSER_TIMEOUT,
            fetch(url).then(res => res.text()),
          )
            .then(({ value: res, time }) => {
              let state = this.newPageState();
              state.url = new URL(url);
              state.hostname = state.url.hostname;

              try {
                const html = res;
                const dom = new JSDOM(html);
                const title = dom.window.document.title;
                state.title = title;
                removeDenseLinks(dom.window.document);
                let quoteText = this.transform(dom);
                // remove consecutive newline
                quoteText = quoteText.replace(/[\r\n]+/g, '\n');
                const quoteLines = quoteText.split('\n');
                state.lines = quoteLines;
                const metadata = {
                  type: 'webpage',
                  title: title,
                  url: url,
                  lines: quoteLines,
                };
                const quoteMetadata = {
                  type: 'webpage',
                  title: title,
                  url: url,
                  text: quoteText,
                };
                state.line_source = {};
                state.line_source[`0-${state.lines.length - 1}`] = metadata;
                this.state.quotes[quoteIndex.toString()] = {
                  text: quoteText,
                  metadata: [metadata],
                };

                const returnContentType = 'quote_result';
                return {
                  contentType: returnContentType,
                  roleMetadata: `${returnContentType} [${quoteIndex}†source]`,
                  message: quoteText,
                  metadataList: [quoteMetadata],
                  metadata: {
                    url,
                  },
                };
              } catch (err) {
                throw new Error(`parse error: ${err}`);
              }
            })
            .catch(err => {
              logger.error(err.message);
              if (err.code === 'ECONNABORTED') {
                throw new Error(`Timeout while loading page w/ URL: ${this.formatErrorUrl(url)}`);
              }
              throw new Error(`Failed to load page w/ URL: ${this.formatErrorUrl(url)}`);
            })
            .catch(err => {
              // format error message
              const returnContentType = 'system_error';
              throw {
                contentType: returnContentType,
                roleMetadata: returnContentType,
                message: `recorded='click(${id})' temporary=None permanent='${
                  err.message
                }' new_state=None final=None success=False feedback='Error fetching url ${this.formatErrorUrl(
                  url,
                )}' metadata={}`,
                metadata: {
                  failedURL: url,
                },
              } as ActionResult;
            }),
        );
      }

      return Promise.allSettled(promises).then(async results => {
        const actionResults = results.map(r => {
          if (r.status === 'fulfilled') {
            return r.value;
          } else {
            logger.error(r.reason);
            return r.reason as ActionResult;
          }
        });

        if (results.filter(r => r.status === 'fulfilled').length === 0) {
          // collect errors
          const err_text = (results as PromiseRejectedResult[])
            .map(r => (r.reason as ActionResult).message)
            .join('\n');
          throw new Error(err_text);
        } else {
          return actionResults;
        }
      });
    },
  };

  constructor() {
    this.state =  {
      pageStack: [],
      quotes: {},
      quoteCounter: 7,
    };

    this.turndownService.remove('script');
    this.turndownService.remove('style');

    // Add rules for turndown
    this.turndownService.addRule('reference', {
      filter: function (node, options: any): boolean {
        return (
          options.linkStyle === 'inlined' &&
          node.nodeName === 'A' &&
          node.getAttribute('href') !== undefined
        );
      },

      replacement: (content, node, options): string => {
        let state = this.state.pageStack[this.state.pageStack.length - 1];
        if (!content || !('getAttribute' in node)) return '';
        let href = undefined;
        try {
          if ('getAttribute' in node) {
            const hostname = new URL(node.getAttribute('href')!).hostname;
            // Do not append hostname when in the same domain
            if (hostname === state.hostname || !hostname) {
              href = '';
            } else {
              href = '' + hostname;
            }
          }
        } catch (e) {
          // To prevent displaying links like '/foo/bar'
          href = '';
        }
        if (href === undefined) return '';

        const url = node.getAttribute('href')!;
        let linkId = state.links.findIndex(link => link === url);
        if (linkId === -1) {
          linkId = state.aCounter++;
          // logger.debug(`New link[${linkId}]: ${url}`);
          state.links_meta.push({
            type: 'webpage',
            title: node.textContent!,
            url: href,
            text: node.textContent!,
          });
          state.links.push(url);
        }
        return `【${linkId}${node.textContent}${href}】`;
      },
    });
    this.turndownService.addRule('img', {
      filter: 'img',

      replacement: (content, node, options): string => {
        let state = this.state.pageStack[this.state.pageStack.length - 1];
        return `[Image ${state.imgCounter++}]`;
      },
    });
    // Just to change indentation, wondering why this isn't exposed as an option
    this.turndownService.addRule('list', {
      filter: 'li',

      replacement: function (content, node, options) {
        content = content
          .replace(/^\n+/, '') // remove leading newlines
          .replace(/\n+$/, '\n') // replace trailing newlines with just a single one
          .replace(/\n/gm, '\n  '); // indent

        let prefix = options.bulletListMarker + ' ';
        const parent = node.parentNode! as Element;
        if (parent.nodeName === 'OL') {
          const start = parent.getAttribute('start');
          const index = Array.prototype.indexOf.call(parent.children, node);
          prefix = (start ? Number(start) + index : index + 1) + '.  ';
        }
        return '  ' + prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '');
      },
    });
    // Remove bold; remove() doesn't work on this, I don't know why
    this.turndownService.addRule('emph', {
      filter: ['strong', 'b'],

      replacement: function (content, node, options) {
        if (!content.trim()) return '';
        return content;
      },
    });
  }

  abstract actionLine(content: string): Promise<ActionResult | ActionResult[]>;

  async action(content: string): Promise<ToolObservation[]> {
    const lines = content.split('\n');
    let results: ActionResult[] = [];
    for (const line of lines) {
      logger.info(`Action line: ${line}`)
      try {
        const lineActionResult = await this.actionLine(line);
        logger.debug(`Action line result: ${JSON.stringify(lineActionResult, null, 2)}`);
        if (Array.isArray(lineActionResult)) {
          results = results.concat(lineActionResult);
        } else {
          results.push(lineActionResult);
        }
      } catch (err) {
        const returnContentType = 'system_error';
        results.push({
          contentType: returnContentType,
          roleMetadata: returnContentType,
          message: `Error when executing command ${line}\n${err}`,
          metadata: {
            failedCommand: line,
          },
        });
      }
    }
    const observations: ToolObservation[] = [];
    for (const result of results) {
      const observation: ToolObservation = {
        contentType: result.contentType,
        result: result.message,
        roleMetadata: result.roleMetadata,
        metadata: result.metadata ?? {},
      };

      if (result.metadataList) {
        observation.metadata.metadata_list = result.metadataList;
      }
      observations.push(observation);
    }
    return observations;
  }

  postProcess(message: Message, metadata: any) {
    const quotePattern = /【(.+?)(.*?)】/g;
    const content = message.content;
    let match;
    let citations: Citation[] = [];
    const citation_format_type = 'tether_og';
    while ((match = quotePattern.exec(content))) {
      logger.debug(`Citation match: ${match[0]}`);
      const start_ix = match.index;
      const end_ix = match.index + match[0].length;

      let invalid_reason = undefined;
      let metadata: TetherQuoteMetadata;
      try {
        let cited_message_idx = parseInt(match[1]);
        let evidence_text = match[2];
        let quote = this.state.quotes[cited_message_idx.toString()];
        if (quote === undefined) {
          invalid_reason = `'Referenced message ${cited_message_idx} in citation 【${cited_message_idx}${evidence_text}】 is not a quote or tether browsing display.'`;
          logger.error(`Triggered citation error with quote undefined: ${invalid_reason}`);
          citations.push({
            citation_format_type,
            start_ix,
            end_ix,
            invalid_reason,
          });
        } else {
          let extra: TetherQuoteExtra = {
            cited_message_idx,
            evidence_text,
          };
          const quote_metadata = quote.metadata[0];
          metadata = {
            type: 'webpage',
            title: quote_metadata.title,
            url: quote_metadata.url,
            text: quote_metadata.lines.join('\n'),
            extra,
          };
          citations.push({
            citation_format_type,
            start_ix,
            end_ix,
            metadata,
          });
        }
      } catch (err) {
        logger.error(`Triggered citation error: ${err}`);
        invalid_reason = `Citation Error: ${err}`;
        citations.push({
          start_ix,
          end_ix,
          citation_format_type,
          invalid_reason,
        });
      }
    }
    metadata.citations = citations;
  }

  getState() {
    return this.state;
  }
}

export class SimpleBrowser extends BaseBrowser {
  public description = 'SimpleBrowser';

  constructor() {
    super();
  }

  async actionLine(content: string): Promise<ActionResult | ActionResult[]> {
    const regex = /(\w+)\(([^)]*)\)/;
    const matches = content.match(regex);

    if (matches) {
      const functionName = matches[1];
      let args_string = matches[2];
      if (functionName === 'mclick') {
        args_string = args_string.trim().slice(1, -1); // remove '[' and ']'
      }

      const args = args_string.split(',').map(arg => arg.trim());

      let result;
      switch (functionName) {
        case 'search':
          logger.debug(`SimpleBrowser action search ${args[0].slice(1, -1)}`);
          const recency_days = /(^|\D)(\d+)($|\D)/.exec(args[1])?.[2] as undefined | `${number}`;
          result = await this.functions.search(
            args[0].slice(1, -1), // slice quote "query"
            recency_days && Number(recency_days),
          );
          break;
        case 'open_url':
          logger.debug(`SimpleBrowser action open_url ${args[0].slice(1, -1)}`);
          result = await this.functions.open_url(args[0].slice(1, -1));
          break;
        case 'mclick':
          logger.debug(`SimpleBrowser action mclick ${args}`);
          result = await this.functions.mclick(args.map(x => parseInt(x)));
          break;
        default:
          throw new Error(`Parse Error: ${content}`);
      }

      return result;
    } else {
      throw new Error('Parse Error');
    }
  }
}

if (require.main === module) {
  (async () => {
    let browser = new SimpleBrowser();
    let demo = async (action: string) => {
      logger.info(` ------ Begin of Action: ${action} ------`);
      let results = await browser.action(action);
      for (const [idx, result] of results.entries()) {
        logger.info(`[Result ${idx}] contentType: ${result.contentType}`);
        logger.info(`[Result ${idx}] roleMetadata: ${result.roleMetadata}`);
        logger.info(`[Result ${idx}] result: ${result.result}`);
        logger.info(`[Result ${idx}] metadata: ${JSON.stringify(result.metadata, null, 2)}`);
      }
      logger.info(` ------ End of Action: ${action} ------\n\n`);
    };

    await demo("search('Apple Latest News')");
    await demo('mclick([0, 1, 5, 6])');
    await demo('mclick([1, 999999])');
    await demo("open_url('https://chatglm.cn')");
    await demo("search('zhipu latest News')");
    await demo('mclick([0, 1, 5, 6])');
  })();
}