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:
@@ -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:*",
|
||||
|
||||
@@ -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}`,
|
||||
};
|
||||
});
|
||||
|
||||
23
packages/agents/src/app.ts
Normal file
23
packages/agents/src/app.ts
Normal 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
1428
packages/agents/src/db.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user