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
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ TYPESAFE_API_KEY=
# Set TYPESAFE_API_KEY above to your OpenRouter key and uncomment this base URL.
# TYPESAFE_BASE_URL=https://openrouter.ai/api

# Codex is the default worker backend. OpenCode is available as an unsandboxed alternative.
# Backends: codex (default), opencode, hermes, or deepagents.
# FOREMAN_WORKER_BACKEND=codex

# Deep Agents Code requires a separately installed dcode CLI (deepagents-code >=0.1.83).
# FOREMAN_DEEPAGENTS_EXECUTABLE=dcode
# FOREMAN_DEEPAGENTS_MODEL=openai:your-model
# FOREMAN_DEEPAGENTS_MAX_TURNS=200
# FOREMAN_DEEPAGENTS_SHELL_ALLOW_LIST=recommended

# Live steering uses Codex App Server by default. Use `exec` as a non-steerable fallback.
# FOREMAN_CODEX_BACKEND=app-server
# FOREMAN_STEERING_ENABLED=true
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,24 @@ than Codex-specific types.
### Worker backends

The semantic-supervision loop is agent-agnostic. Select the worker backend with
`FOREMAN_WORKER_BACKEND` (`codex`, the default, `opencode`, or `hermes`):
`FOREMAN_WORKER_BACKEND` (`codex`, the default, `opencode`, `hermes`, or `deepagents`):

```bash
FOREMAN_WORKER_BACKEND=opencode foreman run --repo ./my-project --job "Add request retries"
```

The OpenCode backend runs `opencode run` non-interactively and streams its output like the Codex
exec backend. The Hermes backend runs `hermes chat` in headless single-query mode and decodes its
newline-delimited JSON events into tool-activity summaries. Live steering into an active turn is only
newline-delimited JSON events into tool-activity summaries. The Deep Agents backend runs the
separately installed `dcode` CLI headlessly with bounded output and turn/time budgets.
Live steering into an active turn is only
available with the Codex App Server backend; other backends degrade to stop/retry. See [Worker
backends](docs/workers.md) for the `Worker` protocol and how to add your own.

Deep Agents also supports interactive attached supervision through native hooks. The core
`foreman deepagents setup` command merges those hooks while preserving existing configuration.
See the [Deep Agents setup guide](integrations/deepagents/README.md) for both paths.

## What Foreman watches

Each observation is compact and bounded. It contains:
Expand Down Expand Up @@ -284,6 +290,8 @@ invent one. Its minimum assessment interval defaults to five seconds and is conf
- For the OpenCode backend: the [OpenCode CLI](https://opencode.ai) on `PATH` with an available
provider and model.
- For the Hermes backend: the Hermes Agent CLI (`hermes`) on `PATH`.
- For the Deep Agents backend: `dcode` on `PATH` (`deepagents-code >= 0.1.83`, which needs
Python 3.12+) and credentials for the selected model provider.

## Installation

Expand Down Expand Up @@ -382,7 +390,7 @@ printf '%s\n' '{"session_id":"thr_123","cwd":"/workspace/project","hook_event_na
| foreman hook --client codex
```

The explicit `--client` selects `codex`, `pi`, or `pi-durable`; `codex` remains
The explicit `--client` selects `codex`, `deepagents`, `pi`, or `pi-durable`; `codex` remains
the compatibility default. Foreman does not infer a client from arbitrary JSON, and unknown
clients fail closed. The adapter normalizes events before they reach the shared attached-worker
runtime and translates semantic outcomes back into client-specific hook JSON.
Expand Down Expand Up @@ -447,7 +455,11 @@ The most useful environment overrides are:
| `FOREMAN_MAX_ITERATIONS` | `20` | Semantic decision ceiling |
| `FOREMAN_MAX_CONSECUTIVE_ASSESSMENT_FAILURES` | `3` | Tolerated supervisor failures before escalation |
| `FOREMAN_CODEX_BACKEND` | `app-server` | `app-server` for steering or `exec` fallback |
| `FOREMAN_WORKER_BACKEND` | `codex` | `codex`, `opencode`, or `hermes` worker backend |
| `FOREMAN_WORKER_BACKEND` | `codex` | `codex`, `opencode`, `hermes`, or `deepagents` worker backend |
| `FOREMAN_DEEPAGENTS_EXECUTABLE` | `dcode` | Installed Deep Agents Code executable |
| `FOREMAN_DEEPAGENTS_MODEL` | unset | Native provider/model identifier |
| `FOREMAN_DEEPAGENTS_MAX_TURNS` | `200` | Headless agentic turn limit |
| `FOREMAN_DEEPAGENTS_SHELL_ALLOW_LIST` | `recommended` | Native shell preset or command allow-list |
| `FOREMAN_STEERING_ENABLED` | `true` | Allow Jev-informed active-turn guidance |
| `FOREMAN_MAX_STEERS_PER_WORKER` | `1` | Steering attempts before stop/retry |
| `FOREMAN_STEERING_GRACE_SECONDS` | `30` | Time to recover before another intervention |
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ These notes explain Foreman's design and implementation:
- [Responsibility configuration and routing](routing.md) explains central definitions and matching.
- [Extensions](extensions.md) defines registration, lifecycle, snapshots, and hierarchical routing.
- [Coding-assistant hooks](hooks.md) describes the adapter-neutral attached-worker protocol.
- [Worker backends](workers.md) describes owned coding-agent transports.
- [Deep Agents setup](../integrations/deepagents/README.md) covers dcode workers and native hooks.
- [Live steering](steering.md) explains how Jev guidance reaches an active Codex turn.
- [Releasing](releasing.md) documents the build and trusted-publishing process.

Expand Down
12 changes: 11 additions & 1 deletion docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ target repository.
## Client adapters

The `--client` option selects the protocol adapter. Foreman does not guess from arbitrary input
JSON. It ships `codex`, `pi`, and `pi-durable` adapters. Codex remains the default for compatibility:
JSON. It ships `codex`, `deepagents`, `pi`, and `pi-durable` adapters.
Codex remains the default for compatibility:

```bash
foreman hook --client codex
Expand All @@ -41,6 +42,15 @@ its assistant's event names and fields into `HookEvent`, then renders Foreman's
session code only sees those normalized types. Adding another assistant therefore requires a new
adapter and registry entry, not another supervision runtime.

Deep Agents Code uses native Hooks v2 command handlers. Run `foreman deepagents setup`
to merge the lifecycle handlers into its user configuration, then start a fresh `dcode`
session. `foreman hook --client deepagents` normalizes native session, prompt, tool,
failure, and stop events; it preserves `prompt_id` and `stop_hook_active`. Post-tool
stop directives become native feedback, while pre-tool and completion hooks provide
operation blocking and continuation control. See the
[Deep Agents setup guide](../integrations/deepagents/README.md) for credentials,
responsibilities, configuration preservation, native limitations, and verification.

Pi uses the TypeScript [bridge package](../integrations/pi/README.md), which wraps native events
in a session/cwd envelope and applies semantic response objects through Pi's native APIs. Its
events are `session_start`, `input`, `tool_call`, `tool_result`, `agent_before_settle`, and
Expand Down
38 changes: 38 additions & 0 deletions docs/releases/0.5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Foreman 0.5.0

This release adds LangChain Deep Agents Code (`dcode`) to Foreman core as both a
headless worker backend and an agent harness supervised through native hooks.

- Select `FOREMAN_WORKER_BACKEND=deepagents` to run coding and verification jobs
through the separately installed CLI. Configure its executable, model, turn
limit, and shell allow-list through Foreman's environment settings.
- Stream bounded output from both pipes, enforce worker deadlines, recognize
native budget exhaustion, and stop descendant process groups, including the
separate LangGraph server, during supervisory termination.
- Use `foreman hook --client deepagents` for seven native lifecycle events,
including tool failures, completion checks, and session cleanup. Existing
responsibilities, routing, evidence, and completion allowances apply.
- Run `foreman deepagents setup` to merge native Hooks v2 handlers atomically
while preserving other settings. Repeating setup with the same executable
does not duplicate handlers.
- Follow the [installation and setup guide](../../integrations/deepagents/README.md)
for provider credentials, repository scope, custom paths, and troubleshooting.

Foreman keeps Python 3.11+ support and gains no LangChain SDK dependency. Install
`deepagents-code >= 0.1.83` separately with Python 3.12+. Native hooks and the
worker were tested with CLI 0.1.83 and SDK 0.7.23.

Live OpenAI runs on isolated copies of the sample calculator repository passed:
Foreman launched a coding worker and independent verifier, reached `FINISHED`,
and passed 36 tests; the separate autonomous native-hook run passed 34 tests and
all 26 hook invocations. The original sample repository remained unchanged.
See the [live test report](../../integrations/deepagents/live-test-results.md)
for scope and limitations.

The automated suite passes 430 Python tests. Native post-tool stop directives
provide model feedback; pre-tool denial and Stop handle their respective control
boundaries. The headless worker uses stop/retry steering. This integration does
not configure a sandbox, and its shell allow-list should match the project.

Since 0.4.4, the repository also documents OpenRouter setup through the TypeSafe
SDK and pins GitHub Actions to immutable commits for CI and publishing.
2 changes: 1 addition & 1 deletion docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Foreman's PyPI distribution is `foreman-core`. It provides the `foreman` import package and
`foreman` command.

Prepared release notes: [Foreman 0.4.4](releases/0.4.4.md).
Prepared release notes: [Foreman 0.5.0](releases/0.5.0.md).

## One-time setup

Expand Down
9 changes: 9 additions & 0 deletions docs/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ one capability and three coroutines:
| Codex exec | `FOREMAN_CODEX_BACKEND=exec` | No — stop/retry only |
| OpenCode | `FOREMAN_WORKER_BACKEND=opencode` | No — stop/retry only |
| Hermes | `FOREMAN_WORKER_BACKEND=hermes` | No — stop/retry only |
| Deep Agents Code | `FOREMAN_WORKER_BACKEND=deepagents` | No — stop/retry only |

The OpenCode backend shells out to `opencode run` in non-interactive mode.
The prompt is passed positionally and `--auto` keeps the headless run from
Expand All @@ -46,6 +47,14 @@ stream. Command flags can be tuned per worker
non-interactive CLIs, Hermes has no live-turn input channel: `steer` always
returns `False` and the policy falls back to stop/retry.

The Deep Agents backend uses the separately installed `dcode` CLI
(`deepagents-code >= 0.1.83`, Python 3.12+). It runs `--non-interactive` with
`--max-turns`, `--timeout`, and a configurable `--shell-allow-list` (default
`recommended`). It streams bounded text chunks from both pipes and maps native
budget exit 124 to a timed-out worker. It does not opt into project hook trust
or configure a sandbox. See the [Deep Agents setup guide](../integrations/deepagents/README.md)
for model credentials, backend settings, and the separate native-hook path.

## Adding a backend

1. Implement the `Worker` protocol (see `OpenCodeWorker` for the
Expand Down
3 changes: 3 additions & 0 deletions integrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ are available to marketplace discovery before installation.

- The [Foreman Codex plugin](https://github.com/thruwire/marketplace/tree/main/plugins/foreman)
invokes the core `foreman hook --client codex` protocol.
- [`deepagents/`](deepagents/) documents the core dcode worker and native hook adapter.
`foreman deepagents setup` merges native hook configuration; no separate bridge or plugin
package is required.
- [`pi/`](pi/) supplies buildable Pi extension and Pi Durable task-hook bridges, invoking
`foreman hook --client pi` and `foreman hook --client pi-durable` respectively. This is a local
integration package with installation documentation and offline tests. Pi supervision requires
Expand Down
Loading
Loading