Skip to main content
Glama
Séance

Séance

by aqeel-spec
README.md
# Séance

**No AI agent acts without a signed pact.**

A platform engineer who lets AI agents deploy, email customers or drop tables has one safeguard today: a yes/no prompt. That prompt isn't tied to the arguments the agent finally runs, and nothing tamper-proof records who approved what. Séance fixes that. Humans sign the SHA-256 hash of the exact action. The executor can redeem that signature once, with an identical action. If any value changes, the pact breaks.

> **Category: Costume Contest.** The séance theme maps to real state: pacts are approvals, omens are risk levels, a *broken* pact is an argument mismatch, and the *Book of the Dead* is the hash-chained audit ledger.

## Who pays and why

Teams that run agents with production access (platform, SRE, fintech and support ops) need provable human oversight for SOC 2 / ISO 27001 change-management controls and for EU AI Act human-oversight duties. Séance would be sold per seat for reviewers, with a hosted ledger.

## Run it (Node.js 20+, no install step)

```
npm start                 # http://localhost:6660, demo mode
```

Open the page and click **Summon demo spirits**. Then try these:

1. Sign the `deploy_service` pact (one reviewer, *Howl*).
2. Open **Sealed pacts**, click **Test the binding** and change `replicas` from 3 to 30. The pact breaks and the UI shows `args.replicas: 3 → 30`.
3. Have two different names sign `drop_table` (*Banshee*, critical).
4. Try signing as `kiro-agent`. You get "The requesting agent cannot decide its own pact".
5. Open **Book of the Dead** and click **Verify the chain**.

Guarded script: `npm run example:deploy`, then approve it in the browser. Add `--tamper` to see the pact break: `node examples/guarded-deploy.js 1.0 --tamper`.

## Use it from Kiro (MCP)

Copy `docs/mcp.example.json` into `.kiro/settings/mcp.json`, or merge it into your user-level config. Then start the server. Kiro gets these tools: `seance_request_pact`, `seance_wait_for_pact`, `seance_redeem_pact`, `seance_pact_status` and `seance_verify_ledger`.

## Use it from code

```js
import { SeanceClient } from './src/client.js';
const seance = new SeanceClient({ agentKey: process.env.SEANCE_AGENT_KEY, agentName: 'release-script' });
await seance.guard(
  { tool: 'deploy_service', target: 'checkout-web', environment: 'production',
    args: { version: '2026.12.03', replicas: 3 }, justification: 'Ship the fix' },
  async (args) => deploy(args)  // runs only after approval + successful redemption
);
```

## Configuration

| Variable | Default | Meaning |
| --- | --- | --- |
| `PORT` | 6660 | HTTP port |
| `SEANCE_AGENT_KEYS` | unset (demo) | `name:key,name:key`. The key fixes the agent's identity |
| `SEANCE_REVIEWER_KEYS` | unset (demo) | `alice:key,bob:key`. The key fixes the reviewer's identity |
| `HOST` | `127.0.0.1` in demo mode, `0.0.0.0` with keys | Bind address |
| `SEANCE_DATA_FILE` | `data/seance.json` | State and ledger |
| `SEANCE_POLICY_FILE` | `config/policy.json` | Risk rules |
| `SEANCE_MAX_PACTS` | 1000 | Maximum open pacts |
| `SEANCE_WRITE_LIMIT` | 60 | Writes per IP per minute |

If neither key variable is set, Séance runs in demo mode on loopback with shared, published keys, and it says so in the UI, the startup log and `/api/config`. Setting only one of the two variables, short keys (under 16 characters), or a key reused across identities stops the server at startup. So does a tampered ledger.

## Tests

```
npm test        # 68 tests, node:test, no dependencies
```

## Docs

[API](docs/API.md) · [MCP](docs/MCP.md) · [Policy](docs/POLICY.md) · [Deploy](docs/DEPLOY.md) · [Code review and fixes](docs/REVIEW.md)

## Repository map

- `.kiro/specs/seance-approval-gate/` contains the Kiro spec (requirements, design, tasks).
- `openspec/` holds the OpenSpec project file and the behavioural scenarios for each capability.
- `.kiro/steering/` holds the product, tech, security and UI steering files (UI steering is loaded by fileMatch).
- `.kiro/hooks/` has three hooks: syntax check on save, ledger integrity on stop, and a pact reminder before risky shell commands.
- `src/core/` is the domain logic. `src/server.js` is the API and UI server, `src/mcp.js` the MCP bridge, `src/client.js` the SDK.
- `docs/KIRO_WRITEUP.md` is the submission write-up draft.

## Limits (v1)

Séance authorises actions but does not run them. The executor has to call `redeem` (the SDK's `guard` does this for you). State is kept in a single JSON file run by a single process. Identity comes from named keys; there is no SSO yet.