@adhdev/daemon-standalone 0.9.76-rc.23 → 0.9.76-rc.25

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.23",
3
+ "version": "0.9.76-rc.25",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -31370,7 +31370,7 @@ async function handleChatHistory(h, args) {
31370
31370
  }
31371
31371
  }
31372
31372
  async function handleReadChat(h, args) {
31373
- const provider = h.getProvider(args?.agentType);
31373
+ const provider = h.getProvider(args?.agentType || args?.providerType);
31374
31374
  const transport = getTargetTransport(h, provider);
31375
31375
  const historySessionId = getHistorySessionId(h, args);
31376
31376
  const _log = (msg) => LOG.debug("Command", `[read_chat] ${msg}`);
@@ -51309,7 +51309,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
51309
51309
  if (!workspace) return { success: false, error: "workspace required" };
51310
51310
  try {
51311
51311
  const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
51312
- const node = addNode3(meshId, { workspace });
51312
+ const providerPriority = Array.isArray(args?.providerPriority) ? args.providerPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
51313
+ const readOnly = args?.readOnly === true;
51314
+ const policy = {
51315
+ ...readOnly ? { readOnly: true } : {},
51316
+ ...providerPriority.length ? { providerPriority } : {}
51317
+ };
51318
+ const node = addNode3(meshId, { workspace, ...policy ? { policy } : {} });
51313
51319
  if (!node) return { success: false, error: "Mesh not found" };
51314
51320
  return { success: true, node };
51315
51321
  } catch (e) {
@@ -56459,6 +56465,7 @@ ${lines.join("\n\n")}`;
56459
56465
  }
56460
56466
 
56461
56467
  // src/tools/mesh-tools.ts
56468
+ var meshSessionProviderMetadata = /* @__PURE__ */ new Map();
56462
56469
  async function refreshMeshFromDaemon(ctx) {
56463
56470
  if (!(ctx.transport instanceof IpcTransport)) return;
56464
56471
  try {
@@ -56507,6 +56514,12 @@ function extractGitDiff(value) {
56507
56514
  const payload = unwrapCommandPayload(value);
56508
56515
  return payload?.diffSummary ?? payload?.diff ?? value?.diffSummary ?? value?.diff ?? payload;
56509
56516
  }
56517
+ function extractLaunchPayload(value) {
56518
+ return findNestedPayload(value, (payload) => Boolean(payload?.sessionId || payload?.id || payload?.runtimeSessionId));
56519
+ }
56520
+ function meshSessionCacheKey(nodeId, runtimeSessionId) {
56521
+ return `${nodeId}:${runtimeSessionId}`;
56522
+ }
56510
56523
  function countUncommittedChanges(status) {
56511
56524
  if (typeof status?.uncommittedChanges === "number") return status.uncommittedChanges;
56512
56525
  const keys = ["staged", "modified", "untracked", "deleted", "renamed"];
@@ -56559,12 +56572,13 @@ var MESH_SEND_TASK_TOOL = {
56559
56572
  };
56560
56573
  var MESH_READ_CHAT_TOOL = {
56561
56574
  name: "mesh_read_chat",
56562
- description: "Read recent chat messages from a delegated agent session on a mesh node. Use this to check progress.",
56575
+ description: "Read recent chat messages from a delegated agent session on a mesh node. Use this to check progress. If the runtime session has completed, provider_session_id can explicitly target provider transcript history.",
56563
56576
  inputSchema: {
56564
56577
  type: "object",
56565
56578
  properties: {
56566
56579
  node_id: { type: "string", description: "Target node ID." },
56567
56580
  session_id: { type: "string", description: "Agent session ID to read from." },
56581
+ provider_session_id: { type: "string", description: "Optional provider transcript/session ID for completed sessions." },
56568
56582
  tail: { type: "number", description: "Number of recent messages to return (default: 10)." }
56569
56583
  },
56570
56584
  required: ["node_id", "session_id"]
@@ -56572,14 +56586,14 @@ var MESH_READ_CHAT_TOOL = {
56572
56586
  };
56573
56587
  var MESH_LAUNCH_SESSION_TOOL = {
56574
56588
  name: "mesh_launch_session",
56575
- description: "Launch a new agent session on a mesh node. Returns the session ID for subsequent send_task/read_chat calls. If the user names a provider, preserve it exactly: Hermes = hermes-cli, Claude Code/Claude = claude-cli, Codex = codex-cli, Gemini = gemini-cli. Do not default to claude-cli unless the user requested Claude Code or no provider was specified.",
56589
+ description: "Launch a new agent session on a mesh node. Returns the session ID for subsequent send_task/read_chat calls. If the user names a provider, preserve it exactly: Hermes = hermes-cli, Claude Code/Claude = claude-cli, Codex = codex-cli, Gemini = gemini-cli. If type is omitted, resolve strictly from the node policy providerPriority and provider detection; fail closed when no configured provider is usable. Do not default to claude-cli.",
56576
56590
  inputSchema: {
56577
56591
  type: "object",
56578
56592
  properties: {
56579
56593
  node_id: { type: "string", description: "Target node ID." },
56580
- type: { type: "string", description: "Provider type to launch. Use hermes-cli for Hermes, claude-cli for Claude Code, codex-cli for Codex, gemini-cli for Gemini." }
56594
+ type: { type: "string", description: "Optional provider type to launch. Use hermes-cli for Hermes, claude-cli for Claude Code, codex-cli for Codex, gemini-cli for Gemini. When omitted, node.policy.providerPriority is probed in order." }
56581
56595
  },
56582
- required: ["node_id", "type"]
56596
+ required: ["node_id"]
56583
56597
  }
56584
56598
  };
56585
56599
  var MESH_GIT_STATUS_TOOL = {
@@ -56736,9 +56750,13 @@ async function meshSendTask(ctx, args) {
56736
56750
  async function meshReadChat(ctx, args) {
56737
56751
  const node = await findNodeWithRefresh(ctx, args.node_id);
56738
56752
  if (isLocalTransport(ctx.transport)) {
56753
+ const cached2 = meshSessionProviderMetadata.get(meshSessionCacheKey(args.node_id, args.session_id));
56754
+ const providerSessionId = typeof args.provider_session_id === "string" && args.provider_session_id.trim() ? args.provider_session_id.trim() : cached2?.providerSessionId;
56739
56755
  const result = await commandForNode(ctx, node, "read_chat", {
56740
56756
  sessionId: args.session_id,
56741
56757
  targetSessionId: args.session_id,
56758
+ ...cached2?.providerType ? { agentType: cached2.providerType, providerType: cached2.providerType } : {},
56759
+ ...providerSessionId ? { providerSessionId } : {},
56742
56760
  tailLimit: args.tail ?? 10
56743
56761
  });
56744
56762
  return JSON.stringify(result, null, 2);
@@ -56749,15 +56767,49 @@ async function meshReadChat(ctx, args) {
56749
56767
  async function meshLaunchSession(ctx, args) {
56750
56768
  const node = await findNodeWithRefresh(ctx, args.node_id);
56751
56769
  if (isLocalTransport(ctx.transport)) {
56770
+ let resolvedProviderType = typeof args.type === "string" && args.type.trim() ? args.type : "";
56771
+ if (!resolvedProviderType) {
56772
+ const rawProviderPriority = node.policy?.providerPriority;
56773
+ const providerPriority = Array.isArray(rawProviderPriority) ? rawProviderPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
56774
+ if (!providerPriority.length) {
56775
+ return JSON.stringify({ error: `Node '${args.node_id}' has no providerPriority policy; pass type explicitly or configure node.policy.providerPriority` });
56776
+ }
56777
+ const failed = [];
56778
+ for (const providerType of providerPriority) {
56779
+ const detectedResult = await commandForNode(ctx, node, "detect_provider", { providerType });
56780
+ const detectedPayload = unwrapCommandPayload(detectedResult);
56781
+ if (detectedPayload?.success && detectedPayload?.detected) {
56782
+ resolvedProviderType = providerType;
56783
+ break;
56784
+ }
56785
+ failed.push(`${providerType}: ${detectedPayload?.error || "not detected"}`);
56786
+ }
56787
+ if (!resolvedProviderType) {
56788
+ return JSON.stringify({ error: `No usable provider detected for node '${args.node_id}' from providerPriority: ${failed.join("; ")}` });
56789
+ }
56790
+ }
56752
56791
  const result = await commandForNode(ctx, node, "launch_cli", {
56753
- cliType: args.type,
56792
+ cliType: resolvedProviderType,
56754
56793
  dir: node.workspace,
56755
56794
  settings: {
56756
56795
  meshNodeFor: ctx.mesh.id,
56757
56796
  launchedByCoordinator: true
56758
56797
  }
56759
56798
  });
56760
- return JSON.stringify(result, null, 2);
56799
+ const launchPayload = extractLaunchPayload(result);
56800
+ const runtimeSessionId = typeof launchPayload?.sessionId === "string" ? launchPayload.sessionId : typeof launchPayload?.id === "string" ? launchPayload.id : typeof launchPayload?.runtimeSessionId === "string" ? launchPayload.runtimeSessionId : "";
56801
+ const providerSessionId = typeof launchPayload?.providerSessionId === "string" && launchPayload.providerSessionId.trim() ? launchPayload.providerSessionId.trim() : void 0;
56802
+ if (runtimeSessionId) {
56803
+ meshSessionProviderMetadata.set(meshSessionCacheKey(args.node_id, runtimeSessionId), {
56804
+ providerType: resolvedProviderType,
56805
+ ...providerSessionId ? { providerSessionId } : {}
56806
+ });
56807
+ }
56808
+ return JSON.stringify({
56809
+ ...launchPayload,
56810
+ resolvedProviderType,
56811
+ ...providerSessionId ? { providerSessionId } : {}
56812
+ }, null, 2);
56761
56813
  } else {
56762
56814
  return JSON.stringify({ error: "Cloud mesh launch_session not yet implemented" });
56763
56815
  }