# 2026-03-30 - Session changelog

## Pi runner: Bash env injection and secret scrubbing

**Summary:** `@bunny-agent/runner-pi` now exposes request `PiRunnerOptions.env` inside Pi
`bash` tool subprocesses, and scrubs injected secret values from tool results before
they enter the LLM conversation.

**Details:**

- `packages/runner-pi/src/pi-runner.ts`
  - **Root cause:** `createAgentSession(options.tools)` in pi-coding-agent only keeps
    tool *names* and rebuilds the registry from built-in factories, so `spawnHook` from
    `createCodingTools` was discarded.
  - **Fix:** Register a custom `ToolDefinition` named `"bash"` via `customTools`.
    `AgentSession` replaces the built-in bash entry in `_refreshToolRegistry`, so our
    implementation runs.
  - The custom `bash` delegates to `createBashTool()` and injects `PiRunnerOptions.env`
    via `spawnHook` on the child process.
  - The custom tool redacts secret values in `execute()` before results are stored for
    the model, reducing leakage into `text-delta` and history.
  - Custom bash is registered only when `options.env` is non-empty.
- `packages/runner-pi/src/__tests__/pi-runner.test.ts`
  - Tests assert `customTools` includes `bash` when `options.env` is set and that
    `process.env` is not mutated; mocks include `createBashTool`.

## Pi runner: Tool approval (`yolo: false`)

**Summary:** Pi runner can require file-based tool approval before execution, aligned
with the Claude runner pattern.

**Changes:**

- `packages/runner-pi/src/bunny-agent-resource-loader.ts` — `yolo` option,
  `createApprovalExtension()` (pending files under `.bunny-agent/approvals/`, polling,
  approve/deny statuses).
- `packages/runner-pi/src/pi-runner.ts` — instantiates `SandagentResourceLoader` when
  `yolo: false` even without `skillPaths`.
- `packages/runner-core/src/index.ts` — passes `yolo` through to `createPiRunner`.
- `packages/sdk/src/provider/bunny-agent-provider.ts` — `yolo` on `RunnerSpec`.

Approval file shape: `status` (`pending` → `completed`/`approved` or `denied`/`rejected`),
plus `toolName` and `input`. See `packages/manager/src/types.ts` and
`packages/runner-claude/src/claude-runner.ts` for reference.

## Web: Buda env pass-through to runner

**Summary:** Example web API forwards Buda automation env into runner settings.

**Changes:**

- `apps/web/app/api/ai/route.ts` — reads `AGENT_KEY` and `BUDA_API_URL` from the body
  and includes them in `BunnyAgentProviderSettings.env` for `createBunnyAgent`.
- `apps/web/.env.example` — placeholders for `AGENT_KEY` and `BUDA_API_URL`
  (example base URL `https://dev.buda.im`).

**Why:** `buda-automations` scripts need these variables; missing values yield errors
such as `AGENT_KEY environment variable is not set`.

## Session notes: Buda automations

- Used the `buda-automations` skill (`create-automation.sh`) to add scheduled
  automations for 2026-03-31 (morning meeting reminders / one-time jobs during
  development).
