# Programmatic Usage

> Foundry can be used programmatically by importing from the main entry point:

Source: https://bifrost5.com/foundry/docs/programmatic/

# Programmatic Usage

Information

Use the AI tool you already pay for as a Foundry worker, through an MCP bridge, with Production-Grade.

[See editions](/foundry/docs/editions)

Foundry can be used programmatically by importing from the main entry point:

```
import {
  controlLoop,
  loadState,
  enqueueTask,
  createQueue,
  type Task,
} from './index';
```

## Design Constraints

- **Operator Authority**: Only operator injects goals and tasks.

- **Deterministic Execution**: Fixed control loop.

- **State Persistence**: Every step persists.

- **Sandbox Isolation**: Projects isolated per directory.

- **Audit Trail**: All decisions logged.

## Diagnostics & Investigation Tools

```
# Check provider status and circuit breakers
npx ts-node scripts/investigations/provider-health.ts

# Inspect task queue and blocked tasks
npx ts-node scripts/investigations/task-queue-inspect.ts

# Analyze execution logs and error patterns
npx ts-node scripts/investigations/log-analyzer.ts --summary
```
