Skip to content
Open
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
30 changes: 30 additions & 0 deletions .changeset/audit-records-for-writes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@github-tools/eve-extension': minor
'@github-tools/sdk': minor
---

Add audit records for GitHub writes in eve.

Pass a function as `audit` in the extension's mount file. It receives a plain record of each GitHub write, so no logging library is needed:

```ts
export default githubExtension({
connector: 'github/my-connector',
requireApproval: 'auto',
audit: record => db.upsert('github_audit', record.id, record),
})
```

- **Two records for each write.** A write that reaches GitHub has a `started` record, sent immediately before the request, and a `settled` record with the `outcome`: `succeeded`, `failed`, or `denied`. Both have the same `id`.
- **No write without a record.** The write waits for the function. When it throws on the `started` record, the write isn't sent and the call fails with the new `github_tools.AUDIT_UNAVAILABLE` error. Reads keep working.
- **Stopped writes are recorded too.** A write that `guardrails`, an approval policy, or a person stopped has one `settled` record with `outcome: 'denied'` and the reason.
- **Who and what.** A record names the agent, the requester, the approver or the person who denied the write, the target, what let the write run (`clearance`), the decision model's verdict under `'auto'`, and whether the write used the App's or a person's GitHub access. It holds no title, body, diff, or tool input.
- **Outcomes aren't lost quietly.** A `settled` record the function rejects is written to stderr as one JSON line prefixed `[github-tools] audit`, and sent again with `reconciled: true` each time a turn of the session ends, until the function accepts it.

Reads and dry-run writes have no record, and a mount without `audit` does nothing more than one check for each call. [Observability](https://github-tools.com/observability) lists every field.

In `@github-tools/sdk/eve-runtime`:

- `githubAuditTarget`, `githubAuditStarted`, `githubAuditSettled`, `reconcileGithubAudit`, and `githubAuditRecordId` build the records, with the `GithubAuditRecord` type and its parts.
- `executeGithubEveTool` takes `beforeWrite`, a function awaited immediately before a write's request. A throw from it stops the write.
- `autoApprovalDecision` also returns the decision model's `risk` and `intent` when it answered.
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pnpm workspaces + Turborepo, with published packages, apps, and examples:
- **`packages/github-tools-eve-extension`** — the published eve extension (`@github-tools/eve-extension`).
- **`examples/*`** — consumer integrations used for development, smoke tests (`examples/eve-smoke`), and canary checks.
- **`examples/eve`** — the Slack and GitHub agent people clone or deploy on its own (Deploy button, `giget`), so it must work outside the monorepo: no `workspace:*`, no root config. It depends on `@github-tools/eve-extension` from npm as `latest`, because Changesets rewrites a semver range to the unreleased version in the Version PR, which breaks `pnpm install --frozen-lockfile`. Only use released options in it; to try unreleased extension code, use `examples/eve-smoke` or `tests/*`. After a release, move its lockfile entry to the new version so CI builds against it: set the dependency to that version, run `pnpm install`, set it back to `latest` and run `pnpm install` again. `pnpm update --filter` also refreshes unrelated transitive dependencies.
- **`tests/*`** — eval-only agents that are not usable examples: `tests/eve-act-as` covers the eve extension's `actAs`, `approvers` and `githubChannel`'s `respondTo`, and `tests/eve-auto` covers `preset: 'auto'` and `requireApproval: 'auto'`, both with stubbed Vercel Connect and GitHub.
- **`tests/*`** — eval-only agents that are not usable examples: `tests/eve-act-as` covers the eve extension's `actAs`, `approvers`, `audit` and `githubChannel`'s `respondTo`, and `tests/eve-auto` covers `preset: 'auto'` and `requireApproval: 'auto'`, both with stubbed Vercel Connect and GitHub.
- **`apps/chat`** — Nuxt 4 demo app with NuxtHub (SQLite + blob), GitHub OAuth, dual-mode agent (standard `ToolLoopAgent` vs durable `WorkflowAgent`).
- **`apps/docs`** — Nuxt 4 docs site built on Docus. Also publishes a consumer-facing Agent Skill at `apps/docs/skills/github-tools-agents/` (served via `/.well-known/skills/`, see `apps/docs/content/docs/1.start/4.agent-skills.md`).

Expand Down Expand Up @@ -110,6 +110,8 @@ Ten presets (`code-review`, `issue-triage`, `repo-explorer`, `ci-ops`, `security

`extension/tools/github.ts` default-exports `defineDynamic(async (ctx) => tools)`. eve runs it before every model call and rebuilds every callback and schema from what it returns, so ordinary closures and Zod schemas are fine; there are no durable descriptors to preserve. Re-read config through `buildSessionOptions()` or `extension.config`. Work that must stay fixed across model calls or processes (the `preset: 'auto'` routing) goes in `ctx.memo(key, fn)` with a JSON result. `examples/eve-smoke` runs the built extension under `eve eval` in CI.

`extension/hooks/audit.ts` sends the `settled` audit records when `audit` is set. eve runs an extension's hooks once per mount, for every call of the agent, including other mounts' and the agent's own tools, so the hook finds its mount's writes in session state (`extension/lib/audit.ts`), which belongs to the mount. A hook's `ctx.view` holds the latest turn only: anything a later turn needs goes in state. The `started` record is sent from `beforeWrite`, which the SDK awaits outside its `"use step"` function.

`channels/index.ts` (`@github-tools/eve-extension/channels`, the `githubChannel` wrapper with `respondTo`) is not part of the mounted extension: `tsc -p tsconfig.channels.json` compiles it to `channels/dist`. Keep it out of `extension/` and `dist/`. eve binds every module under `dist/extension` to a mount, so an agent with two mounts of the package can't import one from a channel file, and building an agent that uses the workspace extension rebuilds `dist/` and deletes anything else in it. A scheduled canary (`.github/workflows/eve-canary.yml`) builds `examples/eve` and runs that smoke eval against a coherent `eve@latest` / `ai@latest` pair.

## Chat App Architecture (`apps/chat`)
Expand Down
1 change: 1 addition & 0 deletions apps/docs/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export default defineAppConfig({
{ label: 'Context', to: '/context' },
{ label: 'Commits', to: '/commits' },
{ label: 'Errors', to: '/errors' },
{ label: 'Observability', to: '/observability' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/app/utils/docs-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const docsSidebar: DocsSidebarGroup[] = [
{ path: '/auth' },
{ path: '/context' },
{ path: '/commits' },
{ path: '/errors' }
{ path: '/errors' },
{ path: '/observability' }
]
},
{
Expand Down
6 changes: 6 additions & 0 deletions apps/docs/content/docs/3.core/7.errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ Every code starts with `github_tools.`, as in `github_tools.NOT_FOUND`.
| `GUARDRAIL_BLOCKED` | 403 | The call targets a repository or branch outside [`guardrails`](/approval#guardrails), or its input contains what looks like a credential. Checked before any request reaches GitHub, whoever approved the call. The message gives the reason |
| `CALLER_FORBIDDEN` | 403 | On the eve extension with [`actAs: 'caller'`](/integrations/eve#per-user-tokens), someone who commented on GitHub asked for a call their role on the target repository doesn't allow. Checked before the call reaches GitHub. The message names the role they have and the one the call needs |

### Audit

| Code | Status | When |
| --- | --- | --- |
| `AUDIT_UNAVAILABLE` | 503 | On the eve extension with [`audit`](/observability), the function rejected the record of a write that was about to be sent. The write isn't sent, and the `fix` tells the model not to retry. Reads keep working |

### GitHub API

| Code | Status | When |
Expand Down
Loading
Loading