mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:35:21 +00:00
* feat(agent-pool): fundacao read-only do orquestrador (fase A) - docs/plans/agent-pool-orchestrator.md: plano completo (14 secoes) - buildClaimQueue extraido de agent-claim para agent-github (comportamento identico, pinado) - agent-pool-eligibility: isAutonomousClaimable puro e fail-closed + buildPoolQueue - agent-pool-state: parsePoolConfig, marcadores pool-worker, classifyPoolClaim, spawn plan, auto-stop - agent-pool-github: leitura de repo variables (degrada nao-estrito), claims/PRs/migration-lock - pnpm agent:pool -- status|tick --dry-run (inspecao local; live chega na fase B) - 34 specs unit novos (992/992 verde); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * feat(agent-pool): spawn remoto de workers via Cursor API (fase B) - agent-pool-cursor: client fino da Cloud Agents API v1 (fetch injetavel; CursorApiError com status/body) - agent-pool-models: resolvePoolModel contra /v1/models (id/alias, sufixo -fast -> param, fallback composer-2.5 com warn) - agent-pool-prompt: contrato do worker (claim pre-feito, pula passo 1; PR base stage + Closes #N; promote proibido) - claim coordenado no tick: lock otimista + flip + marcador; agentId idempotente bc-<uuid>; 409 recupera; rollback em falha de spawn - agent:pool workflow --action start|stop|pause|resume|tick|status (variables POOL_*); doctor; wrappers gh workflow run - .github/workflows/agent-pool.yml (dispatch-only; schedule/triggers na fase C) - 19 specs novos (1011/1011); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * feat(agent-pool): ciclo de vida do supervisor (fase C) - derivePoolClaims com status real dos runs (getCursorRun), heal de spawn via agentId deterministico, cancel de duplicatas - reconcilePoolClaims: falha terminal -> comentario + blocked + archive; merge concluido -> slot livre + archive - auto-stop real: fila drenada + zero ativos -> POOL_ENABLED=false (exclusoes migration-busy nao desligam) - job summary markdown (GITHUB_STEP_SUMMARY) — superficie remota de status - workflow: schedule */10min + pull_request closed em stage (ativam na default branch apos promote) - 2 specs novos (1013/1013); lint/tsc/knip/cycles/format verdes Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * docs(agent-pool): runbook operacional e adendo do spike (fase D) - skill agent-pool: runbook humano (pre-requisitos, start/stop/pause remoto, ciclo de vida, triage, smoke de aceite) - AGENT-OPS: linha na tabela de comandos + secao Agent pool (canal, secrets, ativacao pos-promote) - CHANGELOG-AGENTS: entrada curta da entrega - engineering-audit: pause/resume do pool no protocolo do modo solitario - plano secao 14.1: evidencias do spike 2026-07-30 (environment repo-file confirmado, id bc-<uuid>, degradacao 403, pendencias do primeiro run com CURSOR_API_KEY) Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> * fix(test): teardown flake no homeSearchUi.unit.spec (dono do CI) O scheduler do react (prefetch do next/link) podia disparar apos o teardown do jsdom e derrubar o job unit com 'window is not defined' (run 30587862940). afterEach(cleanup) — padrao dos 14 specs irmaos. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
73 lines
2.5 KiB
JavaScript
73 lines
2.5 KiB
JavaScript
/**
|
|
* Thin Cursor Cloud Agents API v1 client (docs/plans/agent-pool-orchestrator.md
|
|
* §14). REST + `CURSOR_API_KEY` (Basic auth, key as username). The API is in
|
|
* public beta — the whole surface is isolated in this one module so a shape
|
|
* change touches nothing else.
|
|
*/
|
|
|
|
const CURSOR_API_BASE = 'https://api.cursor.com'
|
|
|
|
export class CursorApiError extends Error {
|
|
constructor(message, { status, body }) {
|
|
super(message)
|
|
this.name = 'CursorApiError'
|
|
this.status = status
|
|
this.body = body
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {string} path e.g. '/v1/agents'
|
|
* @param {Object} [options]
|
|
* @param {string} [options.method]
|
|
* @param {Record<string, unknown>} [options.body]
|
|
* @param {string} [options.apiKey] defaults to CURSOR_API_KEY env
|
|
* @param {typeof fetch} [options.fetchImpl] injected in tests
|
|
*/
|
|
export const cursorApiRequest = async (
|
|
path,
|
|
{ method = 'GET', body, apiKey = process.env.CURSOR_API_KEY, fetchImpl = fetch } = {},
|
|
) => {
|
|
if (!apiKey) {
|
|
throw new CursorApiError(`Cursor API ${method} ${path}: CURSOR_API_KEY ausente`, {
|
|
status: 0,
|
|
body: null,
|
|
})
|
|
}
|
|
const response = await fetchImpl(`${CURSOR_API_BASE}${path}`, {
|
|
method,
|
|
headers: {
|
|
authorization: `Basic ${Buffer.from(`${apiKey}:`).toString('base64')}`,
|
|
'content-type': 'application/json',
|
|
},
|
|
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
})
|
|
const text = await response.text()
|
|
const json = text ? JSON.parse(text) : {}
|
|
if (!response.ok) {
|
|
throw new CursorApiError(`Cursor API ${method} ${path} → ${response.status}`, {
|
|
status: response.status,
|
|
body: json,
|
|
})
|
|
}
|
|
return json
|
|
}
|
|
|
|
export const cursorApiMe = (options) => cursorApiRequest('/v1/me', options)
|
|
|
|
export const listCursorModels = (options) => cursorApiRequest('/v1/models', options)
|
|
|
|
/** @param {Record<string, unknown>} payload the Create-An-Agent body */
|
|
export const createCursorAgent = (payload, options) =>
|
|
cursorApiRequest('/v1/agents', { ...options, method: 'POST', body: payload })
|
|
|
|
export const getCursorAgent = (id, options) => cursorApiRequest(`/v1/agents/${id}`, options)
|
|
|
|
export const getCursorRun = (agentId, runId, options) =>
|
|
cursorApiRequest(`/v1/agents/${agentId}/runs/${runId}`, options)
|
|
|
|
export const cancelCursorRun = (agentId, runId, options) =>
|
|
cursorApiRequest(`/v1/agents/${agentId}/runs/${runId}/cancel`, { ...options, method: 'POST' })
|
|
|
|
export const archiveCursorAgent = (id, options) =>
|
|
cursorApiRequest(`/v1/agents/${id}/archive`, { ...options, method: 'POST' })
|