@adhdev/daemon-standalone 0.9.76-rc.24 → 0.9.76-rc.26

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/dist/index.js CHANGED
@@ -43592,7 +43592,7 @@ ${effect.notification.body || ""}`.trim();
43592
43592
  }
43593
43593
  }
43594
43594
  async function handleReadChat(h, args) {
43595
- const provider = h.getProvider(args?.agentType);
43595
+ const provider = h.getProvider(args?.agentType || args?.providerType);
43596
43596
  const transport = getTargetTransport(h, provider);
43597
43597
  const historySessionId = getHistorySessionId(h, args);
43598
43598
  const _log = (msg) => LOG2.debug("Command", `[read_chat] ${msg}`);
@@ -46534,7 +46534,19 @@ ${effect.notification.body || ""}`.trim();
46534
46534
  }
46535
46535
  }
46536
46536
  pushEvent(event) {
46537
- this.events.push(event);
46537
+ const enrichedEvent = {
46538
+ ...event,
46539
+ instanceId: typeof event.instanceId === "string" && event.instanceId.trim() ? event.instanceId : this.instanceId,
46540
+ targetSessionId: typeof event.targetSessionId === "string" && event.targetSessionId.trim() ? event.targetSessionId : this.instanceId,
46541
+ providerType: typeof event.providerType === "string" && event.providerType.trim() ? event.providerType : this.type,
46542
+ workspaceName: typeof event.workspaceName === "string" && event.workspaceName.trim() ? event.workspaceName : this.workingDir,
46543
+ providerSessionId: typeof event.providerSessionId === "string" && event.providerSessionId.trim() ? event.providerSessionId : this.providerSessionId
46544
+ };
46545
+ if (this.context?.emitProviderEvent) {
46546
+ this.context.emitProviderEvent(enrichedEvent);
46547
+ return;
46548
+ }
46549
+ this.events.push(enrichedEvent);
46538
46550
  }
46539
46551
  flushEvents() {
46540
46552
  const events = [...this.events];
@@ -52222,6 +52234,40 @@ Run 'adhdev doctor' for detailed diagnostics.`
52222
52234
  function resolveUpgradeChannel(args) {
52223
52235
  return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig2().updateChannel) || "stable";
52224
52236
  }
52237
+ function readProviderPriorityFromPolicy(policy) {
52238
+ const record2 = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
52239
+ const raw = record2.providerPriority;
52240
+ if (!Array.isArray(raw)) return [];
52241
+ const seen = /* @__PURE__ */ new Set();
52242
+ return raw.map((type) => typeof type === "string" ? type.trim() : "").filter(Boolean).filter((type) => {
52243
+ if (seen.has(type)) return false;
52244
+ seen.add(type);
52245
+ return true;
52246
+ });
52247
+ }
52248
+ async function resolveProviderTypeFromPriority(args) {
52249
+ if (!args.providerPriority.length) {
52250
+ return { error: `Node '${args.nodeId}' has no providerPriority policy; pass cliType explicitly or configure node.policy.providerPriority` };
52251
+ }
52252
+ const failed = [];
52253
+ for (const requestedType of args.providerPriority) {
52254
+ const normalizedType = args.providerLoader.resolveAlias(requestedType);
52255
+ if (!args.providerLoader.isMachineProviderEnabled(normalizedType)) {
52256
+ failed.push(`${requestedType}: disabled`);
52257
+ continue;
52258
+ }
52259
+ const detected = await detectCLI(normalizedType, args.providerLoader, { includeVersion: false });
52260
+ args.providerLoader.setCliDetectionResults([{
52261
+ id: normalizedType,
52262
+ installed: !!detected,
52263
+ path: detected?.path
52264
+ }], false);
52265
+ args.onStatusChange?.();
52266
+ if (detected) return { providerType: normalizedType };
52267
+ failed.push(`${requestedType}: not detected`);
52268
+ }
52269
+ return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
52270
+ }
52225
52271
  function loadYamlModule() {
52226
52272
  return yaml;
52227
52273
  }
@@ -53057,7 +53103,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
53057
53103
  if (!workspace) return { success: false, error: "workspace required" };
53058
53104
  try {
53059
53105
  const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
53060
- const node = addNode3(meshId, { workspace });
53106
+ const providerPriority = Array.isArray(args?.providerPriority) ? args.providerPriority.map((type) => typeof type === "string" ? type.trim() : "").filter(Boolean) : [];
53107
+ const readOnly = args?.readOnly === true;
53108
+ const policy = {
53109
+ ...readOnly ? { readOnly: true } : {},
53110
+ ...providerPriority.length ? { providerPriority } : {}
53111
+ };
53112
+ const node = addNode3(meshId, { workspace, ...policy ? { policy } : {} });
53061
53113
  if (!node) return { success: false, error: "Mesh not found" };
53062
53114
  return { success: true, node };
53063
53115
  } catch (e) {
@@ -53160,7 +53212,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53160
53212
  // ─── Mesh Coordinator Launch ───
53161
53213
  case "launch_mesh_coordinator": {
53162
53214
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
53163
- const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
53215
+ let cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "";
53164
53216
  if (!meshId) return { success: false, error: "meshId required" };
53165
53217
  try {
53166
53218
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
@@ -53188,6 +53240,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
53188
53240
  }
53189
53241
  const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
53190
53242
  if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
53243
+ if (!cliType) {
53244
+ const resolved = await resolveProviderTypeFromPriority({
53245
+ nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || "coordinator"),
53246
+ providerPriority: readProviderPriorityFromPolicy(coordinatorNode.policy),
53247
+ providerLoader: this.deps.providerLoader,
53248
+ onStatusChange: this.deps.onStatusChange
53249
+ });
53250
+ if (!resolved.providerType) {
53251
+ return {
53252
+ success: false,
53253
+ code: "mesh_coordinator_provider_priority_unusable",
53254
+ error: resolved.error || "No usable provider found from node providerPriority",
53255
+ meshId,
53256
+ cliType,
53257
+ workspace
53258
+ };
53259
+ }
53260
+ cliType = resolved.providerType;
53261
+ }
53191
53262
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
53192
53263
  const coordinatorSetup = resolveMeshCoordinatorSetup({
53193
53264
  provider: providerMeta,
@@ -53500,6 +53571,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
53500
53571
  if (providerType) {
53501
53572
  payload.providerType = providerType;
53502
53573
  }
53574
+ if (typeof event.providerSessionId === "string" && event.providerSessionId.trim()) {
53575
+ payload.providerSessionId = event.providerSessionId.trim();
53576
+ }
53577
+ if (typeof event.workspaceName === "string" && event.workspaceName.trim()) {
53578
+ payload.workspaceName = event.workspaceName.trim();
53579
+ }
53503
53580
  if (typeof event.duration === "number" && Number.isFinite(event.duration)) {
53504
53581
  payload.duration = event.duration;
53505
53582
  }
@@ -54729,7 +54806,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
54729
54806
  this.instances.get(id).dispose();
54730
54807
  }
54731
54808
  this.instances.set(id, instance);
54732
- await instance.init(context);
54809
+ await instance.init({
54810
+ ...context,
54811
+ emitProviderEvent: (event) => this.emitProviderEvent(instance.type, id, event)
54812
+ });
54733
54813
  }
54734
54814
  /**
54735
54815
  * Instance remove
@@ -54891,6 +54971,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
54891
54971
  onEvent(listener) {
54892
54972
  this.eventListeners.push(listener);
54893
54973
  }
54974
+ emitProviderEvent(providerType, instanceId, event) {
54975
+ const payload = {
54976
+ ...event,
54977
+ providerType,
54978
+ instanceId: typeof event.instanceId === "string" && event.instanceId.trim() ? event.instanceId : instanceId,
54979
+ targetSessionId: typeof event.targetSessionId === "string" && event.targetSessionId.trim() ? event.targetSessionId : instanceId
54980
+ };
54981
+ for (const listener of this.eventListeners) {
54982
+ listener(payload);
54983
+ }
54984
+ }
54894
54985
  emitPendingEvents(providerType, state, extra = {}) {
54895
54986
  for (const event of state.pendingEvents) {
54896
54987
  for (const listener of this.eventListeners) {