opencode-orchestrator 1.0.46 → 1.0.51
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/README.md +42 -35
- package/dist/core/notification/task-toast-manager.d.ts +9 -20
- package/dist/core/notification/toast-core.d.ts +1 -1
- package/dist/core/notification/toast.d.ts +2 -2
- package/dist/index.js +659 -600
- package/dist/shared/agent/types/index.d.ts +0 -1
- package/dist/shared/core/constants/index.d.ts +1 -1
- package/dist/shared/core/constants/status-labels.d.ts +1 -0
- package/dist/shared/notification/constants/index.d.ts +2 -4
- package/dist/shared/notification/constants/tui.const.d.ts +24 -0
- package/dist/shared/notification/index.d.ts +1 -0
- package/dist/shared/notification/interfaces/index.d.ts +1 -0
- package/dist/shared/notification/interfaces/task-toast.interface.d.ts +18 -0
- package/dist/{core → shared}/notification/presets/mission.d.ts +2 -2
- package/dist/{core → shared}/notification/presets/parallel.d.ts +3 -3
- package/dist/{core → shared}/notification/presets/session.d.ts +3 -3
- package/dist/{core → shared}/notification/presets/task-lifecycle.d.ts +4 -4
- package/dist/{core → shared}/notification/presets/tools.d.ts +3 -3
- package/dist/{core → shared}/notification/presets/warnings.d.ts +4 -4
- package/package.json +1 -1
- package/dist/core/notification/presets.d.ts +0 -7
- package/dist/core/notification/types/index.d.ts +0 -6
- package/dist/core/notification/types/toast-message.d.ts +0 -13
- package/dist/core/notification/types/toast-options.d.ts +0 -10
- package/dist/core/notification/types/toast-variant.d.ts +0 -4
- package/dist/core/notification/types.d.ts +0 -6
- package/dist/shared/agent/types/status-types.d.ts +0 -5
- /package/dist/{core → shared}/notification/presets/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -15,18 +15,10 @@ var init_interfaces = __esm({
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
// src/shared/agent/types/status-types.ts
|
|
19
|
-
var init_status_types = __esm({
|
|
20
|
-
"src/shared/agent/types/status-types.ts"() {
|
|
21
|
-
"use strict";
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
18
|
// src/shared/agent/types/index.ts
|
|
26
19
|
var init_types = __esm({
|
|
27
20
|
"src/shared/agent/types/index.ts"() {
|
|
28
21
|
"use strict";
|
|
29
|
-
init_status_types();
|
|
30
22
|
}
|
|
31
23
|
});
|
|
32
24
|
|
|
@@ -582,6 +574,35 @@ var init_toast_duration = __esm({
|
|
|
582
574
|
}
|
|
583
575
|
});
|
|
584
576
|
|
|
577
|
+
// src/shared/notification/constants/tui.const.ts
|
|
578
|
+
var TUI_ICONS, TUI_BLOCKS, TUI_TAGS, TUI_MESSAGES;
|
|
579
|
+
var init_tui_const = __esm({
|
|
580
|
+
"src/shared/notification/constants/tui.const.ts"() {
|
|
581
|
+
"use strict";
|
|
582
|
+
TUI_ICONS = {
|
|
583
|
+
RUNNING: "\u26A1",
|
|
584
|
+
QUEUED: "\u23F3",
|
|
585
|
+
MISSION_SEALED: "\u{1F389}",
|
|
586
|
+
SHIELD: "\u{1F6E1}\uFE0F",
|
|
587
|
+
NEW: " <- NEW"
|
|
588
|
+
};
|
|
589
|
+
TUI_BLOCKS = {
|
|
590
|
+
FILLED: "\u25A3",
|
|
591
|
+
EMPTY: "\u25A2"
|
|
592
|
+
};
|
|
593
|
+
TUI_TAGS = {
|
|
594
|
+
BACKGROUND: "BACKGROUND",
|
|
595
|
+
FOREGROUND: "FOREGROUND",
|
|
596
|
+
WAITING: "WAITING",
|
|
597
|
+
PENDING: "PENDING"
|
|
598
|
+
};
|
|
599
|
+
TUI_MESSAGES = {
|
|
600
|
+
MISSION_SEALED_TITLE: "MISSION ACCOMPLISHED",
|
|
601
|
+
MISSION_SEALED_SUBTITLE: "Passed all verifications.\nCodebase is sealed."
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
585
606
|
// src/shared/notification/constants/toast-variants.ts
|
|
586
607
|
var init_toast_variants = __esm({
|
|
587
608
|
"src/shared/notification/constants/toast-variants.ts"() {
|
|
@@ -594,14 +615,23 @@ var init_constants5 = __esm({
|
|
|
594
615
|
"src/shared/notification/constants/index.ts"() {
|
|
595
616
|
"use strict";
|
|
596
617
|
init_toast_duration();
|
|
618
|
+
init_tui_const();
|
|
597
619
|
init_toast_variants();
|
|
598
620
|
}
|
|
599
621
|
});
|
|
600
622
|
|
|
623
|
+
// src/shared/notification/interfaces/task-toast.interface.ts
|
|
624
|
+
var init_task_toast_interface = __esm({
|
|
625
|
+
"src/shared/notification/interfaces/task-toast.interface.ts"() {
|
|
626
|
+
"use strict";
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
601
630
|
// src/shared/notification/interfaces/index.ts
|
|
602
631
|
var init_interfaces4 = __esm({
|
|
603
632
|
"src/shared/notification/interfaces/index.ts"() {
|
|
604
633
|
"use strict";
|
|
634
|
+
init_task_toast_interface();
|
|
605
635
|
}
|
|
606
636
|
});
|
|
607
637
|
|
|
@@ -612,121 +642,380 @@ var init_types4 = __esm({
|
|
|
612
642
|
}
|
|
613
643
|
});
|
|
614
644
|
|
|
615
|
-
// src/
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
645
|
+
// src/core/notification/toast-core.ts
|
|
646
|
+
function initToastClient(client) {
|
|
647
|
+
tuiClient = client;
|
|
648
|
+
}
|
|
649
|
+
function show(options) {
|
|
650
|
+
const toast = {
|
|
651
|
+
id: `toast_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
652
|
+
title: options.title,
|
|
653
|
+
message: options.message,
|
|
654
|
+
variant: options.variant || "info",
|
|
655
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
656
|
+
duration: options.duration ?? 5e3,
|
|
657
|
+
dismissed: false
|
|
658
|
+
};
|
|
659
|
+
toasts.push(toast);
|
|
660
|
+
if (toasts.length > HISTORY.MAX_TOAST) {
|
|
661
|
+
toasts.shift();
|
|
622
662
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
"src/shared/recovery/constants/recovery.ts"() {
|
|
629
|
-
"use strict";
|
|
630
|
-
init_time();
|
|
631
|
-
RECOVERY = {
|
|
632
|
-
/** Maximum recovery attempts per session */
|
|
633
|
-
MAX_ATTEMPTS: 3,
|
|
634
|
-
/** Minimum time between recovery attempts */
|
|
635
|
-
MIN_INTERVAL_MS: 30 * TIME.SECOND,
|
|
636
|
-
/** Base delay for retry backoff calculation */
|
|
637
|
-
BASE_DELAY_MS: 1 * TIME.SECOND,
|
|
638
|
-
/** Maximum retry multiplier */
|
|
639
|
-
MAX_RETRY_MULTIPLIER: 5
|
|
640
|
-
};
|
|
663
|
+
for (const handler of handlers) {
|
|
664
|
+
try {
|
|
665
|
+
handler(toast);
|
|
666
|
+
} catch (error45) {
|
|
667
|
+
}
|
|
641
668
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
MAX_PROGRESS: 100
|
|
656
|
-
};
|
|
669
|
+
if (tuiClient) {
|
|
670
|
+
const client = tuiClient;
|
|
671
|
+
if (client.tui?.showToast) {
|
|
672
|
+
client.tui.showToast({
|
|
673
|
+
body: {
|
|
674
|
+
title: toast.title,
|
|
675
|
+
message: toast.message,
|
|
676
|
+
variant: toast.variant,
|
|
677
|
+
duration: toast.duration
|
|
678
|
+
}
|
|
679
|
+
}).catch(() => {
|
|
680
|
+
});
|
|
681
|
+
}
|
|
657
682
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
var
|
|
662
|
-
|
|
663
|
-
"src/shared/recovery/constants/recovery-level.ts"() {
|
|
683
|
+
return toast;
|
|
684
|
+
}
|
|
685
|
+
var tuiClient, toasts, handlers;
|
|
686
|
+
var init_toast_core = __esm({
|
|
687
|
+
"src/core/notification/toast-core.ts"() {
|
|
664
688
|
"use strict";
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
RE_PLAN: "RE-PLAN",
|
|
670
|
-
/** Level 3: Ask user for direction */
|
|
671
|
-
ASK_USER: "ASK USER"
|
|
672
|
-
};
|
|
673
|
-
RECOVERY_PRINCIPLE = "DECOMPOSE \u2192 RE-PLAN \u2192 ASK. Never give up silently.";
|
|
689
|
+
init_shared();
|
|
690
|
+
tuiClient = null;
|
|
691
|
+
toasts = [];
|
|
692
|
+
handlers = [];
|
|
674
693
|
}
|
|
675
694
|
});
|
|
676
695
|
|
|
677
|
-
// src/shared/
|
|
678
|
-
var
|
|
679
|
-
|
|
696
|
+
// src/shared/notification/presets/task-lifecycle.ts
|
|
697
|
+
var taskStarted, taskCompleted, taskFailed, allTasksComplete;
|
|
698
|
+
var init_task_lifecycle = __esm({
|
|
699
|
+
"src/shared/notification/presets/task-lifecycle.ts"() {
|
|
680
700
|
"use strict";
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
701
|
+
init_toast_core();
|
|
702
|
+
taskStarted = (taskId, agent) => show({
|
|
703
|
+
title: "Task Started",
|
|
704
|
+
message: `${agent}: ${taskId}`,
|
|
705
|
+
variant: "info",
|
|
706
|
+
duration: 3e3
|
|
707
|
+
});
|
|
708
|
+
taskCompleted = (taskId, agent) => show({
|
|
709
|
+
title: "Task Completed",
|
|
710
|
+
message: `${agent}: ${taskId}`,
|
|
711
|
+
variant: "success",
|
|
712
|
+
duration: 3e3
|
|
713
|
+
});
|
|
714
|
+
taskFailed = (taskId, error45) => show({
|
|
715
|
+
title: "Task Failed",
|
|
716
|
+
message: `${taskId}: ${error45}`,
|
|
717
|
+
variant: "error",
|
|
718
|
+
duration: 0
|
|
719
|
+
});
|
|
720
|
+
allTasksComplete = (count) => show({
|
|
721
|
+
title: "All Tasks Complete",
|
|
722
|
+
message: `${count} tasks finished successfully`,
|
|
723
|
+
variant: "success",
|
|
724
|
+
duration: 5e3
|
|
725
|
+
});
|
|
684
726
|
}
|
|
685
727
|
});
|
|
686
728
|
|
|
687
|
-
// src/shared/
|
|
688
|
-
var
|
|
689
|
-
|
|
729
|
+
// src/shared/notification/presets/session.ts
|
|
730
|
+
var sessionCreated, sessionResumed, sessionCompleted;
|
|
731
|
+
var init_session = __esm({
|
|
732
|
+
"src/shared/notification/presets/session.ts"() {
|
|
690
733
|
"use strict";
|
|
734
|
+
init_toast_core();
|
|
735
|
+
init_shared();
|
|
736
|
+
sessionCreated = (sessionId, agent) => show({
|
|
737
|
+
title: "Session Created",
|
|
738
|
+
message: `${agent} - ${sessionId.slice(0, 12)}...`,
|
|
739
|
+
variant: STATUS_LABEL.INFO,
|
|
740
|
+
duration: TOAST_DURATION.SHORT
|
|
741
|
+
});
|
|
742
|
+
sessionResumed = (sessionId, agent) => show({
|
|
743
|
+
title: "Session Resumed",
|
|
744
|
+
message: `${agent} - ${sessionId.slice(0, 12)}...`,
|
|
745
|
+
variant: STATUS_LABEL.INFO,
|
|
746
|
+
duration: TOAST_DURATION.SHORT
|
|
747
|
+
});
|
|
748
|
+
sessionCompleted = (sessionId, duration3) => show({
|
|
749
|
+
title: "Session Completed",
|
|
750
|
+
message: `${sessionId.slice(0, 12)}... (${duration3})`,
|
|
751
|
+
variant: STATUS_LABEL.SUCCESS,
|
|
752
|
+
duration: TOAST_DURATION.MEDIUM
|
|
753
|
+
});
|
|
691
754
|
}
|
|
692
755
|
});
|
|
693
756
|
|
|
694
|
-
// src/shared/
|
|
695
|
-
var
|
|
696
|
-
|
|
757
|
+
// src/shared/notification/presets/parallel.ts
|
|
758
|
+
var parallelTasksLaunched, concurrencyAcquired, concurrencyReleased;
|
|
759
|
+
var init_parallel = __esm({
|
|
760
|
+
"src/shared/notification/presets/parallel.ts"() {
|
|
697
761
|
"use strict";
|
|
762
|
+
init_toast_core();
|
|
763
|
+
init_shared();
|
|
764
|
+
parallelTasksLaunched = (count, agents) => show({
|
|
765
|
+
title: "Parallel Tasks Launched",
|
|
766
|
+
message: `${count} tasks: ${agents.join(", ")}`,
|
|
767
|
+
variant: "info",
|
|
768
|
+
duration: TOAST_DURATION.DEFAULT
|
|
769
|
+
});
|
|
770
|
+
concurrencyAcquired = (agent, slot) => show({
|
|
771
|
+
title: "Concurrency Slot",
|
|
772
|
+
message: `${agent} acquired ${slot}`,
|
|
773
|
+
variant: "info",
|
|
774
|
+
duration: TOAST_DURATION.SHORT
|
|
775
|
+
});
|
|
776
|
+
concurrencyReleased = (agent) => show({
|
|
777
|
+
title: "Slot Released",
|
|
778
|
+
message: agent,
|
|
779
|
+
variant: "info",
|
|
780
|
+
duration: TOAST_DURATION.EXTRA_SHORT
|
|
781
|
+
});
|
|
698
782
|
}
|
|
699
783
|
});
|
|
700
784
|
|
|
701
|
-
// src/shared/
|
|
702
|
-
var
|
|
703
|
-
|
|
785
|
+
// src/shared/notification/presets/mission.ts
|
|
786
|
+
var missionComplete, missionStarted;
|
|
787
|
+
var init_mission = __esm({
|
|
788
|
+
"src/shared/notification/presets/mission.ts"() {
|
|
704
789
|
"use strict";
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
790
|
+
init_toast_core();
|
|
791
|
+
missionComplete = (summary) => show({
|
|
792
|
+
title: "Mission Complete",
|
|
793
|
+
message: summary,
|
|
794
|
+
variant: "success",
|
|
795
|
+
duration: 0
|
|
796
|
+
});
|
|
797
|
+
missionStarted = (description) => show({
|
|
798
|
+
title: "Mission Started",
|
|
799
|
+
message: description.slice(0, 100),
|
|
800
|
+
variant: "info",
|
|
801
|
+
duration: 4e3
|
|
802
|
+
});
|
|
708
803
|
}
|
|
709
804
|
});
|
|
710
805
|
|
|
711
|
-
// src/shared/
|
|
712
|
-
var
|
|
713
|
-
var
|
|
714
|
-
"src/shared/
|
|
806
|
+
// src/shared/notification/presets/tools.ts
|
|
807
|
+
var toolExecuted, documentCached, researchStarted;
|
|
808
|
+
var init_tools = __esm({
|
|
809
|
+
"src/shared/notification/presets/tools.ts"() {
|
|
715
810
|
"use strict";
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
811
|
+
init_toast_core();
|
|
812
|
+
init_shared();
|
|
813
|
+
toolExecuted = (toolName, target) => show({
|
|
814
|
+
title: toolName,
|
|
815
|
+
message: target.slice(0, 80),
|
|
816
|
+
variant: "info",
|
|
817
|
+
duration: TOAST_DURATION.SHORT
|
|
818
|
+
});
|
|
819
|
+
documentCached = (filename) => show({
|
|
820
|
+
title: "Document Cached",
|
|
821
|
+
message: `${PATHS.DOCS}/${filename}`,
|
|
822
|
+
variant: "info",
|
|
823
|
+
duration: TOAST_DURATION.SHORT
|
|
824
|
+
});
|
|
825
|
+
researchStarted = (topic) => show({
|
|
826
|
+
title: "Research Started",
|
|
827
|
+
message: topic,
|
|
828
|
+
variant: "info",
|
|
829
|
+
duration: TOAST_DURATION.MEDIUM
|
|
830
|
+
});
|
|
725
831
|
}
|
|
726
832
|
});
|
|
727
833
|
|
|
728
|
-
// src/shared/
|
|
729
|
-
var
|
|
834
|
+
// src/shared/notification/presets/warnings.ts
|
|
835
|
+
var warningRateLimited, errorRecovery, warningMaxDepth, warningMaxRetries;
|
|
836
|
+
var init_warnings = __esm({
|
|
837
|
+
"src/shared/notification/presets/warnings.ts"() {
|
|
838
|
+
"use strict";
|
|
839
|
+
init_toast_core();
|
|
840
|
+
init_shared();
|
|
841
|
+
warningRateLimited = () => show({
|
|
842
|
+
title: "Rate Limited",
|
|
843
|
+
message: "Waiting before retry...",
|
|
844
|
+
variant: "warning",
|
|
845
|
+
duration: TOAST_DURATION.LONG
|
|
846
|
+
});
|
|
847
|
+
errorRecovery = (action) => show({
|
|
848
|
+
title: "Error Recovery",
|
|
849
|
+
message: `Attempting: ${action}`,
|
|
850
|
+
variant: "warning",
|
|
851
|
+
duration: TOAST_DURATION.MEDIUM
|
|
852
|
+
});
|
|
853
|
+
warningMaxDepth = (depth) => show({
|
|
854
|
+
title: "Max Depth Reached",
|
|
855
|
+
message: `Recursion blocked at depth ${depth}`,
|
|
856
|
+
variant: "warning",
|
|
857
|
+
duration: TOAST_DURATION.LONG
|
|
858
|
+
});
|
|
859
|
+
warningMaxRetries = () => show({
|
|
860
|
+
title: "Max Retries Exceeded",
|
|
861
|
+
message: "Automatic recovery has stopped. Manual intervention may be needed.",
|
|
862
|
+
variant: "error",
|
|
863
|
+
duration: TOAST_DURATION.PERSISTENT
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
// src/shared/notification/presets/index.ts
|
|
869
|
+
var presets_exports = {};
|
|
870
|
+
__export(presets_exports, {
|
|
871
|
+
allTasksComplete: () => allTasksComplete,
|
|
872
|
+
concurrencyAcquired: () => concurrencyAcquired,
|
|
873
|
+
concurrencyReleased: () => concurrencyReleased,
|
|
874
|
+
documentCached: () => documentCached,
|
|
875
|
+
errorRecovery: () => errorRecovery,
|
|
876
|
+
missionComplete: () => missionComplete,
|
|
877
|
+
missionStarted: () => missionStarted,
|
|
878
|
+
parallelTasksLaunched: () => parallelTasksLaunched,
|
|
879
|
+
researchStarted: () => researchStarted,
|
|
880
|
+
sessionCompleted: () => sessionCompleted,
|
|
881
|
+
sessionCreated: () => sessionCreated,
|
|
882
|
+
sessionResumed: () => sessionResumed,
|
|
883
|
+
taskCompleted: () => taskCompleted,
|
|
884
|
+
taskFailed: () => taskFailed,
|
|
885
|
+
taskStarted: () => taskStarted,
|
|
886
|
+
toolExecuted: () => toolExecuted,
|
|
887
|
+
warningMaxDepth: () => warningMaxDepth,
|
|
888
|
+
warningMaxRetries: () => warningMaxRetries,
|
|
889
|
+
warningRateLimited: () => warningRateLimited
|
|
890
|
+
});
|
|
891
|
+
var init_presets = __esm({
|
|
892
|
+
"src/shared/notification/presets/index.ts"() {
|
|
893
|
+
"use strict";
|
|
894
|
+
init_task_lifecycle();
|
|
895
|
+
init_session();
|
|
896
|
+
init_parallel();
|
|
897
|
+
init_mission();
|
|
898
|
+
init_tools();
|
|
899
|
+
init_warnings();
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// src/shared/notification/index.ts
|
|
904
|
+
var init_notification = __esm({
|
|
905
|
+
"src/shared/notification/index.ts"() {
|
|
906
|
+
"use strict";
|
|
907
|
+
init_constants5();
|
|
908
|
+
init_interfaces4();
|
|
909
|
+
init_types4();
|
|
910
|
+
init_presets();
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
// src/shared/recovery/constants/recovery.ts
|
|
915
|
+
var RECOVERY;
|
|
916
|
+
var init_recovery = __esm({
|
|
917
|
+
"src/shared/recovery/constants/recovery.ts"() {
|
|
918
|
+
"use strict";
|
|
919
|
+
init_time();
|
|
920
|
+
RECOVERY = {
|
|
921
|
+
/** Maximum recovery attempts per session */
|
|
922
|
+
MAX_ATTEMPTS: 3,
|
|
923
|
+
/** Minimum time between recovery attempts */
|
|
924
|
+
MIN_INTERVAL_MS: 30 * TIME.SECOND,
|
|
925
|
+
/** Base delay for retry backoff calculation */
|
|
926
|
+
BASE_DELAY_MS: 1 * TIME.SECOND,
|
|
927
|
+
/** Maximum retry multiplier */
|
|
928
|
+
MAX_RETRY_MULTIPLIER: 5
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
// src/shared/recovery/constants/history.ts
|
|
934
|
+
var HISTORY;
|
|
935
|
+
var init_history = __esm({
|
|
936
|
+
"src/shared/recovery/constants/history.ts"() {
|
|
937
|
+
"use strict";
|
|
938
|
+
HISTORY = {
|
|
939
|
+
/** Recovery history max entries */
|
|
940
|
+
MAX_RECOVERY: 100,
|
|
941
|
+
/** Toast history max entries */
|
|
942
|
+
MAX_TOAST: 50,
|
|
943
|
+
/** Progress store max entries */
|
|
944
|
+
MAX_PROGRESS: 100
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
// src/shared/recovery/constants/recovery-level.ts
|
|
950
|
+
var RECOVERY_LEVEL, RECOVERY_PRINCIPLE;
|
|
951
|
+
var init_recovery_level = __esm({
|
|
952
|
+
"src/shared/recovery/constants/recovery-level.ts"() {
|
|
953
|
+
"use strict";
|
|
954
|
+
RECOVERY_LEVEL = {
|
|
955
|
+
/** Level 1: Split task into smaller units */
|
|
956
|
+
DECOMPOSE: "DECOMPOSE",
|
|
957
|
+
/** Level 2: Step back and create new strategy */
|
|
958
|
+
RE_PLAN: "RE-PLAN",
|
|
959
|
+
/** Level 3: Ask user for direction */
|
|
960
|
+
ASK_USER: "ASK USER"
|
|
961
|
+
};
|
|
962
|
+
RECOVERY_PRINCIPLE = "DECOMPOSE \u2192 RE-PLAN \u2192 ASK. Never give up silently.";
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
// src/shared/recovery/constants/index.ts
|
|
967
|
+
var init_constants6 = __esm({
|
|
968
|
+
"src/shared/recovery/constants/index.ts"() {
|
|
969
|
+
"use strict";
|
|
970
|
+
init_recovery();
|
|
971
|
+
init_history();
|
|
972
|
+
init_recovery_level();
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// src/shared/recovery/interfaces/index.ts
|
|
977
|
+
var init_interfaces5 = __esm({
|
|
978
|
+
"src/shared/recovery/interfaces/index.ts"() {
|
|
979
|
+
"use strict";
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// src/shared/recovery/types/index.ts
|
|
984
|
+
var init_types5 = __esm({
|
|
985
|
+
"src/shared/recovery/types/index.ts"() {
|
|
986
|
+
"use strict";
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
// src/shared/recovery/index.ts
|
|
991
|
+
var init_recovery2 = __esm({
|
|
992
|
+
"src/shared/recovery/index.ts"() {
|
|
993
|
+
"use strict";
|
|
994
|
+
init_constants6();
|
|
995
|
+
init_interfaces5();
|
|
996
|
+
init_types5();
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
// src/shared/cache/constants/cache.ts
|
|
1001
|
+
var CACHE;
|
|
1002
|
+
var init_cache = __esm({
|
|
1003
|
+
"src/shared/cache/constants/cache.ts"() {
|
|
1004
|
+
"use strict";
|
|
1005
|
+
init_time();
|
|
1006
|
+
CACHE = {
|
|
1007
|
+
/** Default cache TTL (24 hours) */
|
|
1008
|
+
DEFAULT_TTL_MS: 24 * TIME.HOUR,
|
|
1009
|
+
/** Maximum cache entries */
|
|
1010
|
+
MAX_ENTRIES: 100,
|
|
1011
|
+
/** Session TTL (24 hours for long tasks) */
|
|
1012
|
+
SESSION_TTL_MS: 24 * TIME.HOUR
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
// src/shared/cache/constants/cache-actions.ts
|
|
1018
|
+
var CACHE_ACTIONS;
|
|
730
1019
|
var init_cache_actions = __esm({
|
|
731
1020
|
"src/shared/cache/constants/cache-actions.ts"() {
|
|
732
1021
|
"use strict";
|
|
@@ -902,7 +1191,7 @@ var init_constants8 = __esm({
|
|
|
902
1191
|
});
|
|
903
1192
|
|
|
904
1193
|
// src/shared/session/index.ts
|
|
905
|
-
var
|
|
1194
|
+
var init_session2 = __esm({
|
|
906
1195
|
"src/shared/session/index.ts"() {
|
|
907
1196
|
"use strict";
|
|
908
1197
|
init_constants8();
|
|
@@ -1064,7 +1353,7 @@ var init_logging = __esm({
|
|
|
1064
1353
|
});
|
|
1065
1354
|
|
|
1066
1355
|
// src/shared/tool/constants/parallel/index.ts
|
|
1067
|
-
var
|
|
1356
|
+
var init_parallel2 = __esm({
|
|
1068
1357
|
"src/shared/tool/constants/parallel/index.ts"() {
|
|
1069
1358
|
"use strict";
|
|
1070
1359
|
init_logging();
|
|
@@ -1128,7 +1417,7 @@ var init_constants9 = __esm({
|
|
|
1128
1417
|
init_tool_names();
|
|
1129
1418
|
init_tool_output();
|
|
1130
1419
|
init_lsp();
|
|
1131
|
-
|
|
1420
|
+
init_parallel2();
|
|
1132
1421
|
init_common();
|
|
1133
1422
|
}
|
|
1134
1423
|
});
|
|
@@ -1155,7 +1444,7 @@ var init_poll_result = __esm({
|
|
|
1155
1444
|
});
|
|
1156
1445
|
|
|
1157
1446
|
// src/shared/tool/interfaces/parallel/index.ts
|
|
1158
|
-
var
|
|
1447
|
+
var init_parallel3 = __esm({
|
|
1159
1448
|
"src/shared/tool/interfaces/parallel/index.ts"() {
|
|
1160
1449
|
"use strict";
|
|
1161
1450
|
init_session_client();
|
|
@@ -1175,7 +1464,7 @@ var init_interfaces7 = __esm({
|
|
|
1175
1464
|
"src/shared/tool/interfaces/index.ts"() {
|
|
1176
1465
|
"use strict";
|
|
1177
1466
|
init_lsp2();
|
|
1178
|
-
|
|
1467
|
+
init_parallel3();
|
|
1179
1468
|
init_ast();
|
|
1180
1469
|
}
|
|
1181
1470
|
});
|
|
@@ -1784,7 +2073,7 @@ var init_shared = __esm({
|
|
|
1784
2073
|
init_notification();
|
|
1785
2074
|
init_recovery2();
|
|
1786
2075
|
init_cache2();
|
|
1787
|
-
|
|
2076
|
+
init_session2();
|
|
1788
2077
|
init_command();
|
|
1789
2078
|
init_tool();
|
|
1790
2079
|
init_message();
|
|
@@ -1954,484 +2243,216 @@ var init_concurrency = __esm({
|
|
|
1954
2243
|
*/
|
|
1955
2244
|
getConcurrencyInfo(key) {
|
|
1956
2245
|
const active = this.getActiveCount(key);
|
|
1957
|
-
const limit = this.getConcurrencyLimit(key);
|
|
1958
|
-
if (limit === Infinity) return "";
|
|
1959
|
-
return ` (${active}/${limit} slots)`;
|
|
1960
|
-
}
|
|
1961
|
-
};
|
|
1962
|
-
}
|
|
1963
|
-
});
|
|
1964
|
-
|
|
1965
|
-
// src/core/agents/task-store.ts
|
|
1966
|
-
import * as fs2 from "node:fs/promises";
|
|
1967
|
-
import * as path2 from "node:path";
|
|
1968
|
-
var TaskStore;
|
|
1969
|
-
var init_task_store = __esm({
|
|
1970
|
-
"src/core/agents/task-store.ts"() {
|
|
1971
|
-
"use strict";
|
|
1972
|
-
init_shared();
|
|
1973
|
-
TaskStore = class {
|
|
1974
|
-
tasks = /* @__PURE__ */ new Map();
|
|
1975
|
-
pendingByParent = /* @__PURE__ */ new Map();
|
|
1976
|
-
notifications = /* @__PURE__ */ new Map();
|
|
1977
|
-
archivedCount = 0;
|
|
1978
|
-
set(id, task) {
|
|
1979
|
-
this.tasks.set(id, task);
|
|
1980
|
-
if (this.tasks.size > MEMORY_LIMITS.MAX_TASKS_IN_MEMORY) {
|
|
1981
|
-
this.gc();
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
get(id) {
|
|
1985
|
-
return this.tasks.get(id);
|
|
1986
|
-
}
|
|
1987
|
-
getAll() {
|
|
1988
|
-
return Array.from(this.tasks.values());
|
|
1989
|
-
}
|
|
1990
|
-
getRunning() {
|
|
1991
|
-
return this.getAll().filter((t) => t.status === TASK_STATUS.RUNNING || t.status === TASK_STATUS.PENDING);
|
|
1992
|
-
}
|
|
1993
|
-
getByParent(parentSessionID) {
|
|
1994
|
-
return this.getAll().filter((t) => t.parentSessionID === parentSessionID);
|
|
1995
|
-
}
|
|
1996
|
-
delete(id) {
|
|
1997
|
-
return this.tasks.delete(id);
|
|
1998
|
-
}
|
|
1999
|
-
clear() {
|
|
2000
|
-
this.tasks.clear();
|
|
2001
|
-
this.pendingByParent.clear();
|
|
2002
|
-
this.notifications.clear();
|
|
2003
|
-
}
|
|
2004
|
-
// Pending tracking
|
|
2005
|
-
trackPending(parentSessionID, taskId) {
|
|
2006
|
-
const pending2 = this.pendingByParent.get(parentSessionID) ?? /* @__PURE__ */ new Set();
|
|
2007
|
-
pending2.add(taskId);
|
|
2008
|
-
this.pendingByParent.set(parentSessionID, pending2);
|
|
2009
|
-
}
|
|
2010
|
-
untrackPending(parentSessionID, taskId) {
|
|
2011
|
-
const pending2 = this.pendingByParent.get(parentSessionID);
|
|
2012
|
-
if (pending2) {
|
|
2013
|
-
pending2.delete(taskId);
|
|
2014
|
-
if (pending2.size === 0) {
|
|
2015
|
-
this.pendingByParent.delete(parentSessionID);
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
getPendingCount(parentSessionID) {
|
|
2020
|
-
return this.pendingByParent.get(parentSessionID)?.size ?? 0;
|
|
2021
|
-
}
|
|
2022
|
-
hasPending(parentSessionID) {
|
|
2023
|
-
return this.getPendingCount(parentSessionID) > 0;
|
|
2024
|
-
}
|
|
2025
|
-
// Notifications with limit
|
|
2026
|
-
queueNotification(task) {
|
|
2027
|
-
const queue = this.notifications.get(task.parentSessionID) ?? [];
|
|
2028
|
-
queue.push(task);
|
|
2029
|
-
if (queue.length > MEMORY_LIMITS.MAX_NOTIFICATIONS_PER_PARENT) {
|
|
2030
|
-
queue.shift();
|
|
2031
|
-
}
|
|
2032
|
-
this.notifications.set(task.parentSessionID, queue);
|
|
2033
|
-
}
|
|
2034
|
-
getNotifications(parentSessionID) {
|
|
2035
|
-
return this.notifications.get(parentSessionID) ?? [];
|
|
2036
|
-
}
|
|
2037
|
-
clearNotifications(parentSessionID) {
|
|
2038
|
-
this.notifications.delete(parentSessionID);
|
|
2039
|
-
}
|
|
2040
|
-
cleanEmptyNotifications() {
|
|
2041
|
-
for (const [sessionID, queue] of this.notifications.entries()) {
|
|
2042
|
-
if (queue.length === 0) {
|
|
2043
|
-
this.notifications.delete(sessionID);
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
clearNotificationsForTask(taskId) {
|
|
2048
|
-
for (const [sessionID, tasks] of this.notifications.entries()) {
|
|
2049
|
-
const filtered = tasks.filter((t) => t.id !== taskId);
|
|
2050
|
-
if (filtered.length === 0) {
|
|
2051
|
-
this.notifications.delete(sessionID);
|
|
2052
|
-
} else if (filtered.length !== tasks.length) {
|
|
2053
|
-
this.notifications.set(sessionID, filtered);
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
// =========================================================================
|
|
2058
|
-
// Garbage Collection & Memory Management
|
|
2059
|
-
// =========================================================================
|
|
2060
|
-
/**
|
|
2061
|
-
* Get memory statistics
|
|
2062
|
-
*/
|
|
2063
|
-
getStats() {
|
|
2064
|
-
return {
|
|
2065
|
-
tasksInMemory: this.tasks.size,
|
|
2066
|
-
runningTasks: this.getRunning().length,
|
|
2067
|
-
archivedTasks: this.archivedCount,
|
|
2068
|
-
notificationQueues: this.notifications.size,
|
|
2069
|
-
pendingParents: this.pendingByParent.size
|
|
2070
|
-
};
|
|
2071
|
-
}
|
|
2072
|
-
/**
|
|
2073
|
-
* Garbage collect completed tasks
|
|
2074
|
-
* Archives old completed tasks to disk
|
|
2075
|
-
*/
|
|
2076
|
-
async gc() {
|
|
2077
|
-
const now = Date.now();
|
|
2078
|
-
const toRemove = [];
|
|
2079
|
-
const toArchive = [];
|
|
2080
|
-
for (const [id, task] of this.tasks) {
|
|
2081
|
-
if (task.status === TASK_STATUS.RUNNING) continue;
|
|
2082
|
-
const completedAt = task.completedAt?.getTime() ?? 0;
|
|
2083
|
-
const age = now - completedAt;
|
|
2084
|
-
if (age > MEMORY_LIMITS.ARCHIVE_AGE_MS && task.status === TASK_STATUS.COMPLETED) {
|
|
2085
|
-
toArchive.push(task);
|
|
2086
|
-
toRemove.push(id);
|
|
2087
|
-
} else if (age > MEMORY_LIMITS.ERROR_CLEANUP_AGE_MS && (task.status === TASK_STATUS.ERROR || task.status === TASK_STATUS.CANCELLED)) {
|
|
2088
|
-
toRemove.push(id);
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
if (toArchive.length > 0) {
|
|
2092
|
-
await this.archiveTasks(toArchive);
|
|
2093
|
-
}
|
|
2094
|
-
for (const id of toRemove) {
|
|
2095
|
-
this.tasks.delete(id);
|
|
2096
|
-
}
|
|
2097
|
-
return toRemove.length;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* Archive tasks to disk for later analysis
|
|
2101
|
-
*/
|
|
2102
|
-
async archiveTasks(tasks) {
|
|
2103
|
-
try {
|
|
2104
|
-
await fs2.mkdir(PATHS.TASK_ARCHIVE, { recursive: true });
|
|
2105
|
-
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2106
|
-
const filename = `tasks_${date5}.jsonl`;
|
|
2107
|
-
const filepath = path2.join(PATHS.TASK_ARCHIVE, filename);
|
|
2108
|
-
const lines = tasks.map((task) => JSON.stringify({
|
|
2109
|
-
id: task.id,
|
|
2110
|
-
agent: task.agent,
|
|
2111
|
-
prompt: task.prompt.slice(0, 200),
|
|
2112
|
-
// Truncate
|
|
2113
|
-
status: task.status,
|
|
2114
|
-
startedAt: task.startedAt,
|
|
2115
|
-
completedAt: task.completedAt,
|
|
2116
|
-
parentSessionID: task.parentSessionID
|
|
2117
|
-
}));
|
|
2118
|
-
await fs2.appendFile(filepath, lines.join("\n") + "\n");
|
|
2119
|
-
this.archivedCount += tasks.length;
|
|
2120
|
-
} catch (error45) {
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
/**
|
|
2124
|
-
* Force cleanup of all completed tasks
|
|
2125
|
-
*/
|
|
2126
|
-
forceCleanup() {
|
|
2127
|
-
const toRemove = [];
|
|
2128
|
-
for (const [id, task] of this.tasks) {
|
|
2129
|
-
if (task.status !== TASK_STATUS.RUNNING) {
|
|
2130
|
-
toRemove.push(id);
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
for (const id of toRemove) {
|
|
2134
|
-
this.tasks.delete(id);
|
|
2135
|
-
}
|
|
2136
|
-
return toRemove.length;
|
|
2137
|
-
}
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
});
|
|
2141
|
-
|
|
2142
|
-
// src/core/agents/format.ts
|
|
2143
|
-
function formatDuration(start, end) {
|
|
2144
|
-
const duration3 = (end ?? /* @__PURE__ */ new Date()).getTime() - start.getTime();
|
|
2145
|
-
const seconds = Math.floor(duration3 / 1e3);
|
|
2146
|
-
const minutes = Math.floor(seconds / 60);
|
|
2147
|
-
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
2148
|
-
return `${seconds}s`;
|
|
2149
|
-
}
|
|
2150
|
-
function buildNotificationMessage(tasks) {
|
|
2151
|
-
const summary = tasks.map((t) => {
|
|
2152
|
-
const status = t.status === TASK_STATUS.COMPLETED ? "\u2705" : "\u274C";
|
|
2153
|
-
return `${status} \`${t.id}\`: ${t.description}`;
|
|
2154
|
-
}).join("\n");
|
|
2155
|
-
return `<system-notification>
|
|
2156
|
-
**All Parallel Tasks Complete**
|
|
2157
|
-
|
|
2158
|
-
${summary}
|
|
2159
|
-
|
|
2160
|
-
Use \`get_task_result({ taskId: "task_xxx" })\` to retrieve results.
|
|
2161
|
-
</system-notification>`;
|
|
2162
|
-
}
|
|
2163
|
-
var init_format = __esm({
|
|
2164
|
-
"src/core/agents/format.ts"() {
|
|
2165
|
-
"use strict";
|
|
2166
|
-
init_shared();
|
|
2167
|
-
}
|
|
2168
|
-
});
|
|
2169
|
-
|
|
2170
|
-
// src/core/notification/toast-core.ts
|
|
2171
|
-
function initToastClient(client) {
|
|
2172
|
-
tuiClient = client;
|
|
2173
|
-
}
|
|
2174
|
-
function show(options) {
|
|
2175
|
-
const toast = {
|
|
2176
|
-
id: `toast_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
|
|
2177
|
-
title: options.title,
|
|
2178
|
-
message: options.message,
|
|
2179
|
-
variant: options.variant || "info",
|
|
2180
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
2181
|
-
duration: options.duration ?? 5e3,
|
|
2182
|
-
dismissed: false
|
|
2183
|
-
};
|
|
2184
|
-
toasts.push(toast);
|
|
2185
|
-
if (toasts.length > HISTORY.MAX_TOAST) {
|
|
2186
|
-
toasts.shift();
|
|
2187
|
-
}
|
|
2188
|
-
for (const handler of handlers) {
|
|
2189
|
-
try {
|
|
2190
|
-
handler(toast);
|
|
2191
|
-
} catch (error45) {
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
if (tuiClient) {
|
|
2195
|
-
const client = tuiClient;
|
|
2196
|
-
if (client.tui?.showToast) {
|
|
2197
|
-
client.tui.showToast({
|
|
2198
|
-
body: {
|
|
2199
|
-
title: toast.title,
|
|
2200
|
-
message: toast.message,
|
|
2201
|
-
variant: toast.variant,
|
|
2202
|
-
duration: toast.duration
|
|
2203
|
-
}
|
|
2204
|
-
}).catch(() => {
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
return toast;
|
|
2209
|
-
}
|
|
2210
|
-
var tuiClient, toasts, handlers;
|
|
2211
|
-
var init_toast_core = __esm({
|
|
2212
|
-
"src/core/notification/toast-core.ts"() {
|
|
2213
|
-
"use strict";
|
|
2214
|
-
init_shared();
|
|
2215
|
-
tuiClient = null;
|
|
2216
|
-
toasts = [];
|
|
2217
|
-
handlers = [];
|
|
2218
|
-
}
|
|
2219
|
-
});
|
|
2220
|
-
|
|
2221
|
-
// src/core/notification/presets/task-lifecycle.ts
|
|
2222
|
-
var taskStarted, taskCompleted, taskFailed, allTasksComplete;
|
|
2223
|
-
var init_task_lifecycle = __esm({
|
|
2224
|
-
"src/core/notification/presets/task-lifecycle.ts"() {
|
|
2225
|
-
"use strict";
|
|
2226
|
-
init_toast_core();
|
|
2227
|
-
taskStarted = (taskId, agent) => show({
|
|
2228
|
-
title: "Task Started",
|
|
2229
|
-
message: `${agent}: ${taskId}`,
|
|
2230
|
-
variant: "info",
|
|
2231
|
-
duration: 3e3
|
|
2232
|
-
});
|
|
2233
|
-
taskCompleted = (taskId, agent) => show({
|
|
2234
|
-
title: "Task Completed",
|
|
2235
|
-
message: `${agent}: ${taskId}`,
|
|
2236
|
-
variant: "success",
|
|
2237
|
-
duration: 3e3
|
|
2238
|
-
});
|
|
2239
|
-
taskFailed = (taskId, error45) => show({
|
|
2240
|
-
title: "Task Failed",
|
|
2241
|
-
message: `${taskId}: ${error45}`,
|
|
2242
|
-
variant: "error",
|
|
2243
|
-
duration: 0
|
|
2244
|
-
});
|
|
2245
|
-
allTasksComplete = (count) => show({
|
|
2246
|
-
title: "All Tasks Complete",
|
|
2247
|
-
message: `${count} tasks finished successfully`,
|
|
2248
|
-
variant: "success",
|
|
2249
|
-
duration: 5e3
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
-
});
|
|
2253
|
-
|
|
2254
|
-
// src/core/notification/presets/session.ts
|
|
2255
|
-
var sessionCreated, sessionResumed, sessionCompleted;
|
|
2256
|
-
var init_session2 = __esm({
|
|
2257
|
-
"src/core/notification/presets/session.ts"() {
|
|
2258
|
-
"use strict";
|
|
2259
|
-
init_toast_core();
|
|
2260
|
-
init_shared();
|
|
2261
|
-
sessionCreated = (sessionId, agent) => show({
|
|
2262
|
-
title: "Session Created",
|
|
2263
|
-
message: `${agent} - ${sessionId.slice(0, 12)}...`,
|
|
2264
|
-
variant: STATUS_LABEL.INFO,
|
|
2265
|
-
duration: TOAST_DURATION.SHORT
|
|
2266
|
-
});
|
|
2267
|
-
sessionResumed = (sessionId, agent) => show({
|
|
2268
|
-
title: "Session Resumed",
|
|
2269
|
-
message: `${agent} - ${sessionId.slice(0, 12)}...`,
|
|
2270
|
-
variant: STATUS_LABEL.INFO,
|
|
2271
|
-
duration: TOAST_DURATION.SHORT
|
|
2272
|
-
});
|
|
2273
|
-
sessionCompleted = (sessionId, duration3) => show({
|
|
2274
|
-
title: "Session Completed",
|
|
2275
|
-
message: `${sessionId.slice(0, 12)}... (${duration3})`,
|
|
2276
|
-
variant: STATUS_LABEL.SUCCESS,
|
|
2277
|
-
duration: TOAST_DURATION.MEDIUM
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
});
|
|
2281
|
-
|
|
2282
|
-
// src/core/notification/presets/parallel.ts
|
|
2283
|
-
var parallelTasksLaunched, concurrencyAcquired, concurrencyReleased;
|
|
2284
|
-
var init_parallel3 = __esm({
|
|
2285
|
-
"src/core/notification/presets/parallel.ts"() {
|
|
2286
|
-
"use strict";
|
|
2287
|
-
init_toast_core();
|
|
2288
|
-
init_shared();
|
|
2289
|
-
parallelTasksLaunched = (count, agents) => show({
|
|
2290
|
-
title: "Parallel Tasks Launched",
|
|
2291
|
-
message: `${count} tasks: ${agents.join(", ")}`,
|
|
2292
|
-
variant: "info",
|
|
2293
|
-
duration: TOAST_DURATION.DEFAULT
|
|
2294
|
-
});
|
|
2295
|
-
concurrencyAcquired = (agent, slot) => show({
|
|
2296
|
-
title: "Concurrency Slot",
|
|
2297
|
-
message: `${agent} acquired ${slot}`,
|
|
2298
|
-
variant: "info",
|
|
2299
|
-
duration: TOAST_DURATION.SHORT
|
|
2300
|
-
});
|
|
2301
|
-
concurrencyReleased = (agent) => show({
|
|
2302
|
-
title: "Slot Released",
|
|
2303
|
-
message: agent,
|
|
2304
|
-
variant: "info",
|
|
2305
|
-
duration: TOAST_DURATION.EXTRA_SHORT
|
|
2306
|
-
});
|
|
2307
|
-
}
|
|
2308
|
-
});
|
|
2309
|
-
|
|
2310
|
-
// src/core/notification/presets/mission.ts
|
|
2311
|
-
var missionComplete, missionStarted;
|
|
2312
|
-
var init_mission = __esm({
|
|
2313
|
-
"src/core/notification/presets/mission.ts"() {
|
|
2314
|
-
"use strict";
|
|
2315
|
-
init_toast_core();
|
|
2316
|
-
missionComplete = (summary) => show({
|
|
2317
|
-
title: "Mission Complete",
|
|
2318
|
-
message: summary,
|
|
2319
|
-
variant: "success",
|
|
2320
|
-
duration: 0
|
|
2321
|
-
});
|
|
2322
|
-
missionStarted = (description) => show({
|
|
2323
|
-
title: "Mission Started",
|
|
2324
|
-
message: description.slice(0, 100),
|
|
2325
|
-
variant: "info",
|
|
2326
|
-
duration: 4e3
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
2330
|
-
|
|
2331
|
-
// src/core/notification/presets/tools.ts
|
|
2332
|
-
var toolExecuted, documentCached, researchStarted;
|
|
2333
|
-
var init_tools = __esm({
|
|
2334
|
-
"src/core/notification/presets/tools.ts"() {
|
|
2335
|
-
"use strict";
|
|
2336
|
-
init_toast_core();
|
|
2337
|
-
init_shared();
|
|
2338
|
-
toolExecuted = (toolName, target) => show({
|
|
2339
|
-
title: toolName,
|
|
2340
|
-
message: target.slice(0, 80),
|
|
2341
|
-
variant: "info",
|
|
2342
|
-
duration: TOAST_DURATION.SHORT
|
|
2343
|
-
});
|
|
2344
|
-
documentCached = (filename) => show({
|
|
2345
|
-
title: "Document Cached",
|
|
2346
|
-
message: `${PATHS.DOCS}/${filename}`,
|
|
2347
|
-
variant: "info",
|
|
2348
|
-
duration: TOAST_DURATION.SHORT
|
|
2349
|
-
});
|
|
2350
|
-
researchStarted = (topic) => show({
|
|
2351
|
-
title: "Research Started",
|
|
2352
|
-
message: topic,
|
|
2353
|
-
variant: "info",
|
|
2354
|
-
duration: TOAST_DURATION.MEDIUM
|
|
2355
|
-
});
|
|
2356
|
-
}
|
|
2357
|
-
});
|
|
2358
|
-
|
|
2359
|
-
// src/core/notification/presets/warnings.ts
|
|
2360
|
-
var warningRateLimited, errorRecovery, warningMaxDepth, warningMaxRetries;
|
|
2361
|
-
var init_warnings = __esm({
|
|
2362
|
-
"src/core/notification/presets/warnings.ts"() {
|
|
2363
|
-
"use strict";
|
|
2364
|
-
init_toast_core();
|
|
2365
|
-
init_shared();
|
|
2366
|
-
warningRateLimited = () => show({
|
|
2367
|
-
title: "Rate Limited",
|
|
2368
|
-
message: "Waiting before retry...",
|
|
2369
|
-
variant: "warning",
|
|
2370
|
-
duration: TOAST_DURATION.LONG
|
|
2371
|
-
});
|
|
2372
|
-
errorRecovery = (action) => show({
|
|
2373
|
-
title: "Error Recovery",
|
|
2374
|
-
message: `Attempting: ${action}`,
|
|
2375
|
-
variant: "warning",
|
|
2376
|
-
duration: TOAST_DURATION.MEDIUM
|
|
2377
|
-
});
|
|
2378
|
-
warningMaxDepth = (depth) => show({
|
|
2379
|
-
title: "Max Depth Reached",
|
|
2380
|
-
message: `Recursion blocked at depth ${depth}`,
|
|
2381
|
-
variant: "warning",
|
|
2382
|
-
duration: TOAST_DURATION.LONG
|
|
2383
|
-
});
|
|
2384
|
-
warningMaxRetries = () => show({
|
|
2385
|
-
title: "Max Retries Exceeded",
|
|
2386
|
-
message: "Automatic recovery has stopped. Manual intervention may be needed.",
|
|
2387
|
-
variant: "error",
|
|
2388
|
-
duration: TOAST_DURATION.PERSISTENT
|
|
2389
|
-
});
|
|
2246
|
+
const limit = this.getConcurrencyLimit(key);
|
|
2247
|
+
if (limit === Infinity) return "";
|
|
2248
|
+
return ` (${active}/${limit} slots)`;
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2390
2251
|
}
|
|
2391
2252
|
});
|
|
2392
2253
|
|
|
2393
|
-
// src/core/
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
documentCached: () => documentCached,
|
|
2400
|
-
errorRecovery: () => errorRecovery,
|
|
2401
|
-
missionComplete: () => missionComplete,
|
|
2402
|
-
missionStarted: () => missionStarted,
|
|
2403
|
-
parallelTasksLaunched: () => parallelTasksLaunched,
|
|
2404
|
-
researchStarted: () => researchStarted,
|
|
2405
|
-
sessionCompleted: () => sessionCompleted,
|
|
2406
|
-
sessionCreated: () => sessionCreated,
|
|
2407
|
-
sessionResumed: () => sessionResumed,
|
|
2408
|
-
taskCompleted: () => taskCompleted,
|
|
2409
|
-
taskFailed: () => taskFailed,
|
|
2410
|
-
taskStarted: () => taskStarted,
|
|
2411
|
-
toolExecuted: () => toolExecuted,
|
|
2412
|
-
warningMaxDepth: () => warningMaxDepth,
|
|
2413
|
-
warningMaxRetries: () => warningMaxRetries,
|
|
2414
|
-
warningRateLimited: () => warningRateLimited
|
|
2415
|
-
});
|
|
2416
|
-
var init_presets = __esm({
|
|
2417
|
-
"src/core/notification/presets/index.ts"() {
|
|
2254
|
+
// src/core/agents/task-store.ts
|
|
2255
|
+
import * as fs2 from "node:fs/promises";
|
|
2256
|
+
import * as path2 from "node:path";
|
|
2257
|
+
var TaskStore;
|
|
2258
|
+
var init_task_store = __esm({
|
|
2259
|
+
"src/core/agents/task-store.ts"() {
|
|
2418
2260
|
"use strict";
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2261
|
+
init_shared();
|
|
2262
|
+
TaskStore = class {
|
|
2263
|
+
tasks = /* @__PURE__ */ new Map();
|
|
2264
|
+
pendingByParent = /* @__PURE__ */ new Map();
|
|
2265
|
+
notifications = /* @__PURE__ */ new Map();
|
|
2266
|
+
archivedCount = 0;
|
|
2267
|
+
set(id, task) {
|
|
2268
|
+
this.tasks.set(id, task);
|
|
2269
|
+
if (this.tasks.size > MEMORY_LIMITS.MAX_TASKS_IN_MEMORY) {
|
|
2270
|
+
this.gc();
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
get(id) {
|
|
2274
|
+
return this.tasks.get(id);
|
|
2275
|
+
}
|
|
2276
|
+
getAll() {
|
|
2277
|
+
return Array.from(this.tasks.values());
|
|
2278
|
+
}
|
|
2279
|
+
getRunning() {
|
|
2280
|
+
return this.getAll().filter((t) => t.status === TASK_STATUS.RUNNING || t.status === TASK_STATUS.PENDING);
|
|
2281
|
+
}
|
|
2282
|
+
getByParent(parentSessionID) {
|
|
2283
|
+
return this.getAll().filter((t) => t.parentSessionID === parentSessionID);
|
|
2284
|
+
}
|
|
2285
|
+
delete(id) {
|
|
2286
|
+
return this.tasks.delete(id);
|
|
2287
|
+
}
|
|
2288
|
+
clear() {
|
|
2289
|
+
this.tasks.clear();
|
|
2290
|
+
this.pendingByParent.clear();
|
|
2291
|
+
this.notifications.clear();
|
|
2292
|
+
}
|
|
2293
|
+
// Pending tracking
|
|
2294
|
+
trackPending(parentSessionID, taskId) {
|
|
2295
|
+
const pending2 = this.pendingByParent.get(parentSessionID) ?? /* @__PURE__ */ new Set();
|
|
2296
|
+
pending2.add(taskId);
|
|
2297
|
+
this.pendingByParent.set(parentSessionID, pending2);
|
|
2298
|
+
}
|
|
2299
|
+
untrackPending(parentSessionID, taskId) {
|
|
2300
|
+
const pending2 = this.pendingByParent.get(parentSessionID);
|
|
2301
|
+
if (pending2) {
|
|
2302
|
+
pending2.delete(taskId);
|
|
2303
|
+
if (pending2.size === 0) {
|
|
2304
|
+
this.pendingByParent.delete(parentSessionID);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
getPendingCount(parentSessionID) {
|
|
2309
|
+
return this.pendingByParent.get(parentSessionID)?.size ?? 0;
|
|
2310
|
+
}
|
|
2311
|
+
hasPending(parentSessionID) {
|
|
2312
|
+
return this.getPendingCount(parentSessionID) > 0;
|
|
2313
|
+
}
|
|
2314
|
+
// Notifications with limit
|
|
2315
|
+
queueNotification(task) {
|
|
2316
|
+
const queue = this.notifications.get(task.parentSessionID) ?? [];
|
|
2317
|
+
queue.push(task);
|
|
2318
|
+
if (queue.length > MEMORY_LIMITS.MAX_NOTIFICATIONS_PER_PARENT) {
|
|
2319
|
+
queue.shift();
|
|
2320
|
+
}
|
|
2321
|
+
this.notifications.set(task.parentSessionID, queue);
|
|
2322
|
+
}
|
|
2323
|
+
getNotifications(parentSessionID) {
|
|
2324
|
+
return this.notifications.get(parentSessionID) ?? [];
|
|
2325
|
+
}
|
|
2326
|
+
clearNotifications(parentSessionID) {
|
|
2327
|
+
this.notifications.delete(parentSessionID);
|
|
2328
|
+
}
|
|
2329
|
+
cleanEmptyNotifications() {
|
|
2330
|
+
for (const [sessionID, queue] of this.notifications.entries()) {
|
|
2331
|
+
if (queue.length === 0) {
|
|
2332
|
+
this.notifications.delete(sessionID);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
clearNotificationsForTask(taskId) {
|
|
2337
|
+
for (const [sessionID, tasks] of this.notifications.entries()) {
|
|
2338
|
+
const filtered = tasks.filter((t) => t.id !== taskId);
|
|
2339
|
+
if (filtered.length === 0) {
|
|
2340
|
+
this.notifications.delete(sessionID);
|
|
2341
|
+
} else if (filtered.length !== tasks.length) {
|
|
2342
|
+
this.notifications.set(sessionID, filtered);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
// =========================================================================
|
|
2347
|
+
// Garbage Collection & Memory Management
|
|
2348
|
+
// =========================================================================
|
|
2349
|
+
/**
|
|
2350
|
+
* Get memory statistics
|
|
2351
|
+
*/
|
|
2352
|
+
getStats() {
|
|
2353
|
+
return {
|
|
2354
|
+
tasksInMemory: this.tasks.size,
|
|
2355
|
+
runningTasks: this.getRunning().length,
|
|
2356
|
+
archivedTasks: this.archivedCount,
|
|
2357
|
+
notificationQueues: this.notifications.size,
|
|
2358
|
+
pendingParents: this.pendingByParent.size
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Garbage collect completed tasks
|
|
2363
|
+
* Archives old completed tasks to disk
|
|
2364
|
+
*/
|
|
2365
|
+
async gc() {
|
|
2366
|
+
const now = Date.now();
|
|
2367
|
+
const toRemove = [];
|
|
2368
|
+
const toArchive = [];
|
|
2369
|
+
for (const [id, task] of this.tasks) {
|
|
2370
|
+
if (task.status === TASK_STATUS.RUNNING) continue;
|
|
2371
|
+
const completedAt = task.completedAt?.getTime() ?? 0;
|
|
2372
|
+
const age = now - completedAt;
|
|
2373
|
+
if (age > MEMORY_LIMITS.ARCHIVE_AGE_MS && task.status === TASK_STATUS.COMPLETED) {
|
|
2374
|
+
toArchive.push(task);
|
|
2375
|
+
toRemove.push(id);
|
|
2376
|
+
} else if (age > MEMORY_LIMITS.ERROR_CLEANUP_AGE_MS && (task.status === TASK_STATUS.ERROR || task.status === TASK_STATUS.CANCELLED)) {
|
|
2377
|
+
toRemove.push(id);
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
if (toArchive.length > 0) {
|
|
2381
|
+
await this.archiveTasks(toArchive);
|
|
2382
|
+
}
|
|
2383
|
+
for (const id of toRemove) {
|
|
2384
|
+
this.tasks.delete(id);
|
|
2385
|
+
}
|
|
2386
|
+
return toRemove.length;
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Archive tasks to disk for later analysis
|
|
2390
|
+
*/
|
|
2391
|
+
async archiveTasks(tasks) {
|
|
2392
|
+
try {
|
|
2393
|
+
await fs2.mkdir(PATHS.TASK_ARCHIVE, { recursive: true });
|
|
2394
|
+
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2395
|
+
const filename = `tasks_${date5}.jsonl`;
|
|
2396
|
+
const filepath = path2.join(PATHS.TASK_ARCHIVE, filename);
|
|
2397
|
+
const lines = tasks.map((task) => JSON.stringify({
|
|
2398
|
+
id: task.id,
|
|
2399
|
+
agent: task.agent,
|
|
2400
|
+
prompt: task.prompt.slice(0, 200),
|
|
2401
|
+
// Truncate
|
|
2402
|
+
status: task.status,
|
|
2403
|
+
startedAt: task.startedAt,
|
|
2404
|
+
completedAt: task.completedAt,
|
|
2405
|
+
parentSessionID: task.parentSessionID
|
|
2406
|
+
}));
|
|
2407
|
+
await fs2.appendFile(filepath, lines.join("\n") + "\n");
|
|
2408
|
+
this.archivedCount += tasks.length;
|
|
2409
|
+
} catch (error45) {
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Force cleanup of all completed tasks
|
|
2414
|
+
*/
|
|
2415
|
+
forceCleanup() {
|
|
2416
|
+
const toRemove = [];
|
|
2417
|
+
for (const [id, task] of this.tasks) {
|
|
2418
|
+
if (task.status !== TASK_STATUS.RUNNING) {
|
|
2419
|
+
toRemove.push(id);
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
for (const id of toRemove) {
|
|
2423
|
+
this.tasks.delete(id);
|
|
2424
|
+
}
|
|
2425
|
+
return toRemove.length;
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2425
2428
|
}
|
|
2426
2429
|
});
|
|
2427
2430
|
|
|
2428
|
-
// src/core/
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2431
|
+
// src/core/agents/format.ts
|
|
2432
|
+
function formatDuration(start, end) {
|
|
2433
|
+
const duration3 = (end ?? /* @__PURE__ */ new Date()).getTime() - start.getTime();
|
|
2434
|
+
const seconds = Math.floor(duration3 / 1e3);
|
|
2435
|
+
const minutes = Math.floor(seconds / 60);
|
|
2436
|
+
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
2437
|
+
return `${seconds}s`;
|
|
2438
|
+
}
|
|
2439
|
+
function buildNotificationMessage(tasks) {
|
|
2440
|
+
const summary = tasks.map((t) => {
|
|
2441
|
+
const status = t.status === TASK_STATUS.COMPLETED ? "\u2705" : "\u274C";
|
|
2442
|
+
return `${status} \`${t.id}\`: ${t.description}`;
|
|
2443
|
+
}).join("\n");
|
|
2444
|
+
return `<system-notification>
|
|
2445
|
+
**All Parallel Tasks Complete**
|
|
2446
|
+
|
|
2447
|
+
${summary}
|
|
2448
|
+
|
|
2449
|
+
Use \`get_task_result({ taskId: "task_xxx" })\` to retrieve results.
|
|
2450
|
+
</system-notification>`;
|
|
2451
|
+
}
|
|
2452
|
+
var init_format = __esm({
|
|
2453
|
+
"src/core/agents/format.ts"() {
|
|
2432
2454
|
"use strict";
|
|
2433
|
-
|
|
2434
|
-
presets = presets_exports;
|
|
2455
|
+
init_shared();
|
|
2435
2456
|
}
|
|
2436
2457
|
});
|
|
2437
2458
|
|
|
@@ -2529,6 +2550,9 @@ var init_task_toast_manager = __esm({
|
|
|
2529
2550
|
const hours = Math.floor(minutes / 60);
|
|
2530
2551
|
return `${hours}h ${minutes % 60}m`;
|
|
2531
2552
|
}
|
|
2553
|
+
/**
|
|
2554
|
+
* Get concurrency info string (e.g., " [2/5]")
|
|
2555
|
+
*/
|
|
2532
2556
|
/**
|
|
2533
2557
|
* Get concurrency info string (e.g., " [2/5]")
|
|
2534
2558
|
*/
|
|
@@ -2536,10 +2560,12 @@ var init_task_toast_manager = __esm({
|
|
|
2536
2560
|
if (!this.concurrency) return "";
|
|
2537
2561
|
const running = this.getRunningTasks();
|
|
2538
2562
|
const queued = this.getQueuedTasks();
|
|
2539
|
-
const total = running.length
|
|
2563
|
+
const total = running.length;
|
|
2540
2564
|
const limit = this.concurrency.getConcurrencyLimit("default");
|
|
2541
2565
|
if (limit === Infinity) return "";
|
|
2542
|
-
|
|
2566
|
+
const filled = TUI_BLOCKS.FILLED.repeat(total);
|
|
2567
|
+
const empty = TUI_BLOCKS.EMPTY.repeat(Math.max(0, limit - total));
|
|
2568
|
+
return ` [${filled}${empty} ${total}/${limit}]`;
|
|
2543
2569
|
}
|
|
2544
2570
|
/**
|
|
2545
2571
|
* Build consolidated task list message
|
|
@@ -2550,19 +2576,19 @@ var init_task_toast_manager = __esm({
|
|
|
2550
2576
|
const concurrencyInfo = this.getConcurrencyInfo();
|
|
2551
2577
|
const lines = [];
|
|
2552
2578
|
if (running.length > 0) {
|
|
2553
|
-
lines.push(
|
|
2579
|
+
lines.push(`${TUI_ICONS.RUNNING} Running (${running.length}) ${concurrencyInfo}`);
|
|
2554
2580
|
for (const task of running) {
|
|
2555
2581
|
const duration3 = this.formatDuration(task.startedAt);
|
|
2556
|
-
const bgTag = task.isBackground ?
|
|
2557
|
-
const isNew = newTask && task.id === newTask.id ?
|
|
2582
|
+
const bgTag = task.isBackground ? TUI_TAGS.BACKGROUND : TUI_TAGS.FOREGROUND;
|
|
2583
|
+
const isNew = newTask && task.id === newTask.id ? TUI_ICONS.NEW : "";
|
|
2558
2584
|
lines.push(`${bgTag} ${task.description} (${task.agent}) - ${duration3}${isNew}`);
|
|
2559
2585
|
}
|
|
2560
2586
|
}
|
|
2561
2587
|
if (queued.length > 0) {
|
|
2562
2588
|
if (lines.length > 0) lines.push("");
|
|
2563
|
-
lines.push(
|
|
2589
|
+
lines.push(`${TUI_ICONS.QUEUED} Queued (${queued.length}):`);
|
|
2564
2590
|
for (const task of queued) {
|
|
2565
|
-
const bgTag = task.isBackground ?
|
|
2591
|
+
const bgTag = task.isBackground ? TUI_TAGS.WAITING : TUI_TAGS.PENDING;
|
|
2566
2592
|
lines.push(`${bgTag} ${task.description} (${task.agent})`);
|
|
2567
2593
|
}
|
|
2568
2594
|
}
|
|
@@ -2649,6 +2675,31 @@ ${taskList}`,
|
|
|
2649
2675
|
}).catch(() => {
|
|
2650
2676
|
});
|
|
2651
2677
|
}
|
|
2678
|
+
/**
|
|
2679
|
+
* Show Mission Sealed toast (Grand Finale)
|
|
2680
|
+
*/
|
|
2681
|
+
showMissionSealedToast(title = "Mission Sealed", message = "All tasks completed successfully.") {
|
|
2682
|
+
if (!this.client) return;
|
|
2683
|
+
const tuiClient2 = this.client;
|
|
2684
|
+
if (!tuiClient2.tui?.showToast) return;
|
|
2685
|
+
const decoratedMessage = `
|
|
2686
|
+
${TUI_ICONS.MISSION_SEALED} ${TUI_MESSAGES.MISSION_SEALED_TITLE} ${TUI_ICONS.MISSION_SEALED}
|
|
2687
|
+
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2688
|
+
${message}
|
|
2689
|
+
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2690
|
+
${TUI_MESSAGES.MISSION_SEALED_SUBTITLE}
|
|
2691
|
+
`.trim();
|
|
2692
|
+
tuiClient2.tui.showToast({
|
|
2693
|
+
body: {
|
|
2694
|
+
title: `${TUI_ICONS.SHIELD} ${title}`,
|
|
2695
|
+
message: decoratedMessage,
|
|
2696
|
+
variant: "success",
|
|
2697
|
+
duration: 1e4
|
|
2698
|
+
// Longer duration for the finale
|
|
2699
|
+
}
|
|
2700
|
+
}).catch(() => {
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2652
2703
|
/**
|
|
2653
2704
|
* Show progress toast (for long-running tasks)
|
|
2654
2705
|
*/
|
|
@@ -2797,7 +2848,7 @@ var init_task_launcher = __esm({
|
|
|
2797
2848
|
"src/core/agents/manager/task-launcher.ts"() {
|
|
2798
2849
|
"use strict";
|
|
2799
2850
|
init_shared();
|
|
2800
|
-
|
|
2851
|
+
init_shared();
|
|
2801
2852
|
init_task_toast_manager();
|
|
2802
2853
|
init_task_wal();
|
|
2803
2854
|
TaskLauncher = class {
|
|
@@ -2888,7 +2939,7 @@ var init_task_launcher = __esm({
|
|
|
2888
2939
|
sessionID
|
|
2889
2940
|
});
|
|
2890
2941
|
}
|
|
2891
|
-
|
|
2942
|
+
presets_exports.sessionCreated(sessionID, input.agent);
|
|
2892
2943
|
return task;
|
|
2893
2944
|
}
|
|
2894
2945
|
/**
|
|
@@ -3013,7 +3064,7 @@ var init_task_poller = __esm({
|
|
|
3013
3064
|
init_config();
|
|
3014
3065
|
init_logger();
|
|
3015
3066
|
init_format();
|
|
3016
|
-
|
|
3067
|
+
init_shared();
|
|
3017
3068
|
init_shared();
|
|
3018
3069
|
init_task_wal();
|
|
3019
3070
|
TaskPoller = class {
|
|
@@ -3112,7 +3163,7 @@ var init_task_poller = __esm({
|
|
|
3112
3163
|
Promise.resolve(this.onTaskComplete(task)).catch((err) => log("Error in onTaskComplete callback:", err));
|
|
3113
3164
|
}
|
|
3114
3165
|
const duration3 = formatDuration(task.startedAt, task.completedAt);
|
|
3115
|
-
|
|
3166
|
+
presets_exports.sessionCompleted(task.sessionID, duration3);
|
|
3116
3167
|
log(`Completed ${task.id} (${duration3})`);
|
|
3117
3168
|
}
|
|
3118
3169
|
async updateTaskProgress(task) {
|
|
@@ -19093,7 +19144,7 @@ init_manager();
|
|
|
19093
19144
|
|
|
19094
19145
|
// src/tools/parallel/delegate-task.ts
|
|
19095
19146
|
init_logger();
|
|
19096
|
-
|
|
19147
|
+
init_shared();
|
|
19097
19148
|
init_shared();
|
|
19098
19149
|
var MIN_IDLE_TIME_MS = PARALLEL_TASK.MIN_IDLE_TIME_MS;
|
|
19099
19150
|
var POLL_INTERVAL_MS = PARALLEL_TASK.POLL_INTERVAL_MS;
|
|
@@ -19316,7 +19367,7 @@ ${text || "(No output)"}`;
|
|
|
19316
19367
|
depth: parentDepth
|
|
19317
19368
|
});
|
|
19318
19369
|
const task = Array.isArray(launchResult) ? launchResult[0] : launchResult;
|
|
19319
|
-
|
|
19370
|
+
presets_exports.taskStarted(task.id, agent);
|
|
19320
19371
|
return `${OUTPUT_LABEL.SPAWNED} task: \`${task.id}\` (${agent})
|
|
19321
19372
|
Session: \`${task.sessionID}\` (save for resume)`;
|
|
19322
19373
|
} catch (error45) {
|
|
@@ -20314,7 +20365,7 @@ init_shared();
|
|
|
20314
20365
|
|
|
20315
20366
|
// src/core/notification/toast.ts
|
|
20316
20367
|
init_toast_core();
|
|
20317
|
-
|
|
20368
|
+
init_shared();
|
|
20318
20369
|
init_task_toast_manager();
|
|
20319
20370
|
|
|
20320
20371
|
// src/hooks/registry.ts
|
|
@@ -21034,11 +21085,19 @@ var MissionControlHook = class {
|
|
|
21034
21085
|
if (detectSealInText(finalText)) {
|
|
21035
21086
|
log(MISSION_MESSAGES.SEAL_LOG);
|
|
21036
21087
|
clearLoopState(directory);
|
|
21037
|
-
|
|
21038
|
-
|
|
21039
|
-
|
|
21040
|
-
|
|
21041
|
-
|
|
21088
|
+
const toastManager = getTaskToastManager();
|
|
21089
|
+
if (toastManager) {
|
|
21090
|
+
toastManager.showMissionSealedToast(
|
|
21091
|
+
MISSION_MESSAGES.TOAST_COMPLETE_TITLE,
|
|
21092
|
+
MISSION_MESSAGES.TOAST_COMPLETE_MESSAGE
|
|
21093
|
+
);
|
|
21094
|
+
} else {
|
|
21095
|
+
await show({
|
|
21096
|
+
title: MISSION_MESSAGES.TOAST_COMPLETE_TITLE,
|
|
21097
|
+
message: MISSION_MESSAGES.TOAST_COMPLETE_MESSAGE,
|
|
21098
|
+
variant: "success"
|
|
21099
|
+
});
|
|
21100
|
+
}
|
|
21042
21101
|
return { action: HOOK_ACTIONS.STOP, reason: "Mission Sealed" };
|
|
21043
21102
|
}
|
|
21044
21103
|
const now = Date.now();
|
|
@@ -21402,7 +21461,7 @@ init_manager();
|
|
|
21402
21461
|
// src/core/recovery/session-recovery.ts
|
|
21403
21462
|
init_shared();
|
|
21404
21463
|
init_logger();
|
|
21405
|
-
|
|
21464
|
+
init_shared();
|
|
21406
21465
|
|
|
21407
21466
|
// src/core/recovery/constants.ts
|
|
21408
21467
|
init_shared();
|
|
@@ -21418,7 +21477,7 @@ var errorPatterns = [
|
|
|
21418
21477
|
category: "rate_limit",
|
|
21419
21478
|
handler: (ctx) => {
|
|
21420
21479
|
const delay = BASE_DELAY * Math.pow(2, ctx.attempt);
|
|
21421
|
-
|
|
21480
|
+
presets_exports.warningRateLimited();
|
|
21422
21481
|
return { type: "retry", delay, attempt: ctx.attempt + 1 };
|
|
21423
21482
|
}
|
|
21424
21483
|
},
|
|
@@ -21427,7 +21486,7 @@ var errorPatterns = [
|
|
|
21427
21486
|
pattern: /context.?length|token.?limit|maximum.?context/i,
|
|
21428
21487
|
category: "context_overflow",
|
|
21429
21488
|
handler: () => {
|
|
21430
|
-
|
|
21489
|
+
presets_exports.errorRecovery("Compacting context");
|
|
21431
21490
|
return { type: "compact", reason: "Context limit reached" };
|
|
21432
21491
|
}
|
|
21433
21492
|
},
|
|
@@ -21474,7 +21533,7 @@ var errorPatterns = [
|
|
|
21474
21533
|
pattern: /gibberish|hallucination|mixed.?language/i,
|
|
21475
21534
|
category: "gibberish",
|
|
21476
21535
|
handler: () => {
|
|
21477
|
-
|
|
21536
|
+
presets_exports.errorRecovery("Retrying with clean context");
|
|
21478
21537
|
return { type: "retry", delay: 1e3, attempt: 1 };
|
|
21479
21538
|
}
|
|
21480
21539
|
}
|
|
@@ -21561,7 +21620,7 @@ async function handleSessionError(client, sessionID, error45, properties) {
|
|
|
21561
21620
|
log("[session-recovery] Detected error type", { sessionID, errorType, errorCount: state2.errorCount });
|
|
21562
21621
|
if (state2.errorCount > RECOVERY.MAX_ATTEMPTS) {
|
|
21563
21622
|
log("[session-recovery] Max recovery attempts exceeded", { sessionID });
|
|
21564
|
-
|
|
21623
|
+
presets_exports.warningMaxRetries();
|
|
21565
21624
|
return false;
|
|
21566
21625
|
}
|
|
21567
21626
|
state2.isRecovering = true;
|
|
@@ -21605,7 +21664,7 @@ async function handleSessionError(client, sessionID, error45, properties) {
|
|
|
21605
21664
|
return false;
|
|
21606
21665
|
}
|
|
21607
21666
|
if (recoveryPrompt && toastMessage) {
|
|
21608
|
-
|
|
21667
|
+
presets_exports.errorRecovery(toastMessage);
|
|
21609
21668
|
await client.session.prompt({
|
|
21610
21669
|
path: { id: sessionID },
|
|
21611
21670
|
body: {
|
|
@@ -22451,7 +22510,7 @@ function createEventHandler(ctx) {
|
|
|
22451
22510
|
}
|
|
22452
22511
|
if (event.type === SESSION_EVENTS.CREATED) {
|
|
22453
22512
|
const sessionID = event.properties?.id || "";
|
|
22454
|
-
|
|
22513
|
+
presets_exports.missionStarted(`Session ${sessionID.slice(0, 12)}...`);
|
|
22455
22514
|
}
|
|
22456
22515
|
if (event.type === SESSION_EVENTS.DELETED) {
|
|
22457
22516
|
const sessionID = event.properties?.id || event.properties?.info?.id || "";
|
|
@@ -22466,7 +22525,7 @@ function createEventHandler(ctx) {
|
|
|
22466
22525
|
cleanupSession2(sessionID);
|
|
22467
22526
|
cleanupSession3(sessionID);
|
|
22468
22527
|
cleanupSession(sessionID);
|
|
22469
|
-
|
|
22528
|
+
presets_exports.sessionCompleted(sessionID, duration3);
|
|
22470
22529
|
}
|
|
22471
22530
|
}
|
|
22472
22531
|
if (event.type === SESSION_EVENTS.ERROR) {
|
|
@@ -22485,7 +22544,7 @@ function createEventHandler(ctx) {
|
|
|
22485
22544
|
);
|
|
22486
22545
|
if (recovered) return;
|
|
22487
22546
|
}
|
|
22488
|
-
|
|
22547
|
+
presets_exports.taskFailed("session", String(error45).slice(0, 50));
|
|
22489
22548
|
}
|
|
22490
22549
|
if (event.type === MESSAGE_EVENTS.UPDATED) {
|
|
22491
22550
|
const messageProperties = event.properties;
|