Integrate canonical architecture: two-process backend + LiveKit agent
Promote all 12 staged canonical files from docs/generated/files/ to their
live paths, creating the full PodMan architecture:
Backend:
- server.ts: HTTP service (token mint, sync-PR, outcome recording, /health, WS relay)
- agent.ts: worker joining LiveKit room, grabbing screenshare frames at ~1fps
- agent/podman.ts: orchestrator loop (vision -> collision detection -> intervention)
- env.ts: flat env var accessors replacing nested stub
- vision/gemini.ts: JPEG -> Gemini vision -> EngineerContext (real implementation)
- collision/detector.ts: fused vision+GitHub collision detection (the moat)
- github/client.ts: Octokit wrapper with caching + sync PR creation
- memory/store.ts: extended with recordObservation/recordCollision/recordIntervention/recordOutcome helpers
- memory/vectors.ts: stub for Voyage+Atlas vector recall (Loop A)
- memory/policy.ts: stub for intervention policy gate (Loop B)
- voice/live.ts: stub for Gemini Live TTS voice output
Shared:
- messages.ts: LiveKit data-channel wire protocol (DataMessage, InterventionOutcome, TeamModel, LocalGitReport)
- index.ts: re-exports messages module
Frontend:
- livekit/useScreenPublish.ts: hook for joining pod and publishing screenshare
- livekit/useInterventions.ts: hook for receiving collision cards and responding
- lib/api.ts: fetchToken + postOutcome HTTP helpers
Database:
- database/init.ts: MongoDB Atlas collections + indexes + vector search index
Infra:
- infra/.do/app.yaml: DO App Platform spec (static_site + service + worker)
Retire stubs superseded by canonical decomposition:
- backend/src/index.ts (replaced by server.ts)
- backend/src/intervention/engine.ts (logic now in agent/podman.ts)
- backend/src/livekit/token.ts (token minting now in server.ts)
Install missing dependencies: @livekit/rtc-node, sharp, mongodb, ws, @types/ws
Type error fixes:
- vision/gemini.ts: use MediaResolution.MEDIA_RESOLUTION_LOW enum value (not string literal)
- agent/podman.ts: wrap SuggestedActionKind into { kind: action } SuggestedAction object
All packages pass pnpm -r typecheck and pnpm -r build.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+29
-33
@@ -1,39 +1,35 @@
|
||||
import 'dotenv/config';
|
||||
|
||||
/** Reads an env var, throwing if it is required but missing. */
|
||||
function read(name: string, required = false): string {
|
||||
const value = process.env[name] ?? '';
|
||||
if (required && !value) {
|
||||
throw new Error(`Missing required env var: ${name}`);
|
||||
}
|
||||
return value;
|
||||
function req(name: string): string {
|
||||
const v = process.env[name];
|
||||
if (!v) throw new Error(`Missing required env var: ${name}`);
|
||||
return v;
|
||||
}
|
||||
function opt(name: string, fallback = ''): string {
|
||||
return process.env[name] ?? fallback;
|
||||
}
|
||||
|
||||
export const env = {
|
||||
port: Number(process.env.PORT ?? 8787),
|
||||
|
||||
livekit: {
|
||||
url: read('LIVEKIT_URL'),
|
||||
apiKey: read('LIVEKIT_API_KEY'),
|
||||
apiSecret: read('LIVEKIT_API_SECRET'),
|
||||
},
|
||||
|
||||
gemini: {
|
||||
apiKey: read('GEMINI_API_KEY'),
|
||||
visionModel: process.env.GEMINI_VISION_MODEL ?? 'gemini-3.5-flash',
|
||||
liveModel: process.env.GEMINI_LIVE_MODEL ?? '',
|
||||
},
|
||||
|
||||
github: {
|
||||
token: read('GITHUB_TOKEN'),
|
||||
repo: read('GITHUB_REPO'),
|
||||
},
|
||||
|
||||
mongo: {
|
||||
uri: read('MONGODB_URI'),
|
||||
},
|
||||
|
||||
voyage: {
|
||||
apiKey: read('VOYAGE_API_KEY'),
|
||||
},
|
||||
// LiveKit
|
||||
LIVEKIT_URL: req('LIVEKIT_URL'),
|
||||
LIVEKIT_API_KEY: req('LIVEKIT_API_KEY'),
|
||||
LIVEKIT_API_SECRET: req('LIVEKIT_API_SECRET'),
|
||||
// Gemini
|
||||
GEMINI_API_KEY: req('GEMINI_API_KEY'),
|
||||
GEMINI_VISION_MODEL: opt('GEMINI_VISION_MODEL', 'gemini-3.5-flash'),
|
||||
GEMINI_LIVE_MODEL: opt('GEMINI_LIVE_MODEL', 'gemini-3.1-flash-live-preview'),
|
||||
// GitHub
|
||||
GITHUB_TOKEN: req('GITHUB_TOKEN'),
|
||||
GITHUB_REPO: req('GITHUB_REPO'), // owner/name
|
||||
// Mongo + Voyage
|
||||
MONGODB_URI: req('MONGODB_URI'),
|
||||
VOYAGE_API_KEY: opt('VOYAGE_API_KEY'),
|
||||
// Server
|
||||
PORT: Number(opt('PORT', '8787')),
|
||||
} as const;
|
||||
|
||||
export function repoParts(): { owner: string; repo: string } {
|
||||
const [owner, repo] = env.GITHUB_REPO.split('/');
|
||||
if (!owner || !repo) throw new Error('GITHUB_REPO must be "owner/name"');
|
||||
return { owner, repo };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user