@cybertechsoft/loopgrid
v0.1.1
Published
Control plane for AI decision reliability. Capture, replay, and learn from AI decisions.
Maintainers
Readme
@cybertechsoft/loopgrid
The control plane for AI decision reliability.
A system of record for AI decisions. Capture every decision immutably, replay failures with controlled overrides, and build ground truth from human corrections.
Installation
npm install @cybertechsoft/loopgridQuick Start
const { LoopGrid } = require('@cybertechsoft/loopgrid');
// or: import { LoopGrid } from '@cybertechsoft/loopgrid';
const grid = new LoopGrid({ serviceName: 'support-agent' });
// Record an AI decision
const decision = await grid.recordDecision({
decisionType: 'customer_support_reply',
input: { message: 'I was charged twice' },
model: { provider: 'openai', name: 'gpt-4' },
output: { response: 'Your account looks fine.' }
});
// Mark as incorrect
await grid.markIncorrect(decision.decision_id, 'Missed billing issue');
// Replay with different prompt
const replay = await grid.createReplay({
decisionId: decision.decision_id,
overrides: { prompt: { template: 'support_v2' } }
});
// Attach human correction
await grid.attachCorrection({
decisionId: decision.decision_id,
correction: { response: 'Refund initiated.' },
correctedBy: 'agent_42'
});API Reference
Constructor
const grid = new LoopGrid({
baseUrl: 'http://localhost:8000', // LoopGrid server URL
serviceName: 'my-service', // Your service name
timeout: 30000 // Request timeout (ms)
});Decision Methods
| Method | Description |
|--------|-------------|
| recordDecision(params) | Record an AI decision to the ledger |
| getDecision(decisionId) | Get a decision by ID |
| listDecisions(options) | List decisions with filters |
| markIncorrect(decisionId, reason) | Mark a decision as incorrect |
| attachCorrection(params) | Attach human correction |
Replay Methods
| Method | Description |
|--------|-------------|
| createReplay(params) | Create a replay with overrides |
| getReplay(replayId) | Get a replay by ID |
| compare(decisionId, replayId) | Compare decision vs replay |
Utility Methods
| Method | Description |
|--------|-------------|
| health() | Check server health |
| info() | Get server info |
TypeScript Support
Full TypeScript definitions are included:
import { LoopGrid, Decision, Replay } from '@cybertechsoft/loopgrid';
const grid = new LoopGrid({ serviceName: 'my-service' });
const decision: Decision = await grid.recordDecision({
decisionType: 'support_reply',
input: { message: 'Help me' },
model: { provider: 'openai', name: 'gpt-4' },
output: { response: 'Sure!' }
});Server Setup
The SDK requires a LoopGrid server. See the main repository for server setup instructions.
# Quick start with Python server
git clone https://github.com/cybertechsoft/loopgrid.git
cd loopgrid
pip install -r requirements.txt
python run_server.pyLicense
Apache 2.0 — see LICENSE
