MCPcopy
hub / github.com/cursor/cookbook / createCloudAgent

Function createCloudAgent

sdk/agent-kanban/src/lib/agents/server.ts:262–301  ·  view source on GitHub ↗
(
  apiKey: string,
  input: CreateAgentInput
)

Source from the content-addressed store, hash-verified

260}
261
262export async function createCloudAgent(
263 apiKey: string,
264 input: CreateAgentInput
265): Promise<CreateAgentResponse> {
266 const prompt = input.prompt.trim()
267 if (!prompt) {
268 throw new Error("A prompt is required to create a cloud agent.")
269 }
270
271 const repository = await resolveRepository(apiKey, input.repositoryId)
272 const cloudRepository = {
273 url: repository.url,
274 ...(input.branch?.trim() ? { startingRef: input.branch.trim() } : {}),
275 }
276
277 const createdAgent = await agentSdk.create({
278 apiKey,
279 name: input.name?.trim() || prompt.slice(0, 80),
280 ...(input.modelId && input.modelId !== "auto"
281 ? { model: { id: input.modelId } }
282 : {}),
283 cloud: {
284 repos: [cloudRepository],
285 autoCreatePR: input.autoCreatePR ?? true,
286 },
287 })
288
289 if (createdAgent.send) {
290 await createdAgent.send(prompt)
291 }
292
293 const card = normalizeAgent(createdAgent)
294 card.repository = repository.label
295 card.repositoryUrl = repository.url
296 card.branch = input.branch?.trim() || repository.defaultBranch
297 card.latestMessage = prompt
298 card.artifacts = await listArtifactsForAgent(apiKey, card.id).catch(() => [])
299
300 return { agent: card }
301}
302
303export async function listModels(apiKey: string): Promise<ModelOption[]> {
304 try {

Callers 1

POSTFunction · 0.90

Calls 3

resolveRepositoryFunction · 0.85
normalizeAgentFunction · 0.85
listArtifactsForAgentFunction · 0.85

Tested by

no test coverage detected