File size: 8,066 Bytes
e8e08a5 031037c e8e08a5 22a0bd2 e8e08a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | import { Request, Response } from 'express';
export function handleApiDocs(req: Request, res: Response) {
const host = req.get('host');
const protocol = req.headers['x-forwarded-proto'] || req.protocol || 'https';
const publicUrl =
process.env.AUTOMAKER_PUBLIC_URL ||
(host ? `${protocol}://${host}` : 'https://Leon4gr45-automaker.hf.space');
res.status(200).json({
message: 'Automaker API Documentation',
baseUrl: publicUrl,
apiBaseUrl: `${publicUrl}/api`,
authentication: {
bearer: true,
xApiKey: true,
sessionCookie: true,
queryParamApiKey: true,
envVarForApiKey: 'AUTHENTICATION_TOKEN',
},
endpoints: [
...[
['GET', '/api/argus/modes', 'List versioned mode adapters'],
['GET', '/api/argus/mode', 'Read durable project mode state and run history'],
[
'PUT',
'/api/argus/mode',
'Select mode/configuration using expectedRevision; does not activate autonomy',
],
[
'POST',
'/api/argus/mode/command',
'Select /default, /rea, /paper2code or /eval without executing',
],
[
'POST',
'/api/argus/mode/plan',
'Validate mode input and persist idempotent execution plan',
],
[
'POST',
'/api/argus/mode/run',
'Explicitly execute a plan; repository changes require SHA-bound approval',
],
['GET', '/api/argus/mode/runs/:id', 'Read a project-owned run'],
['GET', '/api/argus/mode/runs/:id/artifacts', 'Read hashed evidence artifacts as data'],
[
'POST',
'/api/argus/mode/runs/:id/tasks/:taskId/approve',
'Explicitly admit a task to the existing Argus workflow',
],
[
'GET',
'/api/argus/mode/gate',
'Read current-source evaluation recommendation; never authorizes merge',
],
].map(([method, path, purpose]) => ({
method,
path,
purpose,
request: { projectId: 'registered-project-id' },
response: {
note: 'Existing authentication and registered-project authorization required. See docs/api/ARGUS-MODES.md.',
},
})),
{
method: 'GET',
path: '/health',
purpose: 'Check server health and readiness',
request: {},
response: { status: 'ok' },
},
{
method: 'GET',
path: '/api-docs',
purpose: 'Document all available API endpoints',
request: {},
response: { message: 'Automaker API Documentation', endpoints: [] },
},
{
method: 'GET',
path: '/api/auth/status',
purpose: 'Check authentication status and mode safely',
request: {},
response: { success: true, authenticated: true, required: true, keySource: 'environment' },
},
{
method: 'POST',
path: '/api/auth/login',
purpose: 'Authenticate session (Public/Unauthenticated endpoint)',
request: { apiKey: '...' },
response: { success: true },
},
{
method: 'GET',
path: '/api/auth/token',
purpose: 'Get short-lived websocket token (Authenticated endpoint)',
request: {},
response: { success: true, token: 'wsToken...', expiresIn: 300 },
},
{
method: 'POST',
path: '/api/auth/logout',
purpose: 'Invalidate current session (Authenticated endpoint)',
request: {},
response: { success: true },
},
{
method: 'POST',
path: '/api/agent/chat',
purpose: 'Send a message to the AI agent',
request: { message: 'Hello agent', projectPath: '/app/data/projects/my-project' },
response: { sessionId: 'session-123', status: 'started' },
},
{
method: 'GET',
path: '/api/projects',
purpose: 'List all configured projects',
request: {},
response: {
projects: [
{ id: 'project-1', name: 'My Project', path: '/app/data/projects/my-project' },
],
},
},
{
method: 'POST',
path: '/api/templates/clone',
purpose:
'Clone a starter project. Bootstraps: fresh git, ARGUS.md, spec.md, argus.yaml, baseline commit, project registration, and Argus wake.',
request: {
repoUrl: 'https://github.com/owner/repo',
projectName: 'my-project',
parentDir: '...',
overview: 'optional objective',
},
response: {
success: true,
projectId: '...',
projectPath: '...',
projectName: '...',
},
},
{
method: 'GET',
path: '/api/argus/health',
purpose: 'Check Argus service health and operational capabilities',
request: {},
response: {
running: true,
upstreamInstalled: true,
version: '0.1.1',
provider: 'automaker-compatible',
model: '...',
roleBackends: {
MANAGER: 'opencode',
PLANNER: 'opencode',
ENGINEER: 'opencode',
REVIEWER: 'opencode',
},
autonomy: {
runtime: 'running',
pendingProjects: 1,
blockedProjects: 0,
},
},
},
{
method: 'GET',
path: '/api/argus/status',
purpose: 'Get detailed Argus status for a project',
request: { projectPath: '...' },
response: {
enabled: true,
running: true,
argusProjectId: '...',
specRevision: 1,
phase: 'manager',
managerStatus: 'completed',
plannerStatus: 'completed',
objectiveStatus: 'active',
activeTask: { taskId: '...' },
reconciliation: { nextAt: 1234567, reason: 'api-wake' },
latestStatus: 'ARGUS_WOKEN_BY_API',
},
},
{
method: 'POST',
path: '/api/argus/pause',
purpose: 'Pause future autonomous Argus reconciliation for a project',
request: { projectPath: '...' },
response: { success: true, status: 'paused' },
},
{
method: 'POST',
path: '/api/argus/resume',
purpose: 'Resume Argus autonomous reconciliation for a project',
request: { projectPath: '...' },
response: { success: true, status: 'enabled' },
},
{
method: 'POST',
path: '/api/argus/wake',
purpose: 'Wake/schedule Argus reconciliation immediately',
request: { projectPath: '...', reason: 'optional bounded string' },
response: { success: true },
},
{
method: 'POST',
path: '/api/argus/reconcile',
purpose: 'Operator/debug control to explicitly invoke reconciliation runner',
request: { projectPath: '...' },
response: { success: true },
},
{
method: 'POST',
path: '/api/features',
purpose: 'Create a new feature card on the Kanban board',
request: {
title: 'New Feature',
description: 'Implement feature details',
projectPath: '/app/data/projects/my-project',
},
response: { id: 'feat-123', title: 'New Feature', status: 'backlog' },
},
{
method: 'GET',
path: '/api/settings',
purpose: 'Get global application settings',
request: {},
response: { theme: 'dark', concurrentAgents: 3 },
},
{
method: 'WS',
path: '/api/events',
purpose:
'Subscribe to Automaker websocket events. Connect using short-lived wsToken from /api/auth/token.',
request: {},
response: {},
},
{
method: 'WS',
path: '/api/terminal/ws',
purpose: 'Connect to terminal. Connect using short-lived wsToken from /api/auth/token.',
request: {},
response: {},
},
],
});
}
|