Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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:
Expand Down
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this it failed with:

Running server...
cargo run -p goose-server
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: generate_schema, goosed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah - I guess it wasn't used regularly, vs just run-ui?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yes? I'm just getting started with the codebase, so I can't tell about past usage :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep makes sense.


# Check if OpenAPI schema is up-to-date
check-openapi-schema: generate-openapi
Expand Down
14 changes: 12 additions & 2 deletions ui/desktop/src/goosed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ const checkServerStatus = async (): Promise<boolean> => {

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}`);
Expand Down Expand Up @@ -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
Expand Down
Loading