@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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +76 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/agent-stream/forward.ts +6 -0
- package/src/providers/extension-provider-instance.ts +50 -10
- package/src/providers/provider-instance-manager.ts +27 -10
package/dist/index.mjs
CHANGED
|
@@ -3411,6 +3411,10 @@ var ExtensionProviderInstance = class {
|
|
|
3411
3411
|
// meta
|
|
3412
3412
|
instanceId;
|
|
3413
3413
|
ideType = "";
|
|
3414
|
+
chatId = null;
|
|
3415
|
+
chatTitle = null;
|
|
3416
|
+
agentName = "";
|
|
3417
|
+
extensionId = "";
|
|
3414
3418
|
constructor(provider) {
|
|
3415
3419
|
this.type = provider.type;
|
|
3416
3420
|
this.provider = provider;
|
|
@@ -3437,8 +3441,8 @@ var ExtensionProviderInstance = class {
|
|
|
3437
3441
|
category: "extension",
|
|
3438
3442
|
status: this.currentStatus,
|
|
3439
3443
|
activeChat: this.messages.length > 0 ? {
|
|
3440
|
-
id:
|
|
3441
|
-
title: this.provider.name,
|
|
3444
|
+
id: this.chatId || this.instanceId,
|
|
3445
|
+
title: this.chatTitle || this.agentName || this.provider.name,
|
|
3442
3446
|
status: this.currentStatus,
|
|
3443
3447
|
messages: this.messages,
|
|
3444
3448
|
activeModal: this.activeModal,
|
|
@@ -3460,6 +3464,10 @@ var ExtensionProviderInstance = class {
|
|
|
3460
3464
|
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
3461
3465
|
if (data?.model) this.currentModel = data.model;
|
|
3462
3466
|
if (data?.mode) this.currentMode = data.mode;
|
|
3467
|
+
if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
|
|
3468
|
+
if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
|
|
3469
|
+
if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
|
|
3470
|
+
if (typeof data?.extensionId === "string" && data.extensionId.trim()) this.extensionId = data.extensionId;
|
|
3463
3471
|
if (data?.status) {
|
|
3464
3472
|
const newStatus = data.status;
|
|
3465
3473
|
this.detectTransition(newStatus, data);
|
|
@@ -3479,11 +3487,6 @@ var ExtensionProviderInstance = class {
|
|
|
3479
3487
|
return this.instanceId;
|
|
3480
3488
|
}
|
|
3481
3489
|
// ─── status transition detect ──────────────────────────────
|
|
3482
|
-
// NOTE: Extension transitions are TRACKED but NOT emitted as events.
|
|
3483
|
-
// The parent IdeProviderInstance already emits identical events
|
|
3484
|
-
// (generating_started, generating_completed, waiting_approval)
|
|
3485
|
-
// via its own detectAgentTransitions(). Emitting here would cause
|
|
3486
|
-
// duplicate toasts with slightly different content.
|
|
3487
3490
|
detectTransition(newStatus, data) {
|
|
3488
3491
|
const now = Date.now();
|
|
3489
3492
|
const agentStatus = newStatus === "streaming" || newStatus === "generating" ? "generating" : newStatus === "waiting_approval" ? "waiting_approval" : "idle";
|
|
@@ -3492,7 +3495,40 @@ var ExtensionProviderInstance = class {
|
|
|
3492
3495
|
if (agentStatus !== this.lastAgentStatus) {
|
|
3493
3496
|
if (this.lastAgentStatus === "idle" && agentStatus === "generating") {
|
|
3494
3497
|
this.generatingStartedAt = now;
|
|
3498
|
+
this.pushEvent({
|
|
3499
|
+
event: "agent:generating_started",
|
|
3500
|
+
chatTitle: this.resolveChatTitle(data),
|
|
3501
|
+
timestamp: now,
|
|
3502
|
+
ideType: this.ideType || this.type,
|
|
3503
|
+
agentType: this.type,
|
|
3504
|
+
agentName: this.agentName || this.provider.name,
|
|
3505
|
+
extensionId: this.extensionId || this.type
|
|
3506
|
+
});
|
|
3507
|
+
} else if (agentStatus === "waiting_approval") {
|
|
3508
|
+
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
3509
|
+
this.pushEvent({
|
|
3510
|
+
event: "agent:waiting_approval",
|
|
3511
|
+
chatTitle: this.resolveChatTitle(data),
|
|
3512
|
+
timestamp: now,
|
|
3513
|
+
ideType: this.ideType || this.type,
|
|
3514
|
+
agentType: this.type,
|
|
3515
|
+
agentName: this.agentName || this.provider.name,
|
|
3516
|
+
extensionId: this.extensionId || this.type,
|
|
3517
|
+
modalMessage: data?.activeModal?.message,
|
|
3518
|
+
modalButtons: data?.activeModal?.buttons
|
|
3519
|
+
});
|
|
3495
3520
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
3521
|
+
const duration = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
|
|
3522
|
+
this.pushEvent({
|
|
3523
|
+
event: "agent:generating_completed",
|
|
3524
|
+
chatTitle: this.resolveChatTitle(data),
|
|
3525
|
+
duration,
|
|
3526
|
+
timestamp: now,
|
|
3527
|
+
ideType: this.ideType || this.type,
|
|
3528
|
+
agentType: this.type,
|
|
3529
|
+
agentName: this.agentName || this.provider.name,
|
|
3530
|
+
extensionId: this.extensionId || this.type
|
|
3531
|
+
});
|
|
3496
3532
|
this.generatingStartedAt = 0;
|
|
3497
3533
|
}
|
|
3498
3534
|
this.lastAgentStatus = agentStatus;
|
|
@@ -3512,6 +3548,10 @@ var ExtensionProviderInstance = class {
|
|
|
3512
3548
|
this.events = [];
|
|
3513
3549
|
return events;
|
|
3514
3550
|
}
|
|
3551
|
+
resolveChatTitle(data) {
|
|
3552
|
+
const title = typeof data?.title === "string" && data.title.trim() ? data.title.trim() : this.chatTitle;
|
|
3553
|
+
return title || this.agentName || this.provider.name;
|
|
3554
|
+
}
|
|
3515
3555
|
};
|
|
3516
3556
|
|
|
3517
3557
|
// src/config/chat-history.ts
|
|
@@ -10616,7 +10656,13 @@ function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
|
|
|
10616
10656
|
status: stream.status || "idle",
|
|
10617
10657
|
activeModal: stream.activeModal || null,
|
|
10618
10658
|
model: stream.model || void 0,
|
|
10619
|
-
mode: stream.mode || void 0
|
|
10659
|
+
mode: stream.mode || void 0,
|
|
10660
|
+
sessionId: stream.sessionId || stream.instanceId || void 0,
|
|
10661
|
+
title: stream.title || stream.agentName || void 0,
|
|
10662
|
+
agentType: stream.agentType || void 0,
|
|
10663
|
+
agentName: stream.agentName || void 0,
|
|
10664
|
+
extensionId: stream.extensionId || void 0,
|
|
10665
|
+
inputContent: stream.inputContent || ""
|
|
10620
10666
|
});
|
|
10621
10667
|
}
|
|
10622
10668
|
}
|
|
@@ -10680,14 +10726,13 @@ var ProviderInstanceManager = class {
|
|
|
10680
10726
|
try {
|
|
10681
10727
|
const state = instance.getState();
|
|
10682
10728
|
states.push(state);
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
providerCategory: state.category
|
|
10729
|
+
this.emitPendingEvents(instance.type, state);
|
|
10730
|
+
if (state.category === "ide") {
|
|
10731
|
+
for (const childState of state.extensions) {
|
|
10732
|
+
this.emitPendingEvents(childState.type, childState, {
|
|
10733
|
+
targetSessionId: childState.instanceId,
|
|
10734
|
+
workspaceName: state.workspace || void 0,
|
|
10735
|
+
parentSessionId: state.instanceId
|
|
10691
10736
|
});
|
|
10692
10737
|
}
|
|
10693
10738
|
}
|
|
@@ -10736,6 +10781,21 @@ var ProviderInstanceManager = class {
|
|
|
10736
10781
|
onEvent(listener) {
|
|
10737
10782
|
this.eventListeners.push(listener);
|
|
10738
10783
|
}
|
|
10784
|
+
emitPendingEvents(providerType, state, extra = {}) {
|
|
10785
|
+
for (const event of state.pendingEvents) {
|
|
10786
|
+
for (const listener of this.eventListeners) {
|
|
10787
|
+
listener({
|
|
10788
|
+
...event,
|
|
10789
|
+
providerType,
|
|
10790
|
+
instanceId: state.instanceId,
|
|
10791
|
+
targetSessionId: state.instanceId,
|
|
10792
|
+
providerCategory: state.category,
|
|
10793
|
+
workspaceName: state.workspace || void 0,
|
|
10794
|
+
...extra
|
|
10795
|
+
});
|
|
10796
|
+
}
|
|
10797
|
+
}
|
|
10798
|
+
}
|
|
10739
10799
|
/**
|
|
10740
10800
|
* Forward event to specific Instance
|
|
10741
10801
|
*/
|