@trustloopguard/sdk 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +74 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @trustloopguard/sdk
2
+
3
+ TypeScript SDK for [TrustLoopGuard](https://trustloopguard.dev) — real-time guardrails for AI agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @trustloopguard/sdk
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { guard } from '@trustloopguard/sdk';
15
+
16
+ const guardrail = guard({ agentId: 'my-agent', apiKey: process.env.TLG_API_KEY });
17
+
18
+ const reply = await guardrail({ input: userMessage, draft: agentDraft });
19
+ await sendToUser(reply);
20
+ ```
21
+
22
+ ## Guard modes
23
+
24
+ | Mode | Behavior |
25
+ |------|----------|
26
+ | `strict` | Blocked or rewritten output is always rejected |
27
+ | `rewrite` | Uses `safeOutput` when available, blocks otherwise |
28
+ | `rewrite_or_regenerate` | Uses `safeOutput`, or triggers a regeneration loop |
29
+
30
+ ```ts
31
+ import { guard, GuardMode } from '@trustloopguard/sdk';
32
+
33
+ const guardrail = guard({
34
+ agentId: 'my-agent',
35
+ apiKey: process.env.TLG_API_KEY,
36
+ mode: GuardMode.Rewrite,
37
+ });
38
+ ```
39
+
40
+ ## Custom handlers
41
+
42
+ ```ts
43
+ import { guard } from '@trustloopguard/sdk';
44
+
45
+ const guardrail = guard({
46
+ agentId: 'my-agent',
47
+ apiKey: process.env.TLG_API_KEY,
48
+ onBlock: () => "I can't help with that.",
49
+ onEscalate: () => { humanQueue.push(draft); return 'A human will follow up.'; },
50
+ });
51
+ ```
52
+
53
+ ## Low-level client
54
+
55
+ ```ts
56
+ import { Client } from '@trustloopguard/sdk';
57
+
58
+ const client = new Client({ apiKey: process.env.TLG_API_KEY });
59
+
60
+ const decision = await client.check({
61
+ agent_id: 'my-agent',
62
+ input: userMessage,
63
+ draft: agentDraft,
64
+ });
65
+ ```
66
+
67
+ ## Requirements
68
+
69
+ - Node.js 18+
70
+ - TypeScript 5+ (optional but recommended)
71
+
72
+ ## License
73
+
74
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustloopguard/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "TypeScript SDK for TrustLoopGuard. Types are generated from Rust via tl-codegen; do not hand-edit src/generated.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",