Change AI engine to execute tools in Java instead of on frontend (#6116)

# Description of Changes
Redesign AI engine so that it autogenerates the `tool_models.py` file
from the OpenAPI spec so the Python has access to the Java API
parameters and the full list of Java tools that it can run. CI ensures
that whenever someone modifies a tool endpoint that the AI enigne tool
models get updated as well (the dev gets told to run `task
engine:tool-models`).

There's loads of advantages to having the Java be the one that actually
executes the tools, rather than the frontend as it was previously set up
to theoretically use:
- The AI gets much better descriptions of the params from the API docs
- It'll be usable headless in the future so a Java daemon could run to
execute ops on files in a folder without the need for the UI to run
- The Java already has all the logic it needs to execute the tools 
- We don't need to parse the TypeScript to find the API (which is hard
because the TS wasn't designed to be computer-read to extract the API)

I've also hooked up the prototype frontend to ensure it's working
properly, and have built it in a way that all the tool names can be
translated properly, which was always an issue with previous prototypes
of this.

---------

Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
Co-authored-by: EthanHealy01 <80844253+EthanHealy01@users.noreply.github.com>
This commit is contained in:
James Brunton
2026-04-20 15:57:11 +01:00
committed by GitHub
parent cc9650e7a3
commit e5767ed58b
45 changed files with 3565 additions and 1285 deletions

View File

@@ -66,10 +66,16 @@ tasks:
swagger:
desc: "Generate OpenAPI docs"
cmds:
- cmd: cmd /c gradlew.bat :stirling-pdf:generateOpenApiDocs
- cmd: cmd /c gradlew.bat :stirling-pdf:copySwaggerDoc
platforms: [windows]
- cmd: ./gradlew :stirling-pdf:generateOpenApiDocs
- cmd: ./gradlew :stirling-pdf:copySwaggerDoc
platforms: [linux, darwin]
sources:
- app/core/src/main/java/**/*.java
- app/proprietary/src/main/java/**/*.java
- app/common/src/main/java/**/*.java
generates:
- SwaggerDoc.json
check:
desc: "Backend quality gate"

View File

@@ -13,7 +13,7 @@ tasks:
status:
- test -d .venv
prep:
prepare:
desc: "Set up engine .env from template"
deps: [install]
cmds:
@@ -26,7 +26,7 @@ tasks:
run:
desc: "Run engine server"
deps: [prep]
deps: [prepare]
ignore_error: true
dir: src
env:
@@ -36,7 +36,7 @@ tasks:
dev:
desc: "Start engine dev server with hot reload"
deps: [prep]
deps: [prepare]
ignore_error: true
dir: src
env:
@@ -76,7 +76,7 @@ tasks:
test:
desc: "Run tests"
deps: [prep]
deps: [prepare]
cmds:
- uv run pytest tests
@@ -95,11 +95,15 @@ tasks:
- task: test
tool-models:
desc: "Generate tool_models.py from frontend TypeScript defs"
deps: [install]
desc: "Generate tool_models.py from Java OpenAPI spec (SwaggerDoc.json)"
deps: [install, ":backend:swagger"]
cmds:
- uv run python scripts/generate_tool_models.py --output src/stirling/models/tool_models.py
- task: fix
- uv run python scripts/generate_tool_models.py --spec ../SwaggerDoc.json --output src/stirling/models/tool_models.py
sources:
- ../SwaggerDoc.json
- scripts/generate_tool_models.py
generates:
- src/stirling/models/tool_models.py
clean:
desc: "Clean build artifacts"