feat(phase-2): Theia HTTP sync via sync-server on port 3001

- theia-exec.ts: primary path is now HTTP sync (syncRepoToTheia) via
  sync-server.js running inside Theia on port 3001 — no docker socket needed
- syncRepoToTheia(giteaRepo): POST /sync → Theia git-pulls latest committed code
- isTheiaSyncAvailable(): health check before attempting sync
- docker exec path preserved for future use when socket is mounted
- agent-session-runner: use syncRepoToTheia after auto-commit
- server.ts: log both docker exec + HTTP sync status at startup

Made-with: Cursor
This commit is contained in:
2026-03-07 13:38:07 -08:00
parent 7f10009b4f
commit b04d7b2e13
3 changed files with 100 additions and 80 deletions

View File

@@ -17,7 +17,7 @@ import { createLLM, toOAITools, LLMMessage } from './llm';
import { AgentConfig } from './agents';
import { executeTool, ToolContext } from './tools';
import { resolvePrompt } from './prompts/loader';
import { isTheiaAvailable, theiaExec, syncToTheia, getTheiaContainer } from './theia-exec';
import { isTheiaAvailable, theiaExec, syncRepoToTheia, isTheiaSyncAvailable } from './theia-exec';
const MAX_TURNS = 60;
@@ -116,12 +116,12 @@ async function autoCommitAndDeploy(
const giteaToken = process.env.GITEA_API_TOKEN || '';
try {
// Sync files into Theia so "Open in Theia" shows the agent's work
if (isTheiaAvailable() && opts.theiaWorkspaceSubdir) {
await emit({ ts: now(), type: 'info', text: `Syncing files to Theia…` });
const syncResult = await syncToTheia(repoRoot, opts.theiaWorkspaceSubdir);
// Sync files into Theia via the sync-server so "Open in Theia" shows latest code
if (opts.giteaRepo && await isTheiaSyncAvailable()) {
await emit({ ts: now(), type: 'info', text: `Syncing to Theia…` });
const syncResult = await syncRepoToTheia(opts.giteaRepo);
if (syncResult.ok) {
await emit({ ts: now(), type: 'info', text: '✓ Files available in Theia — open theia.vibnai.com to inspect.' });
await emit({ ts: now(), type: 'info', text: `✓ Theia synced (${syncResult.action}) — open theia.vibnai.com to inspect.` });
} else {
console.warn('[session-runner] Theia sync failed:', syncResult.error);
}