From 5a5241598cbe0bb41cb08b63fac01d788b6f24a4 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Wed, 17 Sep 2025 23:37:40 +0200 Subject: [PATCH 1/2] fix client initialization when using an external backend Signed-off-by: Ignasi Barrera --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ Justfile | 2 +- ui/desktop/src/goosed.ts | 14 ++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85dfc6c78078..45ab1ef27a6c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,6 +93,28 @@ This command regenerates `ui/desktop/openapi.json` and then runs the UI's Changes to the API should be made in the Rust source under `crates/goose-server/src/`. +### Debugging + +To debug the Goose server, you can run it from your preferred IDE with. How to configure the command +to start the server will depend on your IDE. The command to run is: + +``` +export GOOSE_SERVER__SECRET_KEY=test +cargo run --package goose-server --bin goosed -- agent # or: `just run-server` +``` + +The server will start listening on port `3000` by default, but this can be changed by setting the +`GOOSE_PORT` environment variable. + +Once the server is running, you can start a UI and connect it to the server by running: + +``` +just debug-ui +``` + +The UI will now be connected to the server you started in your IDE, allowing you to set breakpoints +and step through the server code as you interact with the UI. + ## Creating a fork To fork the repository: diff --git a/Justfile b/Justfile index d5f32e85d962..30a7b636c170 100644 --- a/Justfile +++ b/Justfile @@ -196,7 +196,7 @@ run-docs: # Run server run-server: @echo "Running server..." - cargo run -p goose-server + cargo run -p goose-server --bin goosed agent # Check if OpenAPI schema is up-to-date check-openapi-schema: generate-openapi diff --git a/ui/desktop/src/goosed.ts b/ui/desktop/src/goosed.ts index 16c8398f3f52..acdb61880d1d 100644 --- a/ui/desktop/src/goosed.ts +++ b/ui/desktop/src/goosed.ts @@ -47,10 +47,20 @@ const checkServerStatus = async (): Promise => { const connectToExternalBackend = async ( workingDir: string, - port: number = 3000 + port: number = 3000, + serverSecret: string ): Promise<[number, string, ChildProcess]> => { log.info(`Using external goosed backend on port ${port}`); + // Configure the client BEFORE checking server status + client.setConfig({ + baseUrl: `http://127.0.0.1:${port}`, + headers: { + 'Content-Type': 'application/json', + 'X-Secret-Key': serverSecret, + }, + }); + const isReady = await checkServerStatus(); if (!isReady) { throw new Error(`External goosed server not accessible on port ${port}`); @@ -94,7 +104,7 @@ export const startGoosed = async ( dir = path.resolve(path.normalize(dir)); if (process.env.GOOSE_EXTERNAL_BACKEND) { - return connectToExternalBackend(dir, 3000); + return connectToExternalBackend(dir, 3000, serverSecret); } // Validate that the directory actually exists and is a directory From 5faf61b2c2c6fc407fe36cd466b510a3a002e072 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Fri, 19 Sep 2025 12:01:21 +0200 Subject: [PATCH 2/2] fix typo Signed-off-by: Ignasi Barrera --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45ab1ef27a6c..2eeff78b1d05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,7 +95,7 @@ Changes to the API should be made in the Rust source under `crates/goose-server/ ### Debugging -To debug the Goose server, you can run it from your preferred IDE with. How to configure the command +To debug the Goose server, you can run it from your preferred IDE. How to configure the command to start the server will depend on your IDE. The command to run is: ```