You've already forked agentic-coding-workflow
ACP / MCP 完善
This commit is contained in:
@@ -36,6 +36,9 @@ type Repository interface {
|
||||
ListAllSessions(ctx context.Context, requirementID *uuid.UUID) ([]*Session, error)
|
||||
UpdateSessionRunning(ctx context.Context, id uuid.UUID, agentSessionID string, pid int32) error
|
||||
UpdateSessionFinished(ctx context.Context, id uuid.UUID, status SessionStatus, exitCode *int32, lastErr *string) error
|
||||
// MarkSessionFailedIfActive 把仍处于 starting/running 的 session 标记为 crashed
|
||||
// 并写入 lastErr;已是终态时不更新(守卫式,避免覆盖 onExit 写入的终态)。
|
||||
MarkSessionFailedIfActive(ctx context.Context, id uuid.UUID, lastErr string) (bool, error)
|
||||
CountActiveSessions(ctx context.Context) (int64, error)
|
||||
CountActiveSessionsByUser(ctx context.Context, userID uuid.UUID) (int64, error)
|
||||
ResetStuckSessionsOnRestart(ctx context.Context) ([]*Session, error)
|
||||
@@ -339,6 +342,17 @@ func (r *pgRepo) UpdateSessionFinished(ctx context.Context, id uuid.UUID, status
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *pgRepo) MarkSessionFailedIfActive(ctx context.Context, id uuid.UUID, lastErr string) (bool, error) {
|
||||
n, err := r.q.MarkSessionFailedIfActive(ctx, acpsqlc.MarkSessionFailedIfActiveParams{
|
||||
ID: toPgUUID(id),
|
||||
LastError: &lastErr,
|
||||
})
|
||||
if err != nil {
|
||||
return false, errs.Wrap(err, errs.CodeInternal, "mark session failed if active")
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (r *pgRepo) CountActiveSessions(ctx context.Context) (int64, error) {
|
||||
n, err := r.q.CountActiveSessions(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user