@adhdev/daemon-core 0.9.76-rc.63 → 0.9.76-rc.65

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.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Core logic for daemon: CDP, Provider, IDE detection, CLI/ACP adapters and more.
5
5
  */
6
6
  export type { ChatBubbleState, ChatMessage, ExtensionInfo, CommandResult as CoreCommandResult, ProviderConfig, DaemonEvent, StatusResponse, SystemInfo, DetectedIde, ProviderInfo, AgentEntry, } from './types.js';
7
- export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemonSummaryEntry, DashboardBootstrapDaemonEntry, VersionUpdateReason, CloudStatusReportPayload, DaemonStatusEventPayload, DashboardStatusEventPayload, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, ReadChatCursor, ReadChatSyncResult, TransportTopic, SessionChatTailSubscriptionParams, SessionRuntimeOutputSubscriptionParams, MachineRuntimeSubscriptionParams, SessionHostDiagnosticsSubscriptionParams, SessionModalSubscriptionParams, DaemonMetadataSubscriptionParams, WorkspaceGitSubscriptionParams, SessionChatTailUpdate, MachineRuntimeUpdate, SessionHostDiagnosticsUpdate, SessionModalUpdate, DaemonMetadataUpdate, TopicUpdateEnvelope, SubscribeRequest, UnsubscribeRequest, StandaloneWsStatusPayload, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, SessionHostDiagnosticsSnapshot, SessionHostRecord, SessionHostWriteOwner, SessionHostAttachedClient, SessionHostLogEntry, SessionHostRequestTrace, SessionHostRuntimeTransition, DetectedIdeInfo, WorkspaceEntry, ProviderSummaryItem, ProviderSummaryMetadata, ProviderState, ProviderStatus, ProviderErrorReason, SessionActiveChatData, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, } from './shared-types.js';
7
+ export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemonSummaryEntry, DashboardBootstrapDaemonEntry, VersionUpdateReason, CloudStatusReportPayload, DaemonStatusEventPayload, DashboardStatusEventPayload, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, ReadChatCursor, ReadChatSyncResult, TransportTopic, SessionChatTailSubscriptionParams, SessionRuntimeOutputSubscriptionParams, MachineRuntimeSubscriptionParams, SessionHostDiagnosticsSubscriptionParams, SessionModalSubscriptionParams, DaemonMetadataSubscriptionParams, WorkspaceGitSubscriptionParams, SessionChatTailUpdate, MachineRuntimeUpdate, SessionHostDiagnosticsUpdate, SessionModalUpdate, DaemonMetadataUpdate, TopicUpdateEnvelope, SubscribeRequest, UnsubscribeRequest, StandaloneWsStatusPayload, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, SessionHostDiagnosticsSnapshot, SessionHostRecord, SessionHostWriteOwner, SessionHostAttachedClient, SessionHostLogEntry, SessionHostRequestTrace, SessionHostRuntimeTransition, DetectedIdeInfo, WorkspaceEntry, ProviderSummaryItem, ProviderSummaryMetadata, ProviderState, ProviderStatus, ProviderErrorReason, SessionActiveChatData, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, MessageInputSupport, InputMediaStrategyDescriptor, InputAttachmentStrategy, InputMediaType, } from './shared-types.js';
8
8
  export type { RepoMesh, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, } from './repo-mesh-types.js';
9
9
  export { DEFAULT_MESH_POLICY } from './repo-mesh-types.js';
10
10
  export * from './git/index.js';
package/dist/index.js CHANGED
@@ -15356,8 +15356,32 @@ function materializeImageDataPart(part, index, dir) {
15356
15356
  fs6.mkdirSync(dir, { recursive: true });
15357
15357
  const filePath = path16.join(dir, safeInputImageBasename(index, part.mimeType));
15358
15358
  fs6.writeFileSync(filePath, Buffer.from(rawData, "base64"));
15359
+ cleanupStaleMaterializedImages(dir);
15359
15360
  return filePath;
15360
15361
  }
15362
+ var MATERIALIZED_IMAGE_MAX_AGE_MS = 60 * 60 * 1e3;
15363
+ var MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS = 5 * 60 * 1e3;
15364
+ var lastMaterializedImageCleanupAt = 0;
15365
+ function cleanupStaleMaterializedImages(dir) {
15366
+ const now = Date.now();
15367
+ if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
15368
+ lastMaterializedImageCleanupAt = now;
15369
+ try {
15370
+ const entries = fs6.readdirSync(dir);
15371
+ for (const entry of entries) {
15372
+ if (!entry.startsWith("adhdev-input-image-")) continue;
15373
+ const fullPath = path16.join(dir, entry);
15374
+ try {
15375
+ const stat2 = fs6.statSync(fullPath);
15376
+ if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
15377
+ fs6.unlinkSync(fullPath);
15378
+ }
15379
+ } catch {
15380
+ }
15381
+ }
15382
+ } catch {
15383
+ }
15384
+ }
15361
15385
  function buildCliStructuredInputPrompt(input, options = {}) {
15362
15386
  const promptParts = [];
15363
15387
  const imageRefs = [];
@@ -15384,7 +15408,10 @@ function buildCliStructuredInputPrompt(input, options = {}) {
15384
15408
  resourceRefs.push([part.name, part.text, part.uri].filter(Boolean).join("\n"));
15385
15409
  }
15386
15410
  });
15387
- if (input.textFallback.trim()) promptParts.push(input.textFallback.trim());
15411
+ const hasExplicitTextParts = input.parts.some((part) => part.type === "text" && part.text.trim());
15412
+ if (!hasExplicitTextParts && input.textFallback.trim()) {
15413
+ promptParts.push(input.textFallback.trim());
15414
+ }
15388
15415
  const ordered = [
15389
15416
  ...imageRefs,
15390
15417
  ...promptParts,
@@ -21240,7 +21267,10 @@ function setupMeshEventForwarding(components) {
21240
21267
  const workspace = readNonEmptyString(state.workspace);
21241
21268
  if (!workspace) return;
21242
21269
  const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
21270
+ if (readNonEmptyString(settings.meshCoordinatorFor)) return;
21243
21271
  const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
21272
+ const isMeshDelegate = Boolean(meshIdFromRuntime || settings.launchedByCoordinator);
21273
+ if (!isMeshDelegate) return;
21244
21274
  const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
21245
21275
  const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
21246
21276
  if (!meshId) return;
@@ -21909,6 +21939,8 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
21909
21939
  }
21910
21940
 
21911
21941
  // src/commands/router.ts
21942
+ var import_os3 = require("os");
21943
+ var import_path4 = require("path");
21912
21944
  var fs10 = __toESM(require("fs"));
21913
21945
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
21914
21946
  var CHANNEL_SERVER_URL = {
@@ -21975,6 +22007,32 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
21975
22007
  if (format === "claude_mcp_json") return JSON.stringify(config, null, 2);
21976
22008
  return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
21977
22009
  }
22010
+ function resolveHermesUserHome() {
22011
+ const explicitHome = process.env.HERMES_HOME?.trim();
22012
+ return explicitHome || (0, import_path4.join)((0, import_os3.homedir)(), ".hermes");
22013
+ }
22014
+ function loadHermesCoordinatorBaseConfig(targetConfigPath) {
22015
+ const sourceHome = resolveHermesUserHome();
22016
+ const sourceConfigPath = (0, import_path4.join)(sourceHome, "config.yaml");
22017
+ if (!fs10.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
22018
+ if ((0, import_path4.resolve)(sourceConfigPath) === (0, import_path4.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
22019
+ const parsed = parseMeshCoordinatorMcpConfig(fs10.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
22020
+ const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
22021
+ return { config: baseConfig, sourceHome, sourceConfigPath };
22022
+ }
22023
+ function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
22024
+ if ((0, import_path4.resolve)(sourceHome) === (0, import_path4.resolve)(targetHome)) return;
22025
+ for (const fileName of [".env", "auth.json"]) {
22026
+ const sourcePath = (0, import_path4.join)(sourceHome, fileName);
22027
+ const targetPath = (0, import_path4.join)(targetHome, fileName);
22028
+ if (!fs10.existsSync(sourcePath)) continue;
22029
+ try {
22030
+ fs10.copyFileSync(sourcePath, targetPath);
22031
+ } catch (error) {
22032
+ LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
22033
+ }
22034
+ }
22035
+ }
21978
22036
  var CHAT_COMMANDS = [
21979
22037
  "send_chat",
21980
22038
  "new_chat",
@@ -23196,10 +23254,20 @@ var DaemonCommandRouter = class {
23196
23254
  workspace
23197
23255
  };
23198
23256
  }
23199
- const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync3, mkdirSync: mkdirSync16 } = await import("fs");
23257
+ const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4, mkdirSync: mkdirSync16 } = await import("fs");
23200
23258
  const { dirname: dirname9 } = await import("path");
23201
23259
  const mcpConfigPath = coordinatorSetup.configPath;
23202
23260
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
23261
+ let hermesBaseConfig = null;
23262
+ if (hermesManualFallback) {
23263
+ try {
23264
+ hermesBaseConfig = loadHermesCoordinatorBaseConfig(mcpConfigPath);
23265
+ } catch (error) {
23266
+ const message = `Failed to parse Hermes base config for automatic coordinator setup: ${error?.message || error}`;
23267
+ LOG.error("MeshCoordinator", message);
23268
+ return { success: false, code: "mesh_coordinator_config_parse_failed", error: message, meshId, cliType, workspace };
23269
+ }
23270
+ }
23203
23271
  const returnManualFallback = (message) => ({
23204
23272
  success: false,
23205
23273
  code: "mesh_coordinator_manual_mcp_setup_required",
@@ -23228,11 +23296,15 @@ var DaemonCommandRouter = class {
23228
23296
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
23229
23297
  }
23230
23298
  const hadExistingMcpConfig = existsSync23(mcpConfigPath);
23231
- let existingMcpConfig = {};
23299
+ let existingMcpConfig = hermesBaseConfig?.config || {};
23300
+ if (hermesBaseConfig) {
23301
+ copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname9(mcpConfigPath));
23302
+ }
23232
23303
  if (hadExistingMcpConfig) {
23233
23304
  try {
23234
- existingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23235
- copyFileSync3(mcpConfigPath, mcpConfigPath + ".backup");
23305
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23306
+ existingMcpConfig = { ...existingMcpConfig, ...parsedExistingMcpConfig };
23307
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
23236
23308
  } catch (error) {
23237
23309
  LOG.error("MeshCoordinator", `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);
23238
23310
  return {
@@ -23688,7 +23760,7 @@ function prepareSessionChatTailUpdate(input) {
23688
23760
  };
23689
23761
  }
23690
23762
  const fullMessages = normalizeChatMessages(Array.isArray(result.messages) ? result.messages : []);
23691
- const messages = filterUserFacingChatMessages(fullMessages);
23763
+ const messages = fullMessages;
23692
23764
  const title = typeof result.title === "string" ? result.title : void 0;
23693
23765
  const activeModal = normalizeChatTailActiveModal(result.activeModal);
23694
23766
  const status = typeof result.status === "string" ? result.status : "idle";
@@ -24965,7 +25037,7 @@ var fs11 = __toESM(require("fs"));
24965
25037
  var path23 = __toESM(require("path"));
24966
25038
  var os20 = __toESM(require("os"));
24967
25039
  var import_child_process10 = require("child_process");
24968
- var import_os3 = require("os");
25040
+ var import_os4 = require("os");
24969
25041
  var ARCHIVE_PATH = path23.join(os20.homedir(), ".adhdev", "version-history.json");
24970
25042
  var MAX_ENTRIES_PER_PROVIDER = 20;
24971
25043
  var VersionArchive = class {
@@ -24991,7 +25063,7 @@ var VersionArchive = class {
24991
25063
  entries.push({
24992
25064
  version,
24993
25065
  detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
24994
- os: (0, import_os3.platform)()
25066
+ os: (0, import_os4.platform)()
24995
25067
  });
24996
25068
  if (entries.length > MAX_ENTRIES_PER_PROVIDER) {
24997
25069
  this.history[type] = entries.slice(-MAX_ENTRIES_PER_PROVIDER);
@@ -25031,7 +25103,7 @@ function runCommand(cmd, timeout = 1e4) {
25031
25103
  }
25032
25104
  }
25033
25105
  function findBinary2(name) {
25034
- const cmd = (0, import_os3.platform)() === "win32" ? `where ${name}` : `which ${name}`;
25106
+ const cmd = (0, import_os4.platform)() === "win32" ? `where ${name}` : `which ${name}`;
25035
25107
  const result = runCommand(cmd, 5e3);
25036
25108
  return result ? result.split("\n")[0] : null;
25037
25109
  }
@@ -25079,7 +25151,7 @@ function checkPathExists2(paths) {
25079
25151
  return null;
25080
25152
  }
25081
25153
  function getMacAppVersion(appPath) {
25082
- if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
25154
+ if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
25083
25155
  const plistPath = path23.join(appPath, "Contents", "Info.plist");
25084
25156
  if (!fs11.existsSync(plistPath)) return null;
25085
25157
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
@@ -25087,7 +25159,7 @@ function getMacAppVersion(appPath) {
25087
25159
  }
25088
25160
  async function detectAllVersions(loader, archive) {
25089
25161
  const results = [];
25090
- const currentOs = (0, import_os3.platform)();
25162
+ const currentOs = (0, import_os4.platform)();
25091
25163
  for (const provider of loader.getAll()) {
25092
25164
  const info = {
25093
25165
  type: provider.type,