@adhdev/daemon-core 0.9.82-rc.227 → 0.9.82-rc.228

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.82-rc.227",
3
+ "version": "0.9.82-rc.228",
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",
@@ -5852,14 +5852,28 @@ export class DaemonCommandRouter {
5852
5852
  let submoduleIgnorePaths = Array.isArray(args?.submoduleIgnorePaths)
5853
5853
  ? args.submoduleIgnorePaths.filter((value: unknown): value is string => typeof value === 'string')
5854
5854
  : undefined;
5855
- if (!workspace && meshId && nodeId) {
5855
+ let nodeDaemonId: string | undefined;
5856
+ if (meshId && nodeId) {
5856
5857
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
5857
5858
  const mesh = meshRecord?.mesh;
5858
5859
  const node = mesh?.nodes?.find((n: any) => n.id === nodeId || n.nodeId === nodeId);
5859
- workspace = typeof node?.workspace === 'string' ? node.workspace.trim() : '';
5860
+ if (!workspace) {
5861
+ workspace = typeof node?.workspace === 'string' ? node.workspace.trim() : '';
5862
+ }
5860
5863
  if (!submoduleIgnorePaths && Array.isArray(node?.policy?.submoduleIgnorePaths)) {
5861
5864
  submoduleIgnorePaths = node.policy.submoduleIgnorePaths.filter((value: unknown): value is string => typeof value === 'string');
5862
5865
  }
5866
+ nodeDaemonId = typeof node?.daemonId === 'string' ? node.daemonId.trim() : undefined;
5867
+ }
5868
+ // If the target node belongs to a remote daemon, forward the command there.
5869
+ const selfDaemonId = this.deps.statusInstanceId;
5870
+ const isRemote = nodeDaemonId && selfDaemonId && nodeDaemonId !== selfDaemonId;
5871
+ if (isRemote && this.deps.dispatchMeshCommand) {
5872
+ const forwarded = await this.deps.dispatchMeshCommand(nodeDaemonId!, 'fast_forward_mesh_node', {
5873
+ ...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
5874
+ workspace,
5875
+ });
5876
+ return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
5863
5877
  }
5864
5878
  const result = await (fastForwardMeshNode({
5865
5879
  meshId: meshId || undefined,
@@ -5901,6 +5915,15 @@ export class DaemonCommandRouter {
5901
5915
 
5902
5916
  let worktreeCleanup: Record<string, unknown> | undefined;
5903
5917
  if (node?.isLocalWorktree) {
5918
+ const nodeDaemonId = typeof node.daemonId === 'string' ? node.daemonId.trim() : undefined;
5919
+ const isRemoteWorktree = nodeDaemonId && nodeDaemonId !== this.deps.statusInstanceId && this.deps.dispatchMeshCommand;
5920
+ if (isRemoteWorktree) {
5921
+ // Worktree lives on a different machine — ask that daemon to clean it up.
5922
+ const forwarded = await this.deps.dispatchMeshCommand!(nodeDaemonId!, 'remove_mesh_node', {
5923
+ ...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
5924
+ });
5925
+ return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
5926
+ }
5904
5927
  const cleanupResult = await this.cleanupLocalWorktreeNode({ mesh, node, nodeId, force: args?.force === true });
5905
5928
  if (cleanupResult.success === false) {
5906
5929
  return {
@@ -5983,6 +6006,15 @@ export class DaemonCommandRouter {
5983
6006
  const sourceNode = mesh.nodes?.find((n: any) => n.id === sourceNodeId || n.nodeId === sourceNodeId);
5984
6007
  if (!sourceNode) return { success: false, error: `Source node '${sourceNodeId}' not found in mesh` };
5985
6008
 
6009
+ // Forward to the source node's daemon if it's on a different machine.
6010
+ const sourceDaemonId = typeof sourceNode.daemonId === 'string' ? sourceNode.daemonId.trim() : undefined;
6011
+ if (sourceDaemonId && sourceDaemonId !== this.deps.statusInstanceId && this.deps.dispatchMeshCommand) {
6012
+ const forwarded = await this.deps.dispatchMeshCommand(sourceDaemonId, 'clone_mesh_node', {
6013
+ ...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
6014
+ });
6015
+ return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
6016
+ }
6017
+
5986
6018
  const repoRoot = sourceNode.repoRoot || sourceNode.workspace;
5987
6019
  const { createWorktree } = await import('../git/git-worktree.js');
5988
6020
  const result = await createWorktree({
@@ -6238,6 +6270,15 @@ export class DaemonCommandRouter {
6238
6270
  if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
6239
6271
  if (!node.isLocalWorktree) return { success: false, error: 'Node is not a local worktree node' };
6240
6272
 
6273
+ // Bootstrap runs scripts in the worktree path — forward to the node's daemon if remote.
6274
+ const nodeDaemonId = typeof node.daemonId === 'string' ? node.daemonId.trim() : undefined;
6275
+ if (nodeDaemonId && nodeDaemonId !== this.deps.statusInstanceId && this.deps.dispatchMeshCommand) {
6276
+ const forwarded = await this.deps.dispatchMeshCommand(nodeDaemonId, 'retry_mesh_node_bootstrap', {
6277
+ ...(typeof args === 'object' && args !== null ? args as Record<string, unknown> : {}),
6278
+ });
6279
+ return (forwarded ?? { success: false, error: 'no response from remote node' }) as CommandRouterResult;
6280
+ }
6281
+
6241
6282
  const currentBootstrap = node.worktreeBootstrap as WorktreeBootstrapState | undefined;
6242
6283
  if (currentBootstrap?.status === 'running') {
6243
6284
  return { success: false, error: 'Bootstrap is already running for this node' };
@@ -326,7 +326,7 @@ function buildCliSession(state: CliProviderState, options: SessionEntryBuildOpti
326
326
  mode: state.mode,
327
327
  resume: state.resume,
328
328
  activeChat,
329
- ...(state.activeInteractivePrompt ? { activeInteractivePrompt: state.activeInteractivePrompt } : {}),
329
+ activeInteractivePrompt: state.activeInteractivePrompt ?? null,
330
330
  ...(summaryMetadata && { summaryMetadata }),
331
331
  ...(includeSessionMetadata && {
332
332
  capabilities: state.mode === 'terminal' ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES,
@@ -342,6 +342,7 @@ function buildCliSession(state: CliProviderState, options: SessionEntryBuildOpti
342
342
  settings: state.settings,
343
343
  ...(coordinator && { coordinator }),
344
344
  ...(meshQueueStats && { meshQueueStats }),
345
+ ...(state.settings?.spawnedSessionVisibility === 'hidden' && { surfaceHidden: true }),
345
346
  };
346
347
  }
347
348
 
@@ -383,6 +384,7 @@ function buildAcpSession(state: AcpProviderState, options: SessionEntryBuildOpti
383
384
  settings: state.settings,
384
385
  ...(coordinator && { coordinator }),
385
386
  ...(meshQueueStats && { meshQueueStats }),
387
+ ...(state.settings?.spawnedSessionVisibility === 'hidden' && { surfaceHidden: true }),
386
388
  };
387
389
  }
388
390