@adhdev/daemon-standalone 0.9.76-rc.25 → 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
@@ -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
  }
@@ -53166,7 +53212,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53166
53212
  // ─── Mesh Coordinator Launch ───
53167
53213
  case "launch_mesh_coordinator": {
53168
53214
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
53169
- const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
53215
+ let cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "";
53170
53216
  if (!meshId) return { success: false, error: "meshId required" };
53171
53217
  try {
53172
53218
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
@@ -53194,6 +53240,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
53194
53240
  }
53195
53241
  const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
53196
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
+ }
53197
53262
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
53198
53263
  const coordinatorSetup = resolveMeshCoordinatorSetup({
53199
53264
  provider: providerMeta,
@@ -53506,6 +53571,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
53506
53571
  if (providerType) {
53507
53572
  payload.providerType = providerType;
53508
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
+ }
53509
53580
  if (typeof event.duration === "number" && Number.isFinite(event.duration)) {
53510
53581
  payload.duration = event.duration;
53511
53582
  }
@@ -54735,7 +54806,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
54735
54806
  this.instances.get(id).dispose();
54736
54807
  }
54737
54808
  this.instances.set(id, instance);
54738
- await instance.init(context);
54809
+ await instance.init({
54810
+ ...context,
54811
+ emitProviderEvent: (event) => this.emitProviderEvent(instance.type, id, event)
54812
+ });
54739
54813
  }
54740
54814
  /**
54741
54815
  * Instance remove
@@ -54897,6 +54971,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
54897
54971
  onEvent(listener) {
54898
54972
  this.eventListeners.push(listener);
54899
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
+ }
54900
54985
  emitPendingEvents(providerType, state, extra = {}) {
54901
54986
  for (const event of state.pendingEvents) {
54902
54987
  for (const listener of this.eventListeners) {