adhdev 0.8.97 → 0.8.99

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.
Files changed (33) hide show
  1. package/dist/cli/index.js +265 -47
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/index.js +248 -45
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/vendor/session-host-daemon/index.js +4 -4
  7. package/vendor/session-host-daemon/index.js.map +1 -1
  8. package/vendor/session-host-daemon/index.mjs +13 -6
  9. package/vendor/session-host-daemon/index.mjs.map +1 -1
  10. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.d.mts +6 -0
  11. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.d.ts +6 -0
  12. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.js +49 -0
  13. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.js.map +1 -0
  14. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.mjs +21 -0
  15. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/defaults.mjs.map +1 -0
  16. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.mts +1 -0
  17. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.ts +1 -0
  18. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +25 -2
  19. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -1
  20. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +21 -2
  21. package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
  22. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.d.mts +6 -0
  23. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.d.ts +6 -0
  24. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.js +49 -0
  25. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.js.map +1 -0
  26. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.mjs +21 -0
  27. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/defaults.mjs.map +1 -0
  28. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.mts +1 -0
  29. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.ts +1 -0
  30. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js +25 -2
  31. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js.map +1 -1
  32. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs +21 -2
  33. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
package/dist/cli/index.js CHANGED
@@ -1259,6 +1259,9 @@ function normalizeProviderSessionId(providerType, providerSessionId) {
1259
1259
  if (normalizedProviderType === "hermes-cli" && !HERMES_SESSION_ID_RE.test(normalizedId)) {
1260
1260
  return "";
1261
1261
  }
1262
+ if (normalizedProviderType === "claude-cli" && !CLAUDE_SESSION_ID_RE.test(normalizedId)) {
1263
+ return "";
1264
+ }
1262
1265
  return normalizedId;
1263
1266
  }
1264
1267
  function isLegacyVolatileSessionReadKey(key) {
@@ -1266,11 +1269,12 @@ function isLegacyVolatileSessionReadKey(key) {
1266
1269
  if (!normalizedKey) return false;
1267
1270
  return normalizedKey.startsWith("provider:codex:vscode-webview://");
1268
1271
  }
1269
- var HERMES_SESSION_ID_RE;
1272
+ var HERMES_SESSION_ID_RE, CLAUDE_SESSION_ID_RE;
1270
1273
  var init_provider_session_id = __esm({
1271
1274
  "../../oss/packages/daemon-core/src/providers/provider-session-id.ts"() {
1272
1275
  "use strict";
1273
1276
  HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i;
1277
+ CLAUDE_SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1274
1278
  }
1275
1279
  });
1276
1280
 
@@ -4677,9 +4681,16 @@ function extractCanonicalHermesMessageTimestamp(message, fallbackTs) {
4677
4681
  if (Number.isFinite(stringTimestamp) && stringTimestamp > 0) return stringTimestamp;
4678
4682
  return fallbackTs;
4679
4683
  }
4680
- function readExistingHermesSessionStartRecord(historySessionId) {
4684
+ function extractTimestampValue(value) {
4685
+ const numericTimestamp = Number(value || 0);
4686
+ if (Number.isFinite(numericTimestamp) && numericTimestamp > 0) return numericTimestamp;
4687
+ const stringTimestamp = typeof value === "string" ? Date.parse(value) : NaN;
4688
+ if (Number.isFinite(stringTimestamp) && stringTimestamp > 0) return stringTimestamp;
4689
+ return 0;
4690
+ }
4691
+ function readExistingSessionStartRecord(agentType, historySessionId) {
4681
4692
  try {
4682
- const dir = path7.join(HISTORY_DIR, "hermes-cli");
4693
+ const dir = path7.join(HISTORY_DIR, agentType);
4683
4694
  if (!fs3.existsSync(dir)) return null;
4684
4695
  const files = listHistoryFiles(dir, historySessionId).sort();
4685
4696
  for (const file2 of files) {
@@ -4700,6 +4711,28 @@ function readExistingHermesSessionStartRecord(historySessionId) {
4700
4711
  return null;
4701
4712
  }
4702
4713
  }
4714
+ function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
4715
+ if (records.length === 0) return false;
4716
+ try {
4717
+ const dir = path7.join(HISTORY_DIR, agentType);
4718
+ fs3.mkdirSync(dir, { recursive: true });
4719
+ const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
4720
+ for (const file2 of fs3.readdirSync(dir)) {
4721
+ if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
4722
+ fs3.unlinkSync(path7.join(dir, file2));
4723
+ }
4724
+ }
4725
+ const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
4726
+ const filePath = path7.join(dir, `${prefix}${targetDate}.jsonl`);
4727
+ fs3.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
4728
+ `, "utf-8");
4729
+ invalidatePersistedSavedHistoryIndex(agentType, dir);
4730
+ savedHistorySessionCache.delete(agentType.replace(/[^a-zA-Z0-9_-]/g, "_"));
4731
+ return true;
4732
+ } catch {
4733
+ return false;
4734
+ }
4735
+ }
4703
4736
  function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
4704
4737
  const normalizedSessionId = normalizeSavedHistorySessionId("hermes-cli", historySessionId);
4705
4738
  if (!normalizedSessionId) return false;
@@ -4710,7 +4743,7 @@ function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
4710
4743
  const canonicalMessages = Array.isArray(raw.messages) ? raw.messages : [];
4711
4744
  const dir = path7.join(HISTORY_DIR, "hermes-cli");
4712
4745
  fs3.mkdirSync(dir, { recursive: true });
4713
- const existingSessionStart = readExistingHermesSessionStartRecord(normalizedSessionId);
4746
+ const existingSessionStart = readExistingSessionStartRecord("hermes-cli", normalizedSessionId);
4714
4747
  const records = [];
4715
4748
  if (existingSessionStart) {
4716
4749
  records.push({
@@ -4762,20 +4795,167 @@ function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
4762
4795
  });
4763
4796
  }
4764
4797
  }
4765
- if (records.length === 0) return false;
4766
- const prefix = `${normalizedSessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
4767
- for (const file2 of fs3.readdirSync(dir)) {
4768
- if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
4769
- fs3.unlinkSync(path7.join(dir, file2));
4798
+ return rewriteCanonicalSavedHistory("hermes-cli", normalizedSessionId, records);
4799
+ } catch {
4800
+ return false;
4801
+ }
4802
+ }
4803
+ function resolveClaudeProjectTranscriptPath(historySessionId, workspace) {
4804
+ const claudeProjectsDir = path7.join(os6.homedir(), ".claude", "projects");
4805
+ if (!fs3.existsSync(claudeProjectsDir)) return null;
4806
+ const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
4807
+ if (normalizedWorkspace) {
4808
+ const directPath = path7.join(claudeProjectsDir, normalizedWorkspace.replace(/[\\/]/g, "-"), `${historySessionId}.jsonl`);
4809
+ if (fs3.existsSync(directPath)) return directPath;
4810
+ }
4811
+ const stack = [claudeProjectsDir];
4812
+ while (stack.length > 0) {
4813
+ const current = stack.pop();
4814
+ if (!current) continue;
4815
+ for (const entry of fs3.readdirSync(current, { withFileTypes: true })) {
4816
+ const entryPath = path7.join(current, entry.name);
4817
+ if (entry.isDirectory()) {
4818
+ stack.push(entryPath);
4819
+ continue;
4820
+ }
4821
+ if (entry.isFile() && entry.name === `${historySessionId}.jsonl`) {
4822
+ return entryPath;
4770
4823
  }
4771
4824
  }
4772
- const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
4773
- const filePath = path7.join(dir, `${prefix}${targetDate}.jsonl`);
4774
- fs3.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
4775
- `, "utf-8");
4776
- invalidatePersistedSavedHistoryIndex("hermes-cli", dir);
4777
- savedHistorySessionCache.delete("hermes-cli");
4778
- return true;
4825
+ }
4826
+ return null;
4827
+ }
4828
+ function extractClaudeAssistantContentParts(content) {
4829
+ if (typeof content === "string") {
4830
+ const trimmed = content.trim();
4831
+ return trimmed ? [{ content: trimmed, kind: "standard", role: "assistant" }] : [];
4832
+ }
4833
+ if (!Array.isArray(content)) return [];
4834
+ const parts = [];
4835
+ for (const block of content) {
4836
+ if (!block || typeof block !== "object") continue;
4837
+ const record2 = block;
4838
+ const type = String(record2.type || "").trim();
4839
+ if (type === "text") {
4840
+ const text = String(record2.text || "").trim();
4841
+ if (text) parts.push({ content: text, kind: "standard", role: "assistant" });
4842
+ continue;
4843
+ }
4844
+ if (type === "tool_use") {
4845
+ const name = String(record2.name || "").trim() || "Tool";
4846
+ const input = record2.input && typeof record2.input === "object" ? record2.input : null;
4847
+ const command = input ? String(input.command || "").trim() : "";
4848
+ const summary = command ? `${name}: ${command}` : name;
4849
+ if (summary) parts.push({ content: summary, kind: "tool", senderName: "Tool", role: "assistant" });
4850
+ }
4851
+ }
4852
+ return parts;
4853
+ }
4854
+ function extractClaudeUserContentParts(content) {
4855
+ if (typeof content === "string") {
4856
+ const trimmed = content.trim();
4857
+ return trimmed ? [{ role: "user", content: trimmed, kind: "standard" }] : [];
4858
+ }
4859
+ if (!Array.isArray(content)) return [];
4860
+ const parts = [];
4861
+ for (const block of content) {
4862
+ if (!block || typeof block !== "object") continue;
4863
+ const record2 = block;
4864
+ const type = String(record2.type || "").trim();
4865
+ if (type === "text") {
4866
+ const text = String(record2.text || "").trim();
4867
+ if (text) parts.push({ role: "user", content: text, kind: "standard" });
4868
+ continue;
4869
+ }
4870
+ if (type === "tool_result") {
4871
+ const rawContent = record2.content;
4872
+ const text = typeof rawContent === "string" ? rawContent.trim() : Array.isArray(rawContent) ? rawContent.map((entry) => {
4873
+ if (typeof entry === "string") return entry.trim();
4874
+ if (!entry || typeof entry !== "object") return "";
4875
+ const nested = entry;
4876
+ if (typeof nested.text === "string") return nested.text.trim();
4877
+ if (typeof nested.content === "string") return nested.content.trim();
4878
+ return "";
4879
+ }).filter(Boolean).join("\n") : "";
4880
+ if (text) parts.push({ role: "assistant", content: text, kind: "tool", senderName: "Tool" });
4881
+ }
4882
+ }
4883
+ return parts;
4884
+ }
4885
+ function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace) {
4886
+ const normalizedSessionId = normalizeSavedHistorySessionId("claude-cli", historySessionId);
4887
+ if (!normalizedSessionId) return false;
4888
+ try {
4889
+ const transcriptPath = resolveClaudeProjectTranscriptPath(normalizedSessionId, workspace);
4890
+ if (!transcriptPath) return false;
4891
+ const lines = fs3.readFileSync(transcriptPath, "utf-8").split("\n").filter(Boolean);
4892
+ const records = [];
4893
+ const existingSessionStart = readExistingSessionStartRecord("claude-cli", normalizedSessionId);
4894
+ if (existingSessionStart) {
4895
+ records.push({
4896
+ ...existingSessionStart,
4897
+ historySessionId: normalizedSessionId
4898
+ });
4899
+ }
4900
+ let fallbackTs = Date.now();
4901
+ for (const line of lines) {
4902
+ let parsed = null;
4903
+ try {
4904
+ parsed = JSON.parse(line);
4905
+ } catch {
4906
+ parsed = null;
4907
+ }
4908
+ if (!parsed) continue;
4909
+ const parsedSessionId = String(parsed.sessionId || "").trim();
4910
+ if (parsedSessionId && parsedSessionId !== normalizedSessionId) continue;
4911
+ const receivedAt = extractTimestampValue(parsed.timestamp) || fallbackTs;
4912
+ fallbackTs = receivedAt + 1;
4913
+ const parsedWorkspace = String(parsed.cwd || workspace || "").trim();
4914
+ if (records.length === 0 && parsedWorkspace) {
4915
+ records.push({
4916
+ ts: new Date(receivedAt).toISOString(),
4917
+ receivedAt,
4918
+ role: "system",
4919
+ kind: "session_start",
4920
+ content: parsedWorkspace,
4921
+ agent: "claude-cli",
4922
+ historySessionId: normalizedSessionId,
4923
+ workspace: parsedWorkspace
4924
+ });
4925
+ }
4926
+ const type = String(parsed.type || "").trim();
4927
+ const message = parsed.message && typeof parsed.message === "object" ? parsed.message : null;
4928
+ if (type === "user" && message) {
4929
+ for (const part of extractClaudeUserContentParts(message.content)) {
4930
+ records.push({
4931
+ ts: new Date(receivedAt).toISOString(),
4932
+ receivedAt,
4933
+ role: part.role,
4934
+ content: part.content,
4935
+ kind: part.kind,
4936
+ senderName: part.senderName,
4937
+ agent: "claude-cli",
4938
+ historySessionId: normalizedSessionId
4939
+ });
4940
+ }
4941
+ continue;
4942
+ }
4943
+ if (type === "assistant" && message) {
4944
+ for (const part of extractClaudeAssistantContentParts(message.content)) {
4945
+ records.push({
4946
+ ts: new Date(receivedAt).toISOString(),
4947
+ receivedAt,
4948
+ role: "assistant",
4949
+ content: part.content,
4950
+ kind: part.kind,
4951
+ senderName: part.senderName,
4952
+ agent: "claude-cli",
4953
+ historySessionId: normalizedSessionId
4954
+ });
4955
+ }
4956
+ }
4957
+ }
4958
+ return rewriteCanonicalSavedHistory("claude-cli", normalizedSessionId, records);
4779
4959
  } catch {
4780
4960
  return false;
4781
4961
  }
@@ -11061,6 +11241,8 @@ var init_terminal_screen = __esm({
11061
11241
  // ../../oss/packages/session-host-core/dist/index.mjs
11062
11242
  var dist_exports = {};
11063
11243
  __export(dist_exports, {
11244
+ DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
11245
+ DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
11064
11246
  SessionHostClient: () => SessionHostClient,
11065
11247
  SessionHostRegistry: () => SessionHostRegistry,
11066
11248
  SessionRingBuffer: () => SessionRingBuffer,
@@ -11079,9 +11261,22 @@ __export(dist_exports, {
11079
11261
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot2,
11080
11262
  resolveAttachableRuntimeRecord: () => resolveAttachableRuntimeRecord,
11081
11263
  resolveRuntimeRecord: () => resolveRuntimeRecord,
11264
+ resolveSessionHostCols: () => resolveSessionHostCols,
11265
+ resolveSessionHostRows: () => resolveSessionHostRows,
11082
11266
  sanitizeSpawnEnv: () => sanitizeSpawnEnv,
11083
11267
  writeEnvelope: () => writeEnvelope
11084
11268
  });
11269
+ function normalizeSessionHostDimension(value, fallback2) {
11270
+ if (typeof value !== "number" || !Number.isFinite(value)) return fallback2;
11271
+ const rounded = Math.floor(value);
11272
+ return rounded > 0 ? rounded : fallback2;
11273
+ }
11274
+ function resolveSessionHostCols(value) {
11275
+ return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_COLS);
11276
+ }
11277
+ function resolveSessionHostRows(value) {
11278
+ return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_ROWS);
11279
+ }
11085
11280
  function normalizeSlug(input) {
11086
11281
  return input.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
11087
11282
  }
@@ -11278,7 +11473,7 @@ function ensureNodePtySpawnHelperPermissions(logFn) {
11278
11473
  } catch {
11279
11474
  }
11280
11475
  }
11281
- var import_crypto3, path9, os9, path22, net, import_crypto4, os22, path32, __require, SessionRingBuffer, LIVE_LIFECYCLES2, SessionHostRegistry, SessionHostClient;
11476
+ var import_crypto3, path9, os9, path22, net, import_crypto4, os22, path32, __require, SessionRingBuffer, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, LIVE_LIFECYCLES2, SessionHostRegistry, SessionHostClient;
11282
11477
  var init_dist = __esm({
11283
11478
  "../../oss/packages/session-host-core/dist/index.mjs"() {
11284
11479
  "use strict";
@@ -11356,6 +11551,8 @@ var init_dist = __esm({
11356
11551
  }
11357
11552
  }
11358
11553
  };
11554
+ DEFAULT_SESSION_HOST_COLS = 80;
11555
+ DEFAULT_SESSION_HOST_ROWS = 48;
11359
11556
  LIVE_LIFECYCLES2 = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
11360
11557
  SessionHostRegistry = class {
11361
11558
  sessions = /* @__PURE__ */ new Map();
@@ -11397,8 +11594,8 @@ var init_dist = __esm({
11397
11594
  meta: payload.meta || {}
11398
11595
  };
11399
11596
  record2.meta = {
11400
- sessionHostCols: payload.cols || 80,
11401
- sessionHostRows: payload.rows || 24,
11597
+ sessionHostCols: resolveSessionHostCols(payload.cols),
11598
+ sessionHostRows: resolveSessionHostRows(payload.rows),
11402
11599
  ...record2.meta
11403
11600
  };
11404
11601
  this.sessions.set(sessionId, {
@@ -12194,8 +12391,8 @@ function resolveCliSpawnPlan(options) {
12194
12391
  isWin,
12195
12392
  useShell,
12196
12393
  ptyOptions: {
12197
- cols: 80,
12198
- rows: 24,
12394
+ cols: DEFAULT_SESSION_HOST_COLS,
12395
+ rows: DEFAULT_SESSION_HOST_ROWS,
12199
12396
  cwd: workingDir,
12200
12397
  env: buildCliSpawnEnv(process.env, spawnConfig.env)
12201
12398
  }
@@ -12252,6 +12449,7 @@ var init_provider_cli_runtime = __esm({
12252
12449
  "use strict";
12253
12450
  os12 = __toESM(require("os"));
12254
12451
  path11 = __toESM(require("path"));
12452
+ init_dist();
12255
12453
  init_provider_cli_shared();
12256
12454
  }
12257
12455
  });
@@ -14639,7 +14837,7 @@ var init_cli_provider_instance = __esm({
14639
14837
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
14640
14838
  }
14641
14839
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
14642
- const canonicalHermesBackedHistory = this.syncCanonicalHermesSavedHistoryIfNeeded();
14840
+ const canonicalBackedHistory = this.syncCanonicalSavedHistoryIfNeeded();
14643
14841
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14644
14842
  if (parsedMessages.length > 0) {
14645
14843
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -14657,7 +14855,7 @@ var init_cli_provider_instance = __esm({
14657
14855
  senderName: typeof message.senderName === "string" ? message.senderName : void 0,
14658
14856
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
14659
14857
  }));
14660
- if (!canonicalHermesBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
14858
+ if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
14661
14859
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
14662
14860
  this.historyWriter.appendNewMessages(
14663
14861
  this.type,
@@ -14667,7 +14865,7 @@ var init_cli_provider_instance = __esm({
14667
14865
  this.providerSessionId
14668
14866
  );
14669
14867
  }
14670
- if (!canonicalHermesBackedHistory) {
14868
+ if (!canonicalBackedHistory) {
14671
14869
  this.lastPersistedHistoryMessages = normalizedMessagesToSave;
14672
14870
  }
14673
14871
  }
@@ -15144,32 +15342,52 @@ ${effect.notification.body || ""}`.trim();
15144
15342
  });
15145
15343
  LOG.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
15146
15344
  }
15147
- syncCanonicalHermesSavedHistoryIfNeeded() {
15148
- if (this.type !== "hermes-cli" || !this.providerSessionId) return false;
15149
- try {
15150
- const canonicalPath = path12.join(os14.homedir(), ".hermes", "sessions", `session_${this.providerSessionId}.json`);
15151
- if (!fs5.existsSync(canonicalPath)) return false;
15152
- const stat4 = fs5.statSync(canonicalPath);
15153
- if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
15154
- const rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
15155
- if (!rebuilt) return false;
15156
- this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
15157
- const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
15158
- this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
15159
- role: message.role,
15160
- content: message.content,
15161
- kind: message.kind,
15162
- senderName: message.senderName,
15163
- receivedAt: message.receivedAt
15164
- }));
15165
- return true;
15166
- } catch {
15167
- return false;
15345
+ syncCanonicalSavedHistoryIfNeeded() {
15346
+ if (!this.providerSessionId) return false;
15347
+ if (this.type === "hermes-cli") {
15348
+ try {
15349
+ const canonicalPath = path12.join(os14.homedir(), ".hermes", "sessions", `session_${this.providerSessionId}.json`);
15350
+ if (!fs5.existsSync(canonicalPath)) return false;
15351
+ const stat4 = fs5.statSync(canonicalPath);
15352
+ if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
15353
+ const rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
15354
+ if (!rebuilt) return false;
15355
+ this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
15356
+ const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
15357
+ this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
15358
+ role: message.role,
15359
+ content: message.content,
15360
+ kind: message.kind,
15361
+ senderName: message.senderName,
15362
+ receivedAt: message.receivedAt
15363
+ }));
15364
+ return true;
15365
+ } catch {
15366
+ return false;
15367
+ }
15368
+ }
15369
+ if (this.type === "claude-cli") {
15370
+ try {
15371
+ const rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
15372
+ if (!rebuilt) return false;
15373
+ const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
15374
+ this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
15375
+ role: message.role,
15376
+ content: message.content,
15377
+ kind: message.kind,
15378
+ senderName: message.senderName,
15379
+ receivedAt: message.receivedAt
15380
+ }));
15381
+ return true;
15382
+ } catch {
15383
+ return false;
15384
+ }
15168
15385
  }
15386
+ return false;
15169
15387
  }
15170
15388
  restorePersistedHistoryFromCurrentSession() {
15171
15389
  if (!this.providerSessionId) return;
15172
- this.syncCanonicalHermesSavedHistoryIfNeeded();
15390
+ this.syncCanonicalSavedHistoryIfNeeded();
15173
15391
  this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
15174
15392
  const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
15175
15393
  this.historyWriter.seedSessionHistory(
@@ -86832,7 +87050,7 @@ var init_adhdev_daemon = __esm({
86832
87050
  init_version();
86833
87051
  init_src();
86834
87052
  init_runtime_defaults();
86835
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.97" });
87053
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.99" });
86836
87054
  AdhdevDaemon = class _AdhdevDaemon {
86837
87055
  localHttpServer = null;
86838
87056
  localWss = null;