@adhdev/daemon-standalone 0.9.76-rc.50 → 0.9.76-rc.51

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
@@ -42986,6 +42986,7 @@ ${effect.notification.body || ""}`.trim();
42986
42986
  }
42987
42987
  var RECENT_SEND_WINDOW_MS = 1200;
42988
42988
  var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
42989
+ var HERMES_CLI_STARTING_SEND_SETTLE_MS = 2e3;
42989
42990
  var recentSendByTarget = /* @__PURE__ */ new Map();
42990
42991
  function getCurrentProviderType(h, fallback = "") {
42991
42992
  return h.currentSession?.providerType || h.currentProviderType || fallback;
@@ -43038,6 +43039,16 @@ ${effect.notification.body || ""}`.trim();
43038
43039
  function getSendChatInputEnvelope(args) {
43039
43040
  return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
43040
43041
  }
43042
+ function sleep(ms2) {
43043
+ return new Promise((resolve16) => setTimeout(resolve16, ms2));
43044
+ }
43045
+ async function waitOnceForFreshHermesCliStart(adapter, log) {
43046
+ if (adapter.cliType !== "hermes-cli") return;
43047
+ const status = typeof adapter.getStatus === "function" ? adapter.getStatus()?.status : void 0;
43048
+ if (status !== "starting") return;
43049
+ log(`Hermes CLI is still starting; waiting ${HERMES_CLI_STARTING_SEND_SETTLE_MS}ms before first send`);
43050
+ await sleep(HERMES_CLI_STARTING_SEND_SETTLE_MS);
43051
+ }
43041
43052
  function getHistorySessionId(h, args) {
43042
43053
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
43043
43054
  if (explicit) return explicit;
@@ -43897,6 +43908,7 @@ ${effect.notification.body || ""}`.trim();
43897
43908
  try {
43898
43909
  assertTextOnlyInput(provider, input);
43899
43910
  if (!text) return { success: false, error: "text required for PTY send" };
43911
+ await waitOnceForFreshHermesCliStart(adapter, _log);
43900
43912
  await adapter.sendMessage(text);
43901
43913
  return _logSendSuccess(`${transport}-adapter`, adapter.cliType);
43902
43914
  } catch (e) {
@@ -46802,8 +46814,6 @@ ${effect.notification.body || ""}`.trim();
46802
46814
  const aTime = getTime(a.message);
46803
46815
  const bTime = getTime(b2.message);
46804
46816
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
46805
- if (aTime && !bTime && a.source === "runtime" && b2.source === "parsed") return -1;
46806
- if (!aTime && bTime && a.source === "parsed" && b2.source === "runtime") return 1;
46807
46817
  return a.index - b2.index;
46808
46818
  }).map((entry) => entry.message));
46809
46819
  }
@@ -57088,7 +57098,7 @@ async (params) => {
57088
57098
  if (!adapter) return null;
57089
57099
  return { target, instance, adapter };
57090
57100
  }
57091
- function sleep(ms2) {
57101
+ function sleep2(ms2) {
57092
57102
  return new Promise((resolve16) => setTimeout(resolve16, ms2));
57093
57103
  }
57094
57104
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
@@ -57105,7 +57115,7 @@ async (params) => {
57105
57115
  return bundle;
57106
57116
  }
57107
57117
  }
57108
- await sleep(100);
57118
+ await sleep2(100);
57109
57119
  }
57110
57120
  return getCliTargetBundle(ctx, type, instanceId);
57111
57121
  }
@@ -57161,7 +57171,7 @@ async (params) => {
57161
57171
  const message = String(lastLaunchError.message || "");
57162
57172
  const retryable = /ECONNREFUSED|session-host|Session host/i.test(message);
57163
57173
  if (!retryable || attempt === 2) break;
57164
- await sleep(1e3);
57174
+ await sleep2(1e3);
57165
57175
  }
57166
57176
  }
57167
57177
  if (!launched) {
@@ -57224,16 +57234,16 @@ async (params) => {
57224
57234
  const modal = debug?.activeModal || trace?.activeModal || null;
57225
57235
  noteStatus(status);
57226
57236
  if (resolveActiveModalIfNeeded(status, modal)) {
57227
- await sleep(150);
57237
+ await sleep2(150);
57228
57238
  continue;
57229
57239
  }
57230
57240
  const startupParseGate = !!debug?.startupParseGate;
57231
57241
  if (status === "idle" && !startupParseGate) break;
57232
- await sleep(150);
57242
+ await sleep2(150);
57233
57243
  }
57234
57244
  ctx.instanceManager.sendEvent(bundle.target.instanceId, "send_message", { text });
57235
57245
  while (Date.now() - startAt < Math.max(1e3, timeoutMs)) {
57236
- await sleep(150);
57246
+ await sleep2(150);
57237
57247
  bundle = getCliTargetBundle(ctx, type, bundle.target.instanceId);
57238
57248
  if (!bundle) {
57239
57249
  throw new Error("CLI instance disappeared during exercise");