MCPcopy
hub / github.com/CodebuffAI/codebuff / getLatestAgentVersion

Function getLatestAgentVersion

packages/internal/src/utils/version-utils.ts:54–87  ·  view source on GitHub ↗
(params: {
  agentId: string
  publisherId: string
  db: CodebuffPgDatabase
})

Source from the content-addressed store, hash-verified

52 * Get the latest version for an agent from the database
53 */
54export async function getLatestAgentVersion(params: {
55 agentId: string
56 publisherId: string
57 db: CodebuffPgDatabase
58}): Promise<Version> {
59 const { agentId, publisherId, db } = params
60
61 const latestAgent = await db
62 .select({
63 major: schema.agentConfig.major,
64 minor: schema.agentConfig.minor,
65 patch: schema.agentConfig.patch,
66 })
67 .from(schema.agentConfig)
68 .where(
69 and(
70 eq(schema.agentConfig.id, agentId),
71 eq(schema.agentConfig.publisher_id, publisherId),
72 ),
73 )
74 .orderBy(
75 desc(schema.agentConfig.major),
76 desc(schema.agentConfig.minor),
77 desc(schema.agentConfig.patch),
78 )
79 .limit(1)
80 .then((rows) => rows[0])
81
82 return {
83 major: latestAgent?.major ?? 0,
84 minor: latestAgent?.minor ?? 0,
85 patch: latestAgent?.patch ?? 0,
86 }
87}
88
89/**
90 * Determine the next version for an agent

Callers 2

determineNextVersionFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected