Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ This _is not_ an "agent harness" and the goal isn't to re-invent the wheel: `loo
- Create a GitHub fine-grained personal access token
- Once you are done, take a snapshot of your "golden image" (e.g. `lume clone`)
- Now you can even set up Tailscale to SSH remotely to your sandbox
- By default, `loop` uses the Codex App Server transport (`codex app-server`) to keep a single session alive.
- Set `CODEX_TRANSPORT=exec` to force the legacy `codex exec --json` path.
- Use `exec` when app-server compatibility problems are expected; `loop` will print:
`[loop] codex app-server transport failed. Falling back to \`codex exec --json\`.` once per session, and continue with the legacy path.
- To permanently force legacy mode for all runs, keep `CODEX_TRANSPORT=exec` set in your environment.

## Requirements

Expand Down
41 changes: 23 additions & 18 deletions src/loop.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
#!/usr/bin/env bun
import { closeAppServer } from "./loop/codex-app-server";
import { cliDeps } from "./loop/deps";
import { updateDeps } from "./loop/update-deps";

const TMUX_DETACH_HINT = "[loop] detach with Ctrl-b d";

export const runCli = async (argv: string[]): Promise<void> => {
await updateDeps.applyStagedUpdateOnStartup();
if (await updateDeps.handleManualUpdateCommand(argv)) {
return;
}
updateDeps.startAutoUpdateCheck();
try {
await updateDeps.applyStagedUpdateOnStartup();
if (await updateDeps.handleManualUpdateCommand(argv)) {
return;
}
updateDeps.startAutoUpdateCheck();

if (process.env.TMUX) {
console.log(TMUX_DETACH_HINT);
}
if (argv.length === 0) {
await cliDeps.runPanel();
return;
}
const opts = cliDeps.parseArgs(argv);
if (opts.tmux && cliDeps.runInTmux(argv)) {
return;
if (process.env.TMUX) {
console.log(TMUX_DETACH_HINT);
}
if (argv.length === 0) {
await cliDeps.runPanel();
return;
}
const opts = cliDeps.parseArgs(argv);
if (opts.tmux && cliDeps.runInTmux(argv)) {
return;
}
await cliDeps.maybeEnterWorktree(opts);
const task = await cliDeps.resolveTask(opts);
await cliDeps.runLoop(task, opts);
} finally {
await closeAppServer();
}
await cliDeps.maybeEnterWorktree(opts);
const task = await cliDeps.resolveTask(opts);
await cliDeps.runLoop(task, opts);
};

const main = async (): Promise<void> => {
Expand Down
Loading