@adhdev/daemon-standalone 0.9.8 → 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
@@ -28719,6 +28719,18 @@ var require_dist2 = __commonJS({
28719
28719
  }
28720
28720
  return role;
28721
28721
  }
28722
+ function validateBubbleState(state, source, index) {
28723
+ if (typeof state !== "string" || !VALID_BUBBLE_STATES.includes(state)) {
28724
+ throw new Error(`${source}: messages[${index}].bubbleState must be one of ${VALID_BUBBLE_STATES.join(", ")}`);
28725
+ }
28726
+ return state;
28727
+ }
28728
+ function validateTurnStatus(turnStatus, source) {
28729
+ if (typeof turnStatus !== "string" || !VALID_TURN_STATUSES.includes(turnStatus)) {
28730
+ throw new Error(`${source}: turnStatus must be one of ${VALID_TURN_STATUSES.join(", ")}`);
28731
+ }
28732
+ return turnStatus;
28733
+ }
28722
28734
  function validateMessageContent(content, source, index) {
28723
28735
  if (typeof content === "string") return content;
28724
28736
  if (Array.isArray(content)) return normalizeMessageParts(content);
@@ -28734,6 +28746,9 @@ var require_dist2 = __commonJS({
28734
28746
  };
28735
28747
  if (typeof message.kind === "string") normalized.kind = message.kind;
28736
28748
  if (typeof message.id === "string") normalized.id = message.id;
28749
+ if (typeof message.bubbleId === "string") normalized.bubbleId = message.bubbleId;
28750
+ if (typeof message.providerUnitKey === "string") normalized.providerUnitKey = message.providerUnitKey;
28751
+ if (message.bubbleState !== void 0) normalized.bubbleState = validateBubbleState(message.bubbleState, source, index);
28737
28752
  if (isFiniteNumber(message.index)) normalized.index = message.index;
28738
28753
  if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp;
28739
28754
  if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt;
@@ -28801,6 +28816,8 @@ var require_dist2 = __commonJS({
28801
28816
  if (activeModal !== void 0) normalized.activeModal = activeModal;
28802
28817
  if (typeof raw.id === "string") normalized.id = raw.id;
28803
28818
  if (typeof raw.title === "string") normalized.title = raw.title;
28819
+ if (typeof raw.currentTurnId === "string") normalized.currentTurnId = raw.currentTurnId;
28820
+ if (raw.turnStatus !== void 0) normalized.turnStatus = validateTurnStatus(raw.turnStatus, source);
28804
28821
  if (typeof raw.agentType === "string") normalized.agentType = raw.agentType;
28805
28822
  if (typeof raw.agentName === "string") normalized.agentName = raw.agentName;
28806
28823
  if (typeof raw.extensionId === "string") normalized.extensionId = raw.extensionId;
@@ -28815,12 +28832,16 @@ var require_dist2 = __commonJS({
28815
28832
  }
28816
28833
  var VALID_STATUSES;
28817
28834
  var VALID_ROLES;
28835
+ var VALID_BUBBLE_STATES;
28836
+ var VALID_TURN_STATUSES;
28818
28837
  var init_read_chat_contract = __esm2({
28819
28838
  "src/providers/read-chat-contract.ts"() {
28820
28839
  "use strict";
28821
28840
  init_contracts();
28822
28841
  VALID_STATUSES = ["idle", "generating", "waiting_approval", "error", "panel_hidden", "streaming", "long_generating"];
28823
28842
  VALID_ROLES = ["user", "assistant", "system", "human"];
28843
+ VALID_BUBBLE_STATES = ["draft", "streaming", "final", "removed"];
28844
+ VALID_TURN_STATUSES = ["open", "waiting_approval", "complete", "error"];
28824
28845
  }
28825
28846
  });
28826
28847
  function normalizeCategories(categories) {
@@ -30055,7 +30076,7 @@ var require_dist2 = __commonJS({
30055
30076
  sendDelayMs;
30056
30077
  sendKey;
30057
30078
  submitStrategy;
30058
- static SCRIPT_STATUS_DEBOUNCE_MS = 1e3;
30079
+ static SCRIPT_STATUS_DEBOUNCE_MS = 3e3;
30059
30080
  /** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
30060
30081
  setCliScripts(scripts) {
30061
30082
  this.cliScripts = scripts;
@@ -37834,6 +37855,7 @@ ${effect.notification.body || ""}`.trim();
37834
37855
  }
37835
37856
  init_chat_message_normalization();
37836
37857
  var RECENT_SEND_WINDOW_MS = 1200;
37858
+ var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
37837
37859
  var recentSendByTarget = /* @__PURE__ */ new Map();
37838
37860
  function getCurrentProviderType(h, fallback = "") {
37839
37861
  return h.currentSession?.providerType || h.currentProviderType || fallback;
@@ -38127,7 +38149,7 @@ ${effect.notification.body || ""}`.trim();
38127
38149
  }
38128
38150
  async function readExtensionChatState(h) {
38129
38151
  try {
38130
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
38152
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
38131
38153
  if (!evalResult?.result) return null;
38132
38154
  const parsed = parseMaybeJson(evalResult.result);
38133
38155
  return parsed && typeof parsed === "object" ? parsed : null;
@@ -38215,7 +38237,7 @@ ${effect.notification.body || ""}`.trim();
38215
38237
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
38216
38238
  const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
38217
38239
  if (status) {
38218
- LOG2.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}`);
38240
+ LOG2.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}`);
38219
38241
  return buildReadChatCommandResult({
38220
38242
  messages: status.messages || [],
38221
38243
  status: status.status,
@@ -38240,7 +38262,7 @@ ${effect.notification.body || ""}`.trim();
38240
38262
  }
38241
38263
  if (isExtensionTransport(transport)) {
38242
38264
  try {
38243
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
38265
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
38244
38266
  if (evalResult?.result) {
38245
38267
  let parsed = evalResult.result;
38246
38268
  if (typeof parsed === "string") {
@@ -38344,7 +38366,7 @@ ${effect.notification.body || ""}`.trim();
38344
38366
  const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
38345
38367
  if (script) {
38346
38368
  try {
38347
- const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
38369
+ const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
38348
38370
  if (evalResult?.result) {
38349
38371
  let parsed = evalResult.result;
38350
38372
  if (typeof parsed === "string") {
@@ -40904,7 +40926,7 @@ ${effect.notification.body || ""}`.trim();
40904
40926
  this.generatingDebouncePending = null;
40905
40927
  }
40906
40928
  this.generatingDebounceTimer = null;
40907
- }, 1e3);
40929
+ }, 3e3);
40908
40930
  } else if (newStatus === "waiting_approval") {
40909
40931
  this.suppressIdleHistoryReplay = false;
40910
40932
  if (this.generatingDebouncePending) {
@@ -40960,7 +40982,7 @@ ${effect.notification.body || ""}`.trim();
40960
40982
  this.generatingStartedAt = 0;
40961
40983
  }
40962
40984
  this.completedDebounceTimer = null;
40963
- }, 2e3);
40985
+ }, 3e3);
40964
40986
  }
40965
40987
  } else if (newStatus === "stopped") {
40966
40988
  if (this.generatingDebounceTimer) {