Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
feat(server): migrate control plane to Nitro v3#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0526f0c5f92d27b7628ddc6eb8ff398133a872826cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,13 +3,13 @@ | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "tsdown", | ||
| "build": "nitro build", | ||
| "clean": "tsc -b --clean", | ||
| "dev": "TMPDIR=/tmp node --import tsx src/index.ts", | ||
| "lint": "oxlint --config ../../.oxlintrc.json --type-aware --type-check src", | ||
| "start": "node dist/index.js", | ||
| "dev": "nitro dev", | ||
| "lint": "oxlint --config ../../.oxlintrc.json --type-aware --type-check src server nitro.config.ts", | ||
| "start": "node .output/server/index.mjs", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new startup command launches Nitro without mapping the documented ArtifactsNitro port runtime probe script
AGENT_ZERO_PORT startup output showing port 4040 refused
NITRO_PORT startup output showing port 4040 connected
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/server/package.json
Line: 10
Comment:
**Documented server port is ignored**
The new startup command launches Nitro without mapping the documented `AGENT_ZERO_PORT` variable to Nitro's port configuration. With `AGENT_ZERO_PORT=4040`, the built server refuses connections on 4040 and instead listens on port 3000. Configure startup to honor `AGENT_ZERO_PORT`, or update the documented configuration contract consistently, and add a listener regression test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. | ||
| "test": "vitest run src --passWithNoTests", | ||
| "typecheck": "tsc --project tsconfig.json --pretty false --noEmit" | ||
| "typecheck": "nitro prepare && tsc --project tsconfig.json --pretty false --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@agent-zero/agent": "workspace:*", | ||
| @@ -18,8 +18,7 @@ | ||
| "@agent-zero/models": "workspace:*", | ||
| "@agent-zero/runner": "workspace:*", | ||
| "@agent-zero/shared": "workspace:*", | ||
| "@orpc/client": "^1.12.2", | ||
| "@orpc/server": "^1.12.2", | ||
| "nitro": "3.0.260522-beta", | ||
| "zod": "^4.1.5" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1 @@ | ||
| import { createServer } from 'node:http'; | ||
| import { onError } from '@orpc/server'; | ||
| import { RPCHandler } from '@orpc/server/node'; | ||
| import { router } from './router.js'; | ||
| export const handler = new RPCHandler(router, { | ||
| interceptors: [onError((error) => console.error(error))], | ||
| }); | ||
| export const server = createServer((request, response) => { | ||
| void handler | ||
| .handle(request, response, { context: {} }) | ||
| .then(({ matched }) => { | ||
| if (!matched) { | ||
| response.statusCode = 404; | ||
| response.end('Not found'); | ||
| } | ||
| return undefined; | ||
| }) | ||
| .catch((error) => { | ||
| console.error(error); | ||
| response.statusCode = 500; | ||
| response.end('Internal server error'); | ||
| return undefined; | ||
| }); | ||
| }); | ||
| if (import.meta.url === `file://${process.argv[1]}`) { | ||
| const port = Number(process.env.AGENT_ZERO_PORT ?? 4040); | ||
| server.listen(port, () => | ||
| console.log(`Agent Zero oRPC API listening on http://localhost:${port}`), | ||
| ); | ||
| } | ||
| export { createTask, getTask, health, listTasks, taskInput, tasks } from './router.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The entrypoint only re-exports task helpers and does not register Nitro handlers. A built and running server returns ArtifactsNitro health and task endpoint validation script
Nitro server control-plane responses before an attempted route fixture
Nitro server responses after an attempted conventional Nitro route fixture
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/server/src/index.ts
Line: 1
Comment:
**Nitro routes are never registered**
The entrypoint only re-exports task helpers and does not register Nitro handlers. A built and running server returns `404 Not Found` for `GET /health`, `GET /tasks`, and `GET /tasks/missing-task`, so the control plane is unreachable over HTTP. Add configured Nitro route handlers for the health and task API contract and cover them with an HTTP-level test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| import { call } from '@orpc/server'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { router } from './router.js'; | ||
| import { health, listTasks, taskInput } from './router.js'; | ||
| describe('oRPC router', () => { | ||
| it('exposes a typed health procedure', async () => { | ||
| await expect(call(router.health, undefined)).resolves.toMatchObject({ | ||
| status: 'ok', | ||
| service: 'agent-zero', | ||
| }); | ||
| describe('server task API', () => { | ||
| it('exposes health metadata for Nitro handlers', () => { | ||
| expect(health()).toMatchObject({ status: 'ok', service: 'agent-zero' }); | ||
| }); | ||
| it('starts with an empty task collection', () => { | ||
| expect(listTasks()).toEqual({ tasks: [] }); | ||
| }); | ||
| it('keeps task input validation independent from HTTP transport', () => { | ||
| expect( | ||
| taskInput.parse({ | ||
| repository: '.', | ||
| feedback: 'Check error handling', | ||
| mode: 'observe', | ||
| }), | ||
| ).toMatchObject({ repository: '.', mode: 'observe' }); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this package to invoke
nitro builddirectly bypasses itstsdown.config.tsand the shared tsdown configuration required by the repository, leaving the server outside the standardized package build toolchain.Context Used: CLAUDE.md (source)
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!