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 | 11x 11x 11x 11x 11x 11x 53x 11x 11x 6x 11x 11x 6x 11x 11x 6x 11x 11x 11x 11x 11x 11x 11x 11x 11x | import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { BaseEntity } from '../core-entities/base.entity';
import { Session } from '../core-entities/session.entity';
import { SubAgent } from './sub-agent.entity';
import { SubAgentRunStatus } from '../core-entities/enums';
// Re-export for backwards compatibility
export { SubAgentRunStatus } from '../core-entities/enums';
/**
* SubAgentRun tracks the execution of a sub-agent within a session.
* When a sub-agent is invoked, it creates a child session and this run record.
*
* Use GET /sub-agent-runs/active to see currently running sub-agents.
* Use POST /sub-agent-runs/{runId}/cancel to stop a running sub-agent.
* The result field contains the sub-agent's final output when completed.
*/
@Entity('sub_agent_runs')
export class SubAgentRun extends BaseEntity {
@ApiProperty({
description: 'UUID of the parent session that invoked this sub-agent',
format: 'uuid',
})
@Column({ type: 'uuid' })
parent_session_id: string;
@ApiProperty({
description: 'The parent session entity',
type: () => Session,
})
@ManyToOne(() => Session, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'parent_session_id' })
parentSession: Session;
@ApiProperty({
description: 'UUID of the child session created by this sub-agent',
format: 'uuid',
})
@Column({ type: 'uuid' })
child_session_id: string;
@ApiPropertyOptional({
description: 'The child session entity created by this sub-agent',
type: () => Session,
})
@ManyToOne(() => Session, { onDelete: 'SET NULL', nullable: true })
@JoinColumn({ name: 'child_session_id' })
childSession: Session | null;
@ApiProperty({
description: 'UUID of the sub-agent configuration used',
format: 'uuid',
})
@Column({ type: 'uuid', nullable: true })
sub_agent_id: string | null;
@ApiPropertyOptional({
description: 'The sub-agent entity used',
type: () => SubAgent,
})
@ManyToOne(() => SubAgent, { onDelete: 'SET NULL', nullable: true })
@JoinColumn({ name: 'sub_agent_id' })
subAgent: SubAgent | null;
@ApiProperty({
description: 'Name of the sub-agent (for display/logging)',
example: 'Bug Fixer',
})
@Column({ type: 'text' })
agent_name: string;
@ApiProperty({
description: 'The initial prompt sent to the sub-agent',
example: 'Fix the authentication bug in src/auth.ts',
})
@Column({ type: 'text' })
initial_prompt: string;
@ApiProperty({
description: 'Current execution status of this run',
enum: SubAgentRunStatus,
enumName: 'SubAgentRunStatus',
example: SubAgentRunStatus.RUNNING,
})
@Column({
type: 'text',
default: SubAgentRunStatus.RUNNING,
})
status: SubAgentRunStatus;
@ApiPropertyOptional({
description: 'Timestamp when the run started',
type: 'string',
format: 'date-time',
})
@Column({ type: 'datetime', nullable: true })
started_at: Date;
@ApiPropertyOptional({
description: 'Timestamp when the run completed',
type: 'string',
format: 'date-time',
})
@Column({ type: 'datetime', nullable: true })
completed_at: Date;
@ApiPropertyOptional({
description: 'Result/output from the sub-agent when completed',
})
@Column({ type: 'text', nullable: true })
result: string | null;
@ApiPropertyOptional({
description: 'Error message if the run failed',
})
@Column({ type: 'text', nullable: true })
error_message: string | null;
@ApiPropertyOptional({
description: 'Duration of the run in milliseconds',
example: 45000,
})
@Column({ type: 'integer', nullable: true })
duration_ms: number | null;
}
|