Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: agent_builder.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const deleteAgentBuilderDraft = `-- name: DeleteAgentBuilderDraft :exec
DELETE FROM agent_builder_draft WHERE chat_session_id = $1
`
// agent_builder_draft has no chat_session FK (repo rule), so every path that
// removes a conversation has to say so explicitly.
func (q *Queries) DeleteAgentBuilderDraft(ctx context.Context, chatSessionID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteAgentBuilderDraft, chatSessionID)
return err
}
const deleteAgentBuilderDraftsBySystemRuntimeAgents = `-- name: DeleteAgentBuilderDraftsBySystemRuntimeAgents :exec
DELETE FROM agent_builder_draft
WHERE chat_session_id IN (
SELECT cs.id FROM chat_session cs
JOIN agent a ON a.id = cs.agent_id
WHERE a.runtime_id = $1 AND a.kind = 'system'
)
`
// chat_session cascades from agent, so a runtime teardown hard-deleting its
// system carriers (DeleteSystemAgentsByRuntime) silently drops their sessions.
// Prune the drafts in the same tx and BEFORE the agent rows go — the join below
// needs them. Mirrors DeleteChatDraftRestoresBySystemRuntimeAgents.
//
// Only the system variant exists: a builder draft can only ever hang off a
// `kind = 'system'` carrier, so the archived-agent prune has nothing to find.
func (q *Queries) DeleteAgentBuilderDraftsBySystemRuntimeAgents(ctx context.Context, runtimeID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteAgentBuilderDraftsBySystemRuntimeAgents, runtimeID)
return err
}
const upsertAgentBuilderDraft = `-- name: UpsertAgentBuilderDraft :one
INSERT INTO agent_builder_draft (chat_session_id, workspace_id, draft)
VALUES ($1, $2, $3)
ON CONFLICT (chat_session_id) DO UPDATE
SET draft = EXCLUDED.draft,
updated_at = now()
RETURNING chat_session_id, workspace_id, draft, updated_at
`
type UpsertAgentBuilderDraftParams struct {
ChatSessionID pgtype.UUID `json:"chat_session_id"`
WorkspaceID pgtype.UUID `json:"workspace_id"`
Draft []byte `json:"draft"`
}
// The current configuration of one creation conversation. Last write wins:
// there is a single editor (the session's creator, on one screen at a time) and
// the client autosaves the whole object, so a partial merge would only be able
// to reconstruct a state the user never saw.
func (q *Queries) UpsertAgentBuilderDraft(ctx context.Context, arg UpsertAgentBuilderDraftParams) (AgentBuilderDraft, error) {
row := q.db.QueryRow(ctx, upsertAgentBuilderDraft, arg.ChatSessionID, arg.WorkspaceID, arg.Draft)
var i AgentBuilderDraft
err := row.Scan(
&i.ChatSessionID,
&i.WorkspaceID,
&i.Draft,
&i.UpdatedAt,
)
return i, err
}