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

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.32",
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) {
@@ -41890,9 +41906,8 @@ ${lastSnapshot}`;
41890
41906
  };
41891
41907
  this.recordTrace("submit_echo_missing", diagnostic);
41892
41908
  if (this.requirePromptEchoBeforeSubmit) {
41893
- const message = `${this.cliName} prompt echo was not observed on the PTY screen before submit`;
41894
- LOG.warn("CLI", `[${this.cliType}] ${message} elapsed=${elapsed}ms maxEchoWaitMs=${state.maxEchoWaitMs} screen=${JSON.stringify(diagnostic.screenText).slice(0, 240)}`);
41895
- completion.rejectOnce(new Error(message));
41909
+ LOG.warn("CLI", `[${this.cliType}] prompt echo was not observed before submit; sending guarded submit key anyway elapsed=${elapsed}ms maxEchoWaitMs=${state.maxEchoWaitMs} screen=${JSON.stringify(diagnostic.screenText).slice(0, 240)}`);
41910
+ this.submitSendKey(state, completion);
41896
41911
  return;
41897
41912
  }
41898
41913
  LOG.warn("CLI", `[${this.cliType}] prompt echo was not observed before submit; sending submit key anyway elapsed=${elapsed}ms maxEchoWaitMs=${state.maxEchoWaitMs}`);
@@ -56629,6 +56644,28 @@ function isGitStatusDirty(status) {
56629
56644
  if (typeof status?.dirty === "boolean") return status.dirty;
56630
56645
  return countUncommittedChanges(status) > 0;
56631
56646
  }
56647
+ function readProviderPriority(policy) {
56648
+ const raw = policy?.providerPriority;
56649
+ return Array.isArray(raw) ? raw.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
56650
+ }
56651
+ function missingProviderPriorityMessage(nodeId) {
56652
+ return `Node '${nodeId}' has no providerPriority policy; pass type explicitly or configure node.policy.providerPriority`;
56653
+ }
56654
+ function getNodeLaunchReadiness(node) {
56655
+ const providerPriority = readProviderPriority(node.policy);
56656
+ if (providerPriority.length) {
56657
+ return {
56658
+ providerPriority,
56659
+ launchReady: true
56660
+ };
56661
+ }
56662
+ return {
56663
+ providerPriority,
56664
+ launchReady: false,
56665
+ launchBlockedReason: "missing_provider_priority",
56666
+ launchBlockedMessage: missingProviderPriorityMessage(node.id)
56667
+ };
56668
+ }
56632
56669
  async function commandForNode(ctx, node, command, args = {}) {
56633
56670
  if (ctx.transport instanceof IpcTransport && node.daemonId) {
56634
56671
  return ctx.transport.meshCommand(node.daemonId, command, args);
@@ -56772,7 +56809,8 @@ async function meshStatus(ctx) {
56772
56809
  for (const node of mesh.nodes) {
56773
56810
  const entry = {
56774
56811
  nodeId: node.id,
56775
- workspace: node.workspace
56812
+ workspace: node.workspace,
56813
+ ...getNodeLaunchReadiness(node)
56776
56814
  };
56777
56815
  try {
56778
56816
  if (!isLocalTransport(transport) && node.daemonId) {
@@ -56824,6 +56862,7 @@ async function meshListNodes(ctx) {
56824
56862
  repoRoot: n.repoRoot,
56825
56863
  isLocalWorktree: n.isLocalWorktree,
56826
56864
  policy: n.policy,
56865
+ ...getNodeLaunchReadiness(n),
56827
56866
  userOverrides: n.userOverrides
56828
56867
  }))
56829
56868
  }, null, 2);
@@ -56877,10 +56916,9 @@ async function meshLaunchSession(ctx, args) {
56877
56916
  if (isLocalTransport(ctx.transport)) {
56878
56917
  let resolvedProviderType = typeof args.type === "string" && args.type.trim() ? args.type : "";
56879
56918
  if (!resolvedProviderType) {
56880
- const rawProviderPriority = node.policy?.providerPriority;
56881
- const providerPriority = Array.isArray(rawProviderPriority) ? rawProviderPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
56919
+ const providerPriority = readProviderPriority(node.policy);
56882
56920
  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` });
56921
+ return JSON.stringify({ success: false, error: missingProviderPriorityMessage(args.node_id) });
56884
56922
  }
56885
56923
  const failed = [];
56886
56924
  for (const providerType of providerPriority) {
@@ -56901,6 +56939,7 @@ async function meshLaunchSession(ctx, args) {
56901
56939
  dir: node.workspace,
56902
56940
  settings: {
56903
56941
  meshNodeFor: ctx.mesh.id,
56942
+ meshNodeId: args.node_id,
56904
56943
  launchedByCoordinator: true
56905
56944
  }
56906
56945
  });