add list runs endpoint

This commit is contained in:
Ramnique Singh 2025-12-09 16:35:27 +05:30
parent 1822deadc1
commit 338cc3d2f9
2 changed files with 91 additions and 2 deletions

View file

@ -12,9 +12,8 @@ import { ModelConfig, Provider } from "./models/models.js";
import { IAgentsRepo } from "./agents/repo.js";
import { Agent } from "./agents/agents.js";
import { AskHumanResponsePayload, authorizePermission, createMessage, createRun, replyToHumanInputRequest, Run, stop, ToolPermissionAuthorizePayload } from './runs/runs.js';
import { IRunsRepo, ListRunsResponse, CreateRunOptions } from './runs/repo.js';
import { IRunsRepo, CreateRunOptions, ListRunsResponse } from './runs/repo.js';
import { IBus } from './application/lib/bus.js';
import { RunEvent } from './entities/run-events.js';
let id = 0;
@ -462,6 +461,31 @@ const routes = new Hono()
return c.json(run);
}
)
.get(
'/runs',
describeRoute({
summary: 'List runs',
description: 'List all runs',
responses: {
200: {
description: 'Runs list',
content: {
'application/json': {
schema: resolver(ListRunsResponse),
},
},
},
},
}),
validator('query', z.object({
cursor: z.string().optional(),
})),
async (c) => {
const repo = container.resolve<IRunsRepo>('runsRepo');
const runs = await repo.list(c.req.valid('query').cursor);
return c.json(runs);
}
)
.post(
'/runs/:runId/messages/new',
describeRoute({