adhdev 0.9.9 → 0.9.10

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
@@ -7525,7 +7525,7 @@ function didProviderConfirmSend(result) {
7525
7525
  }
7526
7526
  async function readExtensionChatState(h) {
7527
7527
  try {
7528
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
7528
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
7529
7529
  if (!evalResult?.result) return null;
7530
7530
  const parsed = parseMaybeJson(evalResult.result);
7531
7531
  return parsed && typeof parsed === "object" ? parsed : null;
@@ -7613,7 +7613,7 @@ async function handleReadChat(h, args) {
7613
7613
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
7614
7614
  const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
7615
7615
  if (status) {
7616
- LOG.info("Command", `[read_chat] cli-like resolved provider=${adapter.cliType} target=${String(args?.targetSessionId || "")} adapterStatus=${String(adapterStatus.status || "")} parsedStatus=${String(parsedRecord?.status || "")} shouldPreferAdapterMessages=${String(shouldPreferAdapterMessages)} adapterMsgCount=${Array.isArray(adapterStatus.messages) ? adapterStatus.messages.length : 0} parsedMsgCount=${Array.isArray(parsedRecord?.messages) ? parsedRecord.messages.length : 0} returnedMsgCount=${Array.isArray(status.messages) ? status.messages.length : 0}`);
7616
+ LOG.debug("Command", `[read_chat] cli-like resolved provider=${adapter.cliType} target=${String(args?.targetSessionId || "")} adapterStatus=${String(adapterStatus.status || "")} parsedStatus=${String(parsedRecord?.status || "")} shouldPreferAdapterMessages=${String(shouldPreferAdapterMessages)} adapterMsgCount=${Array.isArray(adapterStatus.messages) ? adapterStatus.messages.length : 0} parsedMsgCount=${Array.isArray(parsedRecord?.messages) ? parsedRecord.messages.length : 0} returnedMsgCount=${Array.isArray(status.messages) ? status.messages.length : 0}`);
7617
7617
  return buildReadChatCommandResult({
7618
7618
  messages: status.messages || [],
7619
7619
  status: status.status,
@@ -7638,7 +7638,7 @@ async function handleReadChat(h, args) {
7638
7638
  }
7639
7639
  if (isExtensionTransport(transport)) {
7640
7640
  try {
7641
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
7641
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
7642
7642
  if (evalResult?.result) {
7643
7643
  let parsed = evalResult.result;
7644
7644
  if (typeof parsed === "string") {
@@ -7742,7 +7742,7 @@ async function handleReadChat(h, args) {
7742
7742
  const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
7743
7743
  if (script) {
7744
7744
  try {
7745
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
7745
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
7746
7746
  if (evalResult?.result) {
7747
7747
  let parsed = evalResult.result;
7748
7748
  if (typeof parsed === "string") {
@@ -8446,7 +8446,7 @@ async function handleResolveAction(h, args) {
8446
8446
  }
8447
8447
  return { success: false, error: "resolveAction script not available for this provider" };
8448
8448
  }
8449
- var RECENT_SEND_WINDOW_MS, recentSendByTarget;
8449
+ var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
8450
8450
  var init_chat_commands = __esm({
8451
8451
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
8452
8452
  "use strict";
@@ -8459,6 +8459,7 @@ var init_chat_commands = __esm({
8459
8459
  init_chat_signatures();
8460
8460
  init_chat_message_normalization();
8461
8461
  RECENT_SEND_WINDOW_MS = 1200;
8462
+ READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
8462
8463
  recentSendByTarget = /* @__PURE__ */ new Map();
8463
8464
  }
8464
8465
  });
@@ -11827,7 +11828,7 @@ var init_provider_cli_adapter = __esm({
11827
11828
  sendDelayMs;
11828
11829
  sendKey;
11829
11830
  submitStrategy;
11830
- static SCRIPT_STATUS_DEBOUNCE_MS = 1e3;
11831
+ static SCRIPT_STATUS_DEBOUNCE_MS = 3e3;
11831
11832
  /** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
11832
11833
  setCliScripts(scripts) {
11833
11834
  this.cliScripts = scripts;
@@ -13991,7 +13992,7 @@ var init_cli_provider_instance = __esm({
13991
13992
  this.generatingDebouncePending = null;
13992
13993
  }
13993
13994
  this.generatingDebounceTimer = null;
13994
- }, 1e3);
13995
+ }, 3e3);
13995
13996
  } else if (newStatus === "waiting_approval") {
13996
13997
  this.suppressIdleHistoryReplay = false;
13997
13998
  if (this.generatingDebouncePending) {
@@ -14047,7 +14048,7 @@ var init_cli_provider_instance = __esm({
14047
14048
  this.generatingStartedAt = 0;
14048
14049
  }
14049
14050
  this.completedDebounceTimer = null;
14050
- }, 2e3);
14051
+ }, 3e3);
14051
14052
  }
14052
14053
  } else if (newStatus === "stopped") {
14053
14054
  if (this.generatingDebounceTimer) {
@@ -55372,7 +55373,7 @@ var init_adhdev_daemon = __esm({
55372
55373
  init_version();
55373
55374
  init_src();
55374
55375
  init_runtime_defaults();
55375
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.9" });
55376
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.10" });
55376
55377
  AdhdevDaemon = class _AdhdevDaemon {
55377
55378
  localHttpServer = null;
55378
55379
  localWss = null;
@@ -55396,6 +55397,7 @@ var init_adhdev_daemon = __esm({
55396
55397
  mandatoryUpgradeInFlight = false;
55397
55398
  debugConfig = resolveDebugRuntimeConfig();
55398
55399
  recentInteractionIdsBySession = /* @__PURE__ */ new Map();
55400
+ ptyInputDropLogLastAt = /* @__PURE__ */ new Map();
55399
55401
  static MANDATORY_UPDATE_BLOCKED_COMMANDS = /* @__PURE__ */ new Set([
55400
55402
  "launch_ide",
55401
55403
  "launch_cli",
@@ -55447,6 +55449,14 @@ var init_adhdev_daemon = __esm({
55447
55449
  const mode = this.getCliPresentationMode(sessionId);
55448
55450
  return mode === "chat" || mode === "terminal";
55449
55451
  }
55452
+ logPtyInputDrop(sessionId, reason) {
55453
+ const key = `${sessionId || "(missing)"}:${reason}`;
55454
+ const now = Date.now();
55455
+ const last = this.ptyInputDropLogLastAt.get(key) || 0;
55456
+ if (now - last < 3e4) return;
55457
+ this.ptyInputDropLogLastAt.set(key, now);
55458
+ LOG.warn("P2P", `PTY input dropped: session=${sessionId || "(missing)"} reason=${reason}`);
55459
+ }
55450
55460
  getUpgradePackageName() {
55451
55461
  return process.argv[1]?.includes("daemon-standalone") ? "@adhdev/daemon-standalone" : "adhdev";
55452
55462
  }
@@ -55559,9 +55569,13 @@ var init_adhdev_daemon = __esm({
55559
55569
  });
55560
55570
  }
55561
55571
  getHotChatSessionIdsForP2PFlush() {
55562
- const snapshot = this.buildLiveStatusSnapshot();
55572
+ const sessions = buildSessionEntries(
55573
+ this.components.instanceManager.collectAllStates(),
55574
+ this.components.cdpManagers,
55575
+ { profile: "live" }
55576
+ );
55563
55577
  const hotSessions = classifyHotChatSessionsForSubscriptionFlush(
55564
- snapshot.sessions,
55578
+ sessions,
55565
55579
  this.hotP2PChatSessionIds
55566
55580
  );
55567
55581
  this.hotP2PChatSessionIds = hotSessions.active;
@@ -55886,10 +55900,23 @@ ${err?.stack || ""}`);
55886
55900
  }
55887
55901
  });
55888
55902
  this.p2p.onPtyInput((sessionId, data) => {
55889
- if (!this.isCliSession(sessionId)) return;
55903
+ if (!this.isCliSession(sessionId)) {
55904
+ this.logPtyInputDrop(sessionId, "not_cli_session");
55905
+ return;
55906
+ }
55890
55907
  const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
55891
- if (found && typeof found.adapter.writeRaw === "function") {
55908
+ if (!found) {
55909
+ this.logPtyInputDrop(sessionId, "adapter_not_found");
55910
+ return;
55911
+ }
55912
+ if (typeof found.adapter.writeRaw !== "function") {
55913
+ this.logPtyInputDrop(sessionId, "writeRaw_missing");
55914
+ return;
55915
+ }
55916
+ try {
55892
55917
  found.adapter.writeRaw(data);
55918
+ } catch {
55919
+ this.logPtyInputDrop(sessionId, "write_failed");
55893
55920
  }
55894
55921
  });
55895
55922
  this.p2p.onPtyResize((sessionId, cols, rows) => {