@adhdev/daemon-standalone 0.9.82-rc.377 → 0.9.82-rc.378

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.82-rc.377",
3
+ "version": "0.9.82-rc.378",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -801,7 +801,8 @@ var MESH_LAUNCH_SESSION_TOOL = {
801
801
  type: "object",
802
802
  properties: {
803
803
  node_id: { type: "string", description: "Target node ID." },
804
- 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." }
804
+ 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." },
805
+ force: { type: "boolean", description: "Set true to launch an ADDITIONAL session even when this node already has a live mesh-owned worker session. Default false: if a live worker session for this mesh+node already exists (e.g. an enqueue auto-launch just spawned one), the existing session is returned idempotently instead of creating an empty duplicate. Only pass force when you intentionally want a second concurrent provider/session on the node." }
805
806
  },
806
807
  required: ["node_id"]
807
808
  }
@@ -4379,6 +4380,35 @@ async function meshLaunchSession(ctx, args) {
4379
4380
  if (node.daemonId && !isLocalNode && !coordinatorDaemonId) {
4380
4381
  return JSON.stringify(buildMissingCoordinatorDaemonIdFailure(ctx, node, resolvedProviderType), null, 2);
4381
4382
  }
4383
+ if (args.force !== true) {
4384
+ try {
4385
+ const statusResult = await commandForNode(ctx, node, "get_status_metadata", {});
4386
+ const sessions = extractStatusMetadataSessions(statusResult);
4387
+ const existing = sessions.find((session) => !isTerminalSessionRecord(session) && isMeshOwnedDelegateSession(session, ctx.mesh.id, args.node_id));
4388
+ if (existing) {
4389
+ const existingSessionId = readSessionRecordId(existing);
4390
+ if (existingSessionId) {
4391
+ const existingProviderType = resolveSessionProviderType(existing) || resolvedProviderType || void 0;
4392
+ const existingStatus = typeof existing?.status === "string" ? existing.status : "unknown";
4393
+ return JSON.stringify({
4394
+ success: true,
4395
+ duplicate: true,
4396
+ launched: false,
4397
+ reused: true,
4398
+ sessionId: existingSessionId,
4399
+ nodeId: args.node_id,
4400
+ ...existingProviderType ? { resolvedProviderType: existingProviderType, providerType: existingProviderType } : {},
4401
+ sessionStatus: existingStatus,
4402
+ idle: isIdleSessionRecord(existing),
4403
+ reason: "mesh_launch_session_duplicate_guard",
4404
+ warning: `Node '${args.node_id}' already has a live mesh-owned worker session ('${existingSessionId}', status '${existingStatus}'). Returning it instead of launching an empty duplicate (likely an enqueue auto-launch already spawned it).`,
4405
+ nextAction: `Use session '${existingSessionId}' for mesh_send_task/mesh_read_chat. If you intentionally need a second concurrent session on this node, retry mesh_launch_session with force=true.`
4406
+ }, null, 2);
4407
+ }
4408
+ }
4409
+ } catch {
4410
+ }
4411
+ }
4382
4412
  let result;
4383
4413
  try {
4384
4414
  result = await commandForNode(ctx, node, "launch_cli", {