@questionbase/deskfree 0.6.7 → 0.6.9

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 CHANGED
@@ -7000,12 +7000,13 @@ var init_dist = __esm({
7000
7000
  * Validates that a string parameter is non-empty.
7001
7001
  * Catches invalid inputs before they hit the network.
7002
7002
  */
7003
- requireNonEmpty(value, name) {
7003
+ requireNonEmpty(value, name, caller) {
7004
7004
  if (!value || value.trim() === "") {
7005
+ const ctx = caller ? ` (in ${caller})` : "";
7005
7006
  throw new DeskFreeError(
7006
7007
  "client",
7007
7008
  name,
7008
- `${name} is required and cannot be empty`,
7009
+ `${name} is required and cannot be empty${ctx}`,
7009
7010
  `Missing required parameter: ${name}. Please provide a valid value.`
7010
7011
  );
7011
7012
  }
@@ -7031,7 +7032,7 @@ var init_dist = __esm({
7031
7032
  * @param input - Message content, optional userId, taskId, attachments
7032
7033
  */
7033
7034
  async sendMessage(input) {
7034
- this.requireNonEmpty(input.content, "content");
7035
+ this.requireNonEmpty(input.content, "content", "sendMessage");
7035
7036
  return this.request("POST", "messages.send", input);
7036
7037
  }
7037
7038
  /** Fetch paginated message history for a conversation. */
@@ -7068,8 +7069,8 @@ var init_dist = __esm({
7068
7069
  }
7069
7070
  /** Update the content of an existing file. */
7070
7071
  async updateFile(input) {
7071
- this.requireNonEmpty(input.fileId, "fileId");
7072
- this.requireNonEmpty(input.content, "content");
7072
+ this.requireNonEmpty(input.fileId, "fileId", "updateFile");
7073
+ this.requireNonEmpty(input.content, "content", "updateFile");
7073
7074
  return this.request("POST", "files.update", input);
7074
7075
  }
7075
7076
  /** Create a new persistent file. */
@@ -7113,13 +7114,13 @@ var init_dist = __esm({
7113
7114
  }
7114
7115
  /** Report a learning observation from a worker task. Posts a system message in the task thread AND writes to memory_entries. */
7115
7116
  async reportLearning(input) {
7116
- this.requireNonEmpty(input.content, "content");
7117
+ this.requireNonEmpty(input.content, "content", "reportLearning");
7117
7118
  return this.request("POST", "tasks.learning", input);
7118
7119
  }
7119
7120
  // ── Memory ──────────────────────────────────────────────────
7120
7121
  /** Add a memory entry directly (bypasses system message — used by consolidation). */
7121
7122
  async addMemory(input) {
7122
- this.requireNonEmpty(input.content, "content");
7123
+ this.requireNonEmpty(input.content, "content", "addMemory");
7123
7124
  return this.request("POST", "memory.add", input);
7124
7125
  }
7125
7126
  /**
@@ -13630,6 +13631,13 @@ async function routeMessage(message, client, deps, sessionStore, config) {
13630
13631
  const delta = extractTextDelta(message2);
13631
13632
  if (delta) {
13632
13633
  fullText += delta;
13634
+ if (!fullText.trim()) {
13635
+ log.warn(`Skipping whitespace-only delta`, {
13636
+ delta: JSON.stringify(delta),
13637
+ fullText: JSON.stringify(fullText)
13638
+ });
13639
+ continue;
13640
+ }
13633
13641
  if (!streamStarted) {
13634
13642
  await streamingSession.start(fullText, replyTaskId);
13635
13643
  streamStarted = true;
@@ -13665,8 +13673,12 @@ async function routeMessage(message, client, deps, sessionStore, config) {
13665
13673
  }
13666
13674
  if (streamStarted && streamingSession.isActive()) {
13667
13675
  await streamingSession.close(fullText || void 0);
13668
- } else if (!streamStarted && fullText) {
13676
+ } else if (!streamStarted && fullText.trim()) {
13669
13677
  await client.sendMessage({ content: fullText, taskId: replyTaskId });
13678
+ } else if (!streamStarted && fullText && !fullText.trim()) {
13679
+ log.warn(`Skipping sendMessage: fullText is whitespace-only`, {
13680
+ fullText: JSON.stringify(fullText)
13681
+ });
13670
13682
  }
13671
13683
  if (capturedSessionId) {
13672
13684
  sessionStore.setSessionId(sessionKey, capturedSessionId);
@@ -13680,8 +13692,10 @@ async function routeMessage(message, client, deps, sessionStore, config) {
13680
13692
  }
13681
13693
  }
13682
13694
  const errMsg = err instanceof Error ? err.message : String(err);
13695
+ const errStack = err instanceof Error ? err.stack : void 0;
13683
13696
  const errStderr = err?.["stderr"] ?? "";
13684
13697
  log.warn(`Failed to handle message: ${errMsg}`, {
13698
+ stack: errStack,
13685
13699
  stderr: errStderr ? String(errStderr).slice(0, 2e3) : void 0,
13686
13700
  exitCode: err?.["exit_code"]
13687
13701
  });
@@ -14470,7 +14484,7 @@ async function startAgent(opts) {
14470
14484
  log.info("DeskFree Agent Runtime starting...");
14471
14485
  const { getRotationToken: getRotationToken2, setInitialRotationToken: setInitialRotationToken2 } = await Promise.resolve().then(() => (init_ws_gateway(), ws_gateway_exports));
14472
14486
  const { collectFingerprint: collectFingerprint2 } = await Promise.resolve().then(() => (init_fingerprint(), fingerprint_exports));
14473
- const runtimeVersion = "0.6.7";
14487
+ const runtimeVersion = "0.6.9";
14474
14488
  const fingerprint = collectFingerprint2(localConfig.stateDir, runtimeVersion);
14475
14489
  log.info("Connecting to DeskFree...", { wsUrl: localConfig.wsUrl });
14476
14490
  const connectResult = await initialConnect({