docs: add workflow research, architecture, strategy, and critique
Generated by the planning workflow: validated API findings (Gemini/LiveKit/ GitHub/DO), full architecture synthesis, winning strategy, and red-team critique. Canonical source files staged under docs/generated/files/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import {
|
||||
Room,
|
||||
RoomEvent,
|
||||
TrackKind,
|
||||
TrackSource,
|
||||
VideoStream,
|
||||
VideoBufferType,
|
||||
dispose,
|
||||
type RemoteTrack,
|
||||
type RemoteTrackPublication,
|
||||
type RemoteParticipant,
|
||||
} from '@livekit/rtc-node';
|
||||
import sharp from 'sharp';
|
||||
import { AccessToken } from 'livekit-server-sdk';
|
||||
import { env } from './env.js';
|
||||
import { PodMan } from './agent/podman.js';
|
||||
|
||||
const POD_ROOM = process.env.POD_ROOM ?? 'demo-pod';
|
||||
const SAMPLE_INTERVAL_MS = 1000; // ~1 fps to the vision model
|
||||
|
||||
async function agentToken(room: string): Promise<string> {
|
||||
const at = new AccessToken(env.LIVEKIT_API_KEY, env.LIVEKIT_API_SECRET, {
|
||||
identity: 'podman-agent',
|
||||
name: 'PodMan',
|
||||
ttl: '4h',
|
||||
});
|
||||
at.addGrant({ roomJoin: true, room, canPublish: true, canSubscribe: true, canPublishData: true });
|
||||
return at.toJwt();
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const room = new Room();
|
||||
const podman = new PodMan(room, POD_ROOM);
|
||||
await room.connect(env.LIVEKIT_URL, await agentToken(POD_ROOM), {
|
||||
autoSubscribe: true,
|
||||
dynacast: true,
|
||||
});
|
||||
await podman.start();
|
||||
console.log(`[agent] PodMan joined room ${POD_ROOM}`);
|
||||
|
||||
const lastSent = new Map<string, number>();
|
||||
|
||||
room.on(
|
||||
RoomEvent.TrackSubscribed,
|
||||
(track: RemoteTrack, pub: RemoteTrackPublication, participant: RemoteParticipant) => {
|
||||
if (track.kind !== TrackKind.KIND_VIDEO || pub.source !== TrackSource.SOURCE_SCREENSHARE) return;
|
||||
const id = participant.identity;
|
||||
const stream = new VideoStream(track);
|
||||
void (async () => {
|
||||
for await (const event of stream) {
|
||||
const now = Date.now();
|
||||
if (now - (lastSent.get(id) ?? 0) < SAMPLE_INTERVAL_MS) continue; // THROTTLE
|
||||
lastSent.set(id, now);
|
||||
const rgba = event.frame.convert(VideoBufferType.RGBA);
|
||||
const jpeg = await sharp(Buffer.from(rgba.data), {
|
||||
raw: { width: rgba.width, height: rgba.height, channels: 4 },
|
||||
})
|
||||
.resize({ width: 1280, withoutEnlargement: true })
|
||||
.jpeg({ quality: 70 })
|
||||
.toBuffer();
|
||||
await podman.onScreenFrame(id, jpeg);
|
||||
}
|
||||
})();
|
||||
},
|
||||
);
|
||||
|
||||
const shutdown = async () => {
|
||||
await room.disconnect();
|
||||
await dispose();
|
||||
process.exit(0);
|
||||
};
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGTERM', shutdown);
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error('[agent] fatal', e);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
import { RoomEvent, type Room } from '@livekit/rtc-node';
|
||||
import type { EngineerContext, Collision, Intervention, DataMessage } from '@podman/shared';
|
||||
import { DATA_TOPIC } from '@podman/shared';
|
||||
import { analyzeFrame } from '../vision/gemini.js';
|
||||
import { detectCollisions } from '../collision/detector.js';
|
||||
import { getGithubState } from '../github/client.js';
|
||||
import { recordObservation, recordCollision, recordIntervention } from '../memory/store.js';
|
||||
import { recallSimilar } from '../memory/vectors.js';
|
||||
import { shouldIntervene, preferredAction } from '../memory/policy.js';
|
||||
import { speak } from '../voice/live.js';
|
||||
|
||||
export class PodMan {
|
||||
private contexts = new Map<string, EngineerContext>();
|
||||
private encoder = new TextEncoder();
|
||||
|
||||
constructor(
|
||||
private room: Room,
|
||||
private podId: string,
|
||||
) {}
|
||||
|
||||
async start(): Promise<void> {
|
||||
// Tier-2 optional ground-truth + engineer ACKs arrive over the data channel.
|
||||
this.room.on(RoomEvent.DataReceived, (payload) => {
|
||||
try {
|
||||
const msg = JSON.parse(new TextDecoder().decode(payload)) as DataMessage;
|
||||
if (msg.type === 'GIT_REPORT') {
|
||||
const c = this.contexts.get(msg.report.engineerId);
|
||||
if (c) c.hasUnpushedChanges = msg.report.unpushedCount > 0 || msg.report.dirtyFiles.length > 0;
|
||||
}
|
||||
} catch { /* ignore malformed */ }
|
||||
});
|
||||
}
|
||||
|
||||
async onScreenFrame(engineerId: string, jpeg: Buffer): Promise<void> {
|
||||
const ctx = await analyzeFrame(engineerId, this.podId, jpeg);
|
||||
this.contexts.set(engineerId, ctx);
|
||||
await recordObservation(ctx);
|
||||
|
||||
const github = await getGithubState(); // cached
|
||||
const collisions = detectCollisions([...this.contexts.values()], github);
|
||||
for (const collision of collisions) await this.handle(collision);
|
||||
}
|
||||
|
||||
private async handle(collision: Collision): Promise<void> {
|
||||
const prior = await recallSimilar(collision); // Loop A: vector recall raises confidence
|
||||
if (prior) collision.severity = 'critical';
|
||||
if (!shouldIntervene(collision, prior)) return; // Loop B: policy gate
|
||||
|
||||
await recordCollision(collision);
|
||||
const action = preferredAction(collision, prior);
|
||||
const names = collision.engineers.join(' and ');
|
||||
const message = `${names} are both editing ${collision.file}` +
|
||||
(collision.githubState?.unpushed ? ' and one has unpushed changes.' : '.') +
|
||||
(prior ? ` I've seen this conflict pattern before.` : '');
|
||||
|
||||
const intervention: Intervention = {
|
||||
id: `int_${Date.now()}`,
|
||||
collisionId: collision.id,
|
||||
podId: this.podId,
|
||||
kind: 'card',
|
||||
message,
|
||||
suggestedAction: action,
|
||||
status: 'pending',
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
await recordIntervention(intervention);
|
||||
|
||||
const data: DataMessage = { type: 'COLLISION', collision, intervention };
|
||||
await this.room.localParticipant?.publishData(
|
||||
this.encoder.encode(JSON.stringify(data)),
|
||||
{ reliable: true, topic: DATA_TOPIC },
|
||||
);
|
||||
await speak(this.room, message); // gemini-3.1-flash-live voice into the room
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { EngineerContext, Collision, GithubStateSnapshot } from '@podman/shared';
|
||||
|
||||
function normalize(path?: string): string | undefined {
|
||||
if (!path) return undefined;
|
||||
return path.replace(/^\.?\/?(src\/)?/, 'src/').toLowerCase();
|
||||
}
|
||||
|
||||
export function detectCollisions(
|
||||
contexts: EngineerContext[],
|
||||
github: GithubStateSnapshot,
|
||||
): Collision[] {
|
||||
const byFile = new Map<string, EngineerContext[]>();
|
||||
for (const c of contexts) {
|
||||
const f = normalize(c.currentFile);
|
||||
if (!f) continue;
|
||||
(byFile.get(f) ?? byFile.set(f, []).get(f)!).push(c);
|
||||
}
|
||||
|
||||
const out: Collision[] = [];
|
||||
for (const [file, group] of byFile) {
|
||||
const engineers = [...new Set(group.map((g) => g.engineerId))];
|
||||
if (engineers.length < 2) continue;
|
||||
|
||||
const anyUnpushed =
|
||||
group.some((g) => g.hasUnpushedChanges) || github.unpushed === true;
|
||||
if (!anyUnpushed) continue; // the crux GitHub alone cannot answer
|
||||
|
||||
out.push({
|
||||
id: `col_${file}_${Date.now()}`,
|
||||
podId: group[0]!.podId,
|
||||
file,
|
||||
symbol: group.find((g) => g.currentSymbol)?.currentSymbol,
|
||||
engineers,
|
||||
severity: 'warn',
|
||||
githubState: { ...github, unpushed: anyUnpushed },
|
||||
detectedAt: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'dotenv/config';
|
||||
|
||||
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 = {
|
||||
// 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 };
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Octokit } from 'octokit';
|
||||
import type { GithubStateSnapshot } from '@podman/shared';
|
||||
import { env, repoParts } from '../env.js';
|
||||
|
||||
const gh = new Octokit({ auth: env.GITHUB_TOKEN });
|
||||
let cache: { at: number; state: GithubStateSnapshot } | null = null;
|
||||
const TTL_MS = 5000;
|
||||
|
||||
export async function getGithubState(): Promise<GithubStateSnapshot> {
|
||||
if (cache && Date.now() - cache.at < TTL_MS) return cache.state;
|
||||
const { owner, repo } = repoParts();
|
||||
const [{ data: branches }] = await Promise.all([
|
||||
gh.rest.repos.listBranches({ owner, repo, per_page: 50 }),
|
||||
]);
|
||||
const state: GithubStateSnapshot = {
|
||||
branches: Object.fromEntries(branches.map((b) => [b.name, b.commit.sha])),
|
||||
openPrs: [],
|
||||
unpushed: undefined, // vision/Tier-2 fills this; API cannot know
|
||||
};
|
||||
cache = { at: Date.now(), state };
|
||||
return state;
|
||||
}
|
||||
|
||||
export async function remoteHasFile(path: string, ref = 'main'): Promise<boolean> {
|
||||
const { owner, repo } = repoParts();
|
||||
return gh.rest.repos
|
||||
.getContent({ owner, repo, path, ref })
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
}
|
||||
|
||||
export async function createSyncPr(input: { headBranch: string; file: string; summary: string }) {
|
||||
const { owner, repo } = repoParts();
|
||||
const { data: mainRef } = await gh.rest.git.getRef({ owner, repo, ref: 'heads/main' });
|
||||
const branch = `podman-sync-${Date.now()}`;
|
||||
await gh.rest.git.createRef({ owner, repo, ref: `refs/heads/${branch}`, sha: mainRef.object.sha });
|
||||
const { data: pr } = await gh.rest.pulls.create({
|
||||
owner,
|
||||
repo,
|
||||
title: `PodMan: sync ${input.file} before collision`,
|
||||
head: branch,
|
||||
base: 'main',
|
||||
body: input.summary,
|
||||
});
|
||||
return pr;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import express from 'express';
|
||||
import { createServer } from 'node:http';
|
||||
import { WebSocketServer } from 'ws';
|
||||
import { AccessToken } from 'livekit-server-sdk';
|
||||
import { env } from './env.js';
|
||||
import { createSyncPr } from './github/client.js';
|
||||
import { recordOutcome } from './memory/store.js';
|
||||
import type { InterventionOutcome } from '@podman/shared';
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.get('/health', (_req, res) => res.json({ ok: true }));
|
||||
|
||||
// Mint a LiveKit token for an engineer joining a pod.
|
||||
app.post('/api/token', async (req, res) => {
|
||||
const { room, identity, name, githubLogin } = req.body ?? {};
|
||||
if (!room || !identity) return res.status(400).json({ error: 'room+identity required' });
|
||||
const at = new AccessToken(env.LIVEKIT_API_KEY, env.LIVEKIT_API_SECRET, {
|
||||
identity,
|
||||
name,
|
||||
ttl: '4h',
|
||||
metadata: JSON.stringify({ githubLogin: githubLogin ?? name }),
|
||||
});
|
||||
at.addGrant({ roomJoin: true, room, canPublish: true, canSubscribe: true, canPublishData: true });
|
||||
res.json({ token: await at.toJwt(), url: env.LIVEKIT_URL });
|
||||
});
|
||||
|
||||
// PodMan's hero action: open a real sync PR on the PUBLIC repo.
|
||||
app.post('/api/sync-pr', async (req, res) => {
|
||||
try {
|
||||
const { headBranch, file, summary } = req.body ?? {};
|
||||
const pr = await createSyncPr({ headBranch, file, summary });
|
||||
res.json({ url: pr.html_url, number: pr.number });
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: (e as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// Outcome ACK -> closes the continual-learning policy loop.
|
||||
app.post('/api/outcome', async (req, res) => {
|
||||
await recordOutcome(req.body as InterventionOutcome);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
const http = createServer(app);
|
||||
|
||||
// ws relay: the agent pushes collision/intervention JSON here; PWAs subscribed by pod receive it.
|
||||
const wss = new WebSocketServer({ server: http, path: '/api/events' });
|
||||
const clients = new Set<import('ws').WebSocket>();
|
||||
wss.on('connection', (ws) => {
|
||||
clients.add(ws);
|
||||
ws.on('close', () => clients.delete(ws));
|
||||
ws.on('message', (buf) => {
|
||||
// fan out agent->PWA events; (auth/pod-scoping omitted for hackathon brevity)
|
||||
for (const c of clients) if (c !== ws && c.readyState === 1) c.send(buf.toString());
|
||||
});
|
||||
});
|
||||
|
||||
http.listen(env.PORT, '0.0.0.0', () => console.log(`[server] :${env.PORT}`));
|
||||
@@ -0,0 +1,53 @@
|
||||
import { GoogleGenAI, Type } from '@google/genai';
|
||||
import type { EngineerContext } from '@podman/shared';
|
||||
import { env } from '../env.js';
|
||||
|
||||
const ai = new GoogleGenAI({ apiKey: env.GEMINI_API_KEY });
|
||||
|
||||
const SCHEMA = {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
currentFile: { type: Type.STRING, description: 'open file path if visible, e.g. src/auth/session.ts' },
|
||||
currentSymbol: { type: Type.STRING, description: 'function/class under the cursor' },
|
||||
activity: { type: Type.STRING, description: 'editing | reading | debugging | terminal | PR review' },
|
||||
hasUnpushedChanges: { type: Type.BOOLEAN, description: 'dirty git gutter / modified markers visible' },
|
||||
confidence: { type: Type.NUMBER, description: '0..1 confidence in this read' },
|
||||
},
|
||||
propertyOrdering: ['currentFile', 'currentSymbol', 'activity', 'hasUnpushedChanges', 'confidence'],
|
||||
} as const;
|
||||
|
||||
export async function analyzeFrame(
|
||||
engineerId: string,
|
||||
podId: string,
|
||||
jpeg: Buffer,
|
||||
): Promise<EngineerContext> {
|
||||
const res = await ai.models.generateContent({
|
||||
model: env.GEMINI_VISION_MODEL,
|
||||
contents: [
|
||||
{
|
||||
role: 'user',
|
||||
parts: [
|
||||
{ text: "You are PodMan watching an engineer's screen. Identify what file/symbol they are working on and whether there are uncommitted edits. JSON only." },
|
||||
{ inlineData: { mimeType: 'image/jpeg', data: jpeg.toString('base64') } },
|
||||
],
|
||||
},
|
||||
],
|
||||
config: {
|
||||
responseMimeType: 'application/json',
|
||||
responseJsonSchema: SCHEMA,
|
||||
thinkingConfig: { thinkingBudget: 0 }, // minimal thinking: low latency/cost for ambient loop
|
||||
mediaResolution: 'MEDIA_RESOLUTION_LOW',
|
||||
},
|
||||
});
|
||||
const parsed = JSON.parse(res.text ?? '{}') as Partial<EngineerContext>;
|
||||
return {
|
||||
engineerId,
|
||||
podId,
|
||||
currentFile: parsed.currentFile,
|
||||
currentSymbol: parsed.currentSymbol,
|
||||
activity: parsed.activity,
|
||||
hasUnpushedChanges: parsed.hasUnpushedChanges,
|
||||
confidence: parsed.confidence ?? 0.5,
|
||||
observedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { MongoClient } from 'mongodb';
|
||||
|
||||
const uri = process.env.MONGODB_URI!;
|
||||
const DB = 'podman';
|
||||
|
||||
async function main() {
|
||||
const client = new MongoClient(uri);
|
||||
await client.connect();
|
||||
const db = client.db(DB);
|
||||
|
||||
await db.collection('pods').createIndex({ id: 1 }, { unique: true });
|
||||
// High-volume observations expire after 6h to keep the cluster light.
|
||||
await db.collection('observations').createIndex({ observedAt: 1 }, { expireAfterSeconds: 21600 });
|
||||
await db.collection('observations').createIndex({ podId: 1, engineerId: 1 });
|
||||
await db.collection('collisions').createIndex({ podId: 1, detectedAt: -1 });
|
||||
await db.collection('interventions').createIndex({ id: 1 }, { unique: true });
|
||||
await db.collection('team_model').createIndex({ podId: 1 }, { unique: true });
|
||||
await db.collection('policy').createIndex({ pattern: 1 }, { unique: true });
|
||||
|
||||
// Atlas Vector Search index for collision-pattern recall (Voyage voyage-3 = 1024 dims).
|
||||
try {
|
||||
await db.command({
|
||||
createSearchIndexes: 'memory_vectors',
|
||||
indexes: [
|
||||
{
|
||||
name: 'vector_index',
|
||||
type: 'vectorSearch',
|
||||
definition: {
|
||||
fields: [{ type: 'vector', path: 'embedding', numDimensions: 1024, similarity: 'cosine' }],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('vector index (create in Atlas UI if this errors):', (e as Error).message);
|
||||
}
|
||||
|
||||
console.log('PodMan DB initialized.');
|
||||
await client.close();
|
||||
}
|
||||
main().catch((e) => { console.error(e); process.exit(1); });
|
||||
@@ -0,0 +1,39 @@
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { RoomEvent, type Room } from 'livekit-client';
|
||||
import type { DataMessage, Intervention, InterventionStatus } from '@podman/shared';
|
||||
import { DATA_TOPIC } from '@podman/shared';
|
||||
import { postOutcome } from '../lib/api';
|
||||
|
||||
export function useInterventions(room: Room | null) {
|
||||
const [active, setActive] = useState<Intervention | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!room) return;
|
||||
const onData = (payload: Uint8Array, _p: unknown, _k: unknown, topic?: string) => {
|
||||
if (topic !== DATA_TOPIC) return;
|
||||
const msg = JSON.parse(new TextDecoder().decode(payload)) as DataMessage;
|
||||
if (msg.type === 'COLLISION') setActive(msg.intervention);
|
||||
};
|
||||
room.on(RoomEvent.DataReceived, onData);
|
||||
return () => { room.off(RoomEvent.DataReceived, onData); };
|
||||
}, [room]);
|
||||
|
||||
const respond = useCallback(
|
||||
async (status: InterventionStatus, accepted: boolean) => {
|
||||
if (!active) return;
|
||||
await postOutcome({
|
||||
interventionId: active.id,
|
||||
collisionId: active.collisionId,
|
||||
podId: active.podId,
|
||||
wasRealCollision: true,
|
||||
accepted,
|
||||
recordedAt: new Date().toISOString(),
|
||||
});
|
||||
setActive(null);
|
||||
return status;
|
||||
},
|
||||
[active],
|
||||
);
|
||||
|
||||
return { active, respond };
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { Room, Track, createLocalScreenTracks, VideoPresets } from 'livekit-client';
|
||||
import { fetchToken } from '../lib/api';
|
||||
|
||||
export function useScreenPublish() {
|
||||
const roomRef = useRef<Room | null>(null);
|
||||
const [connected, setConnected] = useState(false);
|
||||
const [sharing, setSharing] = useState(false);
|
||||
|
||||
const join = useCallback(async (pod: string, identity: string, name: string, githubLogin?: string) => {
|
||||
const { token, url } = await fetchToken({ room: pod, identity, name, githubLogin });
|
||||
const room = new Room({ adaptiveStream: true, dynacast: true });
|
||||
await room.connect(url, token);
|
||||
roomRef.current = room;
|
||||
setConnected(true);
|
||||
return room;
|
||||
}, []);
|
||||
|
||||
const startSharing = useCallback(async () => {
|
||||
const room = roomRef.current;
|
||||
if (!room) throw new Error('join the pod first');
|
||||
const tracks = await createLocalScreenTracks({
|
||||
audio: true,
|
||||
resolution: VideoPresets.h1080.resolution,
|
||||
});
|
||||
for (const t of tracks) {
|
||||
await room.localParticipant.publishTrack(t.mediaStreamTrack, {
|
||||
source:
|
||||
t.kind === Track.Kind.Audio ? Track.Source.ScreenShareAudio : Track.Source.ScreenShare,
|
||||
});
|
||||
}
|
||||
await room.localParticipant.setMicrophoneEnabled(true);
|
||||
await room.localParticipant.setCameraEnabled(true);
|
||||
setSharing(true);
|
||||
}, []);
|
||||
|
||||
return { join, startSharing, connected, sharing, room: roomRef };
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
name: podman
|
||||
region: nyc
|
||||
|
||||
static_sites:
|
||||
- name: web
|
||||
github:
|
||||
repo: <org>/Podman
|
||||
branch: main
|
||||
deploy_on_push: true
|
||||
source_dir: frontend
|
||||
build_command: corepack enable && pnpm install --frozen-lockfile && pnpm --filter @podman/shared build && pnpm --filter @podman/frontend build
|
||||
output_dir: dist
|
||||
routes:
|
||||
- path: /
|
||||
|
||||
services:
|
||||
- name: api
|
||||
github:
|
||||
repo: <org>/Podman
|
||||
branch: main
|
||||
deploy_on_push: true
|
||||
source_dir: backend
|
||||
build_command: corepack enable && pnpm install --frozen-lockfile && pnpm --filter @podman/shared build && pnpm --filter @podman/backend build
|
||||
run_command: node dist/server.js
|
||||
http_port: 8787
|
||||
instance_size_slug: apps-s-1vcpu-1gb
|
||||
instance_count: 1
|
||||
routes:
|
||||
- path: /api
|
||||
envs:
|
||||
- { key: LIVEKIT_URL, scope: RUN_TIME, type: SECRET }
|
||||
- { key: LIVEKIT_API_KEY, scope: RUN_TIME, type: SECRET }
|
||||
- { key: LIVEKIT_API_SECRET, scope: RUN_TIME, type: SECRET }
|
||||
- { key: GITHUB_TOKEN, scope: RUN_TIME, type: SECRET }
|
||||
- { key: GITHUB_REPO, scope: RUN_TIME, value: <org>/<public-repo> }
|
||||
- { key: MONGODB_URI, scope: RUN_TIME, type: SECRET }
|
||||
|
||||
workers:
|
||||
- name: podman-agent
|
||||
github:
|
||||
repo: <org>/Podman
|
||||
branch: main
|
||||
deploy_on_push: true
|
||||
source_dir: backend
|
||||
build_command: corepack enable && pnpm install --frozen-lockfile && pnpm --filter @podman/shared build && pnpm --filter @podman/backend build
|
||||
run_command: node dist/agent.js
|
||||
instance_size_slug: apps-s-1vcpu-1gb
|
||||
instance_count: 1
|
||||
envs:
|
||||
- { key: LIVEKIT_URL, scope: RUN_TIME, type: SECRET }
|
||||
- { key: LIVEKIT_API_KEY, scope: RUN_TIME, type: SECRET }
|
||||
- { key: LIVEKIT_API_SECRET, scope: RUN_TIME, type: SECRET }
|
||||
- { key: GEMINI_API_KEY, scope: RUN_TIME, type: SECRET }
|
||||
- { key: GEMINI_VISION_MODEL, scope: RUN_TIME, value: gemini-3.5-flash }
|
||||
- { key: GEMINI_LIVE_MODEL, scope: RUN_TIME, value: gemini-3.1-flash-live-preview }
|
||||
- { key: GITHUB_TOKEN, scope: RUN_TIME, type: SECRET }
|
||||
- { key: GITHUB_REPO, scope: RUN_TIME, value: <org>/<public-repo> }
|
||||
- { key: MONGODB_URI, scope: RUN_TIME, type: SECRET }
|
||||
- { key: VOYAGE_API_KEY, scope: RUN_TIME, type: SECRET }
|
||||
- { key: POD_ROOM, scope: RUN_TIME, value: demo-pod }
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { Collision } from './collision.js';
|
||||
import type { Intervention, InterventionStatus } from './intervention.js';
|
||||
|
||||
/** Topics multiplexed over the LiveKit data channel. */
|
||||
export const DATA_TOPIC = 'podman.intervention' as const;
|
||||
|
||||
/** Wire messages exchanged between the PodMan agent and engineer PWAs. */
|
||||
export type DataMessage =
|
||||
| { type: 'COLLISION'; collision: Collision; intervention: Intervention }
|
||||
| { type: 'VOICE_CUE'; text: string }
|
||||
| { type: 'ACK'; interventionId: string; status: InterventionStatus; note?: string }
|
||||
| { type: 'GIT_REPORT'; report: LocalGitReport };
|
||||
|
||||
/** Outcome of an intervention — the supervision signal for policy learning. */
|
||||
export interface InterventionOutcome {
|
||||
interventionId: string;
|
||||
collisionId: string;
|
||||
podId: string;
|
||||
/** Did the predicted collision turn out real? (engineer-confirmed or inferred). */
|
||||
wasRealCollision: boolean;
|
||||
/** Did the engineer accept the offered action (e.g. sync PR)? */
|
||||
accepted: boolean;
|
||||
recordedAt: string;
|
||||
}
|
||||
|
||||
/** The continually-refined per-pod world model (Loop A). */
|
||||
export interface TeamModel {
|
||||
podId: string;
|
||||
/** filePath/dir -> engineerId most associated with it (de-facto owner). */
|
||||
ownership: Record<string, string>;
|
||||
/** Pairs of files that historically collide, with a co-occurrence weight. */
|
||||
hotspots: Array<{ files: [string, string]; weight: number }>;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
/** OPTIONAL Tier-2 ground-truth from a per-laptop git sidecar. */
|
||||
export interface LocalGitReport {
|
||||
engineerId: string;
|
||||
branch: string;
|
||||
/** Commits ahead of upstream (invisible to the GitHub API). */
|
||||
unpushedCount: number;
|
||||
/** Working-tree files with uncommitted edits. */
|
||||
dirtyFiles: string[];
|
||||
reportedAt: string;
|
||||
}
|
||||
Reference in New Issue
Block a user