opencode-feishu 0.6.0 → 0.6.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.
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99178,6 +99178,17 @@ async function updateMessage(client, messageId, text2) {
|
|
|
99178
99178
|
|
|
99179
99179
|
// src/handler/event.ts
|
|
99180
99180
|
var pendingBySession = /* @__PURE__ */ new Map();
|
|
99181
|
+
var sessionErrors = /* @__PURE__ */ new Map();
|
|
99182
|
+
function trackSessionError(sessionId, error) {
|
|
99183
|
+
if (error.includes("ModelNotFound") || error.includes("ProviderModelNotFound")) {
|
|
99184
|
+
sessionErrors.set(sessionId, error);
|
|
99185
|
+
}
|
|
99186
|
+
}
|
|
99187
|
+
function consumeSessionError(sessionId) {
|
|
99188
|
+
const err = sessionErrors.get(sessionId);
|
|
99189
|
+
if (err) sessionErrors.delete(sessionId);
|
|
99190
|
+
return err;
|
|
99191
|
+
}
|
|
99181
99192
|
function registerPending(sessionId, payload) {
|
|
99182
99193
|
pendingBySession.set(sessionId, { ...payload, textBuffer: "" });
|
|
99183
99194
|
}
|
|
@@ -99212,9 +99223,10 @@ async function handleEvent(event) {
|
|
|
99212
99223
|
const props = event.properties;
|
|
99213
99224
|
const sessionId = props.sessionID;
|
|
99214
99225
|
if (!sessionId) break;
|
|
99226
|
+
const errMsg = props.error?.message ?? String(props.error);
|
|
99227
|
+
trackSessionError(sessionId, errMsg);
|
|
99215
99228
|
const payload = pendingBySession.get(sessionId);
|
|
99216
99229
|
if (!payload) break;
|
|
99217
|
-
const errMsg = props.error?.message ?? String(props.error);
|
|
99218
99230
|
const updateRes = await updateMessage(payload.feishuClient, payload.placeholderId, `\u274C \u4F1A\u8BDD\u9519\u8BEF: ${errMsg}`);
|
|
99219
99231
|
if (!updateRes.ok) {
|
|
99220
99232
|
await sendTextMessage(payload.feishuClient, payload.chatId, `\u274C \u4F1A\u8BDD\u9519\u8BEF: ${errMsg}`);
|
|
@@ -99487,9 +99499,11 @@ function abortableSleep(ms, signal) {
|
|
|
99487
99499
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
99488
99500
|
});
|
|
99489
99501
|
}
|
|
99490
|
-
function isModelNotFoundError(err) {
|
|
99502
|
+
function isModelNotFoundError(err, sessionId) {
|
|
99491
99503
|
const msg = err instanceof Error ? err.message : String(err);
|
|
99492
|
-
|
|
99504
|
+
const tracked = consumeSessionError(sessionId);
|
|
99505
|
+
if (msg.includes("ProviderModelNotFound") || msg.includes("ModelNotFound")) return true;
|
|
99506
|
+
return !!tracked;
|
|
99493
99507
|
}
|
|
99494
99508
|
async function promptWithForkRecovery(opts) {
|
|
99495
99509
|
const { client, sessionKey, directory, query, log, body } = opts;
|
|
@@ -99498,7 +99512,7 @@ async function promptWithForkRecovery(opts) {
|
|
|
99498
99512
|
try {
|
|
99499
99513
|
await doPrompt(session);
|
|
99500
99514
|
} catch (err) {
|
|
99501
|
-
if (!isModelNotFoundError(err)) throw err;
|
|
99515
|
+
if (!isModelNotFoundError(err, session.id)) throw err;
|
|
99502
99516
|
log("warn", "\u4F1A\u8BDD\u6A21\u578B\u4E0D\u517C\u5BB9\uFF0Cfork \u65E7\u4F1A\u8BDD\u91CD\u8BD5", { oldSessionId: session.id });
|
|
99503
99517
|
session = await forkSession(client, session.id, sessionKey, directory);
|
|
99504
99518
|
await doPrompt(session);
|