@compilr-dev/sdk 0.1.28 → 0.2.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.
Files changed (39) hide show
  1. package/dist/index.d.ts +6 -2
  2. package/dist/index.js +27 -1
  3. package/dist/team/activity.d.ts +21 -0
  4. package/dist/team/activity.js +34 -0
  5. package/dist/team/agent-selection.d.ts +53 -0
  6. package/dist/team/agent-selection.js +88 -0
  7. package/dist/team/artifacts.d.ts +175 -0
  8. package/dist/team/artifacts.js +279 -0
  9. package/dist/team/collision-utils.d.ts +16 -0
  10. package/dist/team/collision-utils.js +28 -0
  11. package/dist/team/context-resolver.d.ts +97 -0
  12. package/dist/team/context-resolver.js +322 -0
  13. package/dist/team/custom-agents.d.ts +68 -0
  14. package/dist/team/custom-agents.js +150 -0
  15. package/dist/team/delegation-tracker.d.ts +147 -0
  16. package/dist/team/delegation-tracker.js +215 -0
  17. package/dist/team/index.d.ts +34 -0
  18. package/dist/team/index.js +30 -0
  19. package/dist/team/interfaces.d.ts +36 -0
  20. package/dist/team/interfaces.js +7 -0
  21. package/dist/team/mention-parser.d.ts +64 -0
  22. package/dist/team/mention-parser.js +138 -0
  23. package/dist/team/shared-context.d.ts +293 -0
  24. package/dist/team/shared-context.js +673 -0
  25. package/dist/team/skill-requirements.d.ts +66 -0
  26. package/dist/team/skill-requirements.js +178 -0
  27. package/dist/team/task-assignment.d.ts +69 -0
  28. package/dist/team/task-assignment.js +123 -0
  29. package/dist/team/task-suggestion.d.ts +31 -0
  30. package/dist/team/task-suggestion.js +84 -0
  31. package/dist/team/team-agent.d.ts +201 -0
  32. package/dist/team/team-agent.js +492 -0
  33. package/dist/team/team.d.ts +297 -0
  34. package/dist/team/team.js +615 -0
  35. package/dist/team/tool-config.d.ts +110 -0
  36. package/dist/team/tool-config.js +739 -0
  37. package/dist/team/types.d.ts +211 -0
  38. package/dist/team/types.js +638 -0
  39. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -34,8 +34,12 @@
34
34
  * ```
35
35
  */
36
36
  export { createCompilrAgent } from './agent.js';
37
- export { createTeam } from './team.js';
38
- export type { CompilrAgentConfig, CompilrAgent, CompilrTeam, RunOptions, RunResult, ToolCallRecord, ToolConfig, TeamConfig, TeamAgentConfig, TeamResult, TeamEvent, UsageInfo, ProviderType, PermissionCallback, GuardrailConfig, ContextConfig, } from './config.js';
37
+ export type { CompilrAgentConfig, CompilrAgent, RunOptions, RunResult, ToolCallRecord, ToolConfig, UsageInfo, ProviderType, PermissionCallback, GuardrailConfig, ContextConfig, } from './config.js';
38
+ export { AgentTeam, TeamAgent, SharedContextManager, ArtifactStore, DelegationTracker, ContextResolver, } from './team/index.js';
39
+ export type { AgentTeamConfig, TeamAgentConfig, ITeamPersistence, IArtifactStorage, ISessionRegistry, CustomAgentDefinition, ToolConfig as TeamToolConfig, ToolTier, ToolGroup, ProfileInfo, } from './team/index.js';
40
+ export type { AgentRole, RoleMetadata, ToolProfile, MascotExpression, BackgroundSessionInfo, SerializedTeam, SerializedTeamAgent, TeamMetadata, TeamEvent, TeamEventType, TeamEventHandler, Artifact, ArtifactType as TeamArtifactType, ArtifactSummary as TeamArtifactSummary, CreateArtifactOptions, UpdateArtifactOptions, SerializedArtifact, SharedContext, SharedProjectInfo, SharedTeamInfo, TeamRosterEntry, TeamActivity, TeamActivityType, SharedDecision, TokenBudget, SerializedSharedContext, ParsedMention, ParsedInput, ResolvedMention, ResolveOptions, ResolutionSource, Delegation, DelegationStatus, DelegationResult, CompletionEvent, CreateDelegationOptions, DelegationStats, DelegationTrackerEvents, SkillToolRequirement, } from './team/index.js';
41
+ export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS, TOOL_GROUPS, TOOL_PROFILES, PROFILE_INFO, SKILL_REQUIREMENTS, CUSTOM_MASCOTS, } from './team/index.js';
42
+ export { getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap, findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, resolveAgentIdCollision, setActiveSharedContext, getActiveSharedContext, recordTeamActivity, getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
39
43
  export { codingPreset, readOnlyPreset, resolvePreset } from './presets/index.js';
40
44
  export type { Preset } from './presets/index.js';
41
45
  export type { AnyTool } from './presets/types.js';
package/dist/index.js CHANGED
@@ -37,7 +37,33 @@
37
37
  // Core API
38
38
  // =============================================================================
39
39
  export { createCompilrAgent } from './agent.js';
40
- export { createTeam } from './team.js';
40
+ // =============================================================================
41
+ // Multi-Agent Team Orchestration
42
+ // =============================================================================
43
+ // Core classes
44
+ export { AgentTeam, TeamAgent, SharedContextManager, ArtifactStore, DelegationTracker, ContextResolver, } from './team/index.js';
45
+ // Constants
46
+ export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS, TOOL_GROUPS, TOOL_PROFILES, PROFILE_INFO, SKILL_REQUIREMENTS, CUSTOM_MASCOTS, } from './team/index.js';
47
+ // Utility functions
48
+ export {
49
+ // Tool config
50
+ getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance,
51
+ // Tool config (extended)
52
+ createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile,
53
+ // Custom agents
54
+ assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition,
55
+ // Mention parsing
56
+ parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap,
57
+ // Agent selection
58
+ findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists,
59
+ // Task management
60
+ suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign,
61
+ // Delegation
62
+ resolveAgentIdCollision,
63
+ // Activity
64
+ setActiveSharedContext, getActiveSharedContext, recordTeamActivity,
65
+ // Skills
66
+ getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
41
67
  // =============================================================================
42
68
  // Presets
43
69
  // =============================================================================
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Activity Recording Module
3
+ *
4
+ * Provides a global function for tools to record team activity.
5
+ * The SharedContextManager is set by the consumer when a team is active.
6
+ */
7
+ import type { SharedContextManager, TeamActivityType } from './shared-context.js';
8
+ /**
9
+ * Set the active SharedContextManager for activity recording
10
+ * Called by the consumer when a team is initialized
11
+ */
12
+ export declare function setActiveSharedContext(ctx: SharedContextManager | null): void;
13
+ /**
14
+ * Get the active SharedContextManager
15
+ */
16
+ export declare function getActiveSharedContext(): SharedContextManager | null;
17
+ /**
18
+ * Record team activity
19
+ * Safe to call even if no team is active (will be a no-op)
20
+ */
21
+ export declare function recordTeamActivity(agentId: string, action: TeamActivityType, summary: string): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Activity Recording Module
3
+ *
4
+ * Provides a global function for tools to record team activity.
5
+ * The SharedContextManager is set by the consumer when a team is active.
6
+ */
7
+ // Module-level reference to the active SharedContextManager
8
+ let activeSharedContext = null;
9
+ /**
10
+ * Set the active SharedContextManager for activity recording
11
+ * Called by the consumer when a team is initialized
12
+ */
13
+ export function setActiveSharedContext(ctx) {
14
+ activeSharedContext = ctx;
15
+ }
16
+ /**
17
+ * Get the active SharedContextManager
18
+ */
19
+ export function getActiveSharedContext() {
20
+ return activeSharedContext;
21
+ }
22
+ /**
23
+ * Record team activity
24
+ * Safe to call even if no team is active (will be a no-op)
25
+ */
26
+ export function recordTeamActivity(agentId, action, summary) {
27
+ if (activeSharedContext) {
28
+ activeSharedContext.recordActivity({
29
+ agentId,
30
+ action,
31
+ summary,
32
+ });
33
+ }
34
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Agent Selection Helpers
3
+ *
4
+ * Provides functions for selecting the best agent for a task:
5
+ * - findAgentForRole: Find an agent by role (LRU selection if multiple)
6
+ * - findAgentById: Find an agent by ID
7
+ * - getAvailableSpecialists: Get all non-default agents
8
+ *
9
+ * Uses Least Recently Used (LRU) selection when multiple agents have the same role.
10
+ */
11
+ import type { AgentTeam } from './team.js';
12
+ import type { TeamAgent } from './team-agent.js';
13
+ import type { AgentRole } from './types.js';
14
+ /**
15
+ * Find the best agent for a given role.
16
+ * If multiple agents have the same role, selects the least recently used.
17
+ *
18
+ * @param team - The agent team
19
+ * @param role - The role to find (e.g., 'arch', 'dev', 'qa')
20
+ * @returns The best matching agent, or null if none found
21
+ */
22
+ export declare function findAgentForRole(team: AgentTeam, role: AgentRole): TeamAgent | null;
23
+ /**
24
+ * Find an agent by ID.
25
+ *
26
+ * @param team - The agent team
27
+ * @param id - The agent ID (e.g., 'arch', 'dev-1', 'my-custom-agent')
28
+ * @returns The agent, or null if not found
29
+ */
30
+ export declare function findAgentById(team: AgentTeam, id: string): TeamAgent | null;
31
+ /**
32
+ * Get all specialist agents (non-default agents).
33
+ * Useful for listing available delegation targets.
34
+ *
35
+ * @param team - The agent team
36
+ * @returns Array of specialist agents
37
+ */
38
+ export declare function getAvailableSpecialists(team: AgentTeam): TeamAgent[];
39
+ /**
40
+ * Get a summary of available specialists for the coordinator.
41
+ * Returns a formatted string listing specialists by role.
42
+ *
43
+ * @param team - The agent team
44
+ * @returns Formatted string of available specialists
45
+ */
46
+ export declare function getSpecialistsSummary(team: AgentTeam): string;
47
+ /**
48
+ * Check if the team has any specialists available for delegation.
49
+ *
50
+ * @param team - The agent team
51
+ * @returns True if there are specialist agents
52
+ */
53
+ export declare function hasSpecialists(team: AgentTeam): boolean;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Agent Selection Helpers
3
+ *
4
+ * Provides functions for selecting the best agent for a task:
5
+ * - findAgentForRole: Find an agent by role (LRU selection if multiple)
6
+ * - findAgentById: Find an agent by ID
7
+ * - getAvailableSpecialists: Get all non-default agents
8
+ *
9
+ * Uses Least Recently Used (LRU) selection when multiple agents have the same role.
10
+ */
11
+ /**
12
+ * Find the best agent for a given role.
13
+ * If multiple agents have the same role, selects the least recently used.
14
+ *
15
+ * @param team - The agent team
16
+ * @param role - The role to find (e.g., 'arch', 'dev', 'qa')
17
+ * @returns The best matching agent, or null if none found
18
+ */
19
+ export function findAgentForRole(team, role) {
20
+ const agents = team.getAll();
21
+ // Filter to agents with matching role
22
+ const candidates = agents.filter((agent) => agent.role === role);
23
+ if (candidates.length === 0) {
24
+ return null;
25
+ }
26
+ if (candidates.length === 1) {
27
+ return candidates[0];
28
+ }
29
+ // Multiple candidates: select Least Recently Used (LRU)
30
+ // Sort by lastActivity ascending (oldest first)
31
+ candidates.sort((a, b) => a.lastActivity.getTime() - b.lastActivity.getTime());
32
+ return candidates[0];
33
+ }
34
+ /**
35
+ * Find an agent by ID.
36
+ *
37
+ * @param team - The agent team
38
+ * @param id - The agent ID (e.g., 'arch', 'dev-1', 'my-custom-agent')
39
+ * @returns The agent, or null if not found
40
+ */
41
+ export function findAgentById(team, id) {
42
+ return team.get(id) ?? null;
43
+ }
44
+ /**
45
+ * Get all specialist agents (non-default agents).
46
+ * Useful for listing available delegation targets.
47
+ *
48
+ * @param team - The agent team
49
+ * @returns Array of specialist agents
50
+ */
51
+ export function getAvailableSpecialists(team) {
52
+ return team.getAll().filter((agent) => agent.id !== 'default');
53
+ }
54
+ /**
55
+ * Get a summary of available specialists for the coordinator.
56
+ * Returns a formatted string listing specialists by role.
57
+ *
58
+ * @param team - The agent team
59
+ * @returns Formatted string of available specialists
60
+ */
61
+ export function getSpecialistsSummary(team) {
62
+ const specialists = getAvailableSpecialists(team);
63
+ if (specialists.length === 0) {
64
+ return 'No specialist agents available. Add agents via /team.';
65
+ }
66
+ // Group by role
67
+ const byRole = new Map();
68
+ for (const agent of specialists) {
69
+ const list = byRole.get(agent.role) ?? [];
70
+ list.push(agent);
71
+ byRole.set(agent.role, list);
72
+ }
73
+ const lines = [];
74
+ for (const [role, agents] of byRole) {
75
+ const agentList = agents.map((a) => `$${a.id}`).join(', ');
76
+ lines.push(`- ${role}: ${agentList}`);
77
+ }
78
+ return lines.join('\n');
79
+ }
80
+ /**
81
+ * Check if the team has any specialists available for delegation.
82
+ *
83
+ * @param team - The agent team
84
+ * @returns True if there are specialist agents
85
+ */
86
+ export function hasSpecialists(team) {
87
+ return getAvailableSpecialists(team).length > 0;
88
+ }
@@ -0,0 +1,175 @@
1
+ /**
2
+ * ArtifactStore - Storage for team artifacts
3
+ *
4
+ * Artifacts are named pieces of work that agents can publish and reference:
5
+ * - design: Architecture, API specs, data models
6
+ * - plan: Sprint plans, task breakdowns, timelines
7
+ * - review: Code reviews, security audits, feedback
8
+ * - decision: Architectural decisions, trade-off analysis
9
+ * - note: General notes, meeting summaries
10
+ */
11
+ /**
12
+ * Artifact types
13
+ */
14
+ export type ArtifactType = 'design' | 'plan' | 'review' | 'decision' | 'note';
15
+ /**
16
+ * Full artifact structure
17
+ */
18
+ export interface Artifact {
19
+ id: string;
20
+ name: string;
21
+ agent: string;
22
+ type: ArtifactType;
23
+ content: string;
24
+ summary: string;
25
+ version: number;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ mentions: string[];
29
+ referencedBy: string[];
30
+ }
31
+ /**
32
+ * Artifact summary for the shared context index
33
+ */
34
+ export interface ArtifactSummary {
35
+ id: string;
36
+ name: string;
37
+ agent: string;
38
+ type: ArtifactType;
39
+ summary: string;
40
+ updatedAt: Date;
41
+ }
42
+ /**
43
+ * Options for creating an artifact
44
+ */
45
+ export interface CreateArtifactOptions {
46
+ name: string;
47
+ agent: string;
48
+ type: ArtifactType;
49
+ content: string;
50
+ summary?: string;
51
+ }
52
+ /**
53
+ * Options for updating an artifact
54
+ */
55
+ export interface UpdateArtifactOptions {
56
+ content?: string;
57
+ summary?: string;
58
+ type?: ArtifactType;
59
+ }
60
+ /**
61
+ * Serialized artifact for persistence
62
+ */
63
+ export interface SerializedArtifact {
64
+ id: string;
65
+ name: string;
66
+ agent: string;
67
+ type: ArtifactType;
68
+ content: string;
69
+ summary: string;
70
+ version: number;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ mentions?: string[];
74
+ referencedBy?: string[];
75
+ }
76
+ /**
77
+ * Artifact index for persistence
78
+ */
79
+ export interface ArtifactIndex {
80
+ version: number;
81
+ artifacts: Array<{
82
+ id: string;
83
+ name: string;
84
+ agent: string;
85
+ type: ArtifactType;
86
+ summary: string;
87
+ updatedAt: string;
88
+ }>;
89
+ updatedAt: string;
90
+ }
91
+ /**
92
+ * Manages artifact storage and retrieval
93
+ */
94
+ export declare class ArtifactStore {
95
+ private readonly artifacts;
96
+ private readonly nameToId;
97
+ private updatedAt;
98
+ /**
99
+ * Create a new artifact
100
+ */
101
+ create(options: CreateArtifactOptions): Artifact;
102
+ /**
103
+ * Get an artifact by ID
104
+ */
105
+ get(id: string): Artifact | undefined;
106
+ /**
107
+ * Get an artifact by name (case-insensitive)
108
+ */
109
+ getByName(name: string): Artifact | undefined;
110
+ /**
111
+ * Update an artifact
112
+ */
113
+ update(id: string, options: UpdateArtifactOptions): Artifact | undefined;
114
+ /**
115
+ * Delete an artifact
116
+ */
117
+ delete(id: string): boolean;
118
+ /**
119
+ * Rename an artifact
120
+ */
121
+ rename(id: string, newName: string): Artifact | undefined;
122
+ /**
123
+ * List all artifacts
124
+ */
125
+ list(): Artifact[];
126
+ /**
127
+ * List artifacts by agent
128
+ */
129
+ listByAgent(agent: string): Artifact[];
130
+ /**
131
+ * List artifacts by type
132
+ */
133
+ listByType(type: ArtifactType): Artifact[];
134
+ /**
135
+ * Search artifacts by name or content
136
+ */
137
+ search(query: string): Artifact[];
138
+ /**
139
+ * Get artifact count
140
+ */
141
+ get size(): number;
142
+ /**
143
+ * Check if an artifact exists by name
144
+ */
145
+ has(name: string): boolean;
146
+ /**
147
+ * Check if an artifact exists by ID
148
+ */
149
+ hasId(id: string): boolean;
150
+ /**
151
+ * Generate a summary from content
152
+ * Simple extraction of first meaningful lines
153
+ */
154
+ private generateSummary;
155
+ /**
156
+ * Get summaries for shared context injection
157
+ */
158
+ getSummaries(): ArtifactSummary[];
159
+ /**
160
+ * Serialize all artifacts for external persistence
161
+ */
162
+ serialize(): SerializedArtifact[];
163
+ /**
164
+ * Restore artifacts from serialized data
165
+ */
166
+ restore(data: SerializedArtifact[]): void;
167
+ /**
168
+ * Clear all artifacts
169
+ */
170
+ clear(): void;
171
+ /**
172
+ * Get the last update timestamp
173
+ */
174
+ getLastUpdated(): Date;
175
+ }