feat: wire real service agents into chat with LLM tool dispatch + Rivet proxy fix (#3)

# Wire All 4 Microservice Agents Into Chat

Wires all 4 microservice-backed agents into the chat so the LLM can call real services and return session URLs.

---

## Changes

### New

* `src/routes/chat.ts`

  * Added a direct HTTP chat endpoint.
  * When the LLM calls:

    * `start_interview_session`
    * `analyze_resume`
    * `start_roleplay_session`
    * `compute_qscore`
  * The route executes real service probes and returns live session URLs.

---

### Fixed

* `src/index.ts`

  * Rivet proxy now forwards requests to the engine at `localhost:6420`
    instead of using `registry.handler()`.
  * Prevents the:

    ```txt
    Runtime already started as runner
    ```

    conflict.

* `src/actors/user-actor.ts`

  * `receiveMessage()` now returns:

    ```ts
    {
      reply,
      sessions: []
    }
    ```
  * Includes per-module session URLs in responses.

* `docker-compose.yml`

  * Fixed:

    * Gitea health check port
    * Port mapping
    * `A2A_ALLOWED_KEY` default value

* `src/config.ts`

  * Added:

    ```ts
    resumeServiceUrl
    ```
  * Configured to use port `8002`.

---

### Rewritten

* `prompts/system.txt`

  * Reworked into a conversational step-by-step flow.
  * Added explicit rule:

    > CALL THE TOOL IMMEDIATELY

---

### Updated

* `agents/*.md` (6 files)

  * Updated:

    * Domain descriptions
    * Trigger phrases
    * Agent boundaries

---

## Verified

| Agent         | Service                  | Result                      |
| ------------- | ------------------------ | --------------------------- |
| Resume (Mira) | `resume-builder:8002`    | Real analysis               |
| Sara          | `interview-service:8007` | Real Gemini session + URL   |
| Emily         | `roleplay-service:8008`  | Real roleplay session + URL |
| Quinn         | `qscore-service:8000`    | Real Q-Score (~84)          |

---

## Outcome

The chat system can now:

* Trigger real backend agent services directly from LLM tool calls
* Return live session URLs
* Maintain structured multi-agent responses
* Avoid Rivet runtime conflicts
* Support end-to-end conversational workflows across all 4 agents

Reviewed-on: puter/growqr-backend#3
Co-authored-by: NinjasPyajamas <divyansh242805@gmail.com>
Co-committed-by: NinjasPyajamas <divyansh242805@gmail.com>
This commit is contained in:
2026-06-01 09:26:19 +00:00
committed by puter
parent ff0bf5e5f0
commit 9ddbb4a8e5
37 changed files with 2962 additions and 1039 deletions

View File

@@ -3,30 +3,50 @@ LOG_LEVEL=info
NODE_ENV=development
# Postgres (started by docker-compose; defaults match the compose service)
DATABASE_URL=postgres://growqr:growqr@localhost:5432/growqr
DATABASE_URL=***************************************/growqr
POSTGRES_USER=growqr
POSTGRES_PASSWORD=growqr
POSTGRES_PASSWORD=******
POSTGRES_DB=growqr
# Clerk auth — get from dashboard.clerk.com → API Keys
CLERK_SECRET_KEY=sk_test_REPLACE_ME
CLERK_PUBLISHABLE_KEY=pk_test_REPLACE_ME
CLERK_SECRET_KEY=clerk_key
CLERK_PUBLISHABLE_KEY=clerk_publishable_key
# Anthropic — get from console.anthropic.com → API Keys
ANTHROPIC_API_KEY=sk-ant-REPLACE_ME
GROW_AGENT_MODEL=claude-opus-4-7
SUB_AGENT_MODEL=claude-sonnet-4-6
# OpenCode Zen LLM gateway — get from opencode.ai/auth
OPENCODE_API_KEY=sk-REPLACE_ME
LLM_PROVIDER=opencode
LLM_BASE_URL=https://opencode.ai/zen/v1
LLM_MODEL=kimi-k2.6
GROW_AGENT_MODEL=kimi-k2.6
MAX_AGENT_TOKENS=4096
# Shared secret for actor → backend service calls (rotate in prod)
SERVICE_TOKEN=dev-service-token-REPLACE_ME
A2A_ALLOWED_KEY=***********
# ── Central Gitea (shared org-wide, changes.md §2A) ──
GITEA_URL=http://127.0.0.1:3001
GITEA_ADMIN_USER=growqr-admin
GITEA_ADMIN_PASSWORD=growqr-admin-dev
GITEA_ADMIN_TOKEN=
GITEA_ORG_NAME=growqr
# ── Version tracking (changes.md §9) ──
OPENCODE_IMAGE_VERSION=1.0.0
MIGRATION_VERSION=1
PROMPT_VERSION=1
# Rivet Kit engine (self-hosted in docker-compose)
RIVET_ENDPOINT=http://localhost:6420
RIVET_CLIENT_ENDPOINT=http://127.0.0.1:4000/api/rivet
# Per-user container images
GITEA_IMAGE=gitea/gitea:1.22
OPENCODE_IMAGE=ghcr.io/sst/opencode:latest
# Product microservice sub-agent URLs
INTERVIEW_SERVICE_URL=http://localhost:8007
ROLEPLAY_SERVICE_URL=http://localhost:8008
QSCORE_SERVICE_URL=http://localhost:8000
# Per-user OpenCode container image (shared, changes.md §3)
OPENCODE_IMAGE=ghcr.io/anomalyco/opencode:latest
# Host where spawned containers expose their ports.
# - localhost in dev
@@ -36,7 +56,7 @@ USER_CONTAINER_HOST=127.0.0.1
# Workspace root on the host. Each user gets a subdir.
USER_DATA_ROOT=./.data/users
# Port range allocated to spawned per-user containers
# Port range allocated to per-user OpenCode containers (Gitea is central)
USER_PORT_RANGE_START=20000
USER_PORT_RANGE_END=29999