@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/bin.js CHANGED
@@ -7455,12 +7455,13 @@ var init_dist = __esm({
7455
7455
  * Validates that a string parameter is non-empty.
7456
7456
  * Catches invalid inputs before they hit the network.
7457
7457
  */
7458
- requireNonEmpty(value, name2) {
7458
+ requireNonEmpty(value, name2, caller) {
7459
7459
  if (!value || value.trim() === "") {
7460
+ const ctx = caller ? ` (in ${caller})` : "";
7460
7461
  throw new DeskFreeError(
7461
7462
  "client",
7462
7463
  name2,
7463
- `${name2} is required and cannot be empty`,
7464
+ `${name2} is required and cannot be empty${ctx}`,
7464
7465
  `Missing required parameter: ${name2}. Please provide a valid value.`
7465
7466
  );
7466
7467
  }
@@ -7486,7 +7487,7 @@ var init_dist = __esm({
7486
7487
  * @param input - Message content, optional userId, taskId, attachments
7487
7488
  */
7488
7489
  async sendMessage(input) {
7489
- this.requireNonEmpty(input.content, "content");
7490
+ this.requireNonEmpty(input.content, "content", "sendMessage");
7490
7491
  return this.request("POST", "messages.send", input);
7491
7492
  }
7492
7493
  /** Fetch paginated message history for a conversation. */
@@ -7523,8 +7524,8 @@ var init_dist = __esm({
7523
7524
  }
7524
7525
  /** Update the content of an existing file. */
7525
7526
  async updateFile(input) {
7526
- this.requireNonEmpty(input.fileId, "fileId");
7527
- this.requireNonEmpty(input.content, "content");
7527
+ this.requireNonEmpty(input.fileId, "fileId", "updateFile");
7528
+ this.requireNonEmpty(input.content, "content", "updateFile");
7528
7529
  return this.request("POST", "files.update", input);
7529
7530
  }
7530
7531
  /** Create a new persistent file. */
@@ -7568,13 +7569,13 @@ var init_dist = __esm({
7568
7569
  }
7569
7570
  /** Report a learning observation from a worker task. Posts a system message in the task thread AND writes to memory_entries. */
7570
7571
  async reportLearning(input) {
7571
- this.requireNonEmpty(input.content, "content");
7572
+ this.requireNonEmpty(input.content, "content", "reportLearning");
7572
7573
  return this.request("POST", "tasks.learning", input);
7573
7574
  }
7574
7575
  // ── Memory ──────────────────────────────────────────────────
7575
7576
  /** Add a memory entry directly (bypasses system message — used by consolidation). */
7576
7577
  async addMemory(input) {
7577
- this.requireNonEmpty(input.content, "content");
7578
+ this.requireNonEmpty(input.content, "content", "addMemory");
7578
7579
  return this.request("POST", "memory.add", input);
7579
7580
  }
7580
7581
  /**
@@ -14011,6 +14012,13 @@ async function routeMessage(message, client, deps, sessionStore, config) {
14011
14012
  const delta = extractTextDelta(message2);
14012
14013
  if (delta) {
14013
14014
  fullText += delta;
14015
+ if (!fullText.trim()) {
14016
+ log.warn(`Skipping whitespace-only delta`, {
14017
+ delta: JSON.stringify(delta),
14018
+ fullText: JSON.stringify(fullText)
14019
+ });
14020
+ continue;
14021
+ }
14014
14022
  if (!streamStarted) {
14015
14023
  await streamingSession.start(fullText, replyTaskId);
14016
14024
  streamStarted = true;
@@ -14046,8 +14054,12 @@ async function routeMessage(message, client, deps, sessionStore, config) {
14046
14054
  }
14047
14055
  if (streamStarted && streamingSession.isActive()) {
14048
14056
  await streamingSession.close(fullText || void 0);
14049
- } else if (!streamStarted && fullText) {
14057
+ } else if (!streamStarted && fullText.trim()) {
14050
14058
  await client.sendMessage({ content: fullText, taskId: replyTaskId });
14059
+ } else if (!streamStarted && fullText && !fullText.trim()) {
14060
+ log.warn(`Skipping sendMessage: fullText is whitespace-only`, {
14061
+ fullText: JSON.stringify(fullText)
14062
+ });
14051
14063
  }
14052
14064
  if (capturedSessionId) {
14053
14065
  sessionStore.setSessionId(sessionKey, capturedSessionId);
@@ -14061,8 +14073,10 @@ async function routeMessage(message, client, deps, sessionStore, config) {
14061
14073
  }
14062
14074
  }
14063
14075
  const errMsg = err instanceof Error ? err.message : String(err);
14076
+ const errStack = err instanceof Error ? err.stack : void 0;
14064
14077
  const errStderr = err?.["stderr"] ?? "";
14065
14078
  log.warn(`Failed to handle message: ${errMsg}`, {
14079
+ stack: errStack,
14066
14080
  stderr: errStderr ? String(errStderr).slice(0, 2e3) : void 0,
14067
14081
  exitCode: err?.["exit_code"]
14068
14082
  });
@@ -14982,7 +14996,7 @@ async function startAgent(opts) {
14982
14996
  log.info("DeskFree Agent Runtime starting...");
14983
14997
  const { getRotationToken: getRotationToken2, setInitialRotationToken: setInitialRotationToken2 } = await Promise.resolve().then(() => (init_ws_gateway(), ws_gateway_exports));
14984
14998
  const { collectFingerprint: collectFingerprint2 } = await Promise.resolve().then(() => (init_fingerprint(), fingerprint_exports));
14985
- const runtimeVersion = "0.6.7";
14999
+ const runtimeVersion = "0.6.9";
14986
15000
  const fingerprint = collectFingerprint2(localConfig.stateDir, runtimeVersion);
14987
15001
  log.info("Connecting to DeskFree...", { wsUrl: localConfig.wsUrl });
14988
15002
  const connectResult = await initialConnect({