prooflane-sdk 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # prooflane-sdk
2
+
3
+ **The evidence gateway for AI agents that move money — built on the [CooL SDK](https://github.com/Northwind-Cipher/cool-sdk).**
4
+
5
+ Wrap any consequential agent tool. Every call is checked against policy and sealed into an independently verifiable CooL receipt **before** the tool runs; the result is sealed under the same execution id. Blocked calls throw with a signed refusal. No receipt, no action.
6
+
7
+ ```bash
8
+ npm i prooflane-sdk
9
+ ```
10
+
11
+ ```ts
12
+ import { ProofLane, ProofLaneBlockedError } from "prooflane-sdk";
13
+
14
+ const proof = new ProofLane({
15
+ apiKey: process.env.PROOFLANE_API_KEY!, // create a workspace at https://prooflane-mvp.vercel.app/console
16
+ agent: "payments-agent",
17
+ onReceipt: (receipt, vault) => db.save(receipt.record.record_id, vault), // keep plaintext for disclosures
18
+ });
19
+
20
+ const releasePayment = proof.guard("payment.release", bank.releasePayment, (args) => ({
21
+ id: args.approval_id,
22
+ approvers: args.approvers,
23
+ }));
24
+
25
+ try {
26
+ await releasePayment({ amount: 48200, currency: "USD", beneficiary: "Acme Ltd", approval_id: "APR-1", approvers: ["alice@acme.example"] });
27
+ } catch (e) {
28
+ if (e instanceof ProofLaneBlockedError) console.log(e.decision.rule, e.receipt); // e.g. PAY-003, signed refusal
29
+ }
30
+ ```
31
+
32
+ Give `releasePayment` to your OpenAI / Anthropic / LangChain / MCP agent as its tool — it's just an async function.
33
+
34
+ - `baseUrl` defaults to `https://prooflane-mvp.vercel.app`; pass your own deployment's URL to change it.
35
+ - `proof.share(label)` creates an auditor evidence-room link; `approveDisclosure` / `denyDisclosure` answer field requests.
36
+
37
+ Docs, architecture, and the live demo: https://github.com/charansaiponnada/prooflane-mvp
38
+
39
+ MIT licensed.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ProofLane SDK — put an evidence gateway in front of any consequential agent tool.
3
+ *
4
+ * const proof = new ProofLane({ apiKey, agent: "payments-agent" });
5
+ * const releasePayment = proof.guard("payment.release", rawReleasePayment, (args) => ({
6
+ * id: args.approvalId,
7
+ * approvers: args.approvers,
8
+ * }));
9
+ * await releasePayment({ amount: 48200, beneficiary: "…", approvalId: "APR-1", approvers: ["a", "b"] });
10
+ *
11
+ * Every call is authorized against policy and sealed into a CooL receipt BEFORE
12
+ * the tool runs, then its result is sealed under the same execution id. If
13
+ * ProofLane cannot seal the authorization, the tool never runs.
14
+ *
15
+ * Framework-free: works with OpenAI / Anthropic tool calls, LangChain tools, MCP
16
+ * handlers — anything that is an async function.
17
+ */
18
+ import type { ReceiptV2 } from "cool-nwc";
19
+ /** Plaintext the caller keeps. ProofLane receipts only carry its commitments. */
20
+ export type Vault = {
21
+ input?: string;
22
+ output?: string;
23
+ state?: string;
24
+ };
25
+ export type ProofLaneOptions = {
26
+ apiKey: string;
27
+ /** Name of the agent recorded in every receipt. */
28
+ agent: string;
29
+ baseUrl?: string;
30
+ software?: {
31
+ name: string;
32
+ version: string;
33
+ };
34
+ /** Called with each sealed receipt and the plaintext it commits to — store the vault to answer disclosure requests later. */
35
+ onReceipt?: (receipt: ReceiptV2, vault: Vault) => void;
36
+ };
37
+ export type PolicyDecision = {
38
+ decision: string;
39
+ rule: string | null;
40
+ policy_hash: string;
41
+ };
42
+ export declare class ProofLaneBlockedError extends Error {
43
+ readonly decision: PolicyDecision;
44
+ readonly receipt: ReceiptV2;
45
+ constructor(decision: PolicyDecision, receipt: ReceiptV2);
46
+ }
47
+ export declare class ProofLane {
48
+ private readonly options;
49
+ constructor(options: ProofLaneOptions);
50
+ request<T>(path: string, body?: unknown): Promise<T>;
51
+ /** Wrap a tool. No receipt, no action. */
52
+ guard<A extends {
53
+ amount: number;
54
+ }, R>(action: "payment.release", tool: (args: A) => Promise<R>, approval: (args: A) => {
55
+ id: string;
56
+ approvers: string[];
57
+ }): (args: A) => Promise<R>;
58
+ /** Open one committed field for an auditor. The server checks it against the sealed commitment. */
59
+ approveDisclosure(requestId: string, value: string): Promise<unknown>;
60
+ denyDisclosure(requestId: string): Promise<unknown>;
61
+ /** Create an evidence-room link for an auditor. */
62
+ share(label: string, recordIds?: string[]): Promise<{
63
+ share: {
64
+ token: string;
65
+ };
66
+ }>;
67
+ }
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ export class ProofLaneBlockedError extends Error {
2
+ decision;
3
+ receipt;
4
+ constructor(decision, receipt) {
5
+ super(`ProofLane blocked the action: ${decision.decision} (${decision.rule ?? "no rule matched"})`);
6
+ this.decision = decision;
7
+ this.receipt = receipt;
8
+ this.name = "ProofLaneBlockedError";
9
+ }
10
+ }
11
+ export class ProofLane {
12
+ options;
13
+ constructor(options) {
14
+ this.options = options;
15
+ }
16
+ async request(path, body) {
17
+ const res = await fetch(`${this.options.baseUrl ?? "https://prooflane-mvp.vercel.app"}${path}`, {
18
+ method: body === undefined ? "GET" : "POST",
19
+ headers: {
20
+ authorization: `Bearer ${this.options.apiKey}`,
21
+ "content-type": "application/json",
22
+ },
23
+ body: body === undefined ? undefined : JSON.stringify(body),
24
+ });
25
+ const data = await res.json();
26
+ if (!res.ok)
27
+ throw new Error(`ProofLane ${res.status}: ${data.error}`);
28
+ return data;
29
+ }
30
+ /** Wrap a tool. No receipt, no action. */
31
+ guard(action, tool, approval) {
32
+ return async (args) => {
33
+ const input = JSON.stringify(args);
34
+ const appr = approval(args);
35
+ const auth = await this.request("/api/v1/actions/authorize", {
36
+ action,
37
+ agent: this.options.agent,
38
+ software: this.options.software,
39
+ input,
40
+ approval: appr,
41
+ });
42
+ this.options.onReceipt?.(auth.receipt, { input, state: appr.id });
43
+ if (!auth.allowed)
44
+ throw new ProofLaneBlockedError(auth.decision, auth.receipt);
45
+ const finish = async (output, status) => {
46
+ const done = await this.request(`/api/v1/actions/${auth.executionId}/complete`, { output, status });
47
+ this.options.onReceipt?.(done.receipt, { output });
48
+ };
49
+ let result;
50
+ try {
51
+ result = await tool(args);
52
+ }
53
+ catch (error) {
54
+ await finish(JSON.stringify({ error: String(error) }), "failed");
55
+ throw error;
56
+ }
57
+ await finish(JSON.stringify(result ?? null), "succeeded");
58
+ return result;
59
+ };
60
+ }
61
+ /** Open one committed field for an auditor. The server checks it against the sealed commitment. */
62
+ approveDisclosure(requestId, value) {
63
+ return this.request(`/api/v1/disclosure-requests/${requestId}`, { decision: "approve", value });
64
+ }
65
+ denyDisclosure(requestId) {
66
+ return this.request(`/api/v1/disclosure-requests/${requestId}`, { decision: "deny" });
67
+ }
68
+ /** Create an evidence-room link for an auditor. */
69
+ share(label, recordIds) {
70
+ return this.request("/api/v1/shares", { label, record_ids: recordIds });
71
+ }
72
+ }
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "prooflane-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Evidence gateway for AI agents: policy-check and seal every consequential tool call into a verifiable CooL receipt.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
10
+ "files": ["dist"],
11
+ "engines": { "node": ">=20" },
12
+ "repository": { "type": "git", "url": "git+https://github.com/charansaiponnada/prooflane-mvp.git", "directory": "packages/sdk" },
13
+ "homepage": "https://prooflane-mvp.vercel.app",
14
+ "keywords": ["ai-agents", "audit", "evidence", "policy", "receipts", "cool-nwc"],
15
+ "scripts": { "build": "tsc", "prepublishOnly": "npm run build" },
16
+ "dependencies": { "cool-nwc": "^3.0.0" },
17
+ "devDependencies": { "typescript": "^5" }
18
+ }