@compilr-dev/cli 0.6.0 → 0.6.2

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 (73) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +12 -0
  3. package/dist/agent.d.ts +2 -0
  4. package/dist/agent.js +66 -1
  5. package/dist/commands-v2/handlers/index.js +2 -2
  6. package/dist/commands-v2/handlers/project.d.ts +1 -0
  7. package/dist/commands-v2/handlers/project.js +36 -2
  8. package/dist/commands-v2/handlers/team.js +23 -3
  9. package/dist/compilr-diff-companion.vsix +0 -0
  10. package/dist/entitlements/index.d.ts +23 -0
  11. package/dist/entitlements/index.js +110 -0
  12. package/dist/guide/cli-guide-entries.d.ts +15 -0
  13. package/dist/guide/cli-guide-entries.js +99 -0
  14. package/dist/guide/index.d.ts +5 -4
  15. package/dist/guide/index.js +4 -3
  16. package/dist/guide/shared-content.js +188 -21
  17. package/dist/handlers/permission-handler.js +10 -3
  18. package/dist/index.js +23 -2
  19. package/dist/repl-v2.d.ts +16 -0
  20. package/dist/repl-v2.js +51 -17
  21. package/dist/tools/db-tools.d.ts +1 -1
  22. package/dist/tools/platform-adapter.d.ts +1 -1
  23. package/dist/tools/platform-adapter.js +6 -1
  24. package/dist/tools.js +6 -1
  25. package/dist/ui/overlay/impl/app-model-overlay-v2.d.ts +57 -0
  26. package/dist/ui/overlay/impl/app-model-overlay-v2.js +232 -0
  27. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +23 -1
  28. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +203 -47
  29. package/dist/ui/overlay/impl/model-overlay-v2.js +2 -2
  30. package/dist/ui/overlay/impl/new-overlay-v2.d.ts +2 -2
  31. package/dist/ui/overlay/impl/new-overlay-v2.js +10 -17
  32. package/dist/ui/overlay/impl/team-overlay-v2.js +2 -2
  33. package/dist/ui/overlay/index.d.ts +1 -0
  34. package/dist/ui/overlay/index.js +1 -0
  35. package/dist/utils/update-checker.d.ts +6 -1
  36. package/dist/utils/update-checker.js +16 -1
  37. package/package.json +8 -7
  38. package/dist/.tsbuildinfo.app +0 -1
  39. package/dist/.tsbuildinfo.data +0 -1
  40. package/dist/.tsbuildinfo.domain +0 -1
  41. package/dist/.tsbuildinfo.foundation +0 -1
  42. package/dist/guide/guide-content.d.ts +0 -23
  43. package/dist/guide/guide-content.js +0 -196
  44. package/dist/multi-agent/activity.d.ts +0 -21
  45. package/dist/multi-agent/activity.js +0 -34
  46. package/dist/multi-agent/agent-selection.d.ts +0 -55
  47. package/dist/multi-agent/agent-selection.js +0 -90
  48. package/dist/multi-agent/artifacts.d.ts +0 -197
  49. package/dist/multi-agent/artifacts.js +0 -379
  50. package/dist/multi-agent/collision-utils.d.ts +0 -16
  51. package/dist/multi-agent/collision-utils.js +0 -28
  52. package/dist/multi-agent/context-resolver.d.ts +0 -97
  53. package/dist/multi-agent/context-resolver.js +0 -316
  54. package/dist/multi-agent/mention-parser.d.ts +0 -64
  55. package/dist/multi-agent/mention-parser.js +0 -146
  56. package/dist/multi-agent/shared-context.d.ts +0 -293
  57. package/dist/multi-agent/shared-context.js +0 -671
  58. package/dist/multi-agent/skill-requirements.d.ts +0 -66
  59. package/dist/multi-agent/skill-requirements.js +0 -178
  60. package/dist/multi-agent/task-assignment.d.ts +0 -69
  61. package/dist/multi-agent/task-assignment.js +0 -123
  62. package/dist/multi-agent/task-suggestion.d.ts +0 -31
  63. package/dist/multi-agent/task-suggestion.js +0 -72
  64. package/dist/multi-agent/team-agent.d.ts +0 -201
  65. package/dist/multi-agent/team-agent.js +0 -488
  66. package/dist/multi-agent/team.d.ts +0 -286
  67. package/dist/multi-agent/team.js +0 -610
  68. package/dist/multi-agent/tool-config.d.ts +0 -110
  69. package/dist/multi-agent/tool-config.js +0 -661
  70. package/dist/multi-agent/types.d.ts +0 -211
  71. package/dist/multi-agent/types.js +0 -617
  72. package/dist/tools/guide-tool.d.ts +0 -12
  73. package/dist/tools/guide-tool.js +0 -59
@@ -1,201 +0,0 @@
1
- /**
2
- * TeamAgent - Wrapper for persistent team agents
3
- *
4
- * Each team agent has:
5
- * - Unique identity (id, name, mascot)
6
- * - Isolated conversation history
7
- * - Role-specific system prompt additions
8
- * - Optional tool filtering
9
- */
10
- import type { Agent, AgentConfig, ContextManager } from '@compilr-dev/sdk';
11
- import type { TeamAgentConfig, SerializedTeamAgent, MascotExpression, AgentRole } from './types.js';
12
- import type { ModelTier } from '../models/index.js';
13
- import type { ProviderType } from '../models/provider-types.js';
14
- import type { SharedContextManager } from './shared-context.js';
15
- import type { CustomAgentDefinition } from './custom-agents.js';
16
- /**
17
- * TeamAgent wraps an Agent instance with team-specific metadata
18
- */
19
- export declare class TeamAgent {
20
- /**
21
- * Unique identifier (e.g., 'pm', 'arch', 'qa')
22
- */
23
- readonly id: string;
24
- /**
25
- * Display name shown in UI
26
- */
27
- readonly displayName: string;
28
- /**
29
- * Mascot expression for visual differentiation
30
- */
31
- readonly mascot: MascotExpression;
32
- /**
33
- * Role type
34
- */
35
- readonly role: AgentRole;
36
- /**
37
- * Optional description
38
- */
39
- readonly description?: string;
40
- /**
41
- * System prompt addition specific to this agent
42
- */
43
- readonly systemPromptAddition?: string;
44
- /**
45
- * Use minimal system prompt - skip all modules
46
- */
47
- readonly useMinimalSystemPrompt?: boolean;
48
- /**
49
- * Skip all tool registration - agent has no tools
50
- */
51
- readonly noTools?: boolean;
52
- /**
53
- * Tool filter (tool names this agent can use)
54
- */
55
- readonly toolFilter?: string[];
56
- /**
57
- * Tool profile name (for display)
58
- */
59
- readonly toolProfile?: TeamAgentConfig['toolProfile'];
60
- /**
61
- * Enabled skills (empty = all skills)
62
- */
63
- readonly enabledSkills?: string[];
64
- /**
65
- * Auto-approve handoffs from this agent without user confirmation
66
- */
67
- readonly autoApproveHandoff?: boolean;
68
- /**
69
- * Model tier (fast/balanced/powerful)
70
- * Determines which model to use based on provider
71
- */
72
- private _modelTier?;
73
- /**
74
- * The underlying agent instance
75
- */
76
- private _agent;
77
- /**
78
- * Agent configuration for lazy initialization
79
- */
80
- private readonly agentConfig;
81
- /**
82
- * Stored agent state (for persistence before agent is created)
83
- */
84
- private storedState?;
85
- /**
86
- * Token usage tracking
87
- */
88
- private _tokenUsage;
89
- /**
90
- * Last activity timestamp
91
- */
92
- private _lastActivity;
93
- constructor(config: TeamAgentConfig);
94
- /**
95
- * Get the underlying agent instance
96
- */
97
- get agent(): Agent | null;
98
- /**
99
- * Check if agent is initialized
100
- */
101
- get isInitialized(): boolean;
102
- /**
103
- * Get token usage
104
- */
105
- get tokenUsage(): {
106
- input: number;
107
- output: number;
108
- };
109
- /**
110
- * Get last activity timestamp
111
- */
112
- get lastActivity(): Date;
113
- /**
114
- * Get model tier
115
- */
116
- get modelTier(): ModelTier | undefined;
117
- /**
118
- * Change the model tier
119
- * This preserves conversation history but strips thinking blocks
120
- * (which contain provider-specific signatures that don't transfer).
121
- *
122
- * @param newTier - The new model tier to use
123
- */
124
- setModelTier(newTier: ModelTier): void;
125
- /**
126
- * Initialize the agent with the given factory
127
- * This allows the team to control agent creation
128
- *
129
- * @param agentFactory Factory function to create the agent
130
- * @param sharedContext Optional shared context to inject into system prompt
131
- */
132
- initialize(agentFactory: (config: Partial<AgentConfig>, systemPromptAddition?: string, useMinimalSystemPrompt?: boolean, noTools?: boolean, toolFilter?: string[], modelTier?: ModelTier) => Promise<Agent>, sharedContext?: SharedContextManager): Promise<void>;
133
- /**
134
- * Set the agent instance directly
135
- * Used for the default agent when an agent is created before the team
136
- */
137
- setAgent(agent: Agent): void;
138
- /**
139
- * Update token usage after a turn
140
- */
141
- updateTokenUsage(input: number, output: number): void;
142
- /**
143
- * Reset token usage (e.g., after compaction)
144
- */
145
- resetTokenUsage(): void;
146
- /**
147
- * Clear conversation history (for /reset command)
148
- * Clears both the underlying agent and stored state
149
- */
150
- clearHistory(): void;
151
- /**
152
- * Get context manager from the agent (if available)
153
- */
154
- getContextManager(): ContextManager | undefined;
155
- /**
156
- * Get context utilization percentage
157
- */
158
- getContextUtilization(): number;
159
- /**
160
- * Get the max context window for this agent's model.
161
- * Resolves: modelTier → modelId → contextWindow from MODEL_REGISTRY.
162
- */
163
- getMaxContextTokens(provider: ProviderType): number;
164
- /**
165
- * Get context stats (works even when agent is not initialized)
166
- * Returns data from either the live agent or stored state.
167
- * Includes maxTokens for per-agent context window display.
168
- */
169
- getContextStats(provider?: ProviderType): {
170
- messageCount: number;
171
- estimatedTokens: number;
172
- maxTokens: number;
173
- };
174
- /**
175
- * Serialize the team agent for persistence
176
- */
177
- serialize(): SerializedTeamAgent;
178
- /**
179
- * Create a TeamAgent from serialized state
180
- */
181
- static fromSerialized(data: SerializedTeamAgent): TeamAgent;
182
- /**
183
- * Create a TeamAgent from a predefined role
184
- * @param role - The predefined role
185
- * @param id - Optional custom ID (defaults to role name)
186
- * @param modelTier - Optional model tier override (defaults to role's default tier)
187
- */
188
- static fromRole(role: AgentRole, id?: string, modelTier?: ModelTier): TeamAgent;
189
- /**
190
- * Create a TeamAgent from a custom agent definition
191
- */
192
- static fromCustomDefinition(def: CustomAgentDefinition): TeamAgent;
193
- /**
194
- * Get a formatted label for display (e.g., "[◈_◈] $arch")
195
- */
196
- getLabel(): string;
197
- /**
198
- * Get a full label with display name (e.g., "[◈_◈] $arch (Solution Architect)")
199
- */
200
- getFullLabel(): string;
201
- }
@@ -1,488 +0,0 @@
1
- /**
2
- * TeamAgent - Wrapper for persistent team agents
3
- *
4
- * Each team agent has:
5
- * - Unique identity (id, name, mascot)
6
- * - Isolated conversation history
7
- * - Role-specific system prompt additions
8
- * - Optional tool filtering
9
- */
10
- import { ROLE_METADATA } from './types.js';
11
- import { getModelForTier, getModelContextWindow } from '../models/index.js';
12
- import { generateCustomAgentSystemPrompt, getCustomAgentToolFilter } from './custom-agents.js';
13
- import { estimateTokens } from '../utils/token-tracker.js';
14
- import { getToolsForProfile, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, } from './tool-config.js';
15
- /**
16
- * TeamAgent wraps an Agent instance with team-specific metadata
17
- */
18
- export class TeamAgent {
19
- /**
20
- * Unique identifier (e.g., 'pm', 'arch', 'qa')
21
- */
22
- id;
23
- /**
24
- * Display name shown in UI
25
- */
26
- displayName;
27
- /**
28
- * Mascot expression for visual differentiation
29
- */
30
- mascot;
31
- /**
32
- * Role type
33
- */
34
- role;
35
- /**
36
- * Optional description
37
- */
38
- description;
39
- /**
40
- * System prompt addition specific to this agent
41
- */
42
- systemPromptAddition;
43
- /**
44
- * Use minimal system prompt - skip all modules
45
- */
46
- useMinimalSystemPrompt;
47
- /**
48
- * Skip all tool registration - agent has no tools
49
- */
50
- noTools;
51
- /**
52
- * Tool filter (tool names this agent can use)
53
- */
54
- toolFilter;
55
- /**
56
- * Tool profile name (for display)
57
- */
58
- toolProfile;
59
- /**
60
- * Enabled skills (empty = all skills)
61
- */
62
- enabledSkills;
63
- /**
64
- * Auto-approve handoffs from this agent without user confirmation
65
- */
66
- autoApproveHandoff;
67
- /**
68
- * Model tier (fast/balanced/powerful)
69
- * Determines which model to use based on provider
70
- */
71
- _modelTier;
72
- /**
73
- * The underlying agent instance
74
- */
75
- _agent = null;
76
- /**
77
- * Agent configuration for lazy initialization
78
- */
79
- agentConfig;
80
- /**
81
- * Stored agent state (for persistence before agent is created)
82
- */
83
- storedState;
84
- /**
85
- * Token usage tracking
86
- */
87
- _tokenUsage = {
88
- input: 0,
89
- output: 0,
90
- };
91
- /**
92
- * Last activity timestamp
93
- */
94
- _lastActivity = new Date();
95
- constructor(config) {
96
- this.id = config.id;
97
- this.displayName = config.displayName;
98
- this.mascot = config.mascot;
99
- this.role = config.role;
100
- this.description = config.description;
101
- this.systemPromptAddition = config.systemPromptAddition;
102
- this.useMinimalSystemPrompt = config.useMinimalSystemPrompt;
103
- this.noTools = config.noTools;
104
- this.toolFilter = config.toolFilter;
105
- this.toolProfile = config.toolProfile;
106
- this.enabledSkills = config.enabledSkills;
107
- this.autoApproveHandoff = config.autoApproveHandoff;
108
- this._modelTier = config.modelTier;
109
- this.agentConfig = config.agentConfig ?? {};
110
- }
111
- /**
112
- * Get the underlying agent instance
113
- */
114
- get agent() {
115
- return this._agent;
116
- }
117
- /**
118
- * Check if agent is initialized
119
- */
120
- get isInitialized() {
121
- return this._agent !== null;
122
- }
123
- /**
124
- * Get token usage
125
- */
126
- get tokenUsage() {
127
- return { ...this._tokenUsage };
128
- }
129
- /**
130
- * Get last activity timestamp
131
- */
132
- get lastActivity() {
133
- return this._lastActivity;
134
- }
135
- /**
136
- * Get model tier
137
- */
138
- get modelTier() {
139
- return this._modelTier;
140
- }
141
- /**
142
- * Change the model tier
143
- * This preserves conversation history but strips thinking blocks
144
- * (which contain provider-specific signatures that don't transfer).
145
- *
146
- * @param newTier - The new model tier to use
147
- */
148
- setModelTier(newTier) {
149
- if (newTier === this._modelTier) {
150
- return; // No change needed
151
- }
152
- // Store current state if agent is initialized
153
- if (this._agent) {
154
- const state = this._agent.serialize();
155
- // Strip thinking blocks from messages - they contain provider-specific
156
- // signatures (e.g., Gemini's thought_signature) that don't transfer
157
- // between sessions or model changes
158
- state.messages = state.messages.map((msg) => {
159
- // Content can be string or ContentBlock[]
160
- if (typeof msg.content === 'string') {
161
- return msg;
162
- }
163
- return {
164
- ...msg,
165
- content: msg.content.filter((block) => block.type !== 'thinking'),
166
- };
167
- });
168
- this.storedState = state;
169
- this._agent = null; // Clear agent so it will be reinitialized
170
- }
171
- this._modelTier = newTier;
172
- }
173
- /**
174
- * Initialize the agent with the given factory
175
- * This allows the team to control agent creation
176
- *
177
- * @param agentFactory Factory function to create the agent
178
- * @param sharedContext Optional shared context to inject into system prompt
179
- */
180
- async initialize(agentFactory, sharedContext) {
181
- if (this._agent) {
182
- return; // Already initialized
183
- }
184
- // Build system prompt addition with shared context
185
- let finalSystemPromptAddition = this.systemPromptAddition ?? '';
186
- // Inject shared context if provided (excluding roster — that goes via anchor for live updates)
187
- if (sharedContext) {
188
- const sharedContextBlock = sharedContext.format({ excludeRoster: true });
189
- if (sharedContextBlock) {
190
- // Prepend shared context to role-specific prompt
191
- finalSystemPromptAddition = finalSystemPromptAddition
192
- ? `${sharedContextBlock}\n\n${finalSystemPromptAddition}`
193
- : sharedContextBlock;
194
- }
195
- }
196
- this._agent = await agentFactory(this.agentConfig, finalSystemPromptAddition || undefined, this.useMinimalSystemPrompt, this.noTools, this.toolFilter, // Pass tool filter to factory
197
- this._modelTier // Pass model tier to factory
198
- );
199
- // Set the team roster as an anchor (dynamically re-injected on every LLM call).
200
- // This ensures roster updates (agent added/removed) are always visible.
201
- if (sharedContext && sharedContext.hasTeamRoster() && this._agent.hasAnchors()) {
202
- this._agent.addAnchor({
203
- id: 'team-roster',
204
- content: sharedContext.formatTeamRoster(),
205
- priority: 'info',
206
- scope: 'session',
207
- });
208
- }
209
- // Restore state if we have stored state
210
- if (this.storedState && this.storedState.messages.length > 0) {
211
- // Strip thinking blocks - they contain provider-specific signatures
212
- // (e.g., Gemini's thought_signature) that don't transfer between sessions
213
- const messagesWithoutThinking = this.storedState.messages.map((msg) => {
214
- if (typeof msg.content === 'string') {
215
- return msg;
216
- }
217
- return {
218
- ...msg,
219
- content: msg.content.filter((block) => block.type !== 'thinking'),
220
- };
221
- });
222
- await this._agent.setHistory(messagesWithoutThinking, {
223
- turnCount: this.storedState.turnCount,
224
- });
225
- }
226
- }
227
- /**
228
- * Set the agent instance directly
229
- * Used for the default agent when an agent is created before the team
230
- */
231
- setAgent(agent) {
232
- this._agent = agent;
233
- }
234
- /**
235
- * Update token usage after a turn
236
- */
237
- updateTokenUsage(input, output) {
238
- this._tokenUsage.input += input;
239
- this._tokenUsage.output += output;
240
- this._lastActivity = new Date();
241
- }
242
- /**
243
- * Reset token usage (e.g., after compaction)
244
- */
245
- resetTokenUsage() {
246
- this._tokenUsage = { input: 0, output: 0 };
247
- }
248
- /**
249
- * Clear conversation history (for /reset command)
250
- * Clears both the underlying agent and stored state
251
- */
252
- clearHistory() {
253
- // Clear underlying agent if initialized
254
- if (this._agent) {
255
- this._agent.clearHistory();
256
- }
257
- // Clear stored state messages
258
- if (this.storedState) {
259
- this.storedState.messages = [];
260
- this.storedState.todos = [];
261
- this.storedState.turnCount = 0;
262
- }
263
- // Reset token usage
264
- this._tokenUsage = { input: 0, output: 0 };
265
- this._lastActivity = new Date();
266
- }
267
- /**
268
- * Get context manager from the agent (if available)
269
- */
270
- getContextManager() {
271
- return this._agent?.getContextManager();
272
- }
273
- /**
274
- * Get context utilization percentage
275
- */
276
- getContextUtilization() {
277
- const cm = this.getContextManager();
278
- if (!cm)
279
- return 0;
280
- const messageCount = this._agent?.serialize().messages.length ?? 0;
281
- const stats = cm.getStats(messageCount);
282
- return Math.round((stats.currentTokens / stats.maxTokens) * 100);
283
- }
284
- /**
285
- * Get the max context window for this agent's model.
286
- * Resolves: modelTier → modelId → contextWindow from MODEL_REGISTRY.
287
- */
288
- getMaxContextTokens(provider) {
289
- // If agent is initialized, get from ContextManager
290
- if (this._agent) {
291
- const cm = this.getContextManager();
292
- if (cm) {
293
- const state = this._agent.serialize();
294
- const stats = cm.getStats(state.messages.length);
295
- return stats.maxTokens;
296
- }
297
- }
298
- // Fall back to model-based lookup
299
- if (this._modelTier) {
300
- const modelId = getModelForTier(provider, this._modelTier);
301
- return getModelContextWindow(modelId, provider);
302
- }
303
- return getModelContextWindow('', provider); // provider fallback
304
- }
305
- /**
306
- * Get context stats (works even when agent is not initialized)
307
- * Returns data from either the live agent or stored state.
308
- * Includes maxTokens for per-agent context window display.
309
- */
310
- getContextStats(provider) {
311
- // Try live agent first — use ContextManager stats (includes overhead)
312
- if (this._agent) {
313
- const cm = this.getContextManager();
314
- if (cm) {
315
- const state = this._agent.serialize();
316
- const stats = cm.getStats(state.messages.length);
317
- return {
318
- messageCount: state.messages.length,
319
- estimatedTokens: stats.currentTokens,
320
- maxTokens: stats.maxTokens,
321
- };
322
- }
323
- // Agent exists but no context manager — estimate
324
- const state = this._agent.serialize();
325
- const messagesStr = JSON.stringify(state.messages);
326
- return {
327
- messageCount: state.messages.length,
328
- estimatedTokens: estimateTokens(messagesStr),
329
- maxTokens: provider ? this.getMaxContextTokens(provider) : 200000,
330
- };
331
- }
332
- // Fall back to stored state
333
- if (this.storedState && this.storedState.messages.length > 0) {
334
- const messagesStr = JSON.stringify(this.storedState.messages);
335
- return {
336
- messageCount: this.storedState.messages.length,
337
- estimatedTokens: estimateTokens(messagesStr),
338
- maxTokens: provider ? this.getMaxContextTokens(provider) : 200000,
339
- };
340
- }
341
- return {
342
- messageCount: 0,
343
- estimatedTokens: 0,
344
- maxTokens: provider ? this.getMaxContextTokens(provider) : 200000,
345
- };
346
- }
347
- /**
348
- * Serialize the team agent for persistence
349
- */
350
- serialize() {
351
- const now = new Date().toISOString();
352
- const agentState = this._agent?.serialize() ?? this.storedState ?? {
353
- sessionId: '',
354
- messages: [],
355
- systemPrompt: '',
356
- todos: [],
357
- currentIteration: 0,
358
- turnCount: 0,
359
- totalTokensUsed: 0,
360
- createdAt: now,
361
- updatedAt: now,
362
- version: 1,
363
- };
364
- return {
365
- id: this.id,
366
- displayName: this.displayName,
367
- mascot: this.mascot,
368
- role: this.role,
369
- description: this.description,
370
- systemPromptAddition: this.systemPromptAddition,
371
- useMinimalSystemPrompt: this.useMinimalSystemPrompt,
372
- noTools: this.noTools,
373
- toolFilter: this.toolFilter,
374
- toolProfile: this.toolProfile,
375
- enabledSkills: this.enabledSkills,
376
- modelTier: this.modelTier,
377
- autoApproveHandoff: this.autoApproveHandoff,
378
- agentState,
379
- };
380
- }
381
- /**
382
- * Create a TeamAgent from serialized state
383
- */
384
- static fromSerialized(data) {
385
- // Refresh tool filter from profile if available (ensures new tools are picked up)
386
- // This handles the case where tools were added after the agent was created
387
- const toolFilter = data.toolProfile
388
- ? getToolsForProfile(data.toolProfile)
389
- : data.toolFilter;
390
- const agent = new TeamAgent({
391
- id: data.id,
392
- displayName: data.displayName,
393
- mascot: data.mascot,
394
- role: data.role,
395
- description: data.description,
396
- systemPromptAddition: data.systemPromptAddition,
397
- useMinimalSystemPrompt: data.useMinimalSystemPrompt,
398
- noTools: data.noTools,
399
- toolFilter,
400
- toolProfile: data.toolProfile,
401
- enabledSkills: data.enabledSkills,
402
- modelTier: data.modelTier,
403
- autoApproveHandoff: data.autoApproveHandoff,
404
- });
405
- // Store the state for restoration when agent is initialized
406
- agent.storedState = data.agentState;
407
- return agent;
408
- }
409
- /**
410
- * Create a TeamAgent from a predefined role
411
- * @param role - The predefined role
412
- * @param id - Optional custom ID (defaults to role name)
413
- * @param modelTier - Optional model tier override (defaults to role's default tier)
414
- */
415
- static fromRole(role, id, modelTier) {
416
- const metadata = ROLE_METADATA[role];
417
- // Get tool filter from default profile (if specified)
418
- const profile = metadata.defaultToolProfile;
419
- const toolFilter = profile ? getToolsForProfile(profile) : undefined;
420
- // Build system prompt with tool awareness (for non-full profiles)
421
- let systemPromptAddition = metadata.defaultSystemPromptAddition ?? '';
422
- if (profile && profile !== 'full') {
423
- const toolAwareness = generateToolAwarenessPrompt({ profile });
424
- systemPromptAddition = systemPromptAddition
425
- ? `${systemPromptAddition}\n\n${toolAwareness}`
426
- : toolAwareness;
427
- }
428
- // Add delegation guidance based on role
429
- if (role === 'default') {
430
- // Coordinator gets delegation tool guidance
431
- const coordinatorGuidance = generateCoordinatorGuidance();
432
- systemPromptAddition = systemPromptAddition
433
- ? `${systemPromptAddition}\n\n${coordinatorGuidance}`
434
- : coordinatorGuidance;
435
- }
436
- else {
437
- // Specialists get collaboration guidance
438
- const specialistGuidance = generateSpecialistGuidance(role);
439
- systemPromptAddition = systemPromptAddition
440
- ? `${systemPromptAddition}\n\n${specialistGuidance}`
441
- : specialistGuidance;
442
- }
443
- return new TeamAgent({
444
- id: id ?? role,
445
- displayName: metadata.displayName,
446
- mascot: metadata.mascot,
447
- role,
448
- description: metadata.description,
449
- systemPromptAddition: systemPromptAddition || undefined,
450
- useMinimalSystemPrompt: metadata.useMinimalSystemPrompt,
451
- noTools: metadata.noTools,
452
- toolFilter,
453
- toolProfile: profile,
454
- modelTier: modelTier ?? metadata.defaultModelTier,
455
- });
456
- }
457
- /**
458
- * Create a TeamAgent from a custom agent definition
459
- */
460
- static fromCustomDefinition(def) {
461
- // Get tool filter from custom agent config
462
- const toolFilter = getCustomAgentToolFilter(def);
463
- return new TeamAgent({
464
- id: def.id,
465
- displayName: def.displayName,
466
- mascot: def.mascot,
467
- role: 'custom',
468
- description: def.specialty,
469
- systemPromptAddition: generateCustomAgentSystemPrompt(def),
470
- toolFilter, // Pass tool filter from custom agent config
471
- toolProfile: def.toolConfig?.profile, // Store profile for display
472
- enabledSkills: def.enabledSkills, // Store skills for display
473
- modelTier: def.modelTier, // Store model tier
474
- });
475
- }
476
- /**
477
- * Get a formatted label for display (e.g., "[◈_◈] $arch")
478
- */
479
- getLabel() {
480
- return `${this.mascot} $${this.id}`;
481
- }
482
- /**
483
- * Get a full label with display name (e.g., "[◈_◈] $arch (Solution Architect)")
484
- */
485
- getFullLabel() {
486
- return `${this.mascot} $${this.id} (${this.displayName})`;
487
- }
488
- }