Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | 48x 48x 48x 48x 48x 48x 48x 48x 48x 6x 48x 48x 6x 48x 48x 6x 48x 48x 48x 48x 48x 48x 48x | import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { BaseEntity } from '../core-entities/base.entity';
import { SystemPrompt } from '../core-entities/system-prompt.entity';
import { ContextTemplate } from '../core-entities/context-template.entity';
/**
* SubAgent represents a specialized agent configuration for handling specific tasks.
* Each sub-agent has its own system prompt, context templates, and enabled tools.
*
* Use sub-agents to delegate specialized tasks like bug fixing, refactoring, or testing.
* When a session uses a sub_agent_id, all prompts go through that agent's configuration.
* Sub-agent runs are tracked separately in SubAgentRun entities.
*/
@Entity('sub_agents')
export class SubAgent extends BaseEntity {
@ApiProperty({
description: 'Name of this sub-agent',
example: 'Bug Fixer',
})
@Column({ type: 'text' })
name: string;
@ApiPropertyOptional({
description: 'Description of what this sub-agent does',
example: 'Specialized in identifying and fixing bugs in code',
})
@Column({ type: 'text', nullable: true })
description: string | null;
@ApiPropertyOptional({
description: 'UUID of the system prompt for this sub-agent',
format: 'uuid',
})
@Column({ type: 'uuid', nullable: true })
system_prompt_id: string | null;
@ApiPropertyOptional({
description: 'The system prompt entity for this sub-agent',
type: () => SystemPrompt,
})
@ManyToOne(() => SystemPrompt, {
nullable: true,
onDelete: 'SET NULL',
})
@JoinColumn({ name: 'system_prompt_id' })
systemPrompt: SystemPrompt;
@ApiPropertyOptional({
description: 'UUID of context template for initial prompts',
format: 'uuid',
})
@Column({ type: 'uuid', nullable: true })
context_template_id: string | null;
@ApiPropertyOptional({
description: 'The context template entity for initial prompts',
type: () => ContextTemplate,
})
@ManyToOne(() => ContextTemplate, {
nullable: true,
onDelete: 'SET NULL',
})
@JoinColumn({ name: 'context_template_id' })
contextTemplate: ContextTemplate;
@ApiPropertyOptional({
description: 'UUID of context template for follow-up prompts',
format: 'uuid',
})
@Column({ type: 'uuid', nullable: true })
followup_context_template_id: string | null;
@ApiPropertyOptional({
description: 'The context template entity for follow-up prompts',
type: () => ContextTemplate,
})
@ManyToOne(() => ContextTemplate, {
nullable: true,
onDelete: 'SET NULL',
})
@JoinColumn({ name: 'followup_context_template_id' })
followupContextTemplate: ContextTemplate;
@ApiPropertyOptional({
description: 'Array of tool names this sub-agent can use',
example: ['create_file', 'overwrite_file', 'delete_file'],
type: 'array',
})
@Column({ type: 'json', nullable: true })
enabled_tools: string[] | null;
@ApiPropertyOptional({
description:
'Enabled MCP tools: null (no MCP tools), "all", or array of serverName__toolName identifiers',
example: 'all',
})
@Column({ type: 'text', nullable: true })
enabled_mcp_tools: string | null;
@ApiProperty({
description: 'Whether this sub-agent is active/available',
example: true,
default: true,
})
@Column({ type: 'boolean', default: true })
is_active: boolean;
@ApiPropertyOptional({
description: 'Model ID to use for this sub-agent',
example: 'gemini-2.0-flash',
})
@Column({ type: 'text', nullable: true })
model_id: string | null;
@ApiProperty({
description: 'Whether this is a built-in seed sub-agent (immutable)',
example: false,
default: false,
})
@Column({ type: 'boolean', default: false })
is_builtin: boolean;
@ApiPropertyOptional({
description:
'Unique key for built-in sub-agents (used for version updates)',
example: 'explore-codebase',
})
@Column({ type: 'text', nullable: true, unique: true })
builtin_key: string | null;
}
|