@openacp/cli 2026.331.2 → 2026.331.3
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.
- package/dist/cli.js +75 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +64 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3155,6 +3155,16 @@ declare class TelegramAdapter extends MessagingAdapter {
|
|
|
3155
3155
|
assistantTopicId?: number;
|
|
3156
3156
|
}) => Promise<void>);
|
|
3157
3157
|
start(): Promise<void>;
|
|
3158
|
+
/**
|
|
3159
|
+
* Retry an async operation with exponential backoff.
|
|
3160
|
+
* Used for Telegram API calls that may fail due to transient network issues.
|
|
3161
|
+
*/
|
|
3162
|
+
private retryWithBackoff;
|
|
3163
|
+
/**
|
|
3164
|
+
* Register Telegram commands in the background with retries.
|
|
3165
|
+
* Non-critical — bot works fine without autocomplete commands.
|
|
3166
|
+
*/
|
|
3167
|
+
private registerCommandsWithRetry;
|
|
3158
3168
|
stop(): Promise<void>;
|
|
3159
3169
|
private renderCommandResponse;
|
|
3160
3170
|
private toCallbackData;
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function initLogger(config) {
|
|
|
105
105
|
target: "pino-pretty",
|
|
106
106
|
options: {
|
|
107
107
|
colorize: true,
|
|
108
|
-
translateTime: "HH:
|
|
108
|
+
translateTime: "SYS:HH:MM:ss",
|
|
109
109
|
ignore: "pid,hostname",
|
|
110
110
|
singleLine: true
|
|
111
111
|
},
|
|
@@ -6365,8 +6365,19 @@ var OpenACPCore = class {
|
|
|
6365
6365
|
this.agentCatalog.refreshRegistryIfStale().catch((err) => {
|
|
6366
6366
|
log12.warn({ err }, "Background registry refresh failed");
|
|
6367
6367
|
});
|
|
6368
|
-
|
|
6369
|
-
|
|
6368
|
+
const failures = [];
|
|
6369
|
+
for (const [name, adapter] of this.adapters.entries()) {
|
|
6370
|
+
try {
|
|
6371
|
+
await adapter.start();
|
|
6372
|
+
} catch (err) {
|
|
6373
|
+
log12.error({ err, adapter: name }, `Adapter "${name}" failed to start`);
|
|
6374
|
+
failures.push({ name, error: err });
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
6377
|
+
if (failures.length > 0 && failures.length === this.adapters.size) {
|
|
6378
|
+
throw new Error(
|
|
6379
|
+
`All adapters failed to start: ${failures.map((f) => f.name).join(", ")}`
|
|
6380
|
+
);
|
|
6370
6381
|
}
|
|
6371
6382
|
}
|
|
6372
6383
|
async stop() {
|
|
@@ -16703,27 +16714,28 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
16703
16714
|
}
|
|
16704
16715
|
return prev(method, payload, signal);
|
|
16705
16716
|
});
|
|
16706
|
-
|
|
16707
|
-
scope: { type: "chat", chat_id: this.telegramConfig.chatId }
|
|
16708
|
-
});
|
|
16717
|
+
this.registerCommandsWithRetry();
|
|
16709
16718
|
this.bot.use((ctx, next) => {
|
|
16710
16719
|
const chatId = ctx.chat?.id ?? ctx.callbackQuery?.message?.chat?.id;
|
|
16711
16720
|
if (chatId !== this.telegramConfig.chatId) return;
|
|
16712
16721
|
return next();
|
|
16713
16722
|
});
|
|
16714
|
-
const topics = await
|
|
16715
|
-
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
|
|
16723
|
+
const topics = await this.retryWithBackoff(
|
|
16724
|
+
() => ensureTopics(
|
|
16725
|
+
this.bot,
|
|
16726
|
+
this.telegramConfig.chatId,
|
|
16727
|
+
this.telegramConfig,
|
|
16728
|
+
async (updates) => {
|
|
16729
|
+
if (this.saveTopicIds) {
|
|
16730
|
+
await this.saveTopicIds(updates);
|
|
16731
|
+
} else {
|
|
16732
|
+
await this.core.configManager.save({
|
|
16733
|
+
channels: { telegram: updates }
|
|
16734
|
+
});
|
|
16735
|
+
}
|
|
16725
16736
|
}
|
|
16726
|
-
|
|
16737
|
+
),
|
|
16738
|
+
"ensureTopics"
|
|
16727
16739
|
);
|
|
16728
16740
|
this.notificationTopicId = topics.notificationTopicId;
|
|
16729
16741
|
this.assistantTopicId = topics.assistantTopicId;
|
|
@@ -16971,6 +16983,40 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
16971
16983
|
});
|
|
16972
16984
|
}
|
|
16973
16985
|
}
|
|
16986
|
+
/**
|
|
16987
|
+
* Retry an async operation with exponential backoff.
|
|
16988
|
+
* Used for Telegram API calls that may fail due to transient network issues.
|
|
16989
|
+
*/
|
|
16990
|
+
async retryWithBackoff(fn, label, maxRetries = 5, baseDelayMs = 2e3) {
|
|
16991
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
16992
|
+
try {
|
|
16993
|
+
return await fn();
|
|
16994
|
+
} catch (err) {
|
|
16995
|
+
if (attempt === maxRetries) throw err;
|
|
16996
|
+
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
16997
|
+
log31.warn(
|
|
16998
|
+
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
16999
|
+
`${label} failed, retrying in ${delay}ms`
|
|
17000
|
+
);
|
|
17001
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
17002
|
+
}
|
|
17003
|
+
}
|
|
17004
|
+
throw new Error("unreachable");
|
|
17005
|
+
}
|
|
17006
|
+
/**
|
|
17007
|
+
* Register Telegram commands in the background with retries.
|
|
17008
|
+
* Non-critical — bot works fine without autocomplete commands.
|
|
17009
|
+
*/
|
|
17010
|
+
registerCommandsWithRetry() {
|
|
17011
|
+
this.retryWithBackoff(
|
|
17012
|
+
() => this.bot.api.setMyCommands(STATIC_COMMANDS, {
|
|
17013
|
+
scope: { type: "chat", chat_id: this.telegramConfig.chatId }
|
|
17014
|
+
}),
|
|
17015
|
+
"setMyCommands"
|
|
17016
|
+
).catch((err) => {
|
|
17017
|
+
log31.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
17018
|
+
});
|
|
17019
|
+
}
|
|
16974
17020
|
async stop() {
|
|
16975
17021
|
for (const tracker of this.sessionTrackers.values()) {
|
|
16976
17022
|
tracker.destroy();
|