This commit is contained in:
2026-06-22 08:55:57 +08:00
parent dbb87823e8
commit 6ade6e8fa9
325 changed files with 41131 additions and 855 deletions
+97 -40
View File
@@ -24,25 +24,31 @@ func (q *Queries) CountAgentKindUsage(ctx context.Context, agentKindID pgtype.UU
const createAgentKind = `-- name: CreateAgentKind :one
INSERT INTO acp_agent_kinds (
id, name, display_name, description, binary_path, args, encrypted_env, enabled, created_by, tool_allowlist, client_type, encrypted_mcp_servers
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
id, name, display_name, description, binary_path, args, encrypted_env, enabled, created_by, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
RETURNING id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
`
type CreateAgentKindParams struct {
ID pgtype.UUID `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
BinaryPath string `json:"binary_path"`
Args []string `json:"args"`
EncryptedEnv []byte `json:"encrypted_env"`
Enabled bool `json:"enabled"`
CreatedBy pgtype.UUID `json:"created_by"`
ToolAllowlist []string `json:"tool_allowlist"`
ClientType string `json:"client_type"`
EncryptedMcpServers []byte `json:"encrypted_mcp_servers"`
ID pgtype.UUID `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
BinaryPath string `json:"binary_path"`
Args []string `json:"args"`
EncryptedEnv []byte `json:"encrypted_env"`
Enabled bool `json:"enabled"`
CreatedBy pgtype.UUID `json:"created_by"`
ToolAllowlist []string `json:"tool_allowlist"`
ClientType string `json:"client_type"`
EncryptedMcpServers []byte `json:"encrypted_mcp_servers"`
ModelID pgtype.UUID `json:"model_id"`
MaxCostUsd pgtype.Numeric `json:"max_cost_usd"`
MaxTokens *int64 `json:"max_tokens"`
MaxWallClockSeconds *int32 `json:"max_wall_clock_seconds"`
}
func (q *Queries) CreateAgentKind(ctx context.Context, arg CreateAgentKindParams) (AcpAgentKind, error) {
@@ -59,6 +65,10 @@ func (q *Queries) CreateAgentKind(ctx context.Context, arg CreateAgentKindParams
arg.ToolAllowlist,
arg.ClientType,
arg.EncryptedMcpServers,
arg.ModelID,
arg.MaxCostUsd,
arg.MaxTokens,
arg.MaxWallClockSeconds,
)
var i AcpAgentKind
err := row.Scan(
@@ -76,6 +86,11 @@ func (q *Queries) CreateAgentKind(ctx context.Context, arg CreateAgentKindParams
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
)
return i, err
}
@@ -91,7 +106,8 @@ func (q *Queries) DeleteAgentKind(ctx context.Context, id pgtype.UUID) error {
const getAgentKindByID = `-- name: GetAgentKindByID :one
SELECT id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
FROM acp_agent_kinds
WHERE id = $1
`
@@ -114,13 +130,19 @@ func (q *Queries) GetAgentKindByID(ctx context.Context, id pgtype.UUID) (AcpAgen
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
)
return i, err
}
const getAgentKindByName = `-- name: GetAgentKindByName :one
SELECT id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
FROM acp_agent_kinds
WHERE name = $1
`
@@ -143,13 +165,19 @@ func (q *Queries) GetAgentKindByName(ctx context.Context, name string) (AcpAgent
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
)
return i, err
}
const listAgentKinds = `-- name: ListAgentKinds :many
SELECT id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
FROM acp_agent_kinds
ORDER BY created_at DESC
`
@@ -178,6 +206,11 @@ func (q *Queries) ListAgentKinds(ctx context.Context) ([]AcpAgentKind, error) {
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
); err != nil {
return nil, err
}
@@ -191,7 +224,8 @@ func (q *Queries) ListAgentKinds(ctx context.Context) ([]AcpAgentKind, error) {
const listEnabledAgentKinds = `-- name: ListEnabledAgentKinds :many
SELECT id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
FROM acp_agent_kinds
WHERE enabled = TRUE
ORDER BY name ASC
@@ -221,6 +255,11 @@ func (q *Queries) ListEnabledAgentKinds(ctx context.Context) ([]AcpAgentKind, er
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
); err != nil {
return nil, err
}
@@ -234,32 +273,41 @@ func (q *Queries) ListEnabledAgentKinds(ctx context.Context) ([]AcpAgentKind, er
const updateAgentKind = `-- name: UpdateAgentKind :one
UPDATE acp_agent_kinds
SET display_name = $2,
description = $3,
binary_path = $4,
args = $5,
encrypted_env = $6,
enabled = $7,
tool_allowlist = $8,
client_type = $9,
encrypted_mcp_servers = $10,
updated_at = now()
SET display_name = $2,
description = $3,
binary_path = $4,
args = $5,
encrypted_env = $6,
enabled = $7,
tool_allowlist = $8,
client_type = $9,
encrypted_mcp_servers = $10,
model_id = $11,
max_cost_usd = $12,
max_tokens = $13,
max_wall_clock_seconds = $14,
updated_at = now()
WHERE id = $1
RETURNING id, name, display_name, description, binary_path, args, encrypted_env,
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers
enabled, created_by, created_at, updated_at, tool_allowlist, client_type, encrypted_mcp_servers,
model_id, max_cost_usd, max_tokens, max_wall_clock_seconds, key_version
`
type UpdateAgentKindParams struct {
ID pgtype.UUID `json:"id"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
BinaryPath string `json:"binary_path"`
Args []string `json:"args"`
EncryptedEnv []byte `json:"encrypted_env"`
Enabled bool `json:"enabled"`
ToolAllowlist []string `json:"tool_allowlist"`
ClientType string `json:"client_type"`
EncryptedMcpServers []byte `json:"encrypted_mcp_servers"`
ID pgtype.UUID `json:"id"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
BinaryPath string `json:"binary_path"`
Args []string `json:"args"`
EncryptedEnv []byte `json:"encrypted_env"`
Enabled bool `json:"enabled"`
ToolAllowlist []string `json:"tool_allowlist"`
ClientType string `json:"client_type"`
EncryptedMcpServers []byte `json:"encrypted_mcp_servers"`
ModelID pgtype.UUID `json:"model_id"`
MaxCostUsd pgtype.Numeric `json:"max_cost_usd"`
MaxTokens *int64 `json:"max_tokens"`
MaxWallClockSeconds *int32 `json:"max_wall_clock_seconds"`
}
func (q *Queries) UpdateAgentKind(ctx context.Context, arg UpdateAgentKindParams) (AcpAgentKind, error) {
@@ -274,6 +322,10 @@ func (q *Queries) UpdateAgentKind(ctx context.Context, arg UpdateAgentKindParams
arg.ToolAllowlist,
arg.ClientType,
arg.EncryptedMcpServers,
arg.ModelID,
arg.MaxCostUsd,
arg.MaxTokens,
arg.MaxWallClockSeconds,
)
var i AcpAgentKind
err := row.Scan(
@@ -291,6 +343,11 @@ func (q *Queries) UpdateAgentKind(ctx context.Context, arg UpdateAgentKindParams
&i.ToolAllowlist,
&i.ClientType,
&i.EncryptedMcpServers,
&i.ModelID,
&i.MaxCostUsd,
&i.MaxTokens,
&i.MaxWallClockSeconds,
&i.KeyVersion,
)
return i, err
}