@nex-ai/nex 0.1.21 → 0.1.23
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 +11 -2
- package/dist/agent/adoption.d.ts +23 -0
- package/dist/agent/adoption.js +87 -0
- package/dist/agent/adoption.js.map +1 -0
- package/dist/agent/gossip.d.ts +17 -0
- package/dist/agent/gossip.js +48 -0
- package/dist/agent/gossip.js.map +1 -0
- package/dist/agent/loop.d.ts +59 -0
- package/dist/agent/loop.js +389 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/queues.d.ts +16 -0
- package/dist/agent/queues.js +44 -0
- package/dist/agent/queues.js.map +1 -0
- package/dist/agent/session-store.d.ts +21 -0
- package/dist/agent/session-store.js +96 -0
- package/dist/agent/session-store.js.map +1 -0
- package/dist/agent/templates.d.ts +5 -0
- package/dist/agent/templates.js +48 -0
- package/dist/agent/templates.js.map +1 -0
- package/dist/agent/tools.d.ts +25 -0
- package/dist/agent/tools.js +238 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agent/types.d.ts +59 -0
- package/dist/agent/types.js +5 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/calendar/scheduler.d.ts +32 -0
- package/dist/calendar/scheduler.js +178 -0
- package/dist/calendar/scheduler.js.map +1 -0
- package/dist/calendar/store.d.ts +15 -0
- package/dist/calendar/store.js +50 -0
- package/dist/calendar/store.js.map +1 -0
- package/dist/calendar/types.d.ts +17 -0
- package/dist/calendar/types.js +5 -0
- package/dist/calendar/types.js.map +1 -0
- package/dist/chat/channel.d.ts +20 -0
- package/dist/chat/channel.js +84 -0
- package/dist/chat/channel.js.map +1 -0
- package/dist/chat/message-store.d.ts +18 -0
- package/dist/chat/message-store.js +82 -0
- package/dist/chat/message-store.js.map +1 -0
- package/dist/chat/router.d.ts +17 -0
- package/dist/chat/router.js +65 -0
- package/dist/chat/router.js.map +1 -0
- package/dist/chat/suggested-responses.d.ts +6 -0
- package/dist/chat/suggested-responses.js +99 -0
- package/dist/chat/suggested-responses.js.map +1 -0
- package/dist/chat/types.d.ts +28 -0
- package/dist/chat/types.js +5 -0
- package/dist/chat/types.js.map +1 -0
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/dispatch.d.ts +39 -0
- package/dist/commands/dispatch.js +1293 -0
- package/dist/commands/dispatch.js.map +1 -0
- package/dist/commands/init.d.ts +49 -0
- package/dist/commands/init.js +315 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/parse-input.d.ts +5 -0
- package/dist/commands/parse-input.js +37 -0
- package/dist/commands/parse-input.js.map +1 -0
- package/dist/index.d.ts +6 -23
- package/dist/index.js +118 -50
- package/dist/index.js.map +1 -1
- package/dist/lib/client.js +1 -1
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/errors.js +1 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/graph-html.d.ts +1 -0
- package/dist/lib/graph-html.js +16 -3
- package/dist/lib/graph-html.js.map +1 -1
- package/dist/lib/integrations.d.ts +23 -0
- package/dist/lib/integrations.js +25 -0
- package/dist/lib/integrations.js.map +1 -0
- package/dist/lib/nex-mcp-config.d.ts +14 -0
- package/dist/lib/nex-mcp-config.js +26 -0
- package/dist/lib/nex-mcp-config.js.map +1 -0
- package/dist/orchestration/budget.d.ts +32 -0
- package/dist/orchestration/budget.js +72 -0
- package/dist/orchestration/budget.js.map +1 -0
- package/dist/orchestration/executor.d.ts +59 -0
- package/dist/orchestration/executor.js +197 -0
- package/dist/orchestration/executor.js.map +1 -0
- package/dist/orchestration/router.d.ts +30 -0
- package/dist/orchestration/router.js +98 -0
- package/dist/orchestration/router.js.map +1 -0
- package/dist/orchestration/templates.d.ts +11 -0
- package/dist/orchestration/templates.js +99 -0
- package/dist/orchestration/templates.js.map +1 -0
- package/dist/orchestration/types.d.ts +58 -0
- package/dist/orchestration/types.js +7 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/plugin/shared.js +1 -1
- package/dist/plugin/shared.js.map +1 -1
- package/dist/tui/agent-colors.d.ts +19 -0
- package/dist/tui/agent-colors.js +34 -0
- package/dist/tui/agent-colors.js.map +1 -0
- package/dist/tui/app.d.ts +14 -0
- package/dist/tui/app.js +267 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/channel-colors.d.ts +16 -0
- package/dist/tui/channel-colors.js +43 -0
- package/dist/tui/channel-colors.js.map +1 -0
- package/dist/tui/components/agent-card.d.ts +11 -0
- package/dist/tui/components/agent-card.js +40 -0
- package/dist/tui/components/agent-card.js.map +1 -0
- package/dist/tui/components/banner.d.ts +44 -0
- package/dist/tui/components/banner.js +130 -0
- package/dist/tui/components/banner.js.map +1 -0
- package/dist/tui/components/channel-colors.d.ts +21 -0
- package/dist/tui/components/channel-colors.js +53 -0
- package/dist/tui/components/channel-colors.js.map +1 -0
- package/dist/tui/components/channel-message.d.ts +53 -0
- package/dist/tui/components/channel-message.js +66 -0
- package/dist/tui/components/channel-message.js.map +1 -0
- package/dist/tui/components/chat-input.d.ts +11 -0
- package/dist/tui/components/chat-input.js +19 -0
- package/dist/tui/components/chat-input.js.map +1 -0
- package/dist/tui/components/data-table.d.ts +11 -0
- package/dist/tui/components/data-table.js +47 -0
- package/dist/tui/components/data-table.js.map +1 -0
- package/dist/tui/components/error-box.d.ts +11 -0
- package/dist/tui/components/error-box.js +59 -0
- package/dist/tui/components/error-box.js.map +1 -0
- package/dist/tui/components/help-screen.d.ts +3 -0
- package/dist/tui/components/help-screen.js +63 -0
- package/dist/tui/components/help-screen.js.map +1 -0
- package/dist/tui/components/index.d.ts +17 -0
- package/dist/tui/components/index.js +10 -0
- package/dist/tui/components/index.js.map +1 -0
- package/dist/tui/components/inline-confirm.d.ts +14 -0
- package/dist/tui/components/inline-confirm.js +13 -0
- package/dist/tui/components/inline-confirm.js.map +1 -0
- package/dist/tui/components/inline-select.d.ts +21 -0
- package/dist/tui/components/inline-select.js +20 -0
- package/dist/tui/components/inline-select.js.map +1 -0
- package/dist/tui/components/markdown.d.ts +6 -0
- package/dist/tui/components/markdown.js +179 -0
- package/dist/tui/components/markdown.js.map +1 -0
- package/dist/tui/components/mention-autocomplete.d.ts +77 -0
- package/dist/tui/components/mention-autocomplete.js +235 -0
- package/dist/tui/components/mention-autocomplete.js.map +1 -0
- package/dist/tui/components/message-list.d.ts +18 -0
- package/dist/tui/components/message-list.js +29 -0
- package/dist/tui/components/message-list.js.map +1 -0
- package/dist/tui/components/picker.d.ts +16 -0
- package/dist/tui/components/picker.js +32 -0
- package/dist/tui/components/picker.js.map +1 -0
- package/dist/tui/components/progress-steps.d.ts +13 -0
- package/dist/tui/components/progress-steps.js +21 -0
- package/dist/tui/components/progress-steps.js.map +1 -0
- package/dist/tui/components/slack/compose.d.ts +27 -0
- package/dist/tui/components/slack/compose.js +123 -0
- package/dist/tui/components/slack/compose.js.map +1 -0
- package/dist/tui/components/slack/layout.d.ts +36 -0
- package/dist/tui/components/slack/layout.js +96 -0
- package/dist/tui/components/slack/layout.js.map +1 -0
- package/dist/tui/components/slack/messages.d.ts +72 -0
- package/dist/tui/components/slack/messages.js +177 -0
- package/dist/tui/components/slack/messages.js.map +1 -0
- package/dist/tui/components/slack/quick-switcher.d.ts +33 -0
- package/dist/tui/components/slack/quick-switcher.js +98 -0
- package/dist/tui/components/slack/quick-switcher.js.map +1 -0
- package/dist/tui/components/slack/sidebar-types.d.ts +65 -0
- package/dist/tui/components/slack/sidebar-types.js +7 -0
- package/dist/tui/components/slack/sidebar-types.js.map +1 -0
- package/dist/tui/components/slack/sidebar.d.ts +46 -0
- package/dist/tui/components/slack/sidebar.js +52 -0
- package/dist/tui/components/slack/sidebar.js.map +1 -0
- package/dist/tui/components/slack/thread-panel.d.ts +45 -0
- package/dist/tui/components/slack/thread-panel.js +47 -0
- package/dist/tui/components/slack/thread-panel.js.map +1 -0
- package/dist/tui/components/slash-autocomplete.d.ts +81 -0
- package/dist/tui/components/slash-autocomplete.js +218 -0
- package/dist/tui/components/slash-autocomplete.js.map +1 -0
- package/dist/tui/components/spinner.d.ts +17 -0
- package/dist/tui/components/spinner.js +30 -0
- package/dist/tui/components/spinner.js.map +1 -0
- package/dist/tui/components/status-bar.d.ts +23 -0
- package/dist/tui/components/status-bar.js +55 -0
- package/dist/tui/components/status-bar.js.map +1 -0
- package/dist/tui/components/success-box.d.ts +7 -0
- package/dist/tui/components/success-box.js +10 -0
- package/dist/tui/components/success-box.js.map +1 -0
- package/dist/tui/components/tool-indicator.d.ts +12 -0
- package/dist/tui/components/tool-indicator.js +18 -0
- package/dist/tui/components/tool-indicator.js.map +1 -0
- package/dist/tui/components/viewport.d.ts +9 -0
- package/dist/tui/components/viewport.js +24 -0
- package/dist/tui/components/viewport.js.map +1 -0
- package/dist/tui/generative/bindings.d.ts +27 -0
- package/dist/tui/generative/bindings.js +152 -0
- package/dist/tui/generative/bindings.js.map +1 -0
- package/dist/tui/generative/registry.d.ts +19 -0
- package/dist/tui/generative/registry.js +31 -0
- package/dist/tui/generative/registry.js.map +1 -0
- package/dist/tui/generative/renderer.d.ts +24 -0
- package/dist/tui/generative/renderer.js +160 -0
- package/dist/tui/generative/renderer.js.map +1 -0
- package/dist/tui/generative/types.d.ts +68 -0
- package/dist/tui/generative/types.js +7 -0
- package/dist/tui/generative/types.js.map +1 -0
- package/dist/tui/hooks/use-cancellable.d.ts +28 -0
- package/dist/tui/hooks/use-cancellable.js +51 -0
- package/dist/tui/hooks/use-cancellable.js.map +1 -0
- package/dist/tui/hooks/use-streaming.d.ts +44 -0
- package/dist/tui/hooks/use-streaming.js +105 -0
- package/dist/tui/hooks/use-streaming.js.map +1 -0
- package/dist/tui/index.d.ts +4 -0
- package/dist/tui/index.js +7 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/keybindings.d.ts +25 -0
- package/dist/tui/keybindings.js +277 -0
- package/dist/tui/keybindings.js.map +1 -0
- package/dist/tui/register-views.d.ts +8 -0
- package/dist/tui/register-views.js +116 -0
- package/dist/tui/register-views.js.map +1 -0
- package/dist/tui/router.d.ts +29 -0
- package/dist/tui/router.js +87 -0
- package/dist/tui/router.js.map +1 -0
- package/dist/tui/services/agent-service.d.ts +58 -0
- package/dist/tui/services/agent-service.js +197 -0
- package/dist/tui/services/agent-service.js.map +1 -0
- package/dist/tui/services/calendar-service.d.ts +31 -0
- package/dist/tui/services/calendar-service.js +133 -0
- package/dist/tui/services/calendar-service.js.map +1 -0
- package/dist/tui/services/chat-service.d.ts +28 -0
- package/dist/tui/services/chat-service.js +91 -0
- package/dist/tui/services/chat-service.js.map +1 -0
- package/dist/tui/services/orchestration-service.d.ts +42 -0
- package/dist/tui/services/orchestration-service.js +153 -0
- package/dist/tui/services/orchestration-service.js.map +1 -0
- package/dist/tui/slash-commands.d.ts +106 -0
- package/dist/tui/slash-commands.js +1421 -0
- package/dist/tui/slash-commands.js.map +1 -0
- package/dist/tui/store.d.ts +96 -0
- package/dist/tui/store.js +120 -0
- package/dist/tui/store.js.map +1 -0
- package/dist/tui/theme.d.ts +40 -0
- package/dist/tui/theme.js +39 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/tui-context.d.ts +22 -0
- package/dist/tui/tui-context.js +17 -0
- package/dist/tui/tui-context.js.map +1 -0
- package/dist/tui/views/agent-list.d.ts +8 -0
- package/dist/tui/views/agent-list.js +11 -0
- package/dist/tui/views/agent-list.js.map +1 -0
- package/dist/tui/views/ask-chat.d.ts +9 -0
- package/dist/tui/views/ask-chat.js +40 -0
- package/dist/tui/views/ask-chat.js.map +1 -0
- package/dist/tui/views/calendar.d.ts +15 -0
- package/dist/tui/views/calendar.js +29 -0
- package/dist/tui/views/calendar.js.map +1 -0
- package/dist/tui/views/chat.d.ts +18 -0
- package/dist/tui/views/chat.js +28 -0
- package/dist/tui/views/chat.js.map +1 -0
- package/dist/tui/views/generative.d.ts +14 -0
- package/dist/tui/views/generative.js +37 -0
- package/dist/tui/views/generative.js.map +1 -0
- package/dist/tui/views/help.d.ts +6 -0
- package/dist/tui/views/help.js +9 -0
- package/dist/tui/views/help.js.map +1 -0
- package/dist/tui/views/home-screen.d.ts +67 -0
- package/dist/tui/views/home-screen.js +192 -0
- package/dist/tui/views/home-screen.js.map +1 -0
- package/dist/tui/views/home.d.ts +33 -0
- package/dist/tui/views/home.js +60 -0
- package/dist/tui/views/home.js.map +1 -0
- package/dist/tui/views/index.d.ts +20 -0
- package/dist/tui/views/index.js +11 -0
- package/dist/tui/views/index.js.map +1 -0
- package/dist/tui/views/insights.d.ts +19 -0
- package/dist/tui/views/insights.js +46 -0
- package/dist/tui/views/insights.js.map +1 -0
- package/dist/tui/views/orchestration.d.ts +18 -0
- package/dist/tui/views/orchestration.js +73 -0
- package/dist/tui/views/orchestration.js.map +1 -0
- package/dist/tui/views/record-detail.d.ts +10 -0
- package/dist/tui/views/record-detail.js +22 -0
- package/dist/tui/views/record-detail.js.map +1 -0
- package/dist/tui/views/record-list.d.ts +15 -0
- package/dist/tui/views/record-list.js +22 -0
- package/dist/tui/views/record-list.js.map +1 -0
- package/dist/tui/views/slack-channel-header.d.ts +15 -0
- package/dist/tui/views/slack-channel-header.js +16 -0
- package/dist/tui/views/slack-channel-header.js.map +1 -0
- package/dist/tui/views/slack-home.d.ts +21 -0
- package/dist/tui/views/slack-home.js +572 -0
- package/dist/tui/views/slack-home.js.map +1 -0
- package/dist/tui/views/task-board.d.ts +21 -0
- package/dist/tui/views/task-board.js +33 -0
- package/dist/tui/views/task-board.js.map +1 -0
- package/dist/tui/views/timeline.d.ts +17 -0
- package/dist/tui/views/timeline.js +24 -0
- package/dist/tui/views/timeline.js.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI service layer for multi-agent orchestration.
|
|
3
|
+
* Wraps BudgetTracker, TaskRouter, OrchestratorExecutor, and workflow
|
|
4
|
+
* templates into a single facade the orchestration view can consume.
|
|
5
|
+
*/
|
|
6
|
+
import type { GoalDefinition, TaskDefinition, OrchestratorConfig, BudgetSnapshot, SkillDeclaration } from '../../orchestration/types.js';
|
|
7
|
+
export declare class OrchestrationService {
|
|
8
|
+
private executor;
|
|
9
|
+
private budget;
|
|
10
|
+
private router;
|
|
11
|
+
private goals;
|
|
12
|
+
private tasks;
|
|
13
|
+
private listeners;
|
|
14
|
+
constructor(config?: Partial<OrchestratorConfig>);
|
|
15
|
+
createGoal(title: string, description: string): GoalDefinition;
|
|
16
|
+
getGoals(): GoalDefinition[];
|
|
17
|
+
createTask(task: Omit<TaskDefinition, 'id' | 'createdAt' | 'status'>): TaskDefinition;
|
|
18
|
+
getTasks(goalId?: string): TaskDefinition[];
|
|
19
|
+
getActiveTasks(): TaskDefinition[];
|
|
20
|
+
instantiateWorkflow(templateName: string): {
|
|
21
|
+
goal: GoalDefinition;
|
|
22
|
+
tasks: TaskDefinition[];
|
|
23
|
+
};
|
|
24
|
+
getTemplateNames(): string[];
|
|
25
|
+
registerAgentSkills(agentSlug: string, skills: SkillDeclaration[]): void;
|
|
26
|
+
findBestAgentForTask(taskId: string): {
|
|
27
|
+
agentSlug: string;
|
|
28
|
+
score: number;
|
|
29
|
+
} | null;
|
|
30
|
+
getBudgetSnapshots(): BudgetSnapshot[];
|
|
31
|
+
getGlobalBudget(): {
|
|
32
|
+
tokens: number;
|
|
33
|
+
cost: number;
|
|
34
|
+
percentTokens: number;
|
|
35
|
+
percentCost: number;
|
|
36
|
+
};
|
|
37
|
+
submitTask(taskId: string): Promise<void>;
|
|
38
|
+
stopAll(): Promise<void>;
|
|
39
|
+
subscribe(listener: () => void): () => void;
|
|
40
|
+
private notify;
|
|
41
|
+
}
|
|
42
|
+
export declare function getOrchestrationService(): OrchestrationService;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI service layer for multi-agent orchestration.
|
|
3
|
+
* Wraps BudgetTracker, TaskRouter, OrchestratorExecutor, and workflow
|
|
4
|
+
* templates into a single facade the orchestration view can consume.
|
|
5
|
+
*/
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { BudgetTracker } from '../../orchestration/budget.js';
|
|
8
|
+
import { TaskRouter } from '../../orchestration/router.js';
|
|
9
|
+
import { OrchestratorExecutor } from '../../orchestration/executor.js';
|
|
10
|
+
import { workflows } from '../../orchestration/templates.js';
|
|
11
|
+
const DEFAULT_CONFIG = {
|
|
12
|
+
maxConcurrentAgents: 3,
|
|
13
|
+
globalBudget: { maxTokens: 100_000, maxCostUsd: 0.5 },
|
|
14
|
+
taskTimeout: 5 * 60 * 1000, // 5 minutes
|
|
15
|
+
autoRetry: true,
|
|
16
|
+
maxRetries: 2,
|
|
17
|
+
};
|
|
18
|
+
export class OrchestrationService {
|
|
19
|
+
executor;
|
|
20
|
+
budget;
|
|
21
|
+
router;
|
|
22
|
+
goals = new Map();
|
|
23
|
+
tasks = new Map();
|
|
24
|
+
listeners = [];
|
|
25
|
+
constructor(config) {
|
|
26
|
+
const merged = { ...DEFAULT_CONFIG, ...config };
|
|
27
|
+
this.executor = new OrchestratorExecutor(merged);
|
|
28
|
+
this.budget = new BudgetTracker(merged.globalBudget);
|
|
29
|
+
this.router = new TaskRouter();
|
|
30
|
+
}
|
|
31
|
+
// ── Goal management ──
|
|
32
|
+
createGoal(title, description) {
|
|
33
|
+
const goal = {
|
|
34
|
+
id: randomUUID(),
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
tasks: [],
|
|
38
|
+
status: 'active',
|
|
39
|
+
createdAt: Date.now(),
|
|
40
|
+
};
|
|
41
|
+
this.goals.set(goal.id, goal);
|
|
42
|
+
this.notify();
|
|
43
|
+
return goal;
|
|
44
|
+
}
|
|
45
|
+
getGoals() {
|
|
46
|
+
return [...this.goals.values()];
|
|
47
|
+
}
|
|
48
|
+
// ── Task management ──
|
|
49
|
+
createTask(task) {
|
|
50
|
+
const full = {
|
|
51
|
+
...task,
|
|
52
|
+
id: randomUUID(),
|
|
53
|
+
status: 'pending',
|
|
54
|
+
createdAt: Date.now(),
|
|
55
|
+
};
|
|
56
|
+
this.tasks.set(full.id, full);
|
|
57
|
+
// Link to parent goal if specified
|
|
58
|
+
if (full.parentGoalId) {
|
|
59
|
+
const goal = this.goals.get(full.parentGoalId);
|
|
60
|
+
if (goal) {
|
|
61
|
+
goal.tasks.push(full.id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.notify();
|
|
65
|
+
return full;
|
|
66
|
+
}
|
|
67
|
+
getTasks(goalId) {
|
|
68
|
+
const all = [...this.tasks.values()];
|
|
69
|
+
if (goalId) {
|
|
70
|
+
const goal = this.goals.get(goalId);
|
|
71
|
+
if (!goal)
|
|
72
|
+
return [];
|
|
73
|
+
const taskIdSet = new Set(goal.tasks);
|
|
74
|
+
return all.filter((t) => taskIdSet.has(t.id));
|
|
75
|
+
}
|
|
76
|
+
return all;
|
|
77
|
+
}
|
|
78
|
+
getActiveTasks() {
|
|
79
|
+
return [...this.tasks.values()].filter((t) => t.status === 'in_progress' || t.status === 'locked');
|
|
80
|
+
}
|
|
81
|
+
// ── Workflow templates ──
|
|
82
|
+
instantiateWorkflow(templateName) {
|
|
83
|
+
const template = workflows[templateName];
|
|
84
|
+
if (!template) {
|
|
85
|
+
throw new Error(`Unknown workflow template: ${templateName}`);
|
|
86
|
+
}
|
|
87
|
+
// Create goal from first template goal (templates define one)
|
|
88
|
+
const goalDef = template.goals[0];
|
|
89
|
+
const goal = this.createGoal(goalDef.title, goalDef.description);
|
|
90
|
+
// Create tasks linked to the goal
|
|
91
|
+
const tasks = template.tasks.map((t) => this.createTask({
|
|
92
|
+
...t,
|
|
93
|
+
parentGoalId: goal.id,
|
|
94
|
+
}));
|
|
95
|
+
return { goal, tasks };
|
|
96
|
+
}
|
|
97
|
+
getTemplateNames() {
|
|
98
|
+
return Object.keys(workflows);
|
|
99
|
+
}
|
|
100
|
+
// ── Agent routing ──
|
|
101
|
+
registerAgentSkills(agentSlug, skills) {
|
|
102
|
+
this.router.registerAgent(agentSlug, skills);
|
|
103
|
+
this.notify();
|
|
104
|
+
}
|
|
105
|
+
findBestAgentForTask(taskId) {
|
|
106
|
+
const task = this.tasks.get(taskId);
|
|
107
|
+
if (!task)
|
|
108
|
+
return null;
|
|
109
|
+
return this.router.findBestAgent(task);
|
|
110
|
+
}
|
|
111
|
+
// ── Budget ──
|
|
112
|
+
getBudgetSnapshots() {
|
|
113
|
+
return this.budget.getAllSnapshots();
|
|
114
|
+
}
|
|
115
|
+
getGlobalBudget() {
|
|
116
|
+
return this.budget.getGlobalUsage();
|
|
117
|
+
}
|
|
118
|
+
// ── Execution ──
|
|
119
|
+
async submitTask(taskId) {
|
|
120
|
+
const task = this.tasks.get(taskId);
|
|
121
|
+
if (!task)
|
|
122
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
123
|
+
await this.executor.submit(task);
|
|
124
|
+
this.notify();
|
|
125
|
+
}
|
|
126
|
+
async stopAll() {
|
|
127
|
+
await this.executor.stopAll();
|
|
128
|
+
this.notify();
|
|
129
|
+
}
|
|
130
|
+
// ── Subscribe for TUI re-renders ──
|
|
131
|
+
subscribe(listener) {
|
|
132
|
+
this.listeners.push(listener);
|
|
133
|
+
return () => {
|
|
134
|
+
const idx = this.listeners.indexOf(listener);
|
|
135
|
+
if (idx >= 0)
|
|
136
|
+
this.listeners.splice(idx, 1);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
notify() {
|
|
140
|
+
for (const listener of this.listeners) {
|
|
141
|
+
listener();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ── Singleton accessor ──
|
|
146
|
+
let instance;
|
|
147
|
+
export function getOrchestrationService() {
|
|
148
|
+
if (!instance) {
|
|
149
|
+
instance = new OrchestrationService();
|
|
150
|
+
}
|
|
151
|
+
return instance;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=orchestration-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-service.js","sourceRoot":"","sources":["../../../src/tui/services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AAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM;QACZ,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;CACF;AAED,2BAA2B;AAE3B,IAAI,QAA0C,CAAC;AAE/C,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;IACxC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command registry for the conversation-first TUI.
|
|
3
|
+
*
|
|
4
|
+
* Slash commands (/help, /agents, etc.) are the explicit navigation model.
|
|
5
|
+
* Natural language input goes to the Pi agent via dispatch("ask ...").
|
|
6
|
+
*/
|
|
7
|
+
import type { ViewEntry } from "./store.js";
|
|
8
|
+
import type { CommandResult } from "../commands/dispatch.js";
|
|
9
|
+
import type { SelectOption } from "./components/inline-select.js";
|
|
10
|
+
export interface SlashCommand {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
usage?: string;
|
|
14
|
+
execute: (args: string, context: SlashCommandContext) => Promise<SlashCommandResult>;
|
|
15
|
+
}
|
|
16
|
+
export interface SlashCommandContext {
|
|
17
|
+
push: (view: ViewEntry) => void;
|
|
18
|
+
dispatch: (input: string) => Promise<CommandResult>;
|
|
19
|
+
addMessage: (msg: ConversationMessage) => void;
|
|
20
|
+
setLoading: (loading: boolean, hint?: string) => void;
|
|
21
|
+
/** Show an arrow-key navigable inline select picker. */
|
|
22
|
+
showPicker: (title: string, options: SelectOption[], onSelect: (value: string) => void) => void;
|
|
23
|
+
/** Clear the current picker. */
|
|
24
|
+
clearPicker: () => void;
|
|
25
|
+
/** Show an inline y/n confirm prompt. */
|
|
26
|
+
showConfirm: (question: string, onConfirm: (confirmed: boolean) => void) => void;
|
|
27
|
+
/** Clear the current confirm prompt. */
|
|
28
|
+
clearConfirm: () => void;
|
|
29
|
+
}
|
|
30
|
+
export interface SlashCommandResult {
|
|
31
|
+
output?: string;
|
|
32
|
+
silent?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type ConversationMessage = {
|
|
35
|
+
id: string;
|
|
36
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
37
|
+
content: string;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
toolName?: string;
|
|
40
|
+
isError?: boolean;
|
|
41
|
+
/** When true, MessageBubble shows a trailing cursor block ▌ */
|
|
42
|
+
isStreaming?: boolean;
|
|
43
|
+
};
|
|
44
|
+
export declare function registerSlashCommand(cmd: SlashCommand): void;
|
|
45
|
+
export declare function getSlashCommand(name: string): SlashCommand | undefined;
|
|
46
|
+
export declare function listSlashCommands(): SlashCommand[];
|
|
47
|
+
/**
|
|
48
|
+
* Parse raw input to determine if it is a slash command.
|
|
49
|
+
* Returns `{ isSlash: true, command, args }` for "/foo bar baz",
|
|
50
|
+
* or `{ isSlash: false }` for everything else.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseSlashInput(input: string): {
|
|
53
|
+
isSlash: boolean;
|
|
54
|
+
command?: string;
|
|
55
|
+
args?: string;
|
|
56
|
+
};
|
|
57
|
+
export type InitState = {
|
|
58
|
+
phase: "idle";
|
|
59
|
+
} | {
|
|
60
|
+
phase: "awaiting_email";
|
|
61
|
+
loginOnly?: boolean;
|
|
62
|
+
} | {
|
|
63
|
+
phase: "awaiting_new_email";
|
|
64
|
+
loginOnly?: boolean;
|
|
65
|
+
} | {
|
|
66
|
+
phase: "awaiting_agent_prompt";
|
|
67
|
+
};
|
|
68
|
+
export declare function getInitState(): InitState;
|
|
69
|
+
export declare function resetInitState(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Handle user input when the init flow is awaiting a text response.
|
|
72
|
+
* Called by the home adapter when `getInitState().phase !== 'idle'`.
|
|
73
|
+
*
|
|
74
|
+
* Picker-based choices (regen, agent, template) are now handled via
|
|
75
|
+
* showPicker callbacks -- only text-input phases remain here.
|
|
76
|
+
*/
|
|
77
|
+
export declare function handleInitInput(input: string, context: SlashCommandContext): Promise<void>;
|
|
78
|
+
export type AgentWizardState = {
|
|
79
|
+
phase: "idle";
|
|
80
|
+
} | {
|
|
81
|
+
phase: "agent_create_name";
|
|
82
|
+
} | {
|
|
83
|
+
phase: "agent_create_expertise";
|
|
84
|
+
slug: string;
|
|
85
|
+
name: string;
|
|
86
|
+
} | {
|
|
87
|
+
phase: "agent_create_describe";
|
|
88
|
+
} | {
|
|
89
|
+
phase: "agent_edit_name";
|
|
90
|
+
slug: string;
|
|
91
|
+
} | {
|
|
92
|
+
phase: "agent_edit_expertise";
|
|
93
|
+
slug: string;
|
|
94
|
+
};
|
|
95
|
+
export declare function getAgentWizardState(): AgentWizardState;
|
|
96
|
+
export declare function resetAgentWizardState(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Main entry point for the /agents interactive manager.
|
|
99
|
+
* Exported so SlackHome can call it from the sidebar `[a]` shortcut.
|
|
100
|
+
*/
|
|
101
|
+
export declare function openAgentsManager(ctx: SlashCommandContext): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Handle text input when the agent wizard is awaiting user input.
|
|
104
|
+
* Called by SlackHome's handleSend when agentWizardState.phase !== "idle".
|
|
105
|
+
*/
|
|
106
|
+
export declare function handleAgentWizardInput(input: string, ctx: SlashCommandContext): Promise<void>;
|