@adhdev/daemon-core 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.76-rc.50",
3
+ "version": "0.9.76-rc.51",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,6 +22,7 @@ import type { SessionTransport } from '../shared-types.js';
22
22
 
23
23
  const RECENT_SEND_WINDOW_MS = 1200;
24
24
  export const READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25_000;
25
+ const HERMES_CLI_STARTING_SEND_SETTLE_MS = 2_000;
25
26
  const recentSendByTarget = new Map<string, number>();
26
27
 
27
28
  interface ApprovalSelectableInstance extends ProviderInstance {
@@ -101,6 +102,19 @@ function getSendChatInputEnvelope(args: any): InputEnvelope {
101
102
  return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
102
103
  }
103
104
 
105
+ function sleep(ms: number): Promise<void> {
106
+ return new Promise((resolve) => setTimeout(resolve, ms));
107
+ }
108
+
109
+ async function waitOnceForFreshHermesCliStart(adapter: CliAdapter, log: (msg: string) => void): Promise<void> {
110
+ if (adapter.cliType !== 'hermes-cli') return;
111
+ const status = typeof adapter.getStatus === 'function' ? adapter.getStatus()?.status : undefined;
112
+ if (status !== 'starting') return;
113
+
114
+ log(`Hermes CLI is still starting; waiting ${HERMES_CLI_STARTING_SEND_SETTLE_MS}ms before first send`);
115
+ await sleep(HERMES_CLI_STARTING_SEND_SETTLE_MS);
116
+ }
117
+
104
118
  function getHistorySessionId(h: CommandHelpers, args: any): string | undefined {
105
119
  const explicit = typeof args?.historySessionId === 'string' ? args.historySessionId.trim() : '';
106
120
  if (explicit) return explicit;
@@ -1120,6 +1134,7 @@ export async function handleSendChat(h: CommandHelpers, args: any): Promise<Comm
1120
1134
  try {
1121
1135
  assertTextOnlyInput(provider, input);
1122
1136
  if (!text) return { success: false, error: 'text required for PTY send' };
1137
+ await waitOnceForFreshHermesCliStart(adapter, _log);
1123
1138
  await adapter.sendMessage(text);
1124
1139
  return _logSendSuccess(`${transport}-adapter`, adapter.cliType);
1125
1140
  } catch (e: any) {
@@ -1032,8 +1032,11 @@ export class CliProviderInstance implements ProviderInstance {
1032
1032
  const aTime = getTime(a.message);
1033
1033
  const bTime = getTime(b.message);
1034
1034
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
1035
- if (aTime && !bTime && a.source === 'runtime' && b.source === 'parsed') return -1;
1036
- if (!aTime && bTime && a.source === 'parsed' && b.source === 'runtime') return 1;
1035
+ // Many provider-owned CLI transcripts (including Hermes CLI in debug bundles)
1036
+ // do not carry timestamps on parsed messages. In that case there is no safe
1037
+ // clock basis for interleaving timestamped runtime/system messages into the
1038
+ // provider transcript, so preserve parsed order and append runtime entries by
1039
+ // their insertion index instead of moving them ahead of the whole transcript.
1037
1040
  return a.index - b.index;
1038
1041
  })
1039
1042
  .map((entry) => entry.message));