0xkobold 0.4.3 → 0.5.0
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 +226 -383
- package/dist/package.json +13 -4
- package/dist/src/agent/DraconicCapabilityRouter.js +556 -0
- package/dist/src/agent/DraconicCapabilityRouter.js.map +1 -0
- package/dist/src/agent/DraconicErrorClassifier.js +606 -0
- package/dist/src/agent/DraconicErrorClassifier.js.map +1 -0
- package/dist/src/agent/DraconicRunRegistry.js +460 -0
- package/dist/src/agent/DraconicRunRegistry.js.map +1 -0
- package/dist/src/agent/DraconicTokenPredictor.js +500 -0
- package/dist/src/agent/DraconicTokenPredictor.js.map +1 -0
- package/dist/src/agent/embedded-runner.js +3 -2
- package/dist/src/agent/embedded-runner.js.map +1 -1
- package/dist/src/cli/commands/doctor.js +199 -0
- package/dist/src/cli/commands/doctor.js.map +1 -0
- package/dist/src/cli/commands/migrate-from-openclaw.js +39 -0
- package/dist/src/cli/commands/migrate-from-openclaw.js.map +1 -0
- package/dist/src/cli/commands/migrate.js +6 -4
- package/dist/src/cli/commands/migrate.js.map +1 -1
- package/dist/src/cli/program.js +3 -1
- package/dist/src/cli/program.js.map +1 -1
- package/dist/src/config/unified-config.js +195 -0
- package/dist/src/config/unified-config.js.map +1 -0
- package/dist/src/cron/notifications.js +1 -1
- package/dist/src/cron/notifications.js.map +1 -1
- package/dist/src/cron/runner.js +9 -3
- package/dist/src/cron/runner.js.map +1 -1
- package/dist/src/event-bus/index.js +3 -1
- package/dist/src/event-bus/index.js.map +1 -1
- package/dist/src/extensions/community/draconic-messenger-wrapper.js +35 -0
- package/dist/src/extensions/community/draconic-messenger-wrapper.js.map +1 -0
- package/dist/src/extensions/community/draconic-subagents-wrapper.js +115 -0
- package/dist/src/extensions/community/draconic-subagents-wrapper.js.map +1 -0
- package/dist/src/extensions/core/compaction-safeguard-v2.js +95 -0
- package/dist/src/extensions/core/compaction-safeguard-v2.js.map +1 -0
- package/dist/src/extensions/core/compaction-safeguard.js +206 -137
- package/dist/src/extensions/core/compaction-safeguard.js.map +1 -1
- package/dist/src/extensions/core/config-extension.js +122 -0
- package/dist/src/extensions/core/config-extension.js.map +1 -0
- package/dist/src/extensions/core/draconic-hoard-extension.js +194 -0
- package/dist/src/extensions/core/draconic-hoard-extension.js.map +1 -0
- package/dist/src/extensions/core/draconic-lair-extension.js +146 -0
- package/dist/src/extensions/core/draconic-lair-extension.js.map +1 -0
- package/dist/src/extensions/core/draconic-safety-extension.js +402 -0
- package/dist/src/extensions/core/draconic-safety-extension.js.map +1 -0
- package/dist/src/extensions/core/ext-manager.js +40 -0
- package/dist/src/extensions/core/ext-manager.js.map +1 -0
- package/dist/src/extensions/core/gateway-extension.js +413 -624
- package/dist/src/extensions/core/gateway-extension.js.map +1 -1
- package/dist/src/extensions/core/generative-agents-extension.js +704 -0
- package/dist/src/extensions/core/generative-agents-extension.js.map +1 -0
- package/dist/src/extensions/core/memory-bootstrap-extension.js +279 -0
- package/dist/src/extensions/core/memory-bootstrap-extension.js.map +1 -0
- package/dist/src/extensions/core/ollama-extension.js +442 -0
- package/dist/src/extensions/core/ollama-extension.js.map +1 -0
- package/dist/src/extensions/core/ollama-router-extension.js +34 -93
- package/dist/src/extensions/core/ollama-router-extension.js.map +1 -1
- package/dist/src/extensions/core/perennial-memory-extension.js +5 -2
- package/dist/src/extensions/core/perennial-memory-extension.js.map +1 -1
- package/dist/src/extensions/core/persona-loader-extension.js +41 -15
- package/dist/src/extensions/core/persona-loader-extension.js.map +1 -1
- package/dist/src/extensions/core/pi-notify-extension.js +6 -0
- package/dist/src/extensions/core/pi-notify-extension.js.map +1 -1
- package/dist/src/extensions/core/session-bridge-extension.js +8 -72
- package/dist/src/extensions/core/session-bridge-extension.js.map +1 -1
- package/dist/src/extensions/core/tui-integration-extension-fixed.js +3 -0
- package/dist/src/extensions/core/tui-integration-extension-fixed.js.map +1 -0
- package/dist/src/extensions/core/tui-integration-extension.js +984 -0
- package/dist/src/extensions/core/tui-integration-extension.js.map +1 -0
- package/dist/src/gateway/persistence/AgentStore.js +399 -0
- package/dist/src/gateway/persistence/AgentStore.js.map +1 -0
- package/dist/src/gateway/persistence/index.js +9 -0
- package/dist/src/gateway/persistence/index.js.map +1 -0
- package/dist/src/hoard/DraconicHoardSystem.js +465 -0
- package/dist/src/hoard/DraconicHoardSystem.js.map +1 -0
- package/dist/src/index.js +7 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/infra/DraconicConnectionPool.js +492 -0
- package/dist/src/infra/DraconicConnectionPool.js.map +1 -0
- package/dist/src/lair/DraconicLairSystem.js +387 -0
- package/dist/src/lair/DraconicLairSystem.js.map +1 -0
- package/dist/src/llm/ollama.js +143 -99
- package/dist/src/llm/ollama.js.map +1 -1
- package/dist/src/migration/openclaw.js +5 -5
- package/dist/src/migration/openclaw.js.map +1 -1
- package/dist/src/pi-config.js +52 -27
- package/dist/src/pi-config.js.map +1 -1
- package/dist/src/sessions/SessionManager.js +416 -0
- package/dist/src/sessions/SessionManager.js.map +1 -0
- package/dist/src/sessions/SessionStore.js +580 -0
- package/dist/src/sessions/SessionStore.js.map +1 -0
- package/dist/src/sessions/UnifiedSessionBridge.js +394 -0
- package/dist/src/sessions/UnifiedSessionBridge.js.map +1 -0
- package/dist/src/sessions/index.js +15 -0
- package/dist/src/sessions/index.js.map +1 -0
- package/dist/src/sessions/migration/index.js +156 -0
- package/dist/src/sessions/migration/index.js.map +1 -0
- package/dist/src/sessions/types.js +8 -0
- package/dist/src/sessions/types.js.map +1 -0
- package/dist/src/skills/framework.js +1 -1
- package/dist/src/skills/framework.js.map +1 -1
- package/dist/src/tui/commands/final-functions.js +39 -0
- package/dist/src/tui/commands/final-functions.js.map +1 -0
- package/dist/src/tui/commands/natural-language-commands.js +231 -0
- package/dist/src/tui/commands/natural-language-commands.js.map +1 -0
- package/dist/src/tui/commands/orchestration-commands.js +340 -0
- package/dist/src/tui/commands/orchestration-commands.js.map +1 -0
- package/dist/src/tui/commands/orchestration-final-section.js +84 -0
- package/dist/src/tui/commands/orchestration-final-section.js.map +1 -0
- package/dist/src/tui/components/agent-tree-overlay.js +210 -0
- package/dist/src/tui/components/agent-tree-overlay.js.map +1 -0
- package/dist/src/tui/components/agent-tree-panel.js +229 -0
- package/dist/src/tui/components/agent-tree-panel.js.map +1 -0
- package/dist/src/tui/components/sidebar.js +82 -0
- package/dist/src/tui/components/sidebar.js.map +1 -0
- package/dist/src/tui/components/status-bar.js +115 -0
- package/dist/src/tui/components/status-bar.js.map +1 -0
- package/dist/src/tui/components/tree-header.js +85 -0
- package/dist/src/tui/components/tree-header.js.map +1 -0
- package/dist/src/tui/draconic-tui.js +291 -0
- package/dist/src/tui/draconic-tui.js.map +1 -0
- package/dist/src/tui/index.js +93 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/pi-tui-integration.js +260 -0
- package/dist/src/tui/pi-tui-integration.js.map +1 -0
- package/dist/src/utils/nl-patterns.js +145 -0
- package/dist/src/utils/nl-patterns.js.map +1 -0
- package/package.json +13 -4
- package/scripts/migrate-from-openclaw.sh +498 -0
- package/HEARTBEAT.md +0 -121
- package/USAGE.md +0 -191
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Command: /agent-cleanup (Meta-agent pattern!)
|
|
3
|
+
// ============================================================================
|
|
4
|
+
const AgentCleanupCommand = {
|
|
5
|
+
name: "agent-cleanup",
|
|
6
|
+
aliases: ["/cleanup"],
|
|
7
|
+
description: "Spawn cleanup subagent to remove stale completed agents",
|
|
8
|
+
usage: "/agent-cleanup [--dry-run] [--target=stale|artifacts|all]",
|
|
9
|
+
hasArgument: false,
|
|
10
|
+
async execute(ctx, args) {
|
|
11
|
+
const dryRun = args?.includes("--dry-run") || args?.includes("-n");
|
|
12
|
+
const targetMatch = args?.match(/--target=(stale|artifacts|all)/);
|
|
13
|
+
const target = targetMatch?.[1] || "all";
|
|
14
|
+
ctx.chatLog.addSystem(`🧹 Spawning cleanup subagent (target: ${target}, dry-run: ${dryRun})...`);
|
|
15
|
+
try {
|
|
16
|
+
const result = await ctx.tui.spawnSubagent({
|
|
17
|
+
type: "specialist",
|
|
18
|
+
task: `Run agent cleanup: target=${target}, dryRun=${dryRun}. Use agentCleanup skill with proper retention policy.`,
|
|
19
|
+
strategy: "fast",
|
|
20
|
+
});
|
|
21
|
+
if (result.status === "running" || result.status === "completed") {
|
|
22
|
+
ctx.chatLog.addSystem(`🧹 Cleanup subagent spawned: ${result.runId?.slice(-8)}`);
|
|
23
|
+
ctx.chatLog.addSystem("The specialist will auto-report back when complete.");
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
ctx.chatLog.addSystem(`❌ Failed to spawn cleanup`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
ctx.chatLog.addSystem(`❌ Error: ${err}`);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Export all commands
|
|
36
|
+
// ============================================================================
|
|
37
|
+
export const OrchestrationCommands = [
|
|
38
|
+
AgentSpawnCommand,
|
|
39
|
+
AgentTreeCommand,
|
|
40
|
+
AgentResultCommand,
|
|
41
|
+
AgentKillCommand,
|
|
42
|
+
AgentStatusCommand,
|
|
43
|
+
AgentsCommand,
|
|
44
|
+
AgentCleanupCommand,
|
|
45
|
+
];
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Command Handlers Factory
|
|
48
|
+
// ============================================================================
|
|
49
|
+
export function createOrchestrationCommandHandlers(ctx) {
|
|
50
|
+
const handlers = new Map();
|
|
51
|
+
for (const cmd of OrchestrationCommands) {
|
|
52
|
+
handlers.set(cmd.name, cmd);
|
|
53
|
+
if (cmd.aliases) {
|
|
54
|
+
for (const alias of cmd.aliases) {
|
|
55
|
+
handlers.set(alias, cmd);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
handleCommand(input) {
|
|
61
|
+
const match = input.match(/^\/?([\w-]+)(?:\s+(.*))?$/);
|
|
62
|
+
if (!match)
|
|
63
|
+
return null;
|
|
64
|
+
const [, name, args] = match;
|
|
65
|
+
const cmd = handlers.get(name) || handlers.get("/" + name);
|
|
66
|
+
if (!cmd)
|
|
67
|
+
return null;
|
|
68
|
+
if (cmd.hasArgument && !args?.trim()) {
|
|
69
|
+
ctx.chatLog.addSystem(`Usage: ${cmd.usage || `/${cmd.name} <argument>`}`);
|
|
70
|
+
return Promise.resolve();
|
|
71
|
+
}
|
|
72
|
+
return cmd.execute(ctx, args);
|
|
73
|
+
},
|
|
74
|
+
getCommands() {
|
|
75
|
+
return OrchestrationCommands;
|
|
76
|
+
},
|
|
77
|
+
getHelp() {
|
|
78
|
+
return OrchestrationCommands
|
|
79
|
+
.map(c => `/${c.name} - ${c.description}`)
|
|
80
|
+
.join("\n");
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=orchestration-final-section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-final-section.js","sourceRoot":"","sources":["../../../../src/tui/commands/orchestration-final-section.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gDAAgD;AAChD,+EAA+E;AAE/E,MAAM,mBAAmB,GAAiB;IACxC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE,2DAA2D;IAClE,WAAW,EAAE,KAAK;IAElB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI;QACrB,MAAM,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,IAAI,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAClE,MAAM,MAAM,GAA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AI,CAAC,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🐉 Draconic Agent Tree Overlay (for TUI)
|
|
3
|
+
*
|
|
4
|
+
* Interactive agent hierarchy visualization.
|
|
5
|
+
* Shows: tree view, status, actions (kill, view result, restart)
|
|
6
|
+
*
|
|
7
|
+
* Uses pi-tui component patterns for overlay rendering.
|
|
8
|
+
*/
|
|
9
|
+
export class AgentTreeOverlay {
|
|
10
|
+
options;
|
|
11
|
+
tree = null;
|
|
12
|
+
nodes = new Map();
|
|
13
|
+
selectedId = null;
|
|
14
|
+
expandedIds = new Set();
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.expandedIds.add("root"); // Always expand root
|
|
18
|
+
}
|
|
19
|
+
async load(rootId) {
|
|
20
|
+
this.tree = await this.options.tui.getAgentTree(rootId);
|
|
21
|
+
this.buildNodeMap();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Render tree as text (for TUI overlay)
|
|
25
|
+
*/
|
|
26
|
+
render() {
|
|
27
|
+
if (!this.tree) {
|
|
28
|
+
return ["🐉 No agent tree available"];
|
|
29
|
+
}
|
|
30
|
+
const lines = ["🐉 Agent Hierarchy Tree", "─".repeat(50)];
|
|
31
|
+
this.renderNode(this.tree, lines, "", true);
|
|
32
|
+
lines.push("─".repeat(50));
|
|
33
|
+
lines.push("[↑↓] Navigate [Enter] Select [k] Kill [v] View [r] Restart [q] Close");
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Handle keyboard input
|
|
38
|
+
*/
|
|
39
|
+
handleKey(key) {
|
|
40
|
+
switch (key) {
|
|
41
|
+
case "q":
|
|
42
|
+
case "escape":
|
|
43
|
+
this.options.onClose?.();
|
|
44
|
+
return true;
|
|
45
|
+
case "enter":
|
|
46
|
+
if (this.selectedId) {
|
|
47
|
+
this.options.onSelect?.(this.selectedId);
|
|
48
|
+
this.toggleExpanded(this.selectedId);
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
case "k":
|
|
52
|
+
if (this.selectedId) {
|
|
53
|
+
this.options.onKill?.(this.selectedId);
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
case "v":
|
|
57
|
+
if (this.selectedId) {
|
|
58
|
+
this.options.onViewResult?.(this.selectedId);
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
case "r":
|
|
62
|
+
if (this.selectedId) {
|
|
63
|
+
this.options.onRestart?.(this.selectedId);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
case "up":
|
|
67
|
+
this.selectPrevious();
|
|
68
|
+
return true;
|
|
69
|
+
case "down":
|
|
70
|
+
this.selectNext();
|
|
71
|
+
return true;
|
|
72
|
+
case "left":
|
|
73
|
+
if (this.selectedId) {
|
|
74
|
+
this.expandedIds.delete(this.selectedId);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
case "right":
|
|
78
|
+
if (this.selectedId) {
|
|
79
|
+
this.expandedIds.add(this.selectedId);
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get selected node
|
|
87
|
+
*/
|
|
88
|
+
getSelected() {
|
|
89
|
+
return this.selectedId ? this.nodes.get(this.selectedId) || null : null;
|
|
90
|
+
}
|
|
91
|
+
renderNode(node, lines, prefix, isLast) {
|
|
92
|
+
const nodeUI = this.nodes.get(node.runId);
|
|
93
|
+
if (!nodeUI)
|
|
94
|
+
return;
|
|
95
|
+
// Status emoji
|
|
96
|
+
const statusEmoji = {
|
|
97
|
+
running: "●",
|
|
98
|
+
completed: "✓",
|
|
99
|
+
error: "✗",
|
|
100
|
+
idle: "○",
|
|
101
|
+
};
|
|
102
|
+
const emoji = statusEmoji[node.status] || "○";
|
|
103
|
+
// Type color indicator (using text markers)
|
|
104
|
+
const typeMarker = {
|
|
105
|
+
coordinator: "[C]",
|
|
106
|
+
specialist: "[S]",
|
|
107
|
+
researcher: "[R]",
|
|
108
|
+
planner: "[P]",
|
|
109
|
+
reviewer: "[V]",
|
|
110
|
+
};
|
|
111
|
+
const marker = typeMarker[node.type] || "[?]";
|
|
112
|
+
// Selection indicator
|
|
113
|
+
const isSelected = node.runId === this.selectedId;
|
|
114
|
+
const selectedMarker = isSelected ? "> " : " ";
|
|
115
|
+
// Expansion indicator for nodes with children
|
|
116
|
+
const canExpand = node.children.length > 0;
|
|
117
|
+
const isExpanded = this.expandedIds.has(node.runId);
|
|
118
|
+
const expandMarker = canExpand ? (isExpanded ? "▼ " : "▶ ") : " ";
|
|
119
|
+
// Connector
|
|
120
|
+
const connector = isLast ? "└── " : "├── ";
|
|
121
|
+
// Build line
|
|
122
|
+
const taskPreview = node.task ? `: ${node.task.slice(0, 30)}` : "";
|
|
123
|
+
const line = `${prefix}${connector}${selectedMarker}${expandMarker}${emoji} ${marker} ${node.runId}${taskPreview}`;
|
|
124
|
+
lines.push(line);
|
|
125
|
+
// Render children if expanded
|
|
126
|
+
if (isExpanded && node.children.length > 0) {
|
|
127
|
+
const childPrefix = prefix + (isLast ? " " : "│ ");
|
|
128
|
+
node.children.forEach((child, i) => {
|
|
129
|
+
const childIsLast = i === node.children.length - 1;
|
|
130
|
+
this.renderNode(child, lines, childPrefix, childIsLast);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
buildNodeMap() {
|
|
135
|
+
this.nodes.clear();
|
|
136
|
+
if (this.tree) {
|
|
137
|
+
this.buildNodeMapRecursive(this.tree, 0);
|
|
138
|
+
}
|
|
139
|
+
// Select first node if none selected
|
|
140
|
+
if (!this.selectedId && this.nodes.size > 0) {
|
|
141
|
+
this.selectedId = this.nodes.keys().next().value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
buildNodeMapRecursive(node, depth) {
|
|
145
|
+
this.nodes.set(node.runId, {
|
|
146
|
+
runId: node.runId,
|
|
147
|
+
type: node.type,
|
|
148
|
+
status: node.status,
|
|
149
|
+
task: node.task,
|
|
150
|
+
depth,
|
|
151
|
+
isSelected: node.runId === this.selectedId,
|
|
152
|
+
isExpanded: this.expandedIds.has(node.runId),
|
|
153
|
+
children: [], // Will be populated if needed
|
|
154
|
+
});
|
|
155
|
+
node.children.forEach((child) => this.buildNodeMapRecursive(child, depth + 1));
|
|
156
|
+
}
|
|
157
|
+
toggleExpanded(runId) {
|
|
158
|
+
if (this.expandedIds.has(runId)) {
|
|
159
|
+
this.expandedIds.delete(runId);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.expandedIds.add(runId);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
selectNext() {
|
|
166
|
+
const ids = [...this.nodes.keys()];
|
|
167
|
+
const currentIndex = this.selectedId ? ids.indexOf(this.selectedId) : -1;
|
|
168
|
+
const nextIndex = Math.min(currentIndex + 1, ids.length - 1);
|
|
169
|
+
this.selectedId = ids[nextIndex] || null;
|
|
170
|
+
this.updateSelection();
|
|
171
|
+
}
|
|
172
|
+
selectPrevious() {
|
|
173
|
+
const ids = [...this.nodes.keys()];
|
|
174
|
+
const currentIndex = this.selectedId ? ids.indexOf(this.selectedId) : 1;
|
|
175
|
+
const prevIndex = Math.max(currentIndex - 1, 0);
|
|
176
|
+
this.selectedId = ids[prevIndex] || null;
|
|
177
|
+
this.updateSelection();
|
|
178
|
+
}
|
|
179
|
+
updateSelection() {
|
|
180
|
+
for (const node of this.nodes.values()) {
|
|
181
|
+
node.isSelected = node.runId === this.selectedId;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Factory for PI TUI integration
|
|
186
|
+
export function createAgentTreeOverlay(options) {
|
|
187
|
+
return new AgentTreeOverlay(options);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create overlay component for PI TUI
|
|
191
|
+
* Returns a component that can be passed to tui.openOverlay()
|
|
192
|
+
*/
|
|
193
|
+
export async function createAgentTreeComponent(tui, title = "Agent Tree") {
|
|
194
|
+
// This would integrate with PI TUI's component system
|
|
195
|
+
// For now, return a simple text-based component
|
|
196
|
+
const overlay = new AgentTreeOverlay({
|
|
197
|
+
tui,
|
|
198
|
+
onSelect: (runId) => console.log("Selected:", runId),
|
|
199
|
+
onKill: (runId) => console.log("Kill:", runId),
|
|
200
|
+
onViewResult: (runId) => console.log("View:", runId),
|
|
201
|
+
onClose: () => console.log("Close"),
|
|
202
|
+
});
|
|
203
|
+
await overlay.load();
|
|
204
|
+
return {
|
|
205
|
+
title,
|
|
206
|
+
content: overlay.render().join("\n"),
|
|
207
|
+
handleKey: (key) => overlay.handleKey(key),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=agent-tree-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tree-overlay.js","sourceRoot":"","sources":["../../../../src/tui/components/agent-tree-overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,MAAM,OAAO,gBAAgB;IAMP;IALZ,IAAI,GAAqB,IAAI,CAAC;IAC9B,KAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC3C,UAAU,GAAkB,IAAI,CAAC;IACjC,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE7C,YAAoB,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;QAC7C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB;IACrD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAe;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,M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C,IAAI,EAAE,CAAC;IAErB,OAAO;QACL,KAAK;QACL,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,SAAS,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🐉 Persistent Agent Tree Panel
|
|
3
|
+
*
|
|
4
|
+
* Always-visible agent hierarchy that updates automatically.
|
|
5
|
+
* Displays as a sidebar or top panel in the TUI.
|
|
6
|
+
*/
|
|
7
|
+
import { eventBus } from "../../event-bus";
|
|
8
|
+
export class AgentTreePanel {
|
|
9
|
+
tui;
|
|
10
|
+
updateMs;
|
|
11
|
+
state = {
|
|
12
|
+
tree: null,
|
|
13
|
+
selectedId: null,
|
|
14
|
+
expandedIds: new Set(),
|
|
15
|
+
lastUpdate: 0,
|
|
16
|
+
};
|
|
17
|
+
updateInterval = null;
|
|
18
|
+
listeners = new Set();
|
|
19
|
+
constructor(tui, updateMs = 500) {
|
|
20
|
+
this.tui = tui;
|
|
21
|
+
this.updateMs = updateMs;
|
|
22
|
+
this.setupEventListeners();
|
|
23
|
+
this.startAutoUpdate();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe to tree updates
|
|
27
|
+
*/
|
|
28
|
+
onUpdate(callback) {
|
|
29
|
+
this.listeners.add(callback);
|
|
30
|
+
return () => this.listeners.delete(callback);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get current tree state
|
|
34
|
+
*/
|
|
35
|
+
getState() {
|
|
36
|
+
return { ...this.state };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get tree as formatted string lines
|
|
40
|
+
*/
|
|
41
|
+
getLines(maxWidth = 40) {
|
|
42
|
+
if (!this.state.tree) {
|
|
43
|
+
return ["🐉 No agents"];
|
|
44
|
+
}
|
|
45
|
+
const lines = ["🐉 Agents"];
|
|
46
|
+
this.renderNode(this.state.tree, lines, "", true, maxWidth);
|
|
47
|
+
return lines;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get compact one-line status
|
|
51
|
+
*/
|
|
52
|
+
getCompactStatus() {
|
|
53
|
+
if (!this.state.tree)
|
|
54
|
+
return "🐉 idle";
|
|
55
|
+
const { active, total } = this.countAgents(this.state.tree);
|
|
56
|
+
const currentTask = this.findActiveTask(this.state.tree);
|
|
57
|
+
if (active === 0)
|
|
58
|
+
return "🐉 idle";
|
|
59
|
+
return `🐉 ${active}/${total} ${currentTask?.slice(0, 20) || ""}`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Select a node by ID
|
|
63
|
+
*/
|
|
64
|
+
select(runId) {
|
|
65
|
+
this.state.selectedId = runId;
|
|
66
|
+
this.notify();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Toggle expanded state
|
|
70
|
+
*/
|
|
71
|
+
toggleExpanded(runId) {
|
|
72
|
+
if (this.state.expandedIds.has(runId)) {
|
|
73
|
+
this.state.expandedIds.delete(runId);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.state.expandedIds.add(runId);
|
|
77
|
+
}
|
|
78
|
+
this.notify();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Expand all nodes
|
|
82
|
+
*/
|
|
83
|
+
expandAll() {
|
|
84
|
+
this.expandAllRecursive(this.state.tree);
|
|
85
|
+
this.notify();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Collapse all except root
|
|
89
|
+
*/
|
|
90
|
+
collapseAll() {
|
|
91
|
+
this.state.expandedIds.clear();
|
|
92
|
+
if (this.state.tree) {
|
|
93
|
+
this.state.expandedIds.add(this.state.tree.runId);
|
|
94
|
+
}
|
|
95
|
+
this.notify();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Force refresh
|
|
99
|
+
*/
|
|
100
|
+
async refresh() {
|
|
101
|
+
await this.updateTree();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Clean up
|
|
105
|
+
*/
|
|
106
|
+
dispose() {
|
|
107
|
+
if (this.updateInterval) {
|
|
108
|
+
clearInterval(this.updateInterval);
|
|
109
|
+
this.updateInterval = null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// Private methods
|
|
114
|
+
// ============================================================================
|
|
115
|
+
setupEventListeners() {
|
|
116
|
+
// Listen for agent events
|
|
117
|
+
eventBus.on("agent.completed", async (event) => {
|
|
118
|
+
const { runId, type } = event.payload;
|
|
119
|
+
console.log(`[🐉 TreePanel] Agent ${runId} (${type}) completed`);
|
|
120
|
+
await this.updateTree();
|
|
121
|
+
});
|
|
122
|
+
eventBus.on("agent.spawned", async (event) => {
|
|
123
|
+
const { runId, type } = event.payload;
|
|
124
|
+
console.log(`[🐉 TreePanel] Agent ${runId} (${type}) spawned`);
|
|
125
|
+
this.state.expandedIds.add(runId); // Auto-expand new agents
|
|
126
|
+
await this.updateTree();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
startAutoUpdate() {
|
|
130
|
+
this.updateTree(); // Initial load
|
|
131
|
+
this.updateInterval = setInterval(async () => {
|
|
132
|
+
await this.updateTree();
|
|
133
|
+
}, this.updateMs);
|
|
134
|
+
}
|
|
135
|
+
async updateTree() {
|
|
136
|
+
try {
|
|
137
|
+
const tree = await this.tui.getAgentTree();
|
|
138
|
+
// Only update if changed
|
|
139
|
+
const treeChanged = JSON.stringify(tree) !== JSON.stringify(this.state.tree);
|
|
140
|
+
if (treeChanged) {
|
|
141
|
+
this.state.tree = tree;
|
|
142
|
+
this.state.lastUpdate = Date.now();
|
|
143
|
+
// Auto-expand root on first load
|
|
144
|
+
if (tree && this.state.expandedIds.size === 0) {
|
|
145
|
+
this.state.expandedIds.add(tree.runId);
|
|
146
|
+
}
|
|
147
|
+
this.notify();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
console.error("[🐉 TreePanel] Update failed:", err);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
notify() {
|
|
155
|
+
this.listeners.forEach(cb => cb());
|
|
156
|
+
}
|
|
157
|
+
renderNode(node, lines, prefix, isLast, maxWidth) {
|
|
158
|
+
const isSelected = node.runId === this.state.selectedId;
|
|
159
|
+
const isExpanded = this.state.expandedIds.has(node.runId);
|
|
160
|
+
const hasChildren = node.children.length > 0;
|
|
161
|
+
// Status emoji
|
|
162
|
+
const statusEmoji = {
|
|
163
|
+
running: "●",
|
|
164
|
+
completed: "✓",
|
|
165
|
+
error: "✗",
|
|
166
|
+
idle: "○",
|
|
167
|
+
};
|
|
168
|
+
// Type marker
|
|
169
|
+
const typeMarker = {
|
|
170
|
+
coordinator: "[C]",
|
|
171
|
+
specialist: "[S]",
|
|
172
|
+
researcher: "[R]",
|
|
173
|
+
planner: "[P]",
|
|
174
|
+
reviewer: "[V]",
|
|
175
|
+
};
|
|
176
|
+
const connector = isLast ? "└── " : "├── ";
|
|
177
|
+
const expandMarker = hasChildren ? (isExpanded ? "▼ " : "▶ ") : " ";
|
|
178
|
+
const marker = typeMarker[node.type] || "[?]";
|
|
179
|
+
const status = statusEmoji[node.status] || "○";
|
|
180
|
+
// Truncate task to fit
|
|
181
|
+
const maxTaskLen = maxWidth - prefix.length - connector.length - expandMarker.length - marker.length - 10;
|
|
182
|
+
const taskDisplay = node.task
|
|
183
|
+
? `: ${node.task.slice(0, maxTaskLen)}${node.task.length > maxTaskLen ? "…" : ""}`
|
|
184
|
+
: "";
|
|
185
|
+
// Selection highlight
|
|
186
|
+
const linePrefix = isSelected ? "> " : " ";
|
|
187
|
+
lines.push(`${prefix}${connector}${linePrefix}${expandMarker}${status} ${marker} ${node.runId.slice(-8)}${taskDisplay}`);
|
|
188
|
+
// Render children if expanded
|
|
189
|
+
if (isExpanded && hasChildren) {
|
|
190
|
+
const childPrefix = prefix + (isLast ? " " : "│ ");
|
|
191
|
+
node.children.forEach((child, i) => {
|
|
192
|
+
const childIsLast = i === node.children.length - 1;
|
|
193
|
+
this.renderNode(child, lines, childPrefix, childIsLast, maxWidth);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
countAgents(tree) {
|
|
198
|
+
let active = tree.status === "running" ? 1 : 0;
|
|
199
|
+
let total = 1;
|
|
200
|
+
for (const child of tree.children) {
|
|
201
|
+
const childCounts = this.countAgents(child);
|
|
202
|
+
active += childCounts.active;
|
|
203
|
+
total += childCounts.total;
|
|
204
|
+
}
|
|
205
|
+
return { active, total };
|
|
206
|
+
}
|
|
207
|
+
findActiveTask(tree) {
|
|
208
|
+
if (tree.status === "running" && tree.task) {
|
|
209
|
+
return tree.task;
|
|
210
|
+
}
|
|
211
|
+
for (const child of tree.children) {
|
|
212
|
+
const task = this.findActiveTask(child);
|
|
213
|
+
if (task)
|
|
214
|
+
return task;
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
expandAllRecursive(tree) {
|
|
219
|
+
if (!tree)
|
|
220
|
+
return;
|
|
221
|
+
this.state.expandedIds.add(tree.runId);
|
|
222
|
+
tree.children.forEach(child => this.expandAllRecursive(child));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Factory
|
|
226
|
+
export function createAgentTreePanel(tui) {
|
|
227
|
+
return new AgentTreePanel(tui);
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=agent-tree-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tree-panel.js","sourceRoot":"","sources":["../../../../src/tui/components/agent-tree-panel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAS3C,MAAM,OAAO,cAAc;IAWL;IAA0B;IAVtC,KAAK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AI,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC;QACxB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,kBAAkB,CAAC,IAAsB;QAC/C,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAED,UAAU;AACV,MAAM,UAAU,oBAAoB,CAAC,GAAgB;IACnD,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🐉 Persistent Agent Tree Sidebar
|
|
3
|
+
*
|
|
4
|
+
* Displays as a persistent sidebar in the TUI.
|
|
5
|
+
* Updates automatically every 500ms.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useEffect, useState } from "react";
|
|
8
|
+
import { Box, Text } from "@mariozechner/pi-tui";
|
|
9
|
+
import { getDraconicRunRegistry } from "../../agent/DraconicRunRegistry";
|
|
10
|
+
export const AgentTreeSidebar = ({ width = 30 }) => {
|
|
11
|
+
const [runs, setRuns] = useState([]);
|
|
12
|
+
const [selectedId, setSelectedId] = useState(null);
|
|
13
|
+
const registry = getDraconicRunRegistry();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
// Initial load
|
|
16
|
+
updateRuns();
|
|
17
|
+
// Update every 500ms
|
|
18
|
+
const interval = setInterval(updateRuns, 500);
|
|
19
|
+
// Subscribe to registry events
|
|
20
|
+
const unsubscribe = registry.on("run.statusChanged", () => {
|
|
21
|
+
updateRuns();
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
clearInterval(interval);
|
|
25
|
+
unsubscribe?.();
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
const updateRuns = () => {
|
|
29
|
+
const allRuns = registry.query({}).runs;
|
|
30
|
+
setRuns(allRuns);
|
|
31
|
+
};
|
|
32
|
+
const rootRuns = runs.filter(r => !r.parentId);
|
|
33
|
+
const statusEmoji = {
|
|
34
|
+
running: "●",
|
|
35
|
+
completed: "✓",
|
|
36
|
+
error: "✗",
|
|
37
|
+
idle: "○",
|
|
38
|
+
spawning: "◌",
|
|
39
|
+
paused: "⏸",
|
|
40
|
+
};
|
|
41
|
+
const typeMarker = {
|
|
42
|
+
coordinator: "[C]",
|
|
43
|
+
specialist: "[S]",
|
|
44
|
+
researcher: "[R]",
|
|
45
|
+
planner: "[P]",
|
|
46
|
+
reviewer: "[V]",
|
|
47
|
+
};
|
|
48
|
+
const renderRun = (run, depth = 0) => {
|
|
49
|
+
const isSelected = run.id === selectedId;
|
|
50
|
+
const status = statusEmoji[run.status] || "○";
|
|
51
|
+
const marker = typeMarker[run.type] || "[?]";
|
|
52
|
+
const indent = " ".repeat(depth);
|
|
53
|
+
const task = run.task?.slice(0, width - 15) || "";
|
|
54
|
+
const children = runs.filter(r => r.parentId === run.id);
|
|
55
|
+
return (<Box flexDirection="column" key={run.id}>
|
|
56
|
+
<Text color={isSelected ? "white" : "gray"} backgroundColor={isSelected ? "blue" : undefined} onClick={() => setSelectedId(run.id)}>
|
|
57
|
+
{indent}{status} {marker} {run.id.slice(-8)} {task}
|
|
58
|
+
</Text>
|
|
59
|
+
{children.map(child => renderRun(child, depth + 1))}
|
|
60
|
+
</Box>);
|
|
61
|
+
};
|
|
62
|
+
return (<Box flexDirection="column" width={width} borderStyle="single" padding={1}>
|
|
63
|
+
<Text bold color="cyan">🐉 Agents</Text>
|
|
64
|
+
<Text dimColor>───────────────</Text>
|
|
65
|
+
{rootRuns.length === 0 ? (<Text dimColor>No agents</Text>) : (rootRuns.map(run => renderRun(run)))}
|
|
66
|
+
</Box>);
|
|
67
|
+
};
|
|
68
|
+
// Hook for non-React usage
|
|
69
|
+
export function useAgentTreeSidebar() {
|
|
70
|
+
const [runs, setRuns] = useState([]);
|
|
71
|
+
const registry = getDraconicRunRegistry();
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const update = () => {
|
|
74
|
+
setRuns(registry.query({}).runs);
|
|
75
|
+
};
|
|
76
|
+
update();
|
|
77
|
+
const interval = setInterval(update, 500);
|
|
78
|
+
return () => clearInterval(interval);
|
|
79
|
+
}, []);
|
|
80
|
+
return { runs };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../../../../src/tui/components/sidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAoB,MAAM,iCAAiC,CAAC;AAM3F,MAAM,CAAC,MAAM,gBAAgB,GAAoC,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,EAAE;IAClF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAE1C,SAAS,CAAC,GAAG,EAAE;QACb,eAAe;QACf,UAAU,EAAE,CAAC;QAE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