@compilr-dev/cli 0.5.11 → 0.5.12
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.domain +1 -1
- package/dist/agent.js +1 -1
- 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/tools/delegation-status.js +1 -1
- package/dist/tools/platform-adapter.d.ts +1 -1
- package/dist/tools/platform-adapter.js +4 -4
- 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
package/dist/agent.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Agent, ContextManager, DEFAULT_CONTEXT_CONFIG, createTaskTool, createSu
|
|
|
9
9
|
import { isAutoCompactEnabled, isDelegationEnabled, getSetting } from './settings/index.js';
|
|
10
10
|
import { getApiKey } from './utils/credentials.js';
|
|
11
11
|
import { createToolRegistry, createMinimalToolRegistry, getDirectTools, getMetaTools, initializeMetaTools, getToolIndexForSystemPrompt, getFilteredToolIndexForSystemPrompt, getToolStats, setMetaToolFilter, createToolFallback, getRegisteredMetaTools, } from './tools.js';
|
|
12
|
-
import { TOOL_GROUPS } from '
|
|
12
|
+
import { TOOL_GROUPS } from '@compilr-dev/sdk';
|
|
13
13
|
import { setCapabilityManager } from './multi-agent/capability-loader.js';
|
|
14
14
|
import { getAgentRegistry } from './agents/registry.js';
|
|
15
15
|
import { SystemPromptBuilder } from './system-prompt/index.js';
|
|
@@ -148,7 +148,7 @@ export function saveCurrentTeam(team) {
|
|
|
148
148
|
// Save shared context
|
|
149
149
|
checkpointer.saveSharedContext(projectId, team.sharedContext);
|
|
150
150
|
// Save artifacts
|
|
151
|
-
team.artifactStore
|
|
151
|
+
checkpointer.saveArtifactStore(projectId, team.artifactStore);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Load the team for the current project.
|
|
@@ -502,7 +502,7 @@ export async function handleProjectSwitch(oldProjectId, agent, teamOptions, agen
|
|
|
502
502
|
try {
|
|
503
503
|
checkpointer.saveTeam(oldProjectId, teamOptions.team);
|
|
504
504
|
checkpointer.saveSharedContext(oldProjectId, teamOptions.team.sharedContext);
|
|
505
|
-
teamOptions.team.artifactStore
|
|
505
|
+
checkpointer.saveArtifactStore(oldProjectId, teamOptions.team.artifactStore);
|
|
506
506
|
}
|
|
507
507
|
catch {
|
|
508
508
|
// Best effort - continue even if save fails
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Agent, ContextManager } from '@compilr-dev/sdk';
|
|
8
8
|
import type { TerminalUI, AgentMessage } from '../ui/terminal-ui.js';
|
|
9
|
-
import type { AgentTeam } from '
|
|
10
|
-
import type { BackgroundSessionInfo } from '../multi-agent/types.js';
|
|
9
|
+
import type { AgentTeam, BackgroundSessionInfo } from '@compilr-dev/sdk';
|
|
11
10
|
export type { BackgroundSessionInfo };
|
|
12
11
|
/**
|
|
13
12
|
* Context passed to V2 command handlers.
|
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (set by agent.ts during createAgent()). Provides a high-level function
|
|
6
6
|
* for slash command handlers to load capability packs required by a skill.
|
|
7
7
|
*/
|
|
8
|
-
import { SKILL_REQUIREMENTS } from '
|
|
8
|
+
import { SKILL_REQUIREMENTS } from '@compilr-dev/sdk';
|
|
9
9
|
// =============================================================================
|
|
10
10
|
// Module-level state
|
|
11
11
|
// =============================================================================
|
|
@@ -13,10 +13,7 @@
|
|
|
13
13
|
* ├── index.json
|
|
14
14
|
* └── {id}.json
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
17
|
-
import { AgentTeam, type AgentTeamConfig } from './team.js';
|
|
18
|
-
import { SharedContextManager } from './shared-context.js';
|
|
19
|
-
import { ArtifactStore } from './artifacts.js';
|
|
16
|
+
import { AgentTeam, ArtifactStore, SharedContextManager, type AgentTeamConfig, type SerializedTeamAgent, type TeamMetadata } from '@compilr-dev/sdk';
|
|
20
17
|
/**
|
|
21
18
|
* TeamCheckpointer handles persistence for multi-agent teams
|
|
22
19
|
*/
|
|
@@ -107,6 +104,10 @@ export declare class TeamCheckpointer {
|
|
|
107
104
|
* The ArtifactStore handles its own persistence
|
|
108
105
|
*/
|
|
109
106
|
getArtifactStore(projectId: number | null): ArtifactStore;
|
|
107
|
+
/**
|
|
108
|
+
* Save an artifact store to disk for a project
|
|
109
|
+
*/
|
|
110
|
+
saveArtifactStore(projectId: number | null, store: ArtifactStore): void;
|
|
110
111
|
/**
|
|
111
112
|
* Check if artifacts exist for this project
|
|
112
113
|
*/
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import { AgentTeam } from '
|
|
19
|
-
import { SharedContextManager } from './shared-context.js';
|
|
20
|
-
import { ArtifactStore } from './artifacts.js';
|
|
18
|
+
import { AgentTeam, ArtifactStore, SharedContextManager, } from '@compilr-dev/sdk';
|
|
21
19
|
import { getActiveTerminalSessionId } from './session-registry.js';
|
|
22
20
|
const ARTIFACTS_DIR = 'artifacts';
|
|
23
21
|
/**
|
|
@@ -341,11 +339,33 @@ export class TeamCheckpointer {
|
|
|
341
339
|
* The ArtifactStore handles its own persistence
|
|
342
340
|
*/
|
|
343
341
|
getArtifactStore(projectId) {
|
|
342
|
+
const store = new ArtifactStore();
|
|
344
343
|
const artifactsPath = this.getArtifactsPath(projectId);
|
|
345
|
-
const
|
|
346
|
-
|
|
344
|
+
const dataFile = path.join(artifactsPath, 'artifacts.json');
|
|
345
|
+
if (fs.existsSync(dataFile)) {
|
|
346
|
+
try {
|
|
347
|
+
const raw = fs.readFileSync(dataFile, 'utf-8');
|
|
348
|
+
const data = JSON.parse(raw);
|
|
349
|
+
store.restore(data);
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
// Corrupted file — start fresh
|
|
353
|
+
}
|
|
354
|
+
}
|
|
347
355
|
return store;
|
|
348
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Save an artifact store to disk for a project
|
|
359
|
+
*/
|
|
360
|
+
saveArtifactStore(projectId, store) {
|
|
361
|
+
const artifactsPath = this.getArtifactsPath(projectId);
|
|
362
|
+
if (!fs.existsSync(artifactsPath)) {
|
|
363
|
+
fs.mkdirSync(artifactsPath, { recursive: true });
|
|
364
|
+
}
|
|
365
|
+
const dataFile = path.join(artifactsPath, 'artifacts.json');
|
|
366
|
+
const serialized = store.serialize();
|
|
367
|
+
fs.writeFileSync(dataFile, JSON.stringify(serialized, null, 2));
|
|
368
|
+
}
|
|
349
369
|
/**
|
|
350
370
|
* Check if artifacts exist for this project
|
|
351
371
|
*/
|
|
@@ -1,64 +1,11 @@
|
|
|
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
|
-
import { type
|
|
8
|
-
|
|
9
|
-
export interface CustomAgentDefinition {
|
|
10
|
-
id: string;
|
|
11
|
-
displayName: string;
|
|
12
|
-
specialty: string;
|
|
13
|
-
personality?: string;
|
|
14
|
-
mascot: string;
|
|
15
|
-
createdAt: string;
|
|
16
|
-
toolConfig?: ToolConfig;
|
|
17
|
-
enabledSkills?: string[];
|
|
18
|
-
modelTier?: ModelTier;
|
|
19
|
-
}
|
|
20
|
-
export type { ToolConfig, ToolProfile };
|
|
21
|
-
/**
|
|
22
|
-
* Mascots available for custom agents.
|
|
23
|
-
* These are distinct from predefined role mascots.
|
|
24
|
-
*/
|
|
25
|
-
export declare const CUSTOM_MASCOTS: string[];
|
|
26
|
-
/**
|
|
27
|
-
* Assign a mascot from the available pool.
|
|
28
|
-
* Avoids mascots already in use by other custom agents.
|
|
29
|
-
*/
|
|
30
|
-
export declare function assignMascot(existingAgents: CustomAgentDefinition[]): string;
|
|
31
|
-
/**
|
|
32
|
-
* Generate system prompt for a custom agent.
|
|
33
|
-
* Uses a template-based approach (no LLM call).
|
|
34
|
-
* Includes tool awareness if the agent has tool restrictions.
|
|
35
|
-
*/
|
|
36
|
-
export declare function generateCustomAgentSystemPrompt(agent: CustomAgentDefinition): string;
|
|
37
|
-
/**
|
|
38
|
-
* Get the tool filter (list of allowed tools) for a custom agent.
|
|
39
|
-
* Returns undefined for full access (no filtering).
|
|
40
|
-
*/
|
|
41
|
-
export declare function getCustomAgentToolFilter(agent: CustomAgentDefinition): string[] | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Get the profile display name for a custom agent.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getCustomAgentProfileLabel(agent: CustomAgentDefinition): string;
|
|
46
|
-
/**
|
|
47
|
-
* Validate agent ID format.
|
|
48
|
-
* Must be lowercase letters, numbers, and underscores.
|
|
49
|
-
* Must start with a letter.
|
|
50
|
-
*/
|
|
51
|
-
export declare function validateAgentId(id: string): {
|
|
52
|
-
valid: boolean;
|
|
53
|
-
error?: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Check if agent ID is already in use.
|
|
57
|
-
*/
|
|
58
|
-
export declare function isAgentIdTaken(id: string, existingCustomAgents: CustomAgentDefinition[], teamAgentIds: string[], predefinedRoleIds: string[]): {
|
|
59
|
-
taken: boolean;
|
|
60
|
-
reason?: string;
|
|
61
|
-
};
|
|
7
|
+
import { type CustomAgentDefinition } from '@compilr-dev/sdk';
|
|
8
|
+
export { type CustomAgentDefinition, type TeamToolConfig as ToolConfig, type ToolProfile, CUSTOM_MASCOTS, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, } from '@compilr-dev/sdk';
|
|
62
9
|
/**
|
|
63
10
|
* Load custom agents from project directory.
|
|
64
11
|
* Returns empty array if file doesn't exist.
|
|
@@ -77,7 +24,3 @@ export declare function addCustomAgent(projectPath: string, agent: CustomAgentDe
|
|
|
77
24
|
* Remove a custom agent by ID and save.
|
|
78
25
|
*/
|
|
79
26
|
export declare function removeCustomAgent(projectPath: string, agentId: string): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Create a new CustomAgentDefinition with auto-assigned mascot.
|
|
82
|
-
*/
|
|
83
|
-
export declare function createCustomAgentDefinition(id: string, displayName: string, specialty: string, personality: string | undefined, existingAgents: CustomAgentDefinition[], toolConfig?: ToolConfig, enabledSkills?: string[], modelTier?: ModelTier): CustomAgentDefinition;
|
|
@@ -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
|
*/
|