• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

popstas / telegram-functions-bot / 18802835322

25 Oct 2025 12:07PM UTC coverage: 77.384%. First build
18802835322

Pull #164

github

web-flow
Merge 636cfaef6 into 245bee7dc
Pull Request #164: feat: add delay tool

1313 of 1980 branches covered (66.31%)

Branch coverage included in aggregate %.

18 of 19 new or added lines in 1 file covered. (94.74%)

2461 of 2897 relevant lines covered (84.95%)

5.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/src/tools/delay.ts
1
import { aiFunction, AIFunctionsProvider } from "@agentic/core";
2
import { z } from "zod";
3
import type { ConfigChatType, ThreadStateType } from "../types.ts";
4

5
export const description = "Pause execution for a specified number of seconds before continuing.";
4✔
6

7
type ToolArgsType = {
8
  seconds: number;
9
};
10

11
export class DelayClient extends AIFunctionsProvider {
4✔
12
  protected readonly configChat: ConfigChatType;
13
  protected readonly thread: ThreadStateType;
14

15
  constructor(configChat: ConfigChatType, thread: ThreadStateType) {
16
    super();
4✔
17
    this.configChat = configChat;
4✔
18
    this.thread = thread;
4✔
19
  }
20

21
  @aiFunction({
4✔
22
    name: "delay",
23
    description,
24
    inputSchema: z.object({
25
      seconds: z
26
        .number()
27
        .min(0, "seconds must be a non-negative number")
28
        .max(3600, "seconds must not exceed 3600")
29
        .describe("Number of seconds to pause before responding"),
30
    }),
31
  })
32
  async delay({ seconds }: ToolArgsType) {
4✔
33
    const milliseconds = Math.round(seconds * 1000);
2✔
34

35
    if (milliseconds > 0) {
2✔
36
      await new Promise((resolve) => setTimeout(resolve, milliseconds));
1✔
37
    }
38

39
    const secondsLabel = seconds === 1 ? "second" : "seconds";
2!
40
    return { content: `Waited ${seconds} ${secondsLabel}.` };
2✔
41
  }
42

43
  options_string(str: string) {
44
    try {
1✔
45
      const { seconds } = JSON.parse(str) as Partial<ToolArgsType>;
1✔
46
      if (typeof seconds === "number") {
1!
47
        const secondsLabel = seconds === 1 ? "second" : "seconds";
1!
48
        return `**Delay:** wait ${seconds} ${secondsLabel}`;
1✔
49
      }
50
    } catch {
51
      // ignore parsing errors and return original string
52
    }
NEW
53
    return str;
×
54
  }
55
}
56

57
export function call(configChat: ConfigChatType, thread: ThreadStateType) {
58
  return new DelayClient(configChat, thread);
1✔
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc