Simplify codebase per audit of 8b89f14

This commit is contained in:
Ian Gulliver
2026-10-23 15:10:06 -07:00
parent a53b293528
commit b5a72d713b
14 changed files with 361 additions and 820 deletions
+3 -106
View File
@@ -298,19 +298,6 @@ paths:
schema: { $ref: "#/components/schemas/Project" } schema: { $ref: "#/components/schemas/Project" }
"400": { $ref: "#/components/responses/Error" } "400": { $ref: "#/components/responses/Error" }
/api/projects/{projectId}:
parameters:
- { name: projectId, in: path, required: true, schema: { type: string } }
get:
operationId: getProject
responses:
"200":
description: The project.
content:
application/json:
schema: { $ref: "#/components/schemas/Project" }
"404": { $ref: "#/components/responses/Error" }
/api/projects/{projectId}/review-workflow: /api/projects/{projectId}/review-workflow:
parameters: parameters:
- { name: projectId, in: path, required: true, schema: { type: string } } - { name: projectId, in: path, required: true, schema: { type: string } }
@@ -573,22 +560,6 @@ paths:
schema: { $ref: "#/components/schemas/Task" } schema: { $ref: "#/components/schemas/Task" }
"404": { $ref: "#/components/responses/Error" } "404": { $ref: "#/components/responses/Error" }
/api/tasks/{taskId}/workflow:
parameters:
- { name: taskId, in: path, required: true, schema: { type: string } }
get:
operationId: getTaskWorkflow
description: >
The workflow the task's run froze when it was created, as it was then, for a workflow run's task or one of
its stage tasks. Later edits and deletes of the workflow don't change it.
responses:
"200":
description: The frozen workflow.
content:
application/json:
schema: { $ref: "#/components/schemas/TaskWorkflow" }
"404": { $ref: "#/components/responses/Error" }
/api/tasks/{taskId}/summary-read: /api/tasks/{taskId}/summary-read:
parameters: parameters:
- { name: taskId, in: path, required: true, schema: { type: string } } - { name: taskId, in: path, required: true, schema: { type: string } }
@@ -993,40 +964,6 @@ paths:
items: { $ref: "#/components/schemas/Preview" } items: { $ref: "#/components/schemas/Preview" }
"404": { $ref: "#/components/responses/Error" } "404": { $ref: "#/components/responses/Error" }
/api/tasks/{taskId}/snapshots:
parameters:
- { name: taskId, in: path, required: true, schema: { type: string } }
get:
operationId: listSnapshots
description: >
The task's snapshots, oldest first. Each is a commit of the worktree as if everything were staged, kept at
refs/byre/tasks/{taskId}/snap/{n} until the task is merged or discarded; the rows remain after that.
responses:
"200":
description: The snapshots.
content:
application/json:
schema:
type: array
items: { $ref: "#/components/schemas/Snapshot" }
"404": { $ref: "#/components/responses/Error" }
/api/tasks/{taskId}/reviews:
parameters:
- { name: taskId, in: path, required: true, schema: { type: string } }
get:
operationId: listReviews
description: The task's reviews, one per snapshot, oldest first.
responses:
"200":
description: The reviews.
content:
application/json:
schema:
type: array
items: { $ref: "#/components/schemas/Review" }
"404": { $ref: "#/components/responses/Error" }
/api/reviews/{reviewId}/findings/{index}: /api/reviews/{reviewId}/findings/{index}:
parameters: parameters:
- { name: reviewId, in: path, required: true, schema: { type: string } } - { name: reviewId, in: path, required: true, schema: { type: string } }
@@ -1141,19 +1078,6 @@ paths:
"404": { $ref: "#/components/responses/Error" } "404": { $ref: "#/components/responses/Error" }
"409": { $ref: "#/components/responses/Error" } "409": { $ref: "#/components/responses/Error" }
/api/sessions/{sessionId}:
parameters:
- { name: sessionId, in: path, required: true, schema: { type: string } }
get:
operationId: getSession
responses:
"200":
description: The session.
content:
application/json:
schema: { $ref: "#/components/schemas/AgentSession" }
"404": { $ref: "#/components/responses/Error" }
/api/sessions/{sessionId}/messages: /api/sessions/{sessionId}/messages:
parameters: parameters:
- { name: sessionId, in: path, required: true, schema: { type: string } } - { name: sessionId, in: path, required: true, schema: { type: string } }
@@ -1283,35 +1207,16 @@ paths:
/api/inbox: /api/inbox:
get: get:
operationId: listInbox operationId: listInbox
description: > description: Open inbox items with their responses, oldest first.
Inbox items, oldest first.
Filters narrow the one query to a project's or a task's view.
parameters:
- { name: project_id, in: query, required: false, schema: { type: string } }
- { name: task_id, in: query, required: false, schema: { type: string } }
- { name: state, in: query, required: false, schema: { $ref: "#/components/schemas/InboxState" } }
responses: responses:
"200": "200":
description: Matching items with their responses. Defaults to open items. description: The open items.
content: content:
application/json: application/json:
schema: schema:
type: array type: array
items: { $ref: "#/components/schemas/InboxItem" } items: { $ref: "#/components/schemas/InboxItem" }
/api/inbox/{itemId}:
parameters:
- { name: itemId, in: path, required: true, schema: { type: string } }
get:
operationId: getInboxItem
responses:
"200":
description: The item with its responses.
content:
application/json:
schema: { $ref: "#/components/schemas/InboxItem" }
"404": { $ref: "#/components/responses/Error" }
/api/inbox/{itemId}/dismiss: /api/inbox/{itemId}/dismiss:
parameters: parameters:
- { name: itemId, in: path, required: true, schema: { type: string } } - { name: itemId, in: path, required: true, schema: { type: string } }
@@ -1706,7 +1611,7 @@ components:
forked_from: { type: string, description: "The task this one was forked from; absent for other tasks." } forked_from: { type: string, description: "The task this one was forked from; absent for other tasks." }
forked_at: { type: integer, description: "With forked_from: the n of the snapshot it was forked at; absent when it continues a closed task from its end." } forked_at: { type: integer, description: "With forked_from: the n of the snapshot it was forked at; absent when it continues a closed task from its end." }
merge_queued_at: { type: string, format: date-time, description: "When Merge was requested while another task in the project was merging; absent once the merge starts or when none is held." } merge_queued_at: { type: string, format: date-time, description: "When Merge was requested while another task in the project was merging; absent once the merge starts or when none is held." }
workflow: { type: string, description: "For a workflow run's task: the name of the workflow it froze at creation (getTaskWorkflow has its copy). A run's task has no agent, worktree or branch (branch, worktree_path and base_ref are empty); its stage tasks are its subtasks, and it closes once they all have, as merged when any of them merged. Absent for other tasks." } workflow: { type: string, description: "For a workflow run's task: the name of the workflow it froze at creation (getWorkflowRun has its copy). A run's task has no agent, worktree or branch (branch, worktree_path and base_ref are empty); its stage tasks are its subtasks, and it closes once they all have, as merged when any of them merged. Absent for other tasks." }
workflow_stage: { type: string, description: "For a stage task of a workflow run: the name of the stage it runs; parent_task_id is the run's task. Absent for other tasks." } workflow_stage: { type: string, description: "For a stage task of a workflow run: the name of the stage it runs; parent_task_id is the run's task. Absent for other tasks." }
audit: { type: string, description: "The default branch commit an audit audits, on the task of a run of its project's audit workflow; absent for other tasks." } audit: { type: string, description: "The default branch commit an audit audits, on the task of a run of its project's audit workflow; absent for other tasks." }
background: { type: boolean, description: "Whether the task is an audit's run or stage task that hasn't asked for attention yet: no question, ready_for_merge or error so far (for a run, from any of its stage tasks). The app keeps it out of the task switcher and shows it muted on the project's dashboard, and the lead gets no signals about it." } background: { type: boolean, description: "Whether the task is an audit's run or stage task that hasn't asked for attention yet: no question, ready_for_merge or error so far (for a run, from any of its stage tasks). The app keeps it out of the task switcher and shows it muted on the project's dashboard, and the lead gets no signals about it." }
@@ -1882,14 +1787,6 @@ components:
effort: { type: string, x-go-type-skip-optional-pointer: true, description: "The agent's effort; empty means the vendor's default." } effort: { type: string, x-go-type-skip-optional-pointer: true, description: "The agent's effort; empty means the vendor's default." }
prompt: { type: string, description: "This agent's own instructions: its role in the team." } prompt: { type: string, description: "This agent's own instructions: its role in the team." }
TaskWorkflow:
type: object
description: The workflow a task froze when it was created, as it was then.
required: [name, definition]
properties:
name: { type: string }
definition: { $ref: "#/components/schemas/WorkflowDefinition" }
WorkflowRun: WorkflowRun:
type: object type: object
required: [name, title, brief, definition, finished, stages] required: [name, title, brief, definition, finished, stages]
+3 -3
View File
@@ -414,7 +414,7 @@ func (m *Manager) recoverSession(ctx context.Context, sess api.AgentSession) err
l, err := m.ensureLive(ctx, sess, task) l, err := m.ensureLive(ctx, sess, task)
if err != nil { if err != nil {
return m.failResume(ctx, sess, task, err) return m.failResume(ctx, sess, err)
} }
notice := restartNotice notice := restartNotice
@@ -429,7 +429,7 @@ func (m *Manager) recoverSession(ctx context.Context, sess api.AgentSession) err
} }
err = m.message(ctx, sess, task, l, "byre", notice, nil) err = m.message(ctx, sess, task, l, "byre", notice, nil)
if err != nil { if err != nil {
return m.failResume(ctx, sess, task, err) return m.failResume(ctx, sess, err)
} }
slog.Info("resumed session", "session", sess.Id, "task", task.Id, "owner", sess.Owner) slog.Info("resumed session", "session", sess.Id, "task", task.Id, "owner", sess.Owner)
m.logUndelivered(ctx, sess.Id, "resumed with restart notice") m.logUndelivered(ctx, sess.Id, "resumed with restart notice")
@@ -508,7 +508,7 @@ func (m *Manager) Recover(ctx context.Context) error {
return nil return nil
} }
func (m *Manager) failResume(ctx context.Context, sess api.AgentSession, task api.Task, err error) error { func (m *Manager) failResume(ctx context.Context, sess api.AgentSession, err error) error {
slog.Error("resume session", "session", sess.Id, "err", err) slog.Error("resume session", "session", sess.Id, "err", err)
if sess.Role == api.Reviewer { if sess.Role == api.Reviewer {
r, rerr := m.store.ReviewBySession(ctx, sess.Id) r, rerr := m.store.ReviewBySession(ctx, sess.Id)
-4
View File
@@ -256,10 +256,6 @@ func (m *Manager) fileError(ctx context.Context, taskID, msg string) {
slog.Error("list sessions to file error on", "task", taskID, "error", msg, "err", err) slog.Error("list sessions to file error on", "task", taskID, "error", msg, "err", err)
return return
} }
m.fileTaskError(ctx, task, sessions, msg)
}
func (m *Manager) fileTaskError(ctx context.Context, task api.Task, sessions []api.AgentSession, msg string) {
if len(sessions) == 0 { if len(sessions) == 0 {
slog.Error("no session to file task error on", "task", task.Id, "error", msg) slog.Error("no session to file task error on", "task", task.Id, "error", msg)
return return
+7 -19
View File
@@ -77,14 +77,6 @@ func reviewProblem(def api.WorkflowDefinition) error {
return nil return nil
} }
func (m *Manager) TaskWorkflow(ctx context.Context, taskID string) (api.TaskWorkflow, error) {
frozen, err := m.store.TaskWorkflow(ctx, taskID)
if err != nil {
return api.TaskWorkflow{}, err
}
return api.TaskWorkflow{Name: frozen.Name, Definition: frozen.Definition}, nil
}
func (m *Manager) WorkflowRun(ctx context.Context, taskID string) (api.WorkflowRun, error) { func (m *Manager) WorkflowRun(ctx context.Context, taskID string) (api.WorkflowRun, error) {
task, err := m.store.GetTask(ctx, taskID) task, err := m.store.GetTask(ctx, taskID)
if err != nil { if err != nil {
@@ -306,14 +298,14 @@ func (m *Manager) startStage(ctx context.Context, project api.Project, creator a
if err != nil { if err != nil {
return api.Task{}, err return api.Task{}, err
} }
_, err = m.beginStage(ctx, task, project, creator, frozen, parents, actor) err = m.beginStage(ctx, task, project, creator, frozen, parents, actor)
if err != nil { if err != nil {
return task, fmt.Errorf("task %s created, but its agent did not start: %w", task.Id, err) return task, fmt.Errorf("task %s created, but its agent did not start: %w", task.Id, err)
} }
return task, nil return task, nil
} }
func (m *Manager) beginStage(ctx context.Context, task api.Task, project api.Project, creator api.User, frozen store.FrozenWorkflow, parents []parentStage, actor string) (api.AgentSession, error) { func (m *Manager) beginStage(ctx context.Context, task api.Task, project api.Project, creator api.User, frozen store.FrozenWorkflow, parents []parentStage, actor string) error {
stage := *task.WorkflowStage stage := *task.WorkflowStage
after := []string{} after := []string{}
for _, p := range parents { for _, p := range parents {
@@ -327,19 +319,15 @@ func (m *Manager) beginStage(ctx context.Context, task api.Task, project api.Pro
Payload: map[string]any{"id": task.Id, "workflow": frozen.Name, "run": *task.ParentTaskId, "stage": stage, "after": after}, Payload: map[string]any{"id": task.Id, "workflow": frozen.Name, "run": *task.ParentTaskId, "stage": stage, "after": after},
}) })
if err != nil { if err != nil {
return api.AgentSession{}, err return err
} }
s := workflow.Get(frozen.Definition, stage) s := workflow.Get(frozen.Definition, stage)
message := stageMessage(frozen, stage, parents, project.DefaultBranch) message := stageMessage(frozen, stage, parents, project.DefaultBranch)
if s.Agents == nil { if s.Agents == nil {
return m.create(ctx, task, creator, "", "byre", Prompt{Text: message, Model: s.Model, Effort: s.Effort}) _, err = m.create(ctx, task, creator, "", "byre", Prompt{Text: message, Model: s.Model, Effort: s.Effort})
return err
} }
err = m.startTeam(ctx, task, creator, message, *s.Agents, "byre") return m.startTeam(ctx, task, creator, message, *s.Agents, "byre")
if err != nil {
return api.AgentSession{}, err
}
sess, _, err := m.liveSession(ctx, task.Id)
return sess, err
} }
func stageMessage(frozen store.FrozenWorkflow, stage string, parents []parentStage, defaultBranch string) string { func stageMessage(frozen store.FrozenWorkflow, stage string, parents []parentStage, defaultBranch string) string {
@@ -576,7 +564,7 @@ func (m *Manager) resumeStage(ctx context.Context, task api.Task, project api.Pr
return nil, err return nil, err
} }
if len(sessions) == 0 { if len(sessions) == 0 {
_, err := m.beginStage(ctx, task, project, creator, frozen, parents, "byre") err := m.beginStage(ctx, task, project, creator, frozen, parents, "byre")
if err != nil { if err != nil {
return nil, err return nil, err
} }
+329 -574
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -53,7 +53,7 @@ func Inspect(ctx context.Context, path string) (RepoInfo, error) {
return RepoInfo{}, err return RepoInfo{}, err
} }
remote, _, code, err := runCode(ctx, root, nil, "remote", "get-url", Remote) remote, _, code, err := runCode(ctx, root, "remote", "get-url", Remote)
if err != nil { if err != nil {
return RepoInfo{}, err return RepoInfo{}, err
} }
@@ -65,7 +65,7 @@ func Inspect(ctx context.Context, path string) (RepoInfo, error) {
} }
func HasRemote(ctx context.Context, repo string) (bool, error) { func HasRemote(ctx context.Context, repo string) (bool, error) {
_, _, code, err := runCode(ctx, repo, nil, "remote", "get-url", Remote) _, _, code, err := runCode(ctx, repo, "remote", "get-url", Remote)
return err == nil && code == 0, err return err == nil && code == 0, err
} }
@@ -92,7 +92,7 @@ func AddWorktree(ctx context.Context, repo, path, branch, base string) (string,
} }
func EnsureBranchCommit(ctx context.Context, repo, branch string, env []string) error { func EnsureBranchCommit(ctx context.Context, repo, branch string, env []string) error {
_, _, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch+"^{commit}") _, _, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch+"^{commit}")
if err != nil || code == 0 { if err != nil || code == 0 {
return err return err
} }
@@ -152,7 +152,7 @@ func RemoveWorktree(ctx context.Context, repo, path, branch string) error {
} }
} }
_, _, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch) _, _, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch)
if err != nil || code != 0 { if err != nil || code != 0 {
return err return err
} }
@@ -206,7 +206,7 @@ func SquashCommit(ctx context.Context, repo, worktree, target, message string, e
return "", err return "", err
} }
out, stderr, code, err := runCode(ctx, repo, nil, "merge-tree", "--write-tree", "--name-only", "--merge-base="+base, head, tree) out, stderr, code, err := runCode(ctx, repo, "merge-tree", "--write-tree", "--name-only", "--merge-base="+base, head, tree)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -237,7 +237,7 @@ func SquashCommit(ctx context.Context, repo, worktree, target, message string, e
if err != nil { if err != nil {
return "", err return "", err
} }
signing, stderr, code, err := runCode(ctx, repo, nil, "config", "--type=bool", "--get", "commit.gpgsign") signing, stderr, code, err := runCode(ctx, repo, "config", "--type=bool", "--get", "commit.gpgsign")
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -340,7 +340,7 @@ func BranchHead(ctx context.Context, repo, branch string) (string, error) {
} }
func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, error) { func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, error) {
_, stderr, code, err := runCode(ctx, dir, nil, "merge-base", "--is-ancestor", ancestor, descendant) _, stderr, code, err := runCode(ctx, dir, "merge-base", "--is-ancestor", ancestor, descendant)
if err != nil { if err != nil {
return false, err return false, err
} }
@@ -354,7 +354,7 @@ func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, er
} }
func MergeInProgress(ctx context.Context, dir string) (bool, error) { func MergeInProgress(ctx context.Context, dir string) (bool, error) {
_, _, code, err := runCode(ctx, dir, nil, "rev-parse", "--quiet", "--verify", "MERGE_HEAD") _, _, code, err := runCode(ctx, dir, "rev-parse", "--quiet", "--verify", "MERGE_HEAD")
return err == nil && code == 0, err return err == nil && code == 0, err
} }
@@ -368,7 +368,7 @@ func AbortMerge(ctx context.Context, dir string) error {
} }
func ReadFile(ctx context.Context, repo, rev, path string) (string, bool, error) { func ReadFile(ctx context.Context, repo, rev, path string) (string, bool, error) {
_, _, code, err := runCode(ctx, repo, nil, "cat-file", "-e", rev+":"+path) _, _, code, err := runCode(ctx, repo, "cat-file", "-e", rev+":"+path)
if err != nil { if err != nil {
return "", false, err return "", false, err
} }
@@ -434,8 +434,8 @@ func runRaw(ctx context.Context, dir string, env []string, input string, args ..
return out, nil return out, nil
} }
func runCode(ctx context.Context, dir string, env []string, args ...string) (string, string, int, error) { func runCode(ctx context.Context, dir string, args ...string) (string, string, int, error) {
out, stderr, code, err := runCodeInput(context.WithoutCancel(ctx), dir, env, nil, args...) out, stderr, code, err := runCodeInput(context.WithoutCancel(ctx), dir, nil, nil, args...)
return strings.TrimSpace(out), stderr, code, err return strings.TrimSpace(out), stderr, code, err
} }
+3 -3
View File
@@ -19,7 +19,7 @@ func ConfigureNotesFetch(ctx context.Context, repo string) error {
return err return err
} }
key := "remote." + Remote + ".fetch" key := "remote." + Remote + ".fetch"
out, stderr, code, err := runCode(ctx, repo, nil, "config", "--get-all", key) out, stderr, code, err := runCode(ctx, repo, "config", "--get-all", key)
if err != nil { if err != nil {
return err return err
} }
@@ -39,7 +39,7 @@ func NoteCommit(ctx context.Context, repo, commit, note string, env []string) (s
return "", err return "", err
} }
parent, stderr, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", NotesRef) parent, stderr, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", NotesRef)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -75,7 +75,7 @@ func NoteCommit(ctx context.Context, repo, commit, note string, env []string) (s
} }
func AdvanceNotes(ctx context.Context, repo, notes string) error { func AdvanceNotes(ctx context.Context, repo, notes string) error {
current, stderr, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", NotesRef) current, stderr, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", NotesRef)
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -54,7 +54,7 @@ func RepairWorktrees(ctx context.Context, repo string, paths []string) error {
} }
func RewriteNotes(ctx context.Context, repo string, rewrite func(string) string) error { func RewriteNotes(ctx context.Context, repo string, rewrite func(string) string) error {
parent, stderr, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", NotesRef) parent, stderr, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", NotesRef)
if err != nil { if err != nil {
return err return err
} }
+2 -16
View File
@@ -7,13 +7,8 @@ import (
"g.fc.run/ai/byre/internal/store" "g.fc.run/ai/byre/internal/store"
) )
func (s *Server) ListInbox(w http.ResponseWriter, r *http.Request, params api.ListInboxParams) { func (s *Server) ListInbox(w http.ResponseWriter, r *http.Request) {
f := store.InboxFilter{State: api.Open, ProjectID: api.Deref(params.ProjectId), TaskID: api.Deref(params.TaskId)} items, err := s.store.ListInbox(r.Context(), store.InboxFilter{State: api.Open})
if params.State != nil {
f.State = *params.State
}
items, err := s.store.ListInbox(r.Context(), f)
if err != nil { if err != nil {
writeStoreError(w, err) writeStoreError(w, err)
return return
@@ -21,15 +16,6 @@ func (s *Server) ListInbox(w http.ResponseWriter, r *http.Request, params api.Li
writeJSON(w, http.StatusOK, items) writeJSON(w, http.StatusOK, items)
} }
func (s *Server) GetInboxItem(w http.ResponseWriter, r *http.Request, itemID string) {
item, err := s.store.GetInboxItem(r.Context(), itemID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, item)
}
func (s *Server) DismissInbox(w http.ResponseWriter, r *http.Request, itemID string) { func (s *Server) DismissInbox(w http.ResponseWriter, r *http.Request, itemID string) {
item, err := s.agents.Dismiss(r.Context(), actor(r), itemID) item, err := s.agents.Dismiss(r.Context(), actor(r), itemID)
if err != nil { if err != nil {
-13
View File
@@ -7,19 +7,6 @@ import (
"g.fc.run/ai/byre/internal/api" "g.fc.run/ai/byre/internal/api"
) )
func (s *Server) ListReviews(w http.ResponseWriter, r *http.Request, taskID string) {
if !s.taskExists(w, r, taskID) {
return
}
reviews, err := s.store.ListReviews(r.Context(), taskID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, reviews)
}
func (s *Server) SetFindingState(w http.ResponseWriter, r *http.Request, reviewID string, index int) { func (s *Server) SetFindingState(w http.ResponseWriter, r *http.Request, reviewID string, index int) {
req := api.FindingStateUpdate{} req := api.FindingStateUpdate{}
if !readJSON(w, r, &req) { if !readJSON(w, r, &req) {
-31
View File
@@ -355,15 +355,6 @@ func (s *Server) createProject(ctx context.Context, name, repoPath, createdBy st
return p, nil return p, nil
} }
func (s *Server) GetProject(w http.ResponseWriter, r *http.Request, projectID string) {
p, err := s.store.GetProject(r.Context(), projectID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, p)
}
func (s *Server) ListActiveTasks(w http.ResponseWriter, r *http.Request, projectID string) { func (s *Server) ListActiveTasks(w http.ResponseWriter, r *http.Request, projectID string) {
_, err := s.store.GetProject(r.Context(), projectID) _, err := s.store.GetProject(r.Context(), projectID)
if err != nil { if err != nil {
@@ -777,19 +768,6 @@ func (s *Server) ListTaskEvents(w http.ResponseWriter, r *http.Request, taskID s
writeJSON(w, http.StatusOK, events) writeJSON(w, http.StatusOK, events)
} }
func (s *Server) ListSnapshots(w http.ResponseWriter, r *http.Request, taskID string) {
if !s.taskExists(w, r, taskID) {
return
}
snaps, err := s.store.ListSnapshots(r.Context(), taskID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, snaps)
}
func (s *Server) ListPreviews(w http.ResponseWriter, r *http.Request, taskID string) { func (s *Server) ListPreviews(w http.ResponseWriter, r *http.Request, taskID string) {
if !s.taskExists(w, r, taskID) { if !s.taskExists(w, r, taskID) {
return return
@@ -922,15 +900,6 @@ func (s *Server) CreateSession(w http.ResponseWriter, r *http.Request, taskID st
writeJSON(w, http.StatusCreated, sess) writeJSON(w, http.StatusCreated, sess)
} }
func (s *Server) GetSession(w http.ResponseWriter, r *http.Request, sessionID string) {
sess, err := s.store.GetSession(r.Context(), sessionID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, sess)
}
func (s *Server) SendMessage(w http.ResponseWriter, r *http.Request, sessionID string) { func (s *Server) SendMessage(w http.ResponseWriter, r *http.Request, sessionID string) {
prompt, ok := s.readMessage(w, r) prompt, ok := s.readMessage(w, r)
if !ok { if !ok {
-9
View File
@@ -78,15 +78,6 @@ func (s *Server) DeleteWorkflow(w http.ResponseWriter, r *http.Request, name str
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
} }
func (s *Server) GetTaskWorkflow(w http.ResponseWriter, r *http.Request, taskID string) {
tw, err := s.agents.TaskWorkflow(r.Context(), taskID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, tw)
}
func (s *Server) GetWorkflowRun(w http.ResponseWriter, r *http.Request, taskID string) { func (s *Server) GetWorkflowRun(w http.ResponseWriter, r *http.Request, taskID string) {
run, err := s.agents.WorkflowRun(r.Context(), taskID) run, err := s.agents.WorkflowRun(r.Context(), taskID)
if err != nil { if err != nil {
+2 -12
View File
@@ -72,28 +72,18 @@ func (s *Store) GetInboxItem(ctx context.Context, id string) (api.InboxItem, err
} }
type InboxFilter struct { type InboxFilter struct {
ProjectID string TaskID string
TaskID string State api.InboxState
SessionID string
State api.InboxState
} }
func (s *Store) ListInbox(ctx context.Context, f InboxFilter) ([]api.InboxItem, error) { func (s *Store) ListInbox(ctx context.Context, f InboxFilter) ([]api.InboxItem, error) {
where := []string{"state = ?"} where := []string{"state = ?"}
args := []any{string(f.State)} args := []any{string(f.State)}
if f.ProjectID != "" {
where = append(where, "project_id = ?")
args = append(args, f.ProjectID)
}
if f.TaskID != "" { if f.TaskID != "" {
where = append(where, "task_id = ?") where = append(where, "task_id = ?")
args = append(args, f.TaskID) args = append(args, f.TaskID)
} }
if f.SessionID != "" {
where = append(where, "agent_session_id = ?")
args = append(args, f.SessionID)
}
ids, err := queryIDs(ctx, s.db, `SELECT id FROM inbox_items WHERE `+strings.Join(where, " AND ")+` ORDER BY created_at`, args...) ids, err := queryIDs(ctx, s.db, `SELECT id FROM inbox_items WHERE `+strings.Join(where, " AND ")+` ORDER BY created_at`, args...)
if err != nil { if err != nil {
-18
View File
@@ -41,24 +41,6 @@ func (s *Store) CreateSnapshot(ctx context.Context, snap api.Snapshot, projectID
}) })
} }
func (s *Store) ListSnapshots(ctx context.Context, taskID string) ([]api.Snapshot, error) {
rows, err := s.db.QueryContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? ORDER BY n`, taskID)
if err != nil {
return nil, err
}
defer rows.Close()
snaps := []api.Snapshot{}
for rows.Next() {
snap, err := scanSnapshot(rows)
if err != nil {
return nil, err
}
snaps = append(snaps, snap)
}
return snaps, rows.Err()
}
func (s *Store) GetSnapshot(ctx context.Context, taskID string, n int) (api.Snapshot, error) { func (s *Store) GetSnapshot(ctx context.Context, taskID string, n int) (api.Snapshot, error) {
snap, err := scanSnapshot(s.db.QueryRowContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? AND n = ?`, taskID, n)) snap, err := scanSnapshot(s.db.QueryRowContext(ctx, `SELECT `+snapshotColumns+` FROM snapshots WHERE task_id = ? AND n = ?`, taskID, n))
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {