diff --git a/src/worker.ts b/src/worker.ts index 0e6590d..8c07e45 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -713,7 +713,15 @@ const plugin = definePlugin({ const apiBase = (config.legalApiBaseUrl as string) ?? "http://localhost:8085"; - const resp = await ctx.http.fetch(`${apiBase}/api/cases/stale?days=3`); + let resp: Awaited>; + try { + resp = await ctx.http.fetch(`${apiBase}/api/cases/stale?days=3`); + } catch (err) { + ctx.logger.error("stale-case-reminder: fetch failed", { + error: String(err), + }); + return; + } if (!resp.ok) { ctx.logger.error(`stale-case-reminder: API error ${resp.status}`); return; @@ -817,14 +825,21 @@ const plugin = definePlugin({ const { company, ceoId } = mapped[0]; - await ctx.agents.invoke(ceoId, company.id, { - prompt: `ניתוח פידבק שבועי יו"ר (${data.entry_count} פריטים):\n\n${data.summary}\n\nהמשימה: עדכן את /home/chaim/legal-ai/docs/legal-decision-lessons.md עם הלקחים החדשים שעולים מהפידבק. הוסף רק לקחים חדשים שלא קיימים כבר. קבץ לפי נושא.`, - reason: "weekly-feedback-job", - }); - - ctx.logger.info( - `weekly-feedback-analysis: invoked CEO ${ceoId} (company ${company.id}) with ${data.entry_count} feedback entries`, - ); + try { + await ctx.agents.invoke(ceoId, company.id, { + prompt: `ניתוח פידבק שבועי יו"ר (${data.entry_count} פריטים):\n\n${data.summary}\n\nהמשימה: עדכן את /home/chaim/legal-ai/docs/legal-decision-lessons.md עם הלקחים החדשים שעולים מהפידבק. הוסף רק לקחים חדשים שלא קיימים כבר. קבץ לפי נושא.`, + reason: "weekly-feedback-job", + }); + ctx.logger.info( + `weekly-feedback-analysis: invoked CEO ${ceoId} (company ${company.id}) with ${data.entry_count} feedback entries`, + ); + } catch (err) { + ctx.logger.error("weekly-feedback-analysis: failed to invoke CEO", { + error: String(err), + ceoId, + companyId: company.id, + }); + } }); ctx.logger.info("Legal AI plugin ready");