@whoz-oss/coday-web 0.18.3 → 0.18.5

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/package.json CHANGED
@@ -7,5 +7,5 @@
7
7
  "dependencies": {
8
8
  "sharp": "^0.33.5"
9
9
  },
10
- "version": "0.18.3"
10
+ "version": "0.18.5"
11
11
  }
package/server/server.js CHANGED
@@ -69567,6 +69567,7 @@ var AiThreadService = class {
69567
69567
  this.username = userService.username;
69568
69568
  }
69569
69569
  activeThread$ = new import_rxjs2.BehaviorSubject(null);
69570
+ isKilled = false;
69570
69571
  /**
69571
69572
  * Observable of the currently active thread.
69572
69573
  * Emits whenever the active thread changes.
@@ -69574,6 +69575,7 @@ var AiThreadService = class {
69574
69575
  activeThread = this.activeThread$.asObservable();
69575
69576
  username;
69576
69577
  async kill() {
69578
+ this.isKilled = true;
69577
69579
  this.activeThread$.complete();
69578
69580
  }
69579
69581
  /**
@@ -69664,16 +69666,24 @@ var AiThreadService = class {
69664
69666
  this.activeThread$.next(saved);
69665
69667
  }
69666
69668
  async autoSave(newName) {
69669
+ if (this.isKilled) {
69670
+ console.log("Autosave skipped: service has been killed");
69671
+ return;
69672
+ }
69667
69673
  const thread = this.activeThread$.value;
69668
69674
  if (!thread || thread.messagesLength == 0) {
69669
- console.error(`Autosave of an empty or falsy thread aborted, threadId: ${thread?.id}`);
69675
+ console.log(`Autosave of an empty or falsy thread aborted, threadId: ${thread?.id}`);
69670
69676
  return;
69671
69677
  }
69672
- if (newName) {
69673
- thread.name = newName;
69678
+ try {
69679
+ if (newName) {
69680
+ thread.name = newName;
69681
+ }
69682
+ const repository = await this.getRepository();
69683
+ await repository.save(thread);
69684
+ } catch (error) {
69685
+ console.log("Autosave failed (service may have been killed):", error instanceof Error ? error.message : error);
69674
69686
  }
69675
- const repository = await this.getRepository();
69676
- await repository.save(thread);
69677
69687
  }
69678
69688
  /**
69679
69689
  * Truncate the current thread at a specific user message
@@ -102101,7 +102111,7 @@ var { HUMAN_PROMPT, AI_PROMPT } = Anthropic;
102101
102111
  var import_rxjs10 = __toESM(require_cjs(), 1);
102102
102112
  var ANTHROPIC_DEFAULT_MODELS = [
102103
102113
  {
102104
- name: "claude-sonnet-4-20250514",
102114
+ name: "claude-sonnet-4-5-20250929",
102105
102115
  alias: "BIG",
102106
102116
  contextWindow: 2e5,
102107
102117
  price: {
@@ -114313,7 +114323,7 @@ function isElectron() {
114313
114323
 
114314
114324
  // libs/integration/mcp/mcp-tools-factory.ts
114315
114325
  var import_child_process4 = require("child_process");
114316
- var MCP_CONNECT_TIMEOUT = 5e3;
114326
+ var MCP_CONNECT_TIMEOUT = 15e3;
114317
114327
  var McpToolsFactory = class extends AssistantToolFactory {
114318
114328
  constructor(interactor, serverConfig) {
114319
114329
  super(interactor);
@@ -116489,9 +116499,12 @@ var ServerClient = class _ServerClient {
116489
116499
  // Filter out falsy values and type guard
116490
116500
  (0, import_rxjs14.first)(),
116491
116501
  // Take the first truthy value and complete
116492
- (0, import_rxjs14.timeout)(5e3),
116493
- // Timeout after 5 seconds
116494
- (0, import_rxjs14.catchError)(() => (0, import_rxjs14.of)(void 0))
116502
+ (0, import_rxjs14.timeout)(1e4),
116503
+ // Increased timeout to 10 seconds for slower operations
116504
+ (0, import_rxjs14.catchError)((error) => {
116505
+ debugLog("CLIENT", `getThreadId timeout or error for client ${this.clientId}:`, error.message);
116506
+ return (0, import_rxjs14.of)(void 0);
116507
+ })
116495
116508
  // Return undefined on timeout or error
116496
116509
  );
116497
116510
  }
@@ -122173,22 +122186,32 @@ app.post("/api/webhook/:uuid", async (req, res) => {
122173
122186
  clientId
122174
122187
  });
122175
122188
  console.error("Error waiting for webhook completion:", error);
122176
- res.status(500).send({ error: "Webhook processing failed" });
122189
+ if (!res.headersSent) {
122190
+ res.status(500).send({ error: "Webhook processing failed" });
122191
+ }
122177
122192
  });
122178
122193
  } else {
122179
122194
  (0, import_rxjs16.firstValueFrom)(
122180
122195
  threadIdSource.pipe(
122181
- (0, import_rxjs16.timeout)(5e3),
122196
+ (0, import_rxjs16.timeout)(1e4),
122197
+ // Increased timeout to 10 seconds
122182
122198
  (0, import_rxjs16.catchError)((error) => {
122183
122199
  if (error.message === "no elements in sequence" || error.constructor?.name === "EmptyErrorImpl") {
122184
122200
  console.log("Thread ID Observable empty during system sleep - webhook will continue");
122185
122201
  return (0, import_rxjs16.of)("unknown");
122186
122202
  }
122187
- throw error;
122203
+ if (error.name === "TimeoutError") {
122204
+ console.log("Thread ID timeout - webhook will continue with unknown ID");
122205
+ return (0, import_rxjs16.of)("unknown");
122206
+ }
122207
+ console.error("Error in thread ID observable:", error);
122208
+ return (0, import_rxjs16.of)("unknown");
122188
122209
  })
122189
122210
  )
122190
122211
  ).then((threadId) => {
122191
- res.status(201).send({ threadId });
122212
+ if (!res.headersSent) {
122213
+ res.status(201).send({ threadId });
122214
+ }
122192
122215
  }).catch((error) => {
122193
122216
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
122194
122217
  logger.logWebhookError({
@@ -122198,7 +122221,9 @@ app.post("/api/webhook/:uuid", async (req, res) => {
122198
122221
  clientId
122199
122222
  });
122200
122223
  console.error("Error getting thread ID for webhook:", error);
122201
- res.status(500).send({ error: "Failed to initialize webhook processing" });
122224
+ if (!res.headersSent) {
122225
+ res.status(500).send({ error: "Failed to initialize webhook processing" });
122226
+ }
122202
122227
  });
122203
122228
  }
122204
122229
  } catch (error) {
@@ -122496,7 +122521,16 @@ process.on("unhandledRejection", (reason, promise) => {
122496
122521
  console.log("Detected RxJS EmptyError rejection during system sleep - this is expected behavior");
122497
122522
  return;
122498
122523
  }
122524
+ if (error.name === "TimeoutError" || error.message?.includes("timeout")) {
122525
+ console.log("Detected timeout error - handling gracefully without shutdown");
122526
+ return;
122527
+ }
122528
+ if (error.name === "AbortError" || error.message?.includes("aborted")) {
122529
+ console.log("Detected abort error - handling gracefully without shutdown");
122530
+ return;
122531
+ }
122499
122532
  }
122533
+ console.error("Critical unhandled rejection detected");
122500
122534
  if (!isShuttingDown) {
122501
122535
  gracefulShutdown("unhandledRejection");
122502
122536
  }