Wire Flue agents to Convex persistence and agent env

- Add db.ts: a typed ConvexHttpClient-backed PersistenceAdapter implementing
  the full Flue store surface (submissions, streams, runs, attachments).
- Add app.ts: Hono server mounting Flue routing and registering the model
  provider from @code/env/agent.
- Update zopu agent to read provider config via env() and switch
  dev/build scripts to load ../../.env.
This commit is contained in:
-Puter
2026-07-19 17:29:37 +05:30
parent 12537e1576
commit a9a8354346
4 changed files with 1469 additions and 13 deletions

View File

@@ -4,14 +4,17 @@
"private": true,
"type": "module",
"scripts": {
"build": "flue build",
"build": "bun --env-file=../../.env flue build",
"check-types": "tsc --noEmit",
"dev": "flue dev",
"run": "flue run",
"run:zopu": "flue run zopu"
"dev": "bun --env-file=../../.env flue dev",
"run": "bun --env-file=../../.env flue run",
"run:zopu": "bun --env-file=../../.env flue run zopu"
},
"dependencies": {
"@flue/runtime": "latest"
"@code/env": "workspace:*",
"@flue/runtime": "latest",
"convex": "catalog:",
"hono": "^4.12.30"
},
"devDependencies": {
"@code/config": "workspace:*",

View File

@@ -1,11 +1,13 @@
import { parseAgentEnv } from "@code/env/agent";
import { defineAgent } from "@flue/runtime";
export default defineAgent(() => ({
description: "Zopu is the primary coding agent users collaborate with.",
model: "anthropic/claude-sonnet-4-6",
instructions: `You are Zopu, the primary agent users collaborate with.
export default defineAgent(({ env }) => {
const { AGENT_MODEL_NAME, AGENT_MODEL_PROVIDER } = parseAgentEnv(env);
Work as a pragmatic senior coding agent. Understand the user's goal, inspect the current workspace, make the necessary changes, and verify that the result works. Prefer direct, maintainable solutions over unnecessary abstraction.
Your workspace is an isolated agentOS VM dedicated to this agent. Treat its filesystem, processes, and session state as the complete working environment. Use the capabilities available in the workspace, and do not assume access to resources outside it.`,
}));
return {
description: "A simple conversational agent with persistent history.",
instructions:
"You are Zopu, a concise and helpful assistant. Answer the user's request directly. Ask a clarifying question only when the request cannot be completed without one.",
model: `${AGENT_MODEL_PROVIDER}/${AGENT_MODEL_NAME}`,
};
});

View File

@@ -0,0 +1,23 @@
import { parseAgentEnv } from "@code/env/agent";
import { registerProvider } from "@flue/runtime";
import { flue } from "@flue/runtime/routing";
import { Hono } from "hono";
const agentEnv = parseAgentEnv(process.env);
registerProvider(agentEnv.AGENT_MODEL_PROVIDER, {
api: agentEnv.AGENT_MODEL_API,
apiKey: agentEnv.AGENT_MODEL_API_KEY,
baseUrl: agentEnv.AGENT_MODEL_BASE_URL,
models: {
[agentEnv.AGENT_MODEL_NAME]: {
contextWindow: agentEnv.AGENT_MODEL_CONTEXT_WINDOW,
maxTokens: agentEnv.AGENT_MODEL_MAX_TOKENS,
},
},
});
const app = new Hono();
app.route("/", flue());
export default app;

1428
packages/agents/src/db.ts Normal file

File diff suppressed because it is too large Load Diff