opencode-feishu 0.7.2 → 0.7.4
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 +40 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99308,8 +99308,20 @@ function migratePending(oldSessionId, newSessionId) {
|
|
|
99308
99308
|
pendingBySession.set(newSessionId, payload);
|
|
99309
99309
|
}
|
|
99310
99310
|
}
|
|
99311
|
-
function isModelError(errMsg) {
|
|
99312
|
-
|
|
99311
|
+
function isModelError(errMsg, rawError) {
|
|
99312
|
+
if (errMsg.includes("ModelNotFound") || errMsg.includes("ProviderModelNotFound")) {
|
|
99313
|
+
return true;
|
|
99314
|
+
}
|
|
99315
|
+
if (rawError && typeof rawError === "object") {
|
|
99316
|
+
const e = rawError;
|
|
99317
|
+
const fields = [e.type, e.name, e.message].filter(Boolean).map(String);
|
|
99318
|
+
if (e.data && typeof e.data === "object" && "message" in e.data) {
|
|
99319
|
+
const dataMsg = e.data.message;
|
|
99320
|
+
if (dataMsg) fields.push(String(dataMsg));
|
|
99321
|
+
}
|
|
99322
|
+
return fields.some((f) => f.includes("ModelNotFound") || f.includes("ProviderModelNotFound"));
|
|
99323
|
+
}
|
|
99324
|
+
return false;
|
|
99313
99325
|
}
|
|
99314
99326
|
async function handleEvent(event, deps) {
|
|
99315
99327
|
switch (event.type) {
|
|
@@ -99339,9 +99351,30 @@ async function handleEvent(event, deps) {
|
|
|
99339
99351
|
const props = event.properties;
|
|
99340
99352
|
const sessionId = props.sessionID;
|
|
99341
99353
|
if (!sessionId) break;
|
|
99342
|
-
const
|
|
99354
|
+
const error = props.error;
|
|
99355
|
+
let errMsg;
|
|
99356
|
+
if (typeof error === "string") {
|
|
99357
|
+
errMsg = error;
|
|
99358
|
+
} else if (error && typeof error === "object") {
|
|
99359
|
+
const e = error;
|
|
99360
|
+
const rawDataMsg = e.data && typeof e.data === "object" && "message" in e.data ? e.data.message : void 0;
|
|
99361
|
+
const dataMsg = rawDataMsg != null ? String(rawDataMsg) : void 0;
|
|
99362
|
+
errMsg = String(e.message ?? dataMsg ?? e.type ?? e.name ?? "An unexpected error occurred");
|
|
99363
|
+
} else {
|
|
99364
|
+
errMsg = String(error);
|
|
99365
|
+
}
|
|
99366
|
+
const safeErrorFields = error && typeof error === "object" ? {
|
|
99367
|
+
type: error.type,
|
|
99368
|
+
name: error.name,
|
|
99369
|
+
dataMessage: error.data?.message
|
|
99370
|
+
} : { raw: String(error) };
|
|
99371
|
+
deps.log("warn", "\u6536\u5230 session.error \u4E8B\u4EF6", {
|
|
99372
|
+
sessionId,
|
|
99373
|
+
error: safeErrorFields,
|
|
99374
|
+
extractedMsg: errMsg
|
|
99375
|
+
});
|
|
99343
99376
|
setSessionError(sessionId, errMsg);
|
|
99344
|
-
if (isModelError(errMsg)) {
|
|
99377
|
+
if (isModelError(errMsg, props.error)) {
|
|
99345
99378
|
const sessionKey = invalidateCachedSession(sessionId);
|
|
99346
99379
|
if (sessionKey) {
|
|
99347
99380
|
try {
|
|
@@ -99485,6 +99518,9 @@ async function handleChat(ctx, deps) {
|
|
|
99485
99518
|
const thrownError = err instanceof Error ? err.message : String(err);
|
|
99486
99519
|
const errorMessage = sessionError || thrownError;
|
|
99487
99520
|
log("error", "\u5BF9\u8BDD\u5904\u7406\u5931\u8D25", {
|
|
99521
|
+
sessionId: session.id,
|
|
99522
|
+
sessionKey: sessionKey.replace(/-[^-]+$/, "-***"),
|
|
99523
|
+
chatType,
|
|
99488
99524
|
error: thrownError,
|
|
99489
99525
|
...sessionError ? { sessionError } : {}
|
|
99490
99526
|
});
|