@compilr-dev/cli 0.5.11 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo.app +1 -1
- package/dist/.tsbuildinfo.data +1 -1
- package/dist/.tsbuildinfo.domain +1 -1
- package/dist/.tsbuildinfo.foundation +1 -1
- package/dist/agent.js +1 -1
- package/dist/anchors/index.d.ts +1 -1
- package/dist/anchors/index.js +1 -1
- package/dist/anchors/project-anchors.d.ts +9 -60
- package/dist/anchors/project-anchors.js +31 -173
- package/dist/commands-v2/handlers/session.js +2 -2
- package/dist/commands-v2/types.d.ts +1 -2
- package/dist/compilr-diff-companion.vsix +0 -0
- package/dist/multi-agent/capability-loader.js +1 -1
- package/dist/multi-agent/checkpointer.d.ts +5 -4
- package/dist/multi-agent/checkpointer.js +25 -5
- package/dist/multi-agent/custom-agents.d.ts +5 -62
- package/dist/multi-agent/custom-agents.js +10 -136
- package/dist/multi-agent/delegation-tracker.d.ts +5 -146
- package/dist/multi-agent/delegation-tracker.js +7 -218
- package/dist/multi-agent/index.d.ts +14 -18
- package/dist/multi-agent/index.js +22 -23
- package/dist/repl-v2.js +1 -1
- package/dist/settings/index.d.ts +3 -14
- package/dist/settings/index.js +5 -32
- package/dist/settings/mcp-config.d.ts +7 -54
- package/dist/settings/mcp-config.js +18 -104
- package/dist/tools/delegation-status.js +1 -1
- package/dist/tools/platform-adapter.d.ts +2 -12
- package/dist/tools/platform-adapter.js +52 -171
- package/dist/ui/overlay/impl/background-overlay-v2.d.ts +1 -1
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +1 -1
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +1 -4
- package/dist/ui/overlay/impl/delegations-overlay-v2.js +1 -1
- package/dist/ui/overlay/impl/team-overlay-v2.d.ts +1 -1
- package/dist/ui/overlay/impl/team-overlay-v2.js +1 -1
- package/package.json +2 -2
|
@@ -1,125 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom Agent Definitions
|
|
2
|
+
* Custom Agent Definitions - CLI Filesystem Layer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Pure logic (types, validation, generation) lives in @compilr-dev/sdk.
|
|
5
|
+
* This file provides CLI-specific filesystem operations for loading/saving.
|
|
6
6
|
*/
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
-
import { createDefaultToolConfig,
|
|
10
|
-
// Current storage version
|
|
11
|
-
const STORAGE_VERSION = 2;
|
|
12
|
-
// =============================================================================
|
|
13
|
-
// Mascot Pool for Custom Agents
|
|
14
|
-
// =============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Mascots available for custom agents.
|
|
17
|
-
* These are distinct from predefined role mascots.
|
|
18
|
-
*/
|
|
19
|
-
export const CUSTOM_MASCOTS = [
|
|
20
|
-
'[⊡_⊡]', '[⊞_⊞]', '[⊟_⊟]', '[⊠_⊠]',
|
|
21
|
-
'[⋈_⋈]', '[⋐_⋐]', '[⋑_⋑]', '[⋒_⋒]',
|
|
22
|
-
'[◌_◌]', '[◍_◍]', '[●_●]', '[◐_◐]',
|
|
23
|
-
'[◑_◑]', '[◒_◒]', '[◓_◓]', '[◔_◔]',
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Assign a mascot from the available pool.
|
|
27
|
-
* Avoids mascots already in use by other custom agents.
|
|
28
|
-
*/
|
|
29
|
-
export function assignMascot(existingAgents) {
|
|
30
|
-
const usedMascots = new Set(existingAgents.map(a => a.mascot));
|
|
31
|
-
const available = CUSTOM_MASCOTS.filter(m => !usedMascots.has(m));
|
|
32
|
-
if (available.length > 0) {
|
|
33
|
-
return available[0];
|
|
34
|
-
}
|
|
35
|
-
// Fall back to random selection if all are used
|
|
36
|
-
return CUSTOM_MASCOTS[Math.floor(Math.random() * CUSTOM_MASCOTS.length)];
|
|
37
|
-
}
|
|
38
|
-
// =============================================================================
|
|
39
|
-
// System Prompt Generation
|
|
40
|
-
// =============================================================================
|
|
41
|
-
/**
|
|
42
|
-
* Generate system prompt for a custom agent.
|
|
43
|
-
* Uses a template-based approach (no LLM call).
|
|
44
|
-
* Includes tool awareness if the agent has tool restrictions.
|
|
45
|
-
*/
|
|
46
|
-
export function generateCustomAgentSystemPrompt(agent) {
|
|
47
|
-
const lines = [
|
|
48
|
-
`You are a ${agent.displayName} specialized in ${agent.specialty}.`,
|
|
49
|
-
];
|
|
50
|
-
if (agent.personality) {
|
|
51
|
-
lines.push('');
|
|
52
|
-
lines.push(`Your approach: ${agent.personality}`);
|
|
53
|
-
}
|
|
54
|
-
lines.push('');
|
|
55
|
-
lines.push('Focus on your area of expertise. When questions fall outside your specialty, suggest which team member might be better suited to help.');
|
|
56
|
-
// Add tool awareness if agent has tool restrictions
|
|
57
|
-
const toolConfig = agent.toolConfig ?? createDefaultToolConfig();
|
|
58
|
-
if (toolConfig.profile !== 'full') {
|
|
59
|
-
lines.push('');
|
|
60
|
-
lines.push('---');
|
|
61
|
-
lines.push('');
|
|
62
|
-
lines.push(generateToolAwarenessPrompt(toolConfig));
|
|
63
|
-
}
|
|
64
|
-
return lines.join('\n');
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the tool filter (list of allowed tools) for a custom agent.
|
|
68
|
-
* Returns undefined for full access (no filtering).
|
|
69
|
-
*/
|
|
70
|
-
export function getCustomAgentToolFilter(agent) {
|
|
71
|
-
const toolConfig = agent.toolConfig ?? createDefaultToolConfig();
|
|
72
|
-
return getToolsForProfile(toolConfig.profile, toolConfig.customGroups);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get the profile display name for a custom agent.
|
|
76
|
-
*/
|
|
77
|
-
export function getCustomAgentProfileLabel(agent) {
|
|
78
|
-
const toolConfig = agent.toolConfig ?? createDefaultToolConfig();
|
|
79
|
-
const info = PROFILE_INFO[toolConfig.profile];
|
|
80
|
-
return info.label;
|
|
81
|
-
}
|
|
82
|
-
// =============================================================================
|
|
83
|
-
// Validation
|
|
84
|
-
// =============================================================================
|
|
85
|
-
/**
|
|
86
|
-
* Validate agent ID format.
|
|
87
|
-
* Must be lowercase letters, numbers, and underscores.
|
|
88
|
-
* Must start with a letter.
|
|
89
|
-
*/
|
|
90
|
-
export function validateAgentId(id) {
|
|
91
|
-
if (!id || id.trim() === '') {
|
|
92
|
-
return { valid: false, error: 'Agent ID is required' };
|
|
93
|
-
}
|
|
94
|
-
if (id.length > 20) {
|
|
95
|
-
return { valid: false, error: 'Agent ID must be 20 characters or less' };
|
|
96
|
-
}
|
|
97
|
-
if (!/^[a-z][a-z0-9_]*$/.test(id)) {
|
|
98
|
-
return { valid: false, error: 'Must be lowercase letters, numbers, underscore (start with letter)' };
|
|
99
|
-
}
|
|
100
|
-
return { valid: true };
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Check if agent ID is already in use.
|
|
104
|
-
*/
|
|
105
|
-
export function isAgentIdTaken(id, existingCustomAgents, teamAgentIds, predefinedRoleIds) {
|
|
106
|
-
// Check predefined roles
|
|
107
|
-
if (predefinedRoleIds.includes(id)) {
|
|
108
|
-
return { taken: true, reason: `"${id}" is a predefined role` };
|
|
109
|
-
}
|
|
110
|
-
// Check team agents
|
|
111
|
-
if (teamAgentIds.includes(id)) {
|
|
112
|
-
return { taken: true, reason: `"${id}" is already in your team` };
|
|
113
|
-
}
|
|
114
|
-
// Check custom agents
|
|
115
|
-
if (existingCustomAgents.some(a => a.id === id)) {
|
|
116
|
-
return { taken: true, reason: `"${id}" already exists as a custom agent` };
|
|
117
|
-
}
|
|
118
|
-
return { taken: false };
|
|
119
|
-
}
|
|
9
|
+
import { createDefaultToolConfig, } from '@compilr-dev/sdk';
|
|
120
10
|
// =============================================================================
|
|
121
|
-
//
|
|
11
|
+
// Re-exports from SDK (for backward compatibility)
|
|
122
12
|
// =============================================================================
|
|
13
|
+
export { CUSTOM_MASCOTS, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, } from '@compilr-dev/sdk';
|
|
14
|
+
// Current storage version
|
|
15
|
+
const STORAGE_VERSION = 2;
|
|
123
16
|
const CUSTOM_AGENTS_FILENAME = 'custom-agents.json';
|
|
124
17
|
const COMPILR_DIR = '.compilr';
|
|
125
18
|
/**
|
|
@@ -139,13 +32,12 @@ function ensureCompilrDir(projectPath) {
|
|
|
139
32
|
}
|
|
140
33
|
/**
|
|
141
34
|
* Migrate a v1 agent to v2 format.
|
|
142
|
-
* Adds default toolConfig (full access) and empty enabledSkills.
|
|
143
35
|
*/
|
|
144
36
|
function migrateAgentV1toV2(agent) {
|
|
145
37
|
return {
|
|
146
38
|
...agent,
|
|
147
39
|
toolConfig: agent.toolConfig ?? createDefaultToolConfig(),
|
|
148
|
-
enabledSkills: agent.enabledSkills ?? [],
|
|
40
|
+
enabledSkills: agent.enabledSkills ?? [],
|
|
149
41
|
};
|
|
150
42
|
}
|
|
151
43
|
/**
|
|
@@ -165,14 +57,12 @@ export function loadCustomAgents(projectPath) {
|
|
|
165
57
|
// Migrate v1 agents to v2 format if needed
|
|
166
58
|
if (data.version < STORAGE_VERSION) {
|
|
167
59
|
const migratedAgents = agents.map(migrateAgentV1toV2);
|
|
168
|
-
// Save migrated agents
|
|
169
60
|
saveCustomAgents(projectPath, migratedAgents);
|
|
170
61
|
return migratedAgents;
|
|
171
62
|
}
|
|
172
63
|
return agents;
|
|
173
64
|
}
|
|
174
65
|
catch {
|
|
175
|
-
// If file is corrupted, return empty array
|
|
176
66
|
return [];
|
|
177
67
|
}
|
|
178
68
|
}
|
|
@@ -201,7 +91,7 @@ export function addCustomAgent(projectPath, agent) {
|
|
|
201
91
|
*/
|
|
202
92
|
export function removeCustomAgent(projectPath, agentId) {
|
|
203
93
|
const agents = loadCustomAgents(projectPath);
|
|
204
|
-
const index = agents.findIndex(a => a.id === agentId);
|
|
94
|
+
const index = agents.findIndex((a) => a.id === agentId);
|
|
205
95
|
if (index === -1) {
|
|
206
96
|
return false;
|
|
207
97
|
}
|
|
@@ -209,19 +99,3 @@ export function removeCustomAgent(projectPath, agentId) {
|
|
|
209
99
|
saveCustomAgents(projectPath, agents);
|
|
210
100
|
return true;
|
|
211
101
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Create a new CustomAgentDefinition with auto-assigned mascot.
|
|
214
|
-
*/
|
|
215
|
-
export function createCustomAgentDefinition(id, displayName, specialty, personality, existingAgents, toolConfig, enabledSkills, modelTier) {
|
|
216
|
-
return {
|
|
217
|
-
id,
|
|
218
|
-
displayName,
|
|
219
|
-
specialty,
|
|
220
|
-
personality: personality || undefined,
|
|
221
|
-
mascot: assignMascot(existingAgents),
|
|
222
|
-
createdAt: new Date().toISOString(),
|
|
223
|
-
toolConfig: toolConfig ?? createDefaultToolConfig(),
|
|
224
|
-
enabledSkills: enabledSkills ?? [], // Empty = all skills
|
|
225
|
-
modelTier: modelTier ?? 'balanced', // Default tier
|
|
226
|
-
};
|
|
227
|
-
}
|
|
@@ -1,152 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Delegation Tracker
|
|
2
|
+
* Delegation Tracker - CLI Singleton Wrapper
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* when specialists finish their work.
|
|
7
|
-
*
|
|
8
|
-
* Pattern follows PendingRequestsManager (singleton, event-based).
|
|
4
|
+
* The DelegationTracker class lives in @compilr-dev/sdk.
|
|
5
|
+
* This file provides CLI-specific singleton access.
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface Delegation {
|
|
13
|
-
/** Unique delegation ID (del_<uuid>) */
|
|
14
|
-
id: string;
|
|
15
|
-
/** Agent that initiated the delegation (always 'default' for now) */
|
|
16
|
-
coordinatorId: string;
|
|
17
|
-
/** Target specialist agent ID (e.g., 'arch', 'dev', 'qa') */
|
|
18
|
-
targetAgentId: string;
|
|
19
|
-
/** Task description sent to the specialist */
|
|
20
|
-
task: string;
|
|
21
|
-
/** What the specialist is expected to produce */
|
|
22
|
-
expectedOutput?: string;
|
|
23
|
-
/** Associated todo index (if any) */
|
|
24
|
-
todoIndex?: number;
|
|
25
|
-
/** Current status */
|
|
26
|
-
status: DelegationStatus;
|
|
27
|
-
/** Result (set on completion or failure) */
|
|
28
|
-
result?: DelegationResult;
|
|
29
|
-
/** When the delegation was created */
|
|
30
|
-
createdAt: Date;
|
|
31
|
-
/** When the delegation completed */
|
|
32
|
-
completedAt?: Date;
|
|
33
|
-
}
|
|
34
|
-
export interface DelegationResult {
|
|
35
|
-
/** Whether the task completed successfully */
|
|
36
|
-
success: boolean;
|
|
37
|
-
/** Brief outcome summary */
|
|
38
|
-
summary: string;
|
|
39
|
-
/** Artifact IDs created by the specialist */
|
|
40
|
-
artifactIds: string[];
|
|
41
|
-
/** Error message (if failed) */
|
|
42
|
-
error?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface CompletionEvent {
|
|
45
|
-
/** The delegation ID */
|
|
46
|
-
delegationId: string;
|
|
47
|
-
/** The specialist that completed the work */
|
|
48
|
-
agentId: string;
|
|
49
|
-
/** Completion status */
|
|
50
|
-
status: 'completed' | 'failed';
|
|
51
|
-
/** Result details */
|
|
52
|
-
result: DelegationResult;
|
|
53
|
-
/** When the event was generated */
|
|
54
|
-
timestamp: Date;
|
|
55
|
-
}
|
|
56
|
-
export interface CreateDelegationOptions {
|
|
57
|
-
/** Agent that initiated the delegation */
|
|
58
|
-
coordinatorId: string;
|
|
59
|
-
/** Target specialist agent ID */
|
|
60
|
-
targetAgentId: string;
|
|
61
|
-
/** Task description */
|
|
62
|
-
task: string;
|
|
63
|
-
/** Expected output description */
|
|
64
|
-
expectedOutput?: string;
|
|
65
|
-
/** Associated todo index */
|
|
66
|
-
todoIndex?: number;
|
|
67
|
-
}
|
|
68
|
-
export interface DelegationStats {
|
|
69
|
-
total: number;
|
|
70
|
-
pending: number;
|
|
71
|
-
running: number;
|
|
72
|
-
completed: number;
|
|
73
|
-
failed: number;
|
|
74
|
-
cancelled: number;
|
|
75
|
-
}
|
|
76
|
-
export interface DelegationTrackerEvents {
|
|
77
|
-
/** Emitted when a new delegation is created */
|
|
78
|
-
'delegation-created': (delegation: Delegation) => void;
|
|
79
|
-
/** Emitted when a delegation completes successfully */
|
|
80
|
-
'delegation-completed': (event: CompletionEvent) => void;
|
|
81
|
-
/** Emitted when a delegation fails */
|
|
82
|
-
'delegation-failed': (event: CompletionEvent) => void;
|
|
83
|
-
/** Emitted when delegation counts change */
|
|
84
|
-
'count-changed': (stats: DelegationStats) => void;
|
|
85
|
-
}
|
|
86
|
-
export declare class DelegationTracker extends EventEmitter {
|
|
87
|
-
private readonly delegations;
|
|
88
|
-
private readonly completionQueue;
|
|
89
|
-
/**
|
|
90
|
-
* Create a new delegation.
|
|
91
|
-
*/
|
|
92
|
-
create(options: CreateDelegationOptions): Delegation;
|
|
93
|
-
/**
|
|
94
|
-
* Update a delegation's status.
|
|
95
|
-
*/
|
|
96
|
-
updateStatus(id: string, status: DelegationStatus): void;
|
|
97
|
-
/**
|
|
98
|
-
* Mark a delegation as completed with a result.
|
|
99
|
-
*/
|
|
100
|
-
complete(id: string, result: DelegationResult): void;
|
|
101
|
-
/**
|
|
102
|
-
* Mark a delegation as failed.
|
|
103
|
-
*/
|
|
104
|
-
fail(id: string, error: string): void;
|
|
105
|
-
/**
|
|
106
|
-
* Mark a delegation as cancelled.
|
|
107
|
-
*/
|
|
108
|
-
cancel(id: string): void;
|
|
109
|
-
/**
|
|
110
|
-
* Cancel all active delegations for a specific agent.
|
|
111
|
-
*/
|
|
112
|
-
cancelAllForAgent(agentId: string): number;
|
|
113
|
-
/**
|
|
114
|
-
* Get a delegation by ID.
|
|
115
|
-
*/
|
|
116
|
-
get(id: string): Delegation | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Get all delegations targeting a specific agent.
|
|
119
|
-
*/
|
|
120
|
-
getByAgent(agentId: string): Delegation[];
|
|
121
|
-
/**
|
|
122
|
-
* Get all active (pending or running) delegations.
|
|
123
|
-
*/
|
|
124
|
-
getActive(): Delegation[];
|
|
125
|
-
/**
|
|
126
|
-
* Get all delegations.
|
|
127
|
-
*/
|
|
128
|
-
getAll(): Delegation[];
|
|
129
|
-
/**
|
|
130
|
-
* Check if there are pending completion events.
|
|
131
|
-
*/
|
|
132
|
-
hasCompletionEvents(): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Drain all completion events (removes them from queue).
|
|
135
|
-
*/
|
|
136
|
-
drainCompletionEvents(): CompletionEvent[];
|
|
137
|
-
/**
|
|
138
|
-
* Peek at completion events without removing them.
|
|
139
|
-
*/
|
|
140
|
-
peekCompletionEvents(): CompletionEvent[];
|
|
141
|
-
/**
|
|
142
|
-
* Get delegation statistics.
|
|
143
|
-
*/
|
|
144
|
-
getStats(): DelegationStats;
|
|
145
|
-
/**
|
|
146
|
-
* Clear all delegations and completion events.
|
|
147
|
-
*/
|
|
148
|
-
clear(): void;
|
|
149
|
-
}
|
|
7
|
+
export { DelegationTracker, type Delegation, type DelegationStatus, type DelegationResult, type CompletionEvent, type CreateDelegationOptions, type DelegationStats, type DelegationTrackerEvents, } from '@compilr-dev/sdk';
|
|
8
|
+
import { DelegationTracker } from '@compilr-dev/sdk';
|
|
150
9
|
/**
|
|
151
10
|
* Get the singleton DelegationTracker instance.
|
|
152
11
|
*/
|
|
@@ -1,225 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Delegation Tracker
|
|
2
|
+
* Delegation Tracker - CLI Singleton Wrapper
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* when specialists finish their work.
|
|
7
|
-
*
|
|
8
|
-
* Pattern follows PendingRequestsManager (singleton, event-based).
|
|
4
|
+
* The DelegationTracker class lives in @compilr-dev/sdk.
|
|
5
|
+
* This file provides CLI-specific singleton access.
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Tracker Class
|
|
14
|
-
// =============================================================================
|
|
15
|
-
export class DelegationTracker extends EventEmitter {
|
|
16
|
-
delegations = new Map();
|
|
17
|
-
completionQueue = [];
|
|
18
|
-
/**
|
|
19
|
-
* Create a new delegation.
|
|
20
|
-
*/
|
|
21
|
-
create(options) {
|
|
22
|
-
const delegation = {
|
|
23
|
-
id: `del_${randomUUID().slice(0, 8)}`,
|
|
24
|
-
coordinatorId: options.coordinatorId,
|
|
25
|
-
targetAgentId: options.targetAgentId,
|
|
26
|
-
task: options.task,
|
|
27
|
-
expectedOutput: options.expectedOutput,
|
|
28
|
-
todoIndex: options.todoIndex,
|
|
29
|
-
status: 'pending',
|
|
30
|
-
createdAt: new Date(),
|
|
31
|
-
};
|
|
32
|
-
this.delegations.set(delegation.id, delegation);
|
|
33
|
-
this.emit('delegation-created', delegation);
|
|
34
|
-
this.emit('count-changed', this.getStats());
|
|
35
|
-
return delegation;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Update a delegation's status.
|
|
39
|
-
*/
|
|
40
|
-
updateStatus(id, status) {
|
|
41
|
-
const delegation = this.delegations.get(id);
|
|
42
|
-
if (!delegation)
|
|
43
|
-
return;
|
|
44
|
-
delegation.status = status;
|
|
45
|
-
this.emit('count-changed', this.getStats());
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Mark a delegation as completed with a result.
|
|
49
|
-
*/
|
|
50
|
-
complete(id, result) {
|
|
51
|
-
const delegation = this.delegations.get(id);
|
|
52
|
-
if (!delegation)
|
|
53
|
-
return;
|
|
54
|
-
delegation.status = 'completed';
|
|
55
|
-
delegation.result = result;
|
|
56
|
-
delegation.completedAt = new Date();
|
|
57
|
-
const event = {
|
|
58
|
-
delegationId: id,
|
|
59
|
-
agentId: delegation.targetAgentId,
|
|
60
|
-
status: 'completed',
|
|
61
|
-
result,
|
|
62
|
-
timestamp: new Date(),
|
|
63
|
-
};
|
|
64
|
-
this.completionQueue.push(event);
|
|
65
|
-
this.emit('delegation-completed', event);
|
|
66
|
-
this.emit('count-changed', this.getStats());
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Mark a delegation as failed.
|
|
70
|
-
*/
|
|
71
|
-
fail(id, error) {
|
|
72
|
-
const delegation = this.delegations.get(id);
|
|
73
|
-
if (!delegation)
|
|
74
|
-
return;
|
|
75
|
-
const result = {
|
|
76
|
-
success: false,
|
|
77
|
-
summary: `Failed: ${error}`,
|
|
78
|
-
artifactIds: [],
|
|
79
|
-
error,
|
|
80
|
-
};
|
|
81
|
-
delegation.status = 'failed';
|
|
82
|
-
delegation.result = result;
|
|
83
|
-
delegation.completedAt = new Date();
|
|
84
|
-
const event = {
|
|
85
|
-
delegationId: id,
|
|
86
|
-
agentId: delegation.targetAgentId,
|
|
87
|
-
status: 'failed',
|
|
88
|
-
result,
|
|
89
|
-
timestamp: new Date(),
|
|
90
|
-
};
|
|
91
|
-
this.completionQueue.push(event);
|
|
92
|
-
this.emit('delegation-failed', event);
|
|
93
|
-
this.emit('count-changed', this.getStats());
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Mark a delegation as cancelled.
|
|
97
|
-
*/
|
|
98
|
-
cancel(id) {
|
|
99
|
-
const delegation = this.delegations.get(id);
|
|
100
|
-
if (!delegation)
|
|
101
|
-
return;
|
|
102
|
-
delegation.status = 'cancelled';
|
|
103
|
-
delegation.completedAt = new Date();
|
|
104
|
-
this.emit('count-changed', this.getStats());
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Cancel all active delegations for a specific agent.
|
|
108
|
-
*/
|
|
109
|
-
cancelAllForAgent(agentId) {
|
|
110
|
-
const active = this.getByAgent(agentId).filter(d => d.status === 'pending' || d.status === 'running');
|
|
111
|
-
for (const delegation of active) {
|
|
112
|
-
this.cancel(delegation.id);
|
|
113
|
-
}
|
|
114
|
-
return active.length;
|
|
115
|
-
}
|
|
116
|
-
// ===========================================================================
|
|
117
|
-
// Query
|
|
118
|
-
// ===========================================================================
|
|
119
|
-
/**
|
|
120
|
-
* Get a delegation by ID.
|
|
121
|
-
*/
|
|
122
|
-
get(id) {
|
|
123
|
-
return this.delegations.get(id);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get all delegations targeting a specific agent.
|
|
127
|
-
*/
|
|
128
|
-
getByAgent(agentId) {
|
|
129
|
-
return Array.from(this.delegations.values())
|
|
130
|
-
.filter(d => d.targetAgentId === agentId);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get all active (pending or running) delegations.
|
|
134
|
-
*/
|
|
135
|
-
getActive() {
|
|
136
|
-
return Array.from(this.delegations.values())
|
|
137
|
-
.filter(d => d.status === 'pending' || d.status === 'running');
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Get all delegations.
|
|
141
|
-
*/
|
|
142
|
-
getAll() {
|
|
143
|
-
return Array.from(this.delegations.values())
|
|
144
|
-
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
145
|
-
}
|
|
146
|
-
// ===========================================================================
|
|
147
|
-
// Completion Events
|
|
148
|
-
// ===========================================================================
|
|
149
|
-
/**
|
|
150
|
-
* Check if there are pending completion events.
|
|
151
|
-
*/
|
|
152
|
-
hasCompletionEvents() {
|
|
153
|
-
return this.completionQueue.length > 0;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Drain all completion events (removes them from queue).
|
|
157
|
-
*/
|
|
158
|
-
drainCompletionEvents() {
|
|
159
|
-
const events = [...this.completionQueue];
|
|
160
|
-
this.completionQueue.length = 0;
|
|
161
|
-
return events;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Peek at completion events without removing them.
|
|
165
|
-
*/
|
|
166
|
-
peekCompletionEvents() {
|
|
167
|
-
return [...this.completionQueue];
|
|
168
|
-
}
|
|
169
|
-
// ===========================================================================
|
|
170
|
-
// Stats
|
|
171
|
-
// ===========================================================================
|
|
172
|
-
/**
|
|
173
|
-
* Get delegation statistics.
|
|
174
|
-
*/
|
|
175
|
-
getStats() {
|
|
176
|
-
let pending = 0;
|
|
177
|
-
let running = 0;
|
|
178
|
-
let completed = 0;
|
|
179
|
-
let failed = 0;
|
|
180
|
-
let cancelled = 0;
|
|
181
|
-
for (const d of this.delegations.values()) {
|
|
182
|
-
switch (d.status) {
|
|
183
|
-
case 'pending':
|
|
184
|
-
pending++;
|
|
185
|
-
break;
|
|
186
|
-
case 'running':
|
|
187
|
-
running++;
|
|
188
|
-
break;
|
|
189
|
-
case 'completed':
|
|
190
|
-
completed++;
|
|
191
|
-
break;
|
|
192
|
-
case 'failed':
|
|
193
|
-
failed++;
|
|
194
|
-
break;
|
|
195
|
-
case 'cancelled':
|
|
196
|
-
cancelled++;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
total: this.delegations.size,
|
|
202
|
-
pending,
|
|
203
|
-
running,
|
|
204
|
-
completed,
|
|
205
|
-
failed,
|
|
206
|
-
cancelled,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
// ===========================================================================
|
|
210
|
-
// Cleanup
|
|
211
|
-
// ===========================================================================
|
|
212
|
-
/**
|
|
213
|
-
* Clear all delegations and completion events.
|
|
214
|
-
*/
|
|
215
|
-
clear() {
|
|
216
|
-
this.delegations.clear();
|
|
217
|
-
this.completionQueue.length = 0;
|
|
218
|
-
this.emit('count-changed', this.getStats());
|
|
219
|
-
}
|
|
220
|
-
}
|
|
7
|
+
// Re-export everything from SDK
|
|
8
|
+
export { DelegationTracker, } from '@compilr-dev/sdk';
|
|
9
|
+
import { DelegationTracker } from '@compilr-dev/sdk';
|
|
221
10
|
// =============================================================================
|
|
222
|
-
// Singleton
|
|
11
|
+
// CLI Singleton
|
|
223
12
|
// =============================================================================
|
|
224
13
|
let instance = null;
|
|
225
14
|
/**
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-Agent Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* - TeamAgent: Wrapper for individual team agents
|
|
7
|
-
* - Checkpointing: Persistence for team state
|
|
8
|
-
* - SharedContextManager: Shared context across agents
|
|
9
|
-
* - ArtifactStore: Storage for team artifacts
|
|
4
|
+
* Re-exports team orchestration from @compilr-dev/sdk plus
|
|
5
|
+
* CLI-specific implementations (checkpointer, session registry, etc.)
|
|
10
6
|
*/
|
|
11
|
-
export type { MascotExpression, AgentRole, RoleMetadata, TeamAgentConfig, SerializedTeamAgent, TeamMetadata, SerializedTeam, TeamEventType, TeamEvent, TeamEventHandler, } from '
|
|
12
|
-
export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '
|
|
13
|
-
export { TeamAgent } from '
|
|
14
|
-
export {
|
|
7
|
+
export type { MascotExpression, AgentRole, RoleMetadata, TeamAgentConfig, SerializedTeamAgent, TeamMetadata, SerializedTeam, TeamEventType, TeamEvent, TeamEventHandler, BackgroundSessionInfo, } from '@compilr-dev/sdk';
|
|
8
|
+
export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '@compilr-dev/sdk';
|
|
9
|
+
export { TeamAgent, AgentTeam } from '@compilr-dev/sdk';
|
|
10
|
+
export type { AgentTeamConfig } from '@compilr-dev/sdk';
|
|
11
|
+
export { SharedContextManager, type SharedContext, type SharedProjectInfo, type SharedTeamInfo, type TeamRosterEntry, type TeamActivity, type TeamActivityType, type SharedDecision, type TokenBudget, type SerializedSharedContext, } from '@compilr-dev/sdk';
|
|
12
|
+
export { ArtifactStore, type Artifact, type TeamArtifactType as ArtifactType, type TeamArtifactSummary as ArtifactSummary, type CreateArtifactOptions, type UpdateArtifactOptions, } from '@compilr-dev/sdk';
|
|
13
|
+
export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, type ParsedMention, type ParsedInput, } from '@compilr-dev/sdk';
|
|
14
|
+
export { ContextResolver, buildContextMap, type ResolvedMention, type ResolutionSource, type ResolveOptions, } from '@compilr-dev/sdk';
|
|
15
|
+
export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity } from '@compilr-dev/sdk';
|
|
16
|
+
export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from '@compilr-dev/sdk';
|
|
17
|
+
export { suggestOwner, suggestOwners, matchesAgentExpertise } from '@compilr-dev/sdk';
|
|
18
|
+
export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from '@compilr-dev/sdk';
|
|
15
19
|
export { TeamCheckpointer, getTeamCheckpointer, getSessionsPath } from './checkpointer.js';
|
|
16
|
-
export { SharedContextManager, type SharedContext, type SharedProjectInfo, type SharedTeamInfo, type TeamRosterEntry, type TeamActivity, type TeamActivityType, type SharedDecision, type TokenBudget, type SerializedSharedContext, } from './shared-context.js';
|
|
17
|
-
export { ArtifactStore, type Artifact, type ArtifactType, type ArtifactSummary, type CreateArtifactOptions, type UpdateArtifactOptions, } from './artifacts.js';
|
|
18
|
-
export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, type ParsedMention, type ParsedInput, } from './mention-parser.js';
|
|
19
|
-
export { ContextResolver, buildContextMap, type ResolvedMention, type ResolutionSource, type ResolveOptions, } from './context-resolver.js';
|
|
20
|
-
export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity, } from './activity.js';
|
|
21
|
-
export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from './agent-selection.js';
|
|
22
|
-
export { suggestOwner, suggestOwners, matchesAgentExpertise, } from './task-suggestion.js';
|
|
23
|
-
export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from './task-assignment.js';
|
|
24
20
|
export { PendingRequestsManager, getPendingRequestsManager, resetPendingRequestsManager, type PendingRequest, type PendingRequestResponse, type PendingRequestType, type EnqueueOptions, type PendingRequestsEvents, } from './pending-requests.js';
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-Agent Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* - TeamAgent: Wrapper for individual team agents
|
|
7
|
-
* - Checkpointing: Persistence for team state
|
|
8
|
-
* - SharedContextManager: Shared context across agents
|
|
9
|
-
* - ArtifactStore: Storage for team artifacts
|
|
4
|
+
* Re-exports team orchestration from @compilr-dev/sdk plus
|
|
5
|
+
* CLI-specific implementations (checkpointer, session registry, etc.)
|
|
10
6
|
*/
|
|
11
|
-
export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '
|
|
7
|
+
export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '@compilr-dev/sdk';
|
|
12
8
|
// Classes
|
|
13
|
-
export { TeamAgent } from '
|
|
14
|
-
|
|
9
|
+
export { TeamAgent, AgentTeam } from '@compilr-dev/sdk';
|
|
10
|
+
// Shared Context
|
|
11
|
+
export { SharedContextManager, } from '@compilr-dev/sdk';
|
|
12
|
+
// Artifacts
|
|
13
|
+
export { ArtifactStore, } from '@compilr-dev/sdk';
|
|
14
|
+
// Mention References
|
|
15
|
+
export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from '@compilr-dev/sdk';
|
|
16
|
+
export { ContextResolver, buildContextMap, } from '@compilr-dev/sdk';
|
|
17
|
+
// Activity Recording
|
|
18
|
+
export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity } from '@compilr-dev/sdk';
|
|
19
|
+
// Agent Selection
|
|
20
|
+
export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from '@compilr-dev/sdk';
|
|
21
|
+
// Task Ownership
|
|
22
|
+
export { suggestOwner, suggestOwners, matchesAgentExpertise } from '@compilr-dev/sdk';
|
|
23
|
+
export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from '@compilr-dev/sdk';
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// CLI-only modules (filesystem, SQLite, terminal-specific)
|
|
26
|
+
// =============================================================================
|
|
15
27
|
export { TeamCheckpointer, getTeamCheckpointer, getSessionsPath } from './checkpointer.js';
|
|
16
|
-
//
|
|
17
|
-
export { SharedContextManager, } from './shared-context.js';
|
|
18
|
-
export { ArtifactStore, } from './artifacts.js';
|
|
19
|
-
// Phase 2c: Mention References
|
|
20
|
-
export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from './mention-parser.js';
|
|
21
|
-
export { ContextResolver, buildContextMap, } from './context-resolver.js';
|
|
22
|
-
// Phase 2c: Activity Recording
|
|
23
|
-
export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity, } from './activity.js';
|
|
24
|
-
// Phase 3: Agent Selection (for delegation)
|
|
25
|
-
export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from './agent-selection.js';
|
|
26
|
-
// Task Ownership: Suggestion and Assignment
|
|
27
|
-
export { suggestOwner, suggestOwners, matchesAgentExpertise, } from './task-suggestion.js';
|
|
28
|
-
export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from './task-assignment.js';
|
|
29
|
-
// Phase 3b: Background Agents - Pending Requests
|
|
28
|
+
// Background Agents - Pending Requests
|
|
30
29
|
export { PendingRequestsManager, getPendingRequestsManager, resetPendingRequestsManager, } from './pending-requests.js';
|