A TypeScript test harness for Pact. Simulates multi-agent interaction with file-based messaging and storage.
npm install
npm run setupThen open three terminals:
# Terminal 1
npm run client
# Terminal 2
npm run provider
# Terminal 3
npm run resolver┌─────────┐ file msgs ┌──────────┐
│ Client │◄────────────────►│ Provider │
│ (CLI) │ │ (CLI) │
└────┬─────┘ └─────┬─────┘
│ │
│ ┌──────────┐ │
└───────►│ Resolver │◄──────────┘
│ (CLI) │
└─────┬─────┘
│
┌─────▼─────┐
│ Shared │
│ Storage │
│ (pacts + │
│ evidence) │
└────────────┘
pact-test/
├── package.json
├── tsconfig.json
├── src/
│ ├── identity/
│ │ └── wallet.ts # Keypair generation, signing
│ ├── messaging/
│ │ └── inbox.ts # File-based message send/receive
│ ├── storage/
│ │ └── store.ts # Save/load pacts and evidence
│ ├── pact/
│ │ ├── types.ts # Pact TypeScript types
│ │ └── create.ts # Create, sign, verify pacts
│ ├── resolver/
│ │ └── resolve.ts # Resolver logic and prompt generation
│ ├── setup.ts # Setup script (creates wallets + dirs)
│ └── cli.ts # Interactive CLI for agents
├── agents/ # Created by setup script
│ ├── client/
│ │ ├── wallet.json
│ │ └── inbox/
│ ├── provider/
│ │ ├── wallet.json
│ │ └── inbox/
│ └── resolver/
│ ├── wallet.json
│ └── inbox/
└── shared/ # Created by setup script
├── pacts/
└── evidence/
Ethereum wallet-based identity using ethers.js v6. Generates keypairs, signs messages, and verifies signatures.
File-based message passing between agents. Messages are JSON files stored in each agent's inbox directory with timestamp-based filenames.
Filesystem-based storage for pacts and evidence. Pacts are stored as JSON files; evidence as arbitrary files with SHA256 hashes.
Pact lifecycle management: creation, signing, state transitions. A pact moves through states: proposed -> active -> disputed/resolved.
Resolution logic including a simple automated resolver for testing and a prompt generator for AI-based resolution.
npm run client
> [3] Create new pact
> Provider address: 0x... (from provider's wallet)
> Description: Design a logo
> Acceptance criteria: Delivers 3 concepts, Includes source files
> Escrow amount: 500
Pact created: pact_abc123
npm run provider
> [2] View messages
(sees draft_pact notification with pact ID)
> [3] Sign a pact
> Pact ID: pact_abc123
Signed!
npm run client
> [4] Sign a pact
> Pact ID: pact_abc123
Pact is now ACTIVE
npm run provider
> [4] Submit evidence
> Pact ID: pact_abc123
> Filename: deliverable.md
> Content: Here are the 3 logo concepts with source files...
> END
Evidence saved
npm run resolver
> [3] Resolve a pact
> Pact ID: pact_abc123
Outcome: fulfilled
> Apply this resolution? y
Pact resolved!
- proposed - Created but not yet signed by all parties
- active - All parties have signed
- disputed - A party has raised a dispute
- resolved - Resolver has issued a resolution
| Option | Client | Provider | Resolver |
|---|---|---|---|
| 1 | View my pacts | View my pacts | View my pacts |
| 2 | View messages | View messages | View messages |
| 3 | Create new pact | Sign a pact | Resolve a pact |
| 4 | Sign a pact | Submit evidence | Generate resolver prompt |
| 5 | View pact details | View pact details | View pact details |
| 6 | Send message | Send message | Send message |
| q | Quit | Quit | Quit |
- XMTP Integration - Replace file-based messaging with XMTP for real p2p messaging
- IPFS Storage - Store pacts and evidence on IPFS instead of local filesystem
- Claude Skills - Use Claude as the AI resolver via skills/tools
- On-chain Settlement - Smart contract for escrow and resolution enforcement