Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Activity {
isDm: boolean;
artifactId: string | null;
childSessionId: string | null;
taskGroupId: string | null;
createdAt: Date;
completedAt: Date | null;
durationMs: number | null;
Expand Down Expand Up @@ -451,6 +452,7 @@ export class ActivityStreamRepository {
isDm: row.is_dm ?? true,
artifactId: row.artifact_id,
childSessionId: row.child_session_id,
taskGroupId: row.task_group_id ?? null,
createdAt: new Date(row.created_at),
completedAt: row.completed_at ? new Date(row.completed_at) : null,
durationMs: row.duration_ms,
Expand Down
33 changes: 32 additions & 1 deletion packages/api/src/data/repositories/project-tasks.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface ProjectTask {
task_order?: number | null;
due_date?: string | null;
metadata?: Record<string, unknown>;
outcome?: string | null;
outcome_reason?: string | null;
created_at: string;
updated_at: string;
}
Expand All @@ -53,6 +55,9 @@ export interface UpdateProjectTaskInput {
priority?: TaskPriority;
tags?: string[];
blocked_by?: string[];
outcome?: string;
outcome_reason?: string;
completed_at?: string | null;
}

export class ProjectTasksRepository {
Expand Down Expand Up @@ -230,7 +235,21 @@ export class ProjectTasksRepository {
* Mark task as completed
*/
async completeTask(id: string): Promise<ProjectTask> {
return this.update(id, { status: 'completed' });
return this.update(id, { status: 'completed', outcome: 'completed' });
}

async closeTask(
id: string,
outcome: 'completed' | 'skipped' | 'blocked' | 'failed',
reason?: string
): Promise<ProjectTask> {
const status = outcome === 'completed' ? 'completed' : 'blocked';
return this.update(id, {
status,
outcome,
outcome_reason: reason,
completed_at: new Date().toISOString(),
});
}

/**
Expand All @@ -247,6 +266,18 @@ export class ProjectTasksRepository {
return this.update(id, { status: 'pending' });
}

async findByGroupId(groupId: string): Promise<ProjectTask[]> {
const { data, error } = await this.client
.from('tasks')
.select('*')
.eq('task_group_id', groupId)
.order('task_order', { ascending: true, nullsFirst: false })
.order('created_at', { ascending: true });

if (error) throw new Error(`Failed to get group tasks: ${error.message}`);
return (data || []) as unknown as ProjectTask[];
}

/**
* Archive a task (soft delete). Tasks are never hard-deleted —
* the execution log must be reproducible.
Expand Down
8 changes: 8 additions & 0 deletions packages/api/src/data/repositories/task-groups.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export interface TaskGroup {
strategy_started_at: string | null;
strategy_paused_at: string | null;
owner_agent_id: string | null;
group_number: number;
slug: string | null;
outcome: string | null;
conclusion: string | null;
created_at: string;
updated_at: string;
}
Expand Down Expand Up @@ -118,6 +122,8 @@ export interface UpdateTaskGroupInput {
strategy_started_at?: string | null;
strategy_paused_at?: string | null;
owner_agent_id?: string | null;
outcome?: string | null;
conclusion?: string | null;
}

export interface ListTaskGroupsOptions {
Expand Down Expand Up @@ -264,6 +270,8 @@ export class TaskGroupsRepository {
if (input.strategy_paused_at !== undefined)
updates.strategy_paused_at = input.strategy_paused_at;
if (input.owner_agent_id !== undefined) updates.owner_agent_id = input.owner_agent_id;
if (input.outcome !== undefined) updates.outcome = input.outcome;
if (input.conclusion !== undefined) updates.conclusion = input.conclusion;

const { data, error } = await this.client
.from('task_groups' as never)
Expand Down
79 changes: 79 additions & 0 deletions packages/api/src/data/supabase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3131,27 +3131,92 @@ export type Database = {
},
];
};
task_group_comments: {
Row: {
agent_id: string | null;
comment_type: string;
content: string;
created_at: string;
created_by_identity_id: string | null;
deleted_at: string | null;
id: string;
metadata: Json;
task_group_id: string;
updated_at: string;
user_id: string;
};
Insert: {
agent_id?: string | null;
comment_type?: string;
content: string;
created_at?: string;
created_by_identity_id?: string | null;
deleted_at?: string | null;
id?: string;
metadata?: Json;
task_group_id: string;
updated_at?: string;
user_id: string;
};
Update: {
agent_id?: string | null;
comment_type?: string;
content?: string;
created_at?: string;
created_by_identity_id?: string | null;
deleted_at?: string | null;
id?: string;
metadata?: Json;
task_group_id?: string;
updated_at?: string;
user_id?: string;
};
Relationships: [
{
foreignKeyName: 'task_group_comments_created_by_identity_id_fkey';
columns: ['created_by_identity_id'];
referencedRelation: 'agent_identities';
referencedColumns: ['id'];
},
{
foreignKeyName: 'task_group_comments_task_group_id_fkey';
columns: ['task_group_id'];
referencedRelation: 'task_groups';
referencedColumns: ['id'];
},
{
foreignKeyName: 'task_group_comments_user_id_fkey';
columns: ['user_id'];
referencedRelation: 'users';
referencedColumns: ['id'];
},
];
};
task_groups: {
Row: {
autonomous: boolean;
conclusion: string | null;
context_summary: string | null;
created_at: string;
current_task_index: number;
description: string | null;
group_number: number;
id: string;
identity_id: string | null;
instructions: string | null;
iterations_since_approval: number;
max_sessions: number | null;
metadata: Json;
next_run_after: string | null;
outcome: string | null;
output_status: string | null;
output_target: string | null;
owner_agent_id: string | null;
plan_uri: string | null;
priority: string;
project_id: string | null;
sessions_used: number;
slug: string | null;
status: string;
strategy: string | null;
strategy_config: Json;
Expand All @@ -3166,24 +3231,28 @@ export type Database = {
};
Insert: {
autonomous?: boolean;
conclusion?: string | null;
context_summary?: string | null;
created_at?: string;
current_task_index?: number;
description?: string | null;
group_number: number;
id?: string;
identity_id?: string | null;
instructions?: string | null;
iterations_since_approval?: number;
max_sessions?: number | null;
metadata?: Json;
next_run_after?: string | null;
outcome?: string | null;
output_status?: string | null;
output_target?: string | null;
owner_agent_id?: string | null;
plan_uri?: string | null;
priority?: string;
project_id?: string | null;
sessions_used?: number;
slug?: string | null;
status?: string;
strategy?: string | null;
strategy_config?: Json;
Expand All @@ -3198,24 +3267,28 @@ export type Database = {
};
Update: {
autonomous?: boolean;
conclusion?: string | null;
context_summary?: string | null;
created_at?: string;
current_task_index?: number;
description?: string | null;
group_number?: number;
id?: string;
identity_id?: string | null;
instructions?: string | null;
iterations_since_approval?: number;
max_sessions?: number | null;
metadata?: Json;
next_run_after?: string | null;
outcome?: string | null;
output_status?: string | null;
output_target?: string | null;
owner_agent_id?: string | null;
plan_uri?: string | null;
priority?: string;
project_id?: string | null;
sessions_used?: number;
slug?: string | null;
status?: string;
strategy?: string | null;
strategy_config?: Json;
Expand Down Expand Up @@ -3259,6 +3332,8 @@ export type Database = {
due_date: string | null;
id: string;
metadata: Json;
outcome: string | null;
outcome_reason: string | null;
priority: string | null;
project_id: string | null;
status: string;
Expand All @@ -3278,6 +3353,8 @@ export type Database = {
due_date?: string | null;
id?: string;
metadata?: Json;
outcome?: string | null;
outcome_reason?: string | null;
priority?: string | null;
project_id?: string | null;
status?: string;
Expand All @@ -3297,6 +3374,8 @@ export type Database = {
due_date?: string | null;
id?: string;
metadata?: Json;
outcome?: string | null;
outcome_reason?: string | null;
priority?: string | null;
project_id?: string | null;
status?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/mcp/tools/activity-stream-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export async function handleGetActivity(args: unknown, dataComposer: DataCompose
contactId: a.contactId,
sessionId: a.sessionId,
payload: a.payload ?? undefined,
taskGroupId: a.taskGroupId ?? undefined,
status: a.status,
createdAt: a.createdAt.toISOString(),
completedAt: a.completedAt?.toISOString(),
Expand Down
Loading
Loading