Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
491ab5bc8f | ||
|
|
8d4cec9bb3 | ||
|
|
c8b3ff68a7 |
@@ -20,19 +20,19 @@
|
||||
|
||||
## 快速開始
|
||||
|
||||
套件不在官方 npmjs 上,安裝要指定 `--registry`(擇一,公開站不用登入):
|
||||
套件不在官方 npmjs 上,安裝要指定 `--registry`(不用登入):
|
||||
|
||||
```bash
|
||||
# 公開 registry
|
||||
npm install -g telegram-codex-bot --registry=https://jianmiau.ddns.net/api/packages/AI/npm/
|
||||
|
||||
# 或:公司內部 registry(需 git.catan.com.tw 帳號)
|
||||
npm install -g telegram-codex-bot --registry=https://git.catan.com.tw/api/packages/Frontend/npm/
|
||||
|
||||
telegram-codex-bot start # 先做環境檢查(codex/登入/pm2/git),再把控制台掛上 pm2
|
||||
```
|
||||
|
||||
之後升級同樣帶 `--registry`(`npm update -g telegram-codex-bot --registry=...`)。
|
||||
之後升級同樣帶 `--registry`:
|
||||
|
||||
```bash
|
||||
npm update -g telegram-codex-bot --registry=https://jianmiau.ddns.net/api/packages/AI/npm/
|
||||
```
|
||||
|
||||
打開 **http://localhost:3799** →「🤖 Bot 管理」→「➕ 新增 Bot」:
|
||||
|
||||
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "telegram-codex-bot",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.5",
|
||||
"description": "Telegram bot powered by the local Codex CLI — zero-dependency, pm2-managed, with a built-in PM2 web viewer",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
"publishConfig": {
|
||||
"registry": "https://git.catan.com.tw/api/packages/Frontend/npm/"
|
||||
"registry": "https://jianmiau.ddns.net/api/packages/AI/npm/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@git.catan.com.tw:Frontend/telegram-codex-bot.git"
|
||||
"url": "ssh://git@jianmiau.ddns.net:8022/AI/telegram-codex-bot.git"
|
||||
},
|
||||
"main": "src/index.js",
|
||||
"bin": {
|
||||
|
||||
+11
-3
@@ -224,13 +224,21 @@ function startBot(config) {
|
||||
const existing = sessions.get(chatId);
|
||||
|
||||
let result;
|
||||
let sessionResetNote = '';
|
||||
try {
|
||||
result = await runCodex({ config, prompt, threadId: existing?.threadId || null, images, onProgress });
|
||||
} catch (err) {
|
||||
// 舊會話可能已被 codex 清掉,找不到就自動開新會話重試一次
|
||||
if (existing && /session|thread|conversation/i.test(err.message) && /not.*found|找不到|no .*(session|thread)/i.test(err.message)) {
|
||||
// 舊會話 resume 不了的情況,自動開新會話重試一次:
|
||||
// 1) 會話已被 codex 清掉(not found)
|
||||
// 2) bot 換了模型,codex 拒絕跨模型 resume(recorded with model X but resuming with Y)
|
||||
const sessionGone = /session|thread|conversation/i.test(err.message) && /not.*found|找不到|no .*(session|thread)/i.test(err.message);
|
||||
const modelMismatch = /recorded with model/i.test(err.message);
|
||||
if (existing && (sessionGone || modelMismatch)) {
|
||||
sessions.clear(chatId);
|
||||
result = await runCodex({ config, prompt, threadId: null, images, onProgress });
|
||||
sessionResetNote = modelMismatch
|
||||
? '🆕 模型設定已變更,舊會話無法沿用,已自動開新會話(先前的對話記憶未帶入)。\n\n'
|
||||
: '🆕 舊會話已失效,已自動開新會話。\n\n';
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
@@ -239,7 +247,7 @@ function startBot(config) {
|
||||
if (result.threadId) sessions.set(chatId, result.threadId);
|
||||
|
||||
const footer = buildFooter(config, result.usage, modelMeta, codexDefaults);
|
||||
const html = t.mdToTgHtml((result.text || '(Codex 沒有回覆文字)') + footer);
|
||||
const html = t.mdToTgHtml(sessionResetNote + (result.text || '(Codex 沒有回覆文字)') + footer);
|
||||
await t.editOrSplit(chatId, statusMsg.message_id, html, { html: true });
|
||||
await t.react(chatId, message.message_id, '👍');
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user