@adhdev/daemon-core 0.7.5 → 0.7.6

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.d.mts CHANGED
@@ -631,6 +631,7 @@ declare class ProviderInstanceManager {
631
631
  onEvent(listener: (event: ProviderEvent & {
632
632
  providerType: string;
633
633
  }) => void): void;
634
+ private emitPendingEvents;
634
635
  /**
635
636
  * Forward event to specific Instance
636
637
  */
@@ -1052,6 +1053,10 @@ declare class ExtensionProviderInstance implements ProviderInstance {
1052
1053
  private monitor;
1053
1054
  private instanceId;
1054
1055
  private ideType;
1056
+ private chatId;
1057
+ private chatTitle;
1058
+ private agentName;
1059
+ private extensionId;
1055
1060
  constructor(provider: ProviderModule);
1056
1061
  init(context: InstanceContext): Promise<void>;
1057
1062
  onTick(): Promise<void>;
@@ -1063,6 +1068,7 @@ declare class ExtensionProviderInstance implements ProviderInstance {
1063
1068
  private detectTransition;
1064
1069
  private pushEvent;
1065
1070
  private flushEvents;
1071
+ private resolveChatTitle;
1066
1072
  }
1067
1073
 
1068
1074
  /**
package/dist/index.d.ts CHANGED
@@ -631,6 +631,7 @@ declare class ProviderInstanceManager {
631
631
  onEvent(listener: (event: ProviderEvent & {
632
632
  providerType: string;
633
633
  }) => void): void;
634
+ private emitPendingEvents;
634
635
  /**
635
636
  * Forward event to specific Instance
636
637
  */
@@ -1052,6 +1053,10 @@ declare class ExtensionProviderInstance implements ProviderInstance {
1052
1053
  private monitor;
1053
1054
  private instanceId;
1054
1055
  private ideType;
1056
+ private chatId;
1057
+ private chatTitle;
1058
+ private agentName;
1059
+ private extensionId;
1055
1060
  constructor(provider: ProviderModule);
1056
1061
  init(context: InstanceContext): Promise<void>;
1057
1062
  onTick(): Promise<void>;
@@ -1063,6 +1068,7 @@ declare class ExtensionProviderInstance implements ProviderInstance {
1063
1068
  private detectTransition;
1064
1069
  private pushEvent;
1065
1070
  private flushEvents;
1071
+ private resolveChatTitle;
1066
1072
  }
1067
1073
 
1068
1074
  /**
package/dist/index.js CHANGED
@@ -3486,6 +3486,10 @@ var ExtensionProviderInstance = class {
3486
3486
  // meta
3487
3487
  instanceId;
3488
3488
  ideType = "";
3489
+ chatId = null;
3490
+ chatTitle = null;
3491
+ agentName = "";
3492
+ extensionId = "";
3489
3493
  constructor(provider) {
3490
3494
  this.type = provider.type;
3491
3495
  this.provider = provider;
@@ -3512,8 +3516,8 @@ var ExtensionProviderInstance = class {
3512
3516
  category: "extension",
3513
3517
  status: this.currentStatus,
3514
3518
  activeChat: this.messages.length > 0 ? {
3515
- id: `${this.type}_session`,
3516
- title: this.provider.name,
3519
+ id: this.chatId || this.instanceId,
3520
+ title: this.chatTitle || this.agentName || this.provider.name,
3517
3521
  status: this.currentStatus,
3518
3522
  messages: this.messages,
3519
3523
  activeModal: this.activeModal,
@@ -3535,6 +3539,10 @@ var ExtensionProviderInstance = class {
3535
3539
  if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
3536
3540
  if (data?.model) this.currentModel = data.model;
3537
3541
  if (data?.mode) this.currentMode = data.mode;
3542
+ if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
3543
+ if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
3544
+ if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
3545
+ if (typeof data?.extensionId === "string" && data.extensionId.trim()) this.extensionId = data.extensionId;
3538
3546
  if (data?.status) {
3539
3547
  const newStatus = data.status;
3540
3548
  this.detectTransition(newStatus, data);
@@ -3554,11 +3562,6 @@ var ExtensionProviderInstance = class {
3554
3562
  return this.instanceId;
3555
3563
  }
3556
3564
  // ─── status transition detect ──────────────────────────────
3557
- // NOTE: Extension transitions are TRACKED but NOT emitted as events.
3558
- // The parent IdeProviderInstance already emits identical events
3559
- // (generating_started, generating_completed, waiting_approval)
3560
- // via its own detectAgentTransitions(). Emitting here would cause
3561
- // duplicate toasts with slightly different content.
3562
3565
  detectTransition(newStatus, data) {
3563
3566
  const now = Date.now();
3564
3567
  const agentStatus = newStatus === "streaming" || newStatus === "generating" ? "generating" : newStatus === "waiting_approval" ? "waiting_approval" : "idle";
@@ -3567,7 +3570,40 @@ var ExtensionProviderInstance = class {
3567
3570
  if (agentStatus !== this.lastAgentStatus) {
3568
3571
  if (this.lastAgentStatus === "idle" && agentStatus === "generating") {
3569
3572
  this.generatingStartedAt = now;
3573
+ this.pushEvent({
3574
+ event: "agent:generating_started",
3575
+ chatTitle: this.resolveChatTitle(data),
3576
+ timestamp: now,
3577
+ ideType: this.ideType || this.type,
3578
+ agentType: this.type,
3579
+ agentName: this.agentName || this.provider.name,
3580
+ extensionId: this.extensionId || this.type
3581
+ });
3582
+ } else if (agentStatus === "waiting_approval") {
3583
+ if (!this.generatingStartedAt) this.generatingStartedAt = now;
3584
+ this.pushEvent({
3585
+ event: "agent:waiting_approval",
3586
+ chatTitle: this.resolveChatTitle(data),
3587
+ timestamp: now,
3588
+ ideType: this.ideType || this.type,
3589
+ agentType: this.type,
3590
+ agentName: this.agentName || this.provider.name,
3591
+ extensionId: this.extensionId || this.type,
3592
+ modalMessage: data?.activeModal?.message,
3593
+ modalButtons: data?.activeModal?.buttons
3594
+ });
3570
3595
  } else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
3596
+ const duration = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
3597
+ this.pushEvent({
3598
+ event: "agent:generating_completed",
3599
+ chatTitle: this.resolveChatTitle(data),
3600
+ duration,
3601
+ timestamp: now,
3602
+ ideType: this.ideType || this.type,
3603
+ agentType: this.type,
3604
+ agentName: this.agentName || this.provider.name,
3605
+ extensionId: this.extensionId || this.type
3606
+ });
3571
3607
  this.generatingStartedAt = 0;
3572
3608
  }
3573
3609
  this.lastAgentStatus = agentStatus;
@@ -3587,6 +3623,10 @@ var ExtensionProviderInstance = class {
3587
3623
  this.events = [];
3588
3624
  return events;
3589
3625
  }
3626
+ resolveChatTitle(data) {
3627
+ const title = typeof data?.title === "string" && data.title.trim() ? data.title.trim() : this.chatTitle;
3628
+ return title || this.agentName || this.provider.name;
3629
+ }
3590
3630
  };
3591
3631
 
3592
3632
  // src/config/chat-history.ts
@@ -10686,7 +10726,13 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
10686
10726
  status: stream.status || "idle",
10687
10727
  activeModal: stream.activeModal || null,
10688
10728
  model: stream.model || void 0,
10689
- mode: stream.mode || void 0
10729
+ mode: stream.mode || void 0,
10730
+ sessionId: stream.sessionId || stream.instanceId || void 0,
10731
+ title: stream.title || stream.agentName || void 0,
10732
+ agentType: stream.agentType || void 0,
10733
+ agentName: stream.agentName || void 0,
10734
+ extensionId: stream.extensionId || void 0,
10735
+ inputContent: stream.inputContent || ""
10690
10736
  });
10691
10737
  }
10692
10738
  }
@@ -10750,14 +10796,13 @@ var ProviderInstanceManager = class {
10750
10796
  try {
10751
10797
  const state = instance.getState();
10752
10798
  states.push(state);
10753
- for (const event of state.pendingEvents) {
10754
- for (const listener of this.eventListeners) {
10755
- listener({
10756
- ...event,
10757
- providerType: instance.type,
10758
- instanceId: state.instanceId,
10759
- targetSessionId: state.instanceId,
10760
- providerCategory: state.category
10799
+ this.emitPendingEvents(instance.type, state);
10800
+ if (state.category === "ide") {
10801
+ for (const childState of state.extensions) {
10802
+ this.emitPendingEvents(childState.type, childState, {
10803
+ targetSessionId: childState.instanceId,
10804
+ workspaceName: state.workspace || void 0,
10805
+ parentSessionId: state.instanceId
10761
10806
  });
10762
10807
  }
10763
10808
  }
@@ -10806,6 +10851,21 @@ var ProviderInstanceManager = class {
10806
10851
  onEvent(listener) {
10807
10852
  this.eventListeners.push(listener);
10808
10853
  }
10854
+ emitPendingEvents(providerType, state, extra = {}) {
10855
+ for (const event of state.pendingEvents) {
10856
+ for (const listener of this.eventListeners) {
10857
+ listener({
10858
+ ...event,
10859
+ providerType,
10860
+ instanceId: state.instanceId,
10861
+ targetSessionId: state.instanceId,
10862
+ providerCategory: state.category,
10863
+ workspaceName: state.workspace || void 0,
10864
+ ...extra
10865
+ });
10866
+ }
10867
+ }
10868
+ }
10809
10869
  /**
10810
10870
  * Forward event to specific Instance
10811
10871
  */