roboport 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +25 -0
  2. package/core/agent.d.ts +35 -0
  3. package/core/index.d.ts +9 -0
  4. package/core/mcp.d.ts +6 -0
  5. package/core/message.d.ts +36 -0
  6. package/core/model.d.ts +10 -0
  7. package/core/session.d.ts +75 -0
  8. package/core/skill.d.ts +11 -0
  9. package/core/stream.d.ts +33 -0
  10. package/core/tool.d.ts +77 -0
  11. package/env.d.ts +8 -0
  12. package/harness/claudeCode.d.ts +3 -0
  13. package/harness/codex.d.ts +3 -0
  14. package/harness/core.d.ts +7 -0
  15. package/harness/index.d.ts +5 -0
  16. package/harness/index.js +1512 -0
  17. package/harness/pi.d.ts +3 -0
  18. package/harness/shared.d.ts +33 -0
  19. package/harness/tools.d.ts +33 -0
  20. package/index.d.ts +2 -0
  21. package/index.js +537 -0
  22. package/mcp/auth.d.ts +40 -0
  23. package/mcp/clients/grafana.d.ts +17 -0
  24. package/mcp/clients/linear.d.ts +9 -0
  25. package/mcp/clients/tenderly.d.ts +11 -0
  26. package/mcp/core.d.ts +30 -0
  27. package/mcp/index.d.ts +4 -0
  28. package/mcp/index.js +1356 -0
  29. package/mcp/oauth.d.ts +36 -0
  30. package/mcp/servers/calculator.d.ts +1 -0
  31. package/mcp/storage.d.ts +29 -0
  32. package/models/anthropic.d.ts +15 -0
  33. package/models/google.d.ts +14 -0
  34. package/models/index.d.ts +6 -0
  35. package/models/index.js +2039 -0
  36. package/models/moonshot.d.ts +16 -0
  37. package/models/openai-codex-auth.d.ts +17 -0
  38. package/models/openai-compatible.d.ts +41 -0
  39. package/models/openai.d.ts +29 -0
  40. package/package.json +60 -0
  41. package/skills/index.d.ts +7 -0
  42. package/skills/index.js +1007 -0
  43. package/triggers/bus.d.ts +8 -0
  44. package/triggers/core.d.ts +14 -0
  45. package/triggers/index.d.ts +7 -0
  46. package/triggers/index.js +588 -0
  47. package/triggers/sources/cron.d.ts +29 -0
  48. package/triggers/sources/github.d.ts +148 -0
  49. package/triggers/sources/grafana.d.ts +37 -0
  50. package/triggers/sources/linear.d.ts +39 -0
  51. package/triggers/sources/telegram.d.ts +85 -0
@@ -0,0 +1,8 @@
1
+ import type { Emit, Unsub } from './core';
2
+ interface EventBus<T> {
3
+ subs: Set<Emit<T>>;
4
+ }
5
+ declare function makeBus<T>(): EventBus<T>;
6
+ declare function subscribe<T>(bus: EventBus<T>, emit: Emit<T>, filter?: (event: T) => boolean): Unsub;
7
+ declare function dispatch<T>(bus: EventBus<T>, event: T): void;
8
+ export { dispatch, makeBus, subscribe, type EventBus };
@@ -0,0 +1,14 @@
1
+ type MaybePromise<T> = T | Promise<T>;
2
+ type Unsub = () => MaybePromise<void>;
3
+ type Emit<T> = (event: T) => void;
4
+ interface Trigger<T = unknown> {
5
+ name: string;
6
+ start(emit: Emit<T>): MaybePromise<Unsub>;
7
+ }
8
+ type TriggerHandler<T> = (event: T) => MaybePromise<void>;
9
+ interface CustomTriggerInit<T> {
10
+ name: string;
11
+ start: (emit: Emit<T>) => MaybePromise<Unsub>;
12
+ }
13
+ declare function trigger<T = unknown>(init: CustomTriggerInit<T>): Trigger<T>;
14
+ export { trigger, type Emit, type Trigger, type TriggerHandler, type Unsub };
@@ -0,0 +1,7 @@
1
+ import { trigger, type Emit, type Trigger, type TriggerHandler, type Unsub } from './core';
2
+ import { cron, type CronEvent } from './sources/cron';
3
+ import { github, GithubReceiver, type GithubReviewComment, type IssueCommentEvent, type IssuesEvent, type PullRequestEvent, type PullRequestReviewCommentEvent, type PushEvent } from './sources/github';
4
+ import { grafana, GrafanaReceiver, type GrafanaAlertEvent } from './sources/grafana';
5
+ import { linear, LinearReceiver, type LinearCommentEvent, type LinearIssueEvent, type LinearProjectEvent } from './sources/linear';
6
+ import { telegram, TelegramClient, TelegramReceiver, splitMessage, type SendMessageDraftOptions, type SendMessageOptions, type TelegramChat, type TelegramChatAction, type TelegramMessage, type TelegramReceiverOptions, type TelegramUpdate, type TelegramUser } from './sources/telegram';
7
+ export { cron, github, GithubReceiver, grafana, GrafanaReceiver, linear, LinearReceiver, splitMessage, telegram, TelegramClient, TelegramReceiver, trigger, type CronEvent, type Emit, type GithubReviewComment, type GrafanaAlertEvent, type IssueCommentEvent, type IssuesEvent, type LinearCommentEvent, type LinearIssueEvent, type LinearProjectEvent, type PullRequestEvent, type PullRequestReviewCommentEvent, type PushEvent, type SendMessageDraftOptions, type SendMessageOptions, type TelegramChat, type TelegramChatAction, type TelegramMessage, type TelegramReceiverOptions, type TelegramUpdate, type TelegramUser, type Trigger, type TriggerHandler, type Unsub, };
@@ -0,0 +1,588 @@
1
+ // @bun
2
+ // src/triggers/core.ts
3
+ function trigger(init) {
4
+ return { name: init.name, start: init.start };
5
+ }
6
+
7
+ // src/triggers/sources/cron.ts
8
+ var WEEKDAY_INDEX = {
9
+ sun: 0,
10
+ mon: 1,
11
+ tue: 2,
12
+ wed: 3,
13
+ thu: 4,
14
+ fri: 5,
15
+ sat: 6
16
+ };
17
+ function utcDate(parts) {
18
+ return new Date(Date.UTC(parts.year, parts.month, parts.day, parts.hour, parts.minute, 0, 0));
19
+ }
20
+ function nextRun(schedule, from) {
21
+ const year = from.getUTCFullYear();
22
+ const month = from.getUTCMonth();
23
+ const day = from.getUTCDate();
24
+ const hour = from.getUTCHours();
25
+ const minute = from.getUTCMinutes();
26
+ if (schedule.every === "minute") {
27
+ return utcDate({ year, month, day, hour, minute: minute + 1 });
28
+ }
29
+ if (schedule.every === "hour") {
30
+ const targetMinute2 = schedule.minute ?? 0;
31
+ if (minute < targetMinute2) {
32
+ return utcDate({ year, month, day, hour, minute: targetMinute2 });
33
+ }
34
+ return utcDate({ year, month, day, hour: hour + 1, minute: targetMinute2 });
35
+ }
36
+ if (schedule.every === "day") {
37
+ const targetHour2 = schedule.at?.hour ?? 0;
38
+ const targetMinute2 = schedule.at?.minute ?? 0;
39
+ if (hour < targetHour2 || hour === targetHour2 && minute < targetMinute2) {
40
+ return utcDate({
41
+ year,
42
+ month,
43
+ day,
44
+ hour: targetHour2,
45
+ minute: targetMinute2
46
+ });
47
+ }
48
+ return utcDate({
49
+ year,
50
+ month,
51
+ day: day + 1,
52
+ hour: targetHour2,
53
+ minute: targetMinute2
54
+ });
55
+ }
56
+ const weekdays = (Array.isArray(schedule.on) ? schedule.on : [schedule.on]).map((w) => WEEKDAY_INDEX[w]).sort((a, b) => a - b);
57
+ const targetHour = schedule.at?.hour ?? 0;
58
+ const targetMinute = schedule.at?.minute ?? 0;
59
+ const currentWeekday = from.getUTCDay();
60
+ for (let offset = 0;offset < 8; offset++) {
61
+ const candidateWeekday = (currentWeekday + offset) % 7;
62
+ if (!weekdays.includes(candidateWeekday))
63
+ continue;
64
+ const candidate = utcDate({
65
+ year,
66
+ month,
67
+ day: day + offset,
68
+ hour: targetHour,
69
+ minute: targetMinute
70
+ });
71
+ if (candidate.getTime() > from.getTime())
72
+ return candidate;
73
+ }
74
+ throw new Error("cron: failed to compute next run");
75
+ }
76
+ function cron(opts) {
77
+ return {
78
+ name: "cron",
79
+ start: (emit) => {
80
+ let stopped = false;
81
+ let timer = null;
82
+ function schedule() {
83
+ if (stopped)
84
+ return;
85
+ const now = new Date;
86
+ const next = nextRun(opts.schedule, now);
87
+ const delay = Math.max(0, next.getTime() - now.getTime());
88
+ timer = setTimeout(() => {
89
+ if (stopped)
90
+ return;
91
+ emit({ firedAt: new Date });
92
+ schedule();
93
+ }, delay);
94
+ }
95
+ schedule();
96
+ return () => {
97
+ stopped = true;
98
+ if (timer)
99
+ clearTimeout(timer);
100
+ };
101
+ }
102
+ };
103
+ }
104
+
105
+ // src/triggers/bus.ts
106
+ function makeBus() {
107
+ return { subs: new Set };
108
+ }
109
+ function subscribe(bus, emit, filter) {
110
+ const wrapped = filter ? (event) => {
111
+ if (filter(event))
112
+ emit(event);
113
+ } : emit;
114
+ bus.subs.add(wrapped);
115
+ return () => {
116
+ bus.subs.delete(wrapped);
117
+ };
118
+ }
119
+ function dispatch(bus, event) {
120
+ for (const sub of bus.subs)
121
+ sub(event);
122
+ }
123
+
124
+ // src/triggers/sources/github.ts
125
+ var DEFAULT_DELIVERY_CACHE_SIZE = 1024;
126
+ function timingSafeEqual(a, b) {
127
+ if (a.length !== b.length)
128
+ return false;
129
+ let diff = 0;
130
+ for (let i = 0;i < a.length; i++) {
131
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
132
+ }
133
+ return diff === 0;
134
+ }
135
+ async function verifySignature(secret, body, signatureHeader) {
136
+ if (!signatureHeader)
137
+ return false;
138
+ const prefix = "sha256=";
139
+ if (!signatureHeader.startsWith(prefix))
140
+ return false;
141
+ const provided = signatureHeader.slice(prefix.length).toLowerCase();
142
+ if (!/^[0-9a-f]+$/.test(provided))
143
+ return false;
144
+ const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
145
+ const computedBytes = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(body));
146
+ const computed = Array.from(new Uint8Array(computedBytes)).map((b) => b.toString(16).padStart(2, "0")).join("");
147
+ return timingSafeEqual(provided, computed);
148
+ }
149
+
150
+ class DeliveryCache {
151
+ seen = new Set;
152
+ order = [];
153
+ maxSize;
154
+ constructor(maxSize) {
155
+ this.maxSize = maxSize;
156
+ }
157
+ has(id) {
158
+ return this.seen.has(id);
159
+ }
160
+ add(id) {
161
+ if (this.seen.has(id))
162
+ return;
163
+ this.seen.add(id);
164
+ this.order.push(id);
165
+ while (this.order.length > this.maxSize) {
166
+ const dropped = this.order.shift();
167
+ if (dropped !== undefined)
168
+ this.seen.delete(dropped);
169
+ }
170
+ }
171
+ }
172
+
173
+ class GithubReceiver {
174
+ prBus = makeBus();
175
+ issueCommentBus = makeBus();
176
+ reviewCommentBus = makeBus();
177
+ issuesBus = makeBus();
178
+ pushBus = makeBus();
179
+ secret;
180
+ deliveries;
181
+ constructor(options) {
182
+ if (!options.secret) {
183
+ throw new Error("GithubReceiver requires a non-empty secret");
184
+ }
185
+ this.secret = options.secret;
186
+ this.deliveries = new DeliveryCache(options.deliveryCacheSize ?? DEFAULT_DELIVERY_CACHE_SIZE);
187
+ }
188
+ pullRequest(opts) {
189
+ const bus = this.prBus;
190
+ const actions = opts?.actions;
191
+ return {
192
+ name: "github:pull_request",
193
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
194
+ };
195
+ }
196
+ issueComment(opts) {
197
+ const bus = this.issueCommentBus;
198
+ const actions = opts?.actions;
199
+ return {
200
+ name: "github:issue_comment",
201
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
202
+ };
203
+ }
204
+ pullRequestReviewComment(opts) {
205
+ const bus = this.reviewCommentBus;
206
+ const actions = opts?.actions;
207
+ return {
208
+ name: "github:pull_request_review_comment",
209
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
210
+ };
211
+ }
212
+ issues(opts) {
213
+ const bus = this.issuesBus;
214
+ const actions = opts?.actions;
215
+ return {
216
+ name: "github:issues",
217
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
218
+ };
219
+ }
220
+ push() {
221
+ const bus = this.pushBus;
222
+ return {
223
+ name: "github:push",
224
+ start: (emit) => subscribe(bus, emit)
225
+ };
226
+ }
227
+ handle = async (req) => {
228
+ const eventType = req.headers.get("x-github-event");
229
+ if (!eventType) {
230
+ return new Response("missing x-github-event", { status: 400 });
231
+ }
232
+ const body = await req.text();
233
+ const signatureValid = await verifySignature(this.secret, body, req.headers.get("x-hub-signature-256"));
234
+ if (!signatureValid) {
235
+ return new Response("invalid signature", { status: 401 });
236
+ }
237
+ const deliveryId = req.headers.get("x-github-delivery");
238
+ if (deliveryId && this.deliveries.has(deliveryId)) {
239
+ return new Response("duplicate", { status: 200 });
240
+ }
241
+ let payload;
242
+ try {
243
+ payload = JSON.parse(body);
244
+ } catch {
245
+ return new Response("invalid json", { status: 400 });
246
+ }
247
+ switch (eventType) {
248
+ case "pull_request":
249
+ dispatch(this.prBus, payload);
250
+ break;
251
+ case "issue_comment":
252
+ dispatch(this.issueCommentBus, payload);
253
+ break;
254
+ case "pull_request_review_comment":
255
+ dispatch(this.reviewCommentBus, payload);
256
+ break;
257
+ case "issues":
258
+ dispatch(this.issuesBus, payload);
259
+ break;
260
+ case "push":
261
+ dispatch(this.pushBus, payload);
262
+ break;
263
+ default:
264
+ break;
265
+ }
266
+ if (deliveryId)
267
+ this.deliveries.add(deliveryId);
268
+ return new Response("ok", { status: 200 });
269
+ };
270
+ }
271
+ function github(options) {
272
+ return new GithubReceiver(options);
273
+ }
274
+
275
+ // src/triggers/sources/grafana.ts
276
+ class GrafanaReceiver {
277
+ alertBus = makeBus();
278
+ alert(opts) {
279
+ const bus = this.alertBus;
280
+ const status = opts?.status;
281
+ return {
282
+ name: "grafana:alert",
283
+ start: (emit) => subscribe(bus, emit, status ? (e) => e.status === status : undefined)
284
+ };
285
+ }
286
+ handle = async (req) => {
287
+ let payload;
288
+ try {
289
+ payload = await req.json();
290
+ } catch {
291
+ return new Response("invalid json", { status: 400 });
292
+ }
293
+ for (const alert of payload.alerts ?? []) {
294
+ dispatch(this.alertBus, {
295
+ ...alert,
296
+ groupKey: payload.groupKey,
297
+ externalURL: payload.externalURL
298
+ });
299
+ }
300
+ return new Response("ok", { status: 200 });
301
+ };
302
+ }
303
+ function grafana() {
304
+ return new GrafanaReceiver;
305
+ }
306
+
307
+ // src/triggers/sources/linear.ts
308
+ class LinearReceiver {
309
+ issueBus = makeBus();
310
+ commentBus = makeBus();
311
+ projectBus = makeBus();
312
+ issue(opts) {
313
+ const bus = this.issueBus;
314
+ const actions = opts?.actions;
315
+ return {
316
+ name: "linear:issue",
317
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
318
+ };
319
+ }
320
+ comment(opts) {
321
+ const bus = this.commentBus;
322
+ const actions = opts?.actions;
323
+ return {
324
+ name: "linear:comment",
325
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
326
+ };
327
+ }
328
+ project(opts) {
329
+ const bus = this.projectBus;
330
+ const actions = opts?.actions;
331
+ return {
332
+ name: "linear:project",
333
+ start: (emit) => subscribe(bus, emit, actions ? (e) => actions.includes(e.action) : undefined)
334
+ };
335
+ }
336
+ handle = async (req) => {
337
+ let payload;
338
+ try {
339
+ payload = await req.json();
340
+ } catch {
341
+ return new Response("invalid json", { status: 400 });
342
+ }
343
+ switch (payload.type) {
344
+ case "Issue":
345
+ dispatch(this.issueBus, payload);
346
+ break;
347
+ case "Comment":
348
+ dispatch(this.commentBus, payload);
349
+ break;
350
+ case "Project":
351
+ dispatch(this.projectBus, payload);
352
+ break;
353
+ default:
354
+ break;
355
+ }
356
+ return new Response("ok", { status: 200 });
357
+ };
358
+ }
359
+ function linear() {
360
+ return new LinearReceiver;
361
+ }
362
+
363
+ // src/triggers/sources/telegram.ts
364
+ var DEFAULT_UPDATE_CACHE_SIZE = 1024;
365
+ var TELEGRAM_API_BASE = "https://api.telegram.org";
366
+ var MAX_MESSAGE_LENGTH = 4096;
367
+ function timingSafeEqual2(a, b) {
368
+ if (a.length !== b.length)
369
+ return false;
370
+ let diff = 0;
371
+ for (let i = 0;i < a.length; i++) {
372
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
373
+ }
374
+ return diff === 0;
375
+ }
376
+
377
+ class UpdateCache {
378
+ seen = new Set;
379
+ order = [];
380
+ maxSize;
381
+ constructor(maxSize) {
382
+ this.maxSize = maxSize;
383
+ }
384
+ has(id) {
385
+ return this.seen.has(id);
386
+ }
387
+ add(id) {
388
+ if (this.seen.has(id))
389
+ return;
390
+ this.seen.add(id);
391
+ this.order.push(id);
392
+ while (this.order.length > this.maxSize) {
393
+ const dropped = this.order.shift();
394
+ if (dropped !== undefined)
395
+ this.seen.delete(dropped);
396
+ }
397
+ }
398
+ }
399
+ function matchesCommand(message, commands, botUsername) {
400
+ const text = message.text;
401
+ if (!text || !text.startsWith("/"))
402
+ return false;
403
+ const token = text.slice(1).split(/\s/, 1)[0] ?? "";
404
+ const [name, target] = token.split("@");
405
+ if (target && botUsername) {
406
+ const normalized = botUsername.replace(/^@/, "").toLowerCase();
407
+ if (target.toLowerCase() !== normalized)
408
+ return false;
409
+ }
410
+ return commands.some((command) => (command.startsWith("/") ? command.slice(1) : command) === name);
411
+ }
412
+
413
+ class TelegramReceiver {
414
+ messageBus = makeBus();
415
+ editedMessageBus = makeBus();
416
+ secretToken;
417
+ updates;
418
+ constructor(options) {
419
+ if (!options.secretToken) {
420
+ throw new Error("TelegramReceiver requires a non-empty secretToken");
421
+ }
422
+ this.secretToken = options.secretToken;
423
+ this.updates = new UpdateCache(options.updateCacheSize ?? DEFAULT_UPDATE_CACHE_SIZE);
424
+ }
425
+ message(opts) {
426
+ const bus = this.messageBus;
427
+ const commands = opts?.commands;
428
+ const botUsername = opts?.botUsername;
429
+ return {
430
+ name: "telegram:message",
431
+ start: (emit) => subscribe(bus, emit, commands ? (m) => matchesCommand(m, commands, botUsername) : undefined)
432
+ };
433
+ }
434
+ editedMessage() {
435
+ const bus = this.editedMessageBus;
436
+ return {
437
+ name: "telegram:edited_message",
438
+ start: (emit) => subscribe(bus, emit)
439
+ };
440
+ }
441
+ handle = async (req) => {
442
+ const provided = req.headers.get("x-telegram-bot-api-secret-token");
443
+ if (!provided || !timingSafeEqual2(provided, this.secretToken)) {
444
+ return new Response("invalid secret token", { status: 401 });
445
+ }
446
+ let update;
447
+ try {
448
+ update = await req.json();
449
+ } catch {
450
+ return new Response("invalid json", { status: 400 });
451
+ }
452
+ if (typeof update.update_id !== "number") {
453
+ return new Response("missing update_id", { status: 400 });
454
+ }
455
+ if (this.updates.has(update.update_id)) {
456
+ return new Response("duplicate", { status: 200 });
457
+ }
458
+ if (update.message) {
459
+ dispatch(this.messageBus, update.message);
460
+ } else if (update.edited_message) {
461
+ dispatch(this.editedMessageBus, update.edited_message);
462
+ }
463
+ this.updates.add(update.update_id);
464
+ return new Response("ok", { status: 200 });
465
+ };
466
+ }
467
+ function splitMessage(text, max = MAX_MESSAGE_LENGTH) {
468
+ if (max < 1)
469
+ throw new Error("splitMessage requires max >= 1");
470
+ if (text.length <= max)
471
+ return [text];
472
+ const chunks = [];
473
+ let remaining = text;
474
+ while (remaining.length > max) {
475
+ let cut = remaining.lastIndexOf(`
476
+ `, max);
477
+ if (cut <= 0) {
478
+ cut = max;
479
+ const code = remaining.charCodeAt(cut - 1);
480
+ if (code >= 55296 && code <= 56319)
481
+ cut -= 1;
482
+ }
483
+ chunks.push(remaining.slice(0, cut));
484
+ remaining = remaining.slice(cut).replace(/^\n/, "");
485
+ }
486
+ if (remaining.length > 0)
487
+ chunks.push(remaining);
488
+ return chunks;
489
+ }
490
+
491
+ class TelegramClient {
492
+ token;
493
+ baseUrl;
494
+ constructor(token, opts) {
495
+ if (!token)
496
+ throw new Error("TelegramClient requires a bot token");
497
+ this.token = token;
498
+ this.baseUrl = (opts?.baseUrl ?? TELEGRAM_API_BASE).replace(/\/+$/, "");
499
+ }
500
+ async call(method, params) {
501
+ const response = await fetch(`${this.baseUrl}/bot${this.token}/${method}`, {
502
+ method: "POST",
503
+ headers: { "content-type": "application/json" },
504
+ body: JSON.stringify(params)
505
+ });
506
+ const data = await response.json();
507
+ if (!data.ok) {
508
+ throw new Error(`Telegram ${method} failed (${response.status}): ${data.description ?? "unknown error"}`);
509
+ }
510
+ return data.result;
511
+ }
512
+ getMe() {
513
+ return this.call("getMe", {});
514
+ }
515
+ sendChatAction(chatId, action = "typing") {
516
+ return this.call("sendChatAction", { chat_id: chatId, action });
517
+ }
518
+ async sendMessage(chatId, text, opts) {
519
+ if (opts?.parseMode && text.length > MAX_MESSAGE_LENGTH) {
520
+ throw new Error(`sendMessage: text exceeds ${MAX_MESSAGE_LENGTH} chars with parse_mode ${opts.parseMode}; auto-splitting could break entities. Split it yourself.`);
521
+ }
522
+ const sent = [];
523
+ for (const chunk of splitMessage(text)) {
524
+ sent.push(await this.call("sendMessage", {
525
+ chat_id: chatId,
526
+ text: chunk,
527
+ ...opts?.parseMode ? { parse_mode: opts.parseMode } : {},
528
+ ...opts?.messageThreadId !== undefined ? { message_thread_id: opts.messageThreadId } : {},
529
+ ...opts?.replyToMessageId ? { reply_parameters: { message_id: opts.replyToMessageId } } : {},
530
+ ...opts?.disableNotification ? { disable_notification: true } : {},
531
+ ...opts?.linkPreview === false ? { link_preview_options: { is_disabled: true } } : {}
532
+ }));
533
+ }
534
+ return sent;
535
+ }
536
+ editMessageText(chatId, messageId, text, opts) {
537
+ return this.call("editMessageText", {
538
+ chat_id: chatId,
539
+ message_id: messageId,
540
+ text,
541
+ ...opts?.parseMode ? { parse_mode: opts.parseMode } : {}
542
+ });
543
+ }
544
+ async sendMessageDraft(chatId, draftId, text, opts) {
545
+ if (!Number.isInteger(draftId) || draftId === 0) {
546
+ throw new Error("sendMessageDraft: draftId must be a non-zero integer");
547
+ }
548
+ if (text.length > MAX_MESSAGE_LENGTH) {
549
+ throw new Error(`sendMessageDraft: text exceeds ${MAX_MESSAGE_LENGTH} chars; a draft is a single bubble and can't be split. Truncate it and persist the full reply via sendMessage.`);
550
+ }
551
+ return this.call("sendMessageDraft", {
552
+ chat_id: chatId,
553
+ draft_id: draftId,
554
+ text,
555
+ ...opts?.parseMode ? { parse_mode: opts.parseMode } : {},
556
+ ...opts?.messageThreadId !== undefined ? { message_thread_id: opts.messageThreadId } : {}
557
+ });
558
+ }
559
+ setWebhook(url, opts) {
560
+ return this.call("setWebhook", {
561
+ url,
562
+ ...opts?.secretToken ? { secret_token: opts.secretToken } : {},
563
+ ...opts?.allowedUpdates ? { allowed_updates: opts.allowedUpdates } : {}
564
+ });
565
+ }
566
+ deleteWebhook(opts) {
567
+ return this.call("deleteWebhook", {
568
+ ...opts?.dropPendingUpdates ? { drop_pending_updates: true } : {}
569
+ });
570
+ }
571
+ }
572
+ function telegram(options) {
573
+ return new TelegramReceiver(options);
574
+ }
575
+ export {
576
+ trigger,
577
+ telegram,
578
+ splitMessage,
579
+ linear,
580
+ grafana,
581
+ github,
582
+ cron,
583
+ TelegramReceiver,
584
+ TelegramClient,
585
+ LinearReceiver,
586
+ GrafanaReceiver,
587
+ GithubReceiver
588
+ };
@@ -0,0 +1,29 @@
1
+ import type { Trigger } from '../core';
2
+ type Weekday = 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
3
+ type Schedule = {
4
+ every: 'minute';
5
+ } | {
6
+ every: 'hour';
7
+ minute?: number;
8
+ } | {
9
+ every: 'day';
10
+ at?: {
11
+ hour: number;
12
+ minute?: number;
13
+ };
14
+ } | {
15
+ every: 'week';
16
+ on: Weekday | Weekday[];
17
+ at?: {
18
+ hour: number;
19
+ minute?: number;
20
+ };
21
+ };
22
+ interface CronOptions {
23
+ schedule: Schedule;
24
+ }
25
+ interface CronEvent {
26
+ firedAt: Date;
27
+ }
28
+ declare function cron(opts: CronOptions): Trigger<CronEvent>;
29
+ export { cron, type CronEvent, type CronOptions, type Schedule, type Weekday };