@adhdev/daemon-standalone 0.9.76-rc.30 → 0.9.76-rc.31

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-standalone",
3
- "version": "0.9.76-rc.30",
3
+ "version": "0.9.76-rc.31",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -39498,33 +39498,49 @@ function launchIDE(ide, workspacePath) {
39498
39498
  return false;
39499
39499
  }
39500
39500
  }
39501
+ function readNonEmptyString(value) {
39502
+ return typeof value === "string" && value.trim() ? value.trim() : "";
39503
+ }
39504
+ function formatCompletionMetadata(event) {
39505
+ const parts = [
39506
+ readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
39507
+ readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
39508
+ readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
39509
+ ].filter(Boolean);
39510
+ return parts.length > 0 ? ` (${parts.join("; ")})` : "";
39511
+ }
39501
39512
  function setupMeshEventForwarding(components) {
39502
39513
  components.instanceManager.onEvent((event) => {
39503
39514
  if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
39504
- const instanceId = event.instanceId;
39515
+ const instanceId = readNonEmptyString(event.instanceId);
39505
39516
  if (!instanceId) return;
39506
39517
  const sourceInstance = components.instanceManager.getInstance(instanceId);
39507
39518
  if (!sourceInstance || sourceInstance.category !== "cli") return;
39508
39519
  const state = sourceInstance.getState();
39509
- const workspace = state.workspace;
39520
+ const workspace = readNonEmptyString(state.workspace);
39510
39521
  if (!workspace) return;
39511
- const mesh = getMeshByRepo(workspace);
39512
- if (!mesh) return;
39522
+ const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
39523
+ const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
39524
+ const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
39525
+ const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
39526
+ if (!meshId) return;
39513
39527
  const allInstances = components.instanceManager.getByCategory("cli");
39514
39528
  const coordinatorInstances = allInstances.filter((inst) => {
39515
39529
  const instState = inst.getState();
39516
- if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
39530
+ if (instState.settings?.meshCoordinatorFor !== meshId) return false;
39517
39531
  if (instState.instanceId === instanceId) return false;
39518
39532
  return true;
39519
39533
  });
39520
39534
  if (coordinatorInstances.length === 0) return;
39521
- const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
39522
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
39535
+ const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
39536
+ const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
39537
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
39538
+ const metadata = formatCompletionMetadata(event);
39523
39539
  let messageText = "";
39524
39540
  if (event.event === "agent:generating_completed") {
39525
- messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
39541
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
39526
39542
  } else if (event.event === "agent:waiting_approval") {
39527
- messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
39543
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
39528
39544
  }
39529
39545
  if (!messageText) return;
39530
39546
  for (const coord of coordinatorInstances) {
@@ -56629,6 +56645,28 @@ function isGitStatusDirty(status) {
56629
56645
  if (typeof status?.dirty === "boolean") return status.dirty;
56630
56646
  return countUncommittedChanges(status) > 0;
56631
56647
  }
56648
+ function readProviderPriority(policy) {
56649
+ const raw = policy?.providerPriority;
56650
+ return Array.isArray(raw) ? raw.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
56651
+ }
56652
+ function missingProviderPriorityMessage(nodeId) {
56653
+ return `Node '${nodeId}' has no providerPriority policy; pass type explicitly or configure node.policy.providerPriority`;
56654
+ }
56655
+ function getNodeLaunchReadiness(node) {
56656
+ const providerPriority = readProviderPriority(node.policy);
56657
+ if (providerPriority.length) {
56658
+ return {
56659
+ providerPriority,
56660
+ launchReady: true
56661
+ };
56662
+ }
56663
+ return {
56664
+ providerPriority,
56665
+ launchReady: false,
56666
+ launchBlockedReason: "missing_provider_priority",
56667
+ launchBlockedMessage: missingProviderPriorityMessage(node.id)
56668
+ };
56669
+ }
56632
56670
  async function commandForNode(ctx, node, command, args = {}) {
56633
56671
  if (ctx.transport instanceof IpcTransport && node.daemonId) {
56634
56672
  return ctx.transport.meshCommand(node.daemonId, command, args);
@@ -56772,7 +56810,8 @@ async function meshStatus(ctx) {
56772
56810
  for (const node of mesh.nodes) {
56773
56811
  const entry = {
56774
56812
  nodeId: node.id,
56775
- workspace: node.workspace
56813
+ workspace: node.workspace,
56814
+ ...getNodeLaunchReadiness(node)
56776
56815
  };
56777
56816
  try {
56778
56817
  if (!isLocalTransport(transport) && node.daemonId) {
@@ -56824,6 +56863,7 @@ async function meshListNodes(ctx) {
56824
56863
  repoRoot: n.repoRoot,
56825
56864
  isLocalWorktree: n.isLocalWorktree,
56826
56865
  policy: n.policy,
56866
+ ...getNodeLaunchReadiness(n),
56827
56867
  userOverrides: n.userOverrides
56828
56868
  }))
56829
56869
  }, null, 2);
@@ -56877,10 +56917,9 @@ async function meshLaunchSession(ctx, args) {
56877
56917
  if (isLocalTransport(ctx.transport)) {
56878
56918
  let resolvedProviderType = typeof args.type === "string" && args.type.trim() ? args.type : "";
56879
56919
  if (!resolvedProviderType) {
56880
- const rawProviderPriority = node.policy?.providerPriority;
56881
- const providerPriority = Array.isArray(rawProviderPriority) ? rawProviderPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
56920
+ const providerPriority = readProviderPriority(node.policy);
56882
56921
  if (!providerPriority.length) {
56883
- return JSON.stringify({ success: false, error: `Node '${args.node_id}' has no providerPriority policy; pass type explicitly or configure node.policy.providerPriority` });
56922
+ return JSON.stringify({ success: false, error: missingProviderPriorityMessage(args.node_id) });
56884
56923
  }
56885
56924
  const failed = [];
56886
56925
  for (const providerType of providerPriority) {
@@ -56901,6 +56940,7 @@ async function meshLaunchSession(ctx, args) {
56901
56940
  dir: node.workspace,
56902
56941
  settings: {
56903
56942
  meshNodeFor: ctx.mesh.id,
56943
+ meshNodeId: args.node_id,
56904
56944
  launchedByCoordinator: true
56905
56945
  }
56906
56946
  });