@compilr-dev/sdk 0.1.28 → 0.2.1

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 (41) hide show
  1. package/dist/agent.js +16 -4
  2. package/dist/config.d.ts +12 -1
  3. package/dist/index.d.ts +6 -2
  4. package/dist/index.js +27 -1
  5. package/dist/team/activity.d.ts +21 -0
  6. package/dist/team/activity.js +34 -0
  7. package/dist/team/agent-selection.d.ts +53 -0
  8. package/dist/team/agent-selection.js +88 -0
  9. package/dist/team/artifacts.d.ts +175 -0
  10. package/dist/team/artifacts.js +279 -0
  11. package/dist/team/collision-utils.d.ts +16 -0
  12. package/dist/team/collision-utils.js +28 -0
  13. package/dist/team/context-resolver.d.ts +97 -0
  14. package/dist/team/context-resolver.js +322 -0
  15. package/dist/team/custom-agents.d.ts +68 -0
  16. package/dist/team/custom-agents.js +150 -0
  17. package/dist/team/delegation-tracker.d.ts +147 -0
  18. package/dist/team/delegation-tracker.js +215 -0
  19. package/dist/team/index.d.ts +34 -0
  20. package/dist/team/index.js +30 -0
  21. package/dist/team/interfaces.d.ts +36 -0
  22. package/dist/team/interfaces.js +7 -0
  23. package/dist/team/mention-parser.d.ts +64 -0
  24. package/dist/team/mention-parser.js +138 -0
  25. package/dist/team/shared-context.d.ts +293 -0
  26. package/dist/team/shared-context.js +673 -0
  27. package/dist/team/skill-requirements.d.ts +66 -0
  28. package/dist/team/skill-requirements.js +178 -0
  29. package/dist/team/task-assignment.d.ts +69 -0
  30. package/dist/team/task-assignment.js +123 -0
  31. package/dist/team/task-suggestion.d.ts +31 -0
  32. package/dist/team/task-suggestion.js +84 -0
  33. package/dist/team/team-agent.d.ts +201 -0
  34. package/dist/team/team-agent.js +492 -0
  35. package/dist/team/team.d.ts +297 -0
  36. package/dist/team/team.js +615 -0
  37. package/dist/team/tool-config.d.ts +110 -0
  38. package/dist/team/tool-config.js +739 -0
  39. package/dist/team/types.d.ts +211 -0
  40. package/dist/team/types.js +638 -0
  41. package/package.json +1 -1
@@ -0,0 +1,297 @@
1
+ /**
2
+ * AgentTeam - Multi-agent orchestration
3
+ *
4
+ * Manages a team of persistent agents:
5
+ * - Agent switching ($name prefix)
6
+ * - Isolated contexts per agent
7
+ * - Team-level persistence
8
+ * - Event notifications
9
+ */
10
+ import type { Agent, AgentConfig } from '@compilr-dev/agents';
11
+ import { TeamAgent } from './team-agent.js';
12
+ import type { TeamAgentConfig, SerializedTeam, TeamEventHandler, AgentRole } from './types.js';
13
+ import type { ModelTier } from '../models/index.js';
14
+ import { SharedContextManager } from './shared-context.js';
15
+ import { ArtifactStore } from './artifacts.js';
16
+ import type { CustomAgentDefinition } from './custom-agents.js';
17
+ import type { ISessionRegistry } from './interfaces.js';
18
+ /**
19
+ * Configuration for creating an AgentTeam
20
+ */
21
+ export interface AgentTeamConfig {
22
+ /**
23
+ * Team name (for display and persistence)
24
+ */
25
+ name?: string;
26
+ /**
27
+ * Factory function to create Agent instances
28
+ * The team uses this to create agents with consistent configuration
29
+ * @param config - Agent configuration
30
+ * @param systemPromptAddition - Additional system prompt content
31
+ * @param useMinimalSystemPrompt - Use minimal system prompt
32
+ * @param noTools - Skip tool registration
33
+ * @param toolFilter - Limit which tools this agent can use
34
+ * @param modelTier - Model tier for this agent (fast/balanced/powerful)
35
+ */
36
+ agentFactory: (config: Partial<AgentConfig>, systemPromptAddition?: string, useMinimalSystemPrompt?: boolean, noTools?: boolean, toolFilter?: string[], modelTier?: ModelTier) => Promise<Agent>;
37
+ /**
38
+ * Initial agents to add to the team (optional)
39
+ * If not provided, starts with just the default agent
40
+ */
41
+ initialAgents?: TeamAgentConfig[];
42
+ /**
43
+ * Event handler for team events
44
+ */
45
+ onEvent?: TeamEventHandler;
46
+ /**
47
+ * Shared context manager (optional, created if not provided)
48
+ */
49
+ sharedContext?: SharedContextManager;
50
+ /**
51
+ * Artifact store (optional, created if not provided)
52
+ */
53
+ artifactStore?: ArtifactStore;
54
+ /**
55
+ * Session registry for cross-terminal collision detection (optional).
56
+ * CLI provides this via SQLite; desktop/other consumers may omit it.
57
+ */
58
+ sessionRegistry?: ISessionRegistry;
59
+ }
60
+ /**
61
+ * AgentTeam orchestrates multiple persistent agents
62
+ */
63
+ export declare class AgentTeam {
64
+ /**
65
+ * Team name
66
+ */
67
+ readonly name: string;
68
+ /**
69
+ * Map of agent ID to TeamAgent
70
+ */
71
+ private readonly agents;
72
+ /**
73
+ * Currently active agent ID
74
+ */
75
+ private _activeAgentId;
76
+ /**
77
+ * Coordinator agent ID (optional)
78
+ */
79
+ private _coordinatorId?;
80
+ /**
81
+ * Factory for creating agents
82
+ */
83
+ private readonly agentFactory;
84
+ /**
85
+ * Event handler
86
+ */
87
+ private readonly onEvent?;
88
+ /**
89
+ * Shared context manager for cross-agent knowledge sharing
90
+ */
91
+ private readonly _sharedContext;
92
+ /**
93
+ * Artifact store for team artifacts
94
+ */
95
+ private readonly _artifactStore;
96
+ /**
97
+ * Optional session registry for collision detection
98
+ */
99
+ private readonly _sessionRegistry?;
100
+ /**
101
+ * Track handoff source: targetAgentId → sourceAgentId
102
+ * Used for one-hop prevention (agents that were handed a task
103
+ * cannot re-hand it off, except back to the coordinator)
104
+ */
105
+ private readonly _handedFrom;
106
+ /**
107
+ * Creation timestamp
108
+ */
109
+ private readonly createdAt;
110
+ /**
111
+ * Last updated timestamp
112
+ */
113
+ private updatedAt;
114
+ constructor(config: AgentTeamConfig);
115
+ /**
116
+ * Get the currently active agent ID
117
+ */
118
+ get activeAgentId(): string;
119
+ /**
120
+ * Get the coordinator agent ID (if set)
121
+ */
122
+ get coordinatorId(): string | undefined;
123
+ /**
124
+ * Get the shared context manager
125
+ */
126
+ get sharedContext(): SharedContextManager;
127
+ /**
128
+ * Get the artifact store
129
+ */
130
+ get artifactStore(): ArtifactStore;
131
+ /**
132
+ * Get the currently active TeamAgent
133
+ */
134
+ getActive(): TeamAgent;
135
+ /**
136
+ * Get the currently active Agent instance
137
+ * Returns null if not initialized
138
+ */
139
+ getActiveAgent(): Agent | null;
140
+ /**
141
+ * Get a specific TeamAgent by ID
142
+ */
143
+ get(id: string): TeamAgent | undefined;
144
+ /**
145
+ * Set the agent instance for the default TeamAgent
146
+ * Used when the agent is created before the team
147
+ */
148
+ setDefaultAgent(agent: Agent): void;
149
+ /**
150
+ * Check if an agent exists in the team
151
+ */
152
+ has(id: string): boolean;
153
+ /**
154
+ * Get all agent IDs
155
+ */
156
+ getAgentIds(): string[];
157
+ /**
158
+ * Get all TeamAgents
159
+ */
160
+ getAll(): TeamAgent[];
161
+ /**
162
+ * Get team size (number of agents)
163
+ */
164
+ get size(): number;
165
+ /**
166
+ * Add a new agent to the team
167
+ */
168
+ addAgent(config: TeamAgentConfig): Promise<TeamAgent>;
169
+ /**
170
+ * Add an agent from a predefined role
171
+ * @param role - The predefined role
172
+ * @param id - Optional custom ID (defaults to role name)
173
+ * @param modelTier - Optional model tier override (defaults to role's default tier)
174
+ */
175
+ addAgentFromRole(role: AgentRole, id?: string, modelTier?: ModelTier): Promise<TeamAgent>;
176
+ /**
177
+ * Add a custom agent from a CustomAgentDefinition
178
+ */
179
+ addCustomAgent(def: CustomAgentDefinition): Promise<TeamAgent>;
180
+ /**
181
+ * Remove an agent from the team
182
+ */
183
+ removeAgent(id: string): boolean;
184
+ /**
185
+ * Clear conversation history for all agents in the team
186
+ * Used by /reset command to start fresh
187
+ */
188
+ clearAllHistories(): void;
189
+ /**
190
+ * Callback for checking in-progress tasks when switching agents
191
+ * Set by the consumer to provide task counts for warnings
192
+ */
193
+ private _getInProgressTasksCallback?;
194
+ /**
195
+ * Set the callback for getting in-progress tasks
196
+ * Used by consumer to integrate with todo list and work items
197
+ */
198
+ setInProgressTasksCallback(callback: (agentId: string) => {
199
+ todos: string[];
200
+ workItems: string[];
201
+ }): void;
202
+ /**
203
+ * Switch to a different agent
204
+ */
205
+ switchTo(id: string): Promise<TeamAgent>;
206
+ /**
207
+ * Set the coordinator agent
208
+ */
209
+ setCoordinator(id: string | undefined): void;
210
+ /**
211
+ * Check if an agent is the coordinator
212
+ * The default agent is considered coordinator if no explicit coordinator is set.
213
+ */
214
+ isCoordinator(id: string): boolean;
215
+ /**
216
+ * Check if the active agent is the coordinator
217
+ * The default agent is considered coordinator if no explicit coordinator is set.
218
+ */
219
+ isActiveCoordinator(): boolean;
220
+ /**
221
+ * Change an agent's model tier
222
+ * This updates the tier and reinitializes the agent with the new model.
223
+ * Conversation history is preserved.
224
+ *
225
+ * @param id - The agent ID
226
+ * @param newTier - The new model tier
227
+ * @returns The updated TeamAgent
228
+ */
229
+ changeAgentTier(id: string, newTier: ModelTier): Promise<TeamAgent>;
230
+ /**
231
+ * Initialize all agents (lazy initialization)
232
+ */
233
+ initializeAll(): Promise<void>;
234
+ /**
235
+ * Initialize only the active agent
236
+ */
237
+ initializeActive(): Promise<Agent>;
238
+ /**
239
+ * Parse a message for $agent prefix and switch if needed
240
+ * Returns the message without the prefix and whether a switch occurred
241
+ */
242
+ parseAndSwitch(message: string): Promise<{
243
+ message: string;
244
+ switched: boolean;
245
+ agentId: string;
246
+ }>;
247
+ /**
248
+ * Get autocomplete suggestions for $agent prefix
249
+ */
250
+ getAgentSuggestions(prefix: string): Array<{
251
+ id: string;
252
+ label: string;
253
+ }>;
254
+ /**
255
+ * Record that sourceAgent handed off to targetAgent.
256
+ * Used for one-hop prevention.
257
+ */
258
+ recordHandoff(targetAgentId: string, sourceAgentId: string): void;
259
+ /**
260
+ * Check if an agent was handed a task (i.e., is a handoff target).
261
+ * If true, this agent cannot re-hand off (except back to coordinator).
262
+ */
263
+ wasHandedTo(agentId: string): boolean;
264
+ /**
265
+ * Get the source agent that handed off to the given agent.
266
+ */
267
+ getHandoffSource(agentId: string): string | undefined;
268
+ /**
269
+ * Clear handoff tracking for an agent (after it completes its task).
270
+ */
271
+ clearHandoffRecord(agentId: string): void;
272
+ /**
273
+ * Serialize the team for persistence
274
+ */
275
+ serialize(): SerializedTeam;
276
+ /**
277
+ * Restore team state from serialized data
278
+ */
279
+ static restore(data: SerializedTeam, agentFactory: AgentTeamConfig['agentFactory'], onEvent?: TeamEventHandler, options?: {
280
+ sharedContext?: SharedContextManager;
281
+ artifactStore?: ArtifactStore;
282
+ sessionRegistry?: ISessionRegistry;
283
+ }): AgentTeam;
284
+ /**
285
+ * Emit a team event
286
+ */
287
+ private emit;
288
+ /**
289
+ * Build and update the team roster in shared context
290
+ * Called when team composition or active agent changes
291
+ */
292
+ updateTeamRoster(): void;
293
+ /**
294
+ * Build the team roster from current agents
295
+ */
296
+ private buildTeamRoster;
297
+ }