@clawbureau/clawsig-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Clawbureau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # @clawbureau/clawsig-sdk
2
+
3
+ Lightweight SDK for emitting **verifiable proof bundles** from any Node.js agent. Five lines to go from raw LLM calls to a cryptographically signed, offline-verifiable evidence pack.
4
+
5
+ ## Quickstart
6
+
7
+ ```ts
8
+ import { createClawsigRun } from '@clawbureau/clawsig-sdk';
9
+
10
+ const run = await createClawsigRun({
11
+ agentDid: 'did:key:z6Mk...', // Your agent's DID
12
+ proxyUrl: 'https://proxy.example.com',
13
+ keyFile: '.clawsig-key.json', // Ed25519 JWK
14
+ });
15
+
16
+ // Record an LLM call
17
+ const response = await run.callLLM({
18
+ model: 'claude-sonnet-4-20250514',
19
+ messages: [{ role: 'user', content: 'Explain proof bundles' }],
20
+ });
21
+
22
+ // Finalize → signed proof bundle + URM
23
+ const bundle = await run.finalize();
24
+ console.log(bundle.path); // artifacts/poh/.../run_xxx-bundle.json
25
+ ```
26
+
27
+ ## What it records
28
+
29
+ | Method | Receipt type | Coverage level |
30
+ |--------|-------------|----------------|
31
+ | `callLLM()` | Gateway receipt | M (model) |
32
+ | `recordToolCall()` | Tool receipt | MT (model + tools) |
33
+ | `recordSideEffect()` | Side-effect receipt | MTS (+ side-effects) |
34
+ | `recordHumanApproval()` | Human approval receipt | MTS (+ approvals) |
35
+ | `finalize()` | Proof bundle + URM | — |
36
+
37
+ ## API
38
+
39
+ ### `createClawsigRun(options)`
40
+
41
+ Creates a new proof run. Options:
42
+
43
+ ```ts
44
+ interface ClawsigRunOptions {
45
+ agentDid: string; // Agent DID (did:key:...)
46
+ proxyUrl: string; // Clawsig proxy URL
47
+ keyFile?: string; // Path to Ed25519 JWK key file
48
+ outputDir?: string; // Output directory (default: artifacts/poh/<branch>/)
49
+ branchName?: string; // Git branch name for output path
50
+ }
51
+ ```
52
+
53
+ ### `run.callLLM(params)`
54
+
55
+ Proxies an LLM call through the gateway and records a gateway receipt.
56
+
57
+ ```ts
58
+ const response = await run.callLLM({
59
+ model: 'claude-sonnet-4-20250514',
60
+ messages: [{ role: 'user', content: '...' }],
61
+ // All standard OpenAI-compatible params supported
62
+ });
63
+ ```
64
+
65
+ ### `run.recordToolCall(params)`
66
+
67
+ Records a tool invocation as a hash-only receipt (arguments and results are digested, not stored).
68
+
69
+ ```ts
70
+ run.recordToolCall({
71
+ tool_name: 'file_read',
72
+ args_digest: 'sha256:abc123...', // SHA-256 of JSON-serialized args
73
+ result_digest: 'sha256:def456...', // SHA-256 of JSON-serialized result
74
+ duration_ms: 42,
75
+ });
76
+ ```
77
+
78
+ ### `run.recordSideEffect(params)`
79
+
80
+ Records a side-effect (network call, file write, external API write).
81
+
82
+ ```ts
83
+ run.recordSideEffect({
84
+ effect_class: 'network_egress', // or 'filesystem_write', 'external_api_write'
85
+ target_digest: 'sha256:...', // Digest of target URL/path
86
+ request_digest: 'sha256:...',
87
+ response_digest: 'sha256:...',
88
+ vendor_id: 'api.github.com',
89
+ bytes_written: 1024,
90
+ });
91
+ ```
92
+
93
+ ### `run.recordHumanApproval(params)`
94
+
95
+ Records a human approval decision that gates capability minting.
96
+
97
+ ```ts
98
+ run.recordHumanApproval({
99
+ approval_type: 'explicit_approve', // or 'explicit_deny', 'auto_approve', 'timeout_deny'
100
+ scope_hash_b64u: '...', // Scope being approved
101
+ plan_hash_b64u: '...', // Hash of the proposed plan
102
+ approver_subject: 'user@example.com',
103
+ capability_minted: true,
104
+ });
105
+ ```
106
+
107
+ ### `run.finalize()`
108
+
109
+ Finalizes the run, signs the proof bundle, and writes all artifacts.
110
+
111
+ Returns:
112
+ ```ts
113
+ interface FinalizeResult {
114
+ path: string; // Path to proof bundle JSON
115
+ urmPath: string; // Path to URM (Universal Receipt Manifest)
116
+ trustPulsePath: string; // Path to trust pulse
117
+ runId: string; // Run UUID
118
+ eventCount: number; // Number of events in the chain
119
+ receiptCount: number; // Number of gateway receipts
120
+ }
121
+ ```
122
+
123
+ ## Verification
124
+
125
+ Proof bundles produced by this SDK can be verified offline with:
126
+
127
+ ```bash
128
+ npx @clawbureau/clawverify-cli verify proof-bundle --input run_xxx-bundle.json
129
+ ```
130
+
131
+ Or programmatically:
132
+
133
+ ```ts
134
+ import { verifyProofBundle } from '@clawbureau/clawverify-core';
135
+ const result = verifyProofBundle(bundleJson, config);
136
+ // result.status === 'PASS' | 'FAIL'
137
+ ```
138
+
139
+ ## Coverage levels
140
+
141
+ The Clawsig Protocol defines three coverage levels:
142
+
143
+ - **M** (Model): Gateway receipts prove which model was called
144
+ - **MT** (Model + Tools): Tool receipts prove which tools were invoked
145
+ - **MTS** (Model + Tools + Side-effects): Side-effect and human approval receipts prove what external effects occurred and who approved them
146
+
147
+ ## License
148
+
149
+ MIT
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Cryptographic utilities for the clawsig SDK.
3
+ *
4
+ * Standalone copy so this package typechecks independently.
5
+ * Uses the Web Crypto API (Node 20+, Deno, Workers).
6
+ */
7
+ import type { Ed25519KeyPair } from './types.js';
8
+ export declare function base64UrlEncode(bytes: Uint8Array): string;
9
+ export declare function base64UrlDecode(str: string): Uint8Array;
10
+ export declare function hexToBytes(hex: string): Uint8Array;
11
+ /**
12
+ * Normalize a SHA-256 hash string into base64url (no padding).
13
+ * Converts clawproxy's hex SHA-256 output (64 chars) when needed.
14
+ */
15
+ export declare function normalizeSha256HashB64u(hash: string): string;
16
+ export declare function base58Encode(bytes: Uint8Array): string;
17
+ export declare function sha256B64u(data: Uint8Array): Promise<string>;
18
+ export declare function hashJsonB64u(value: unknown): Promise<string>;
19
+ export declare function generateKeyPair(): Promise<Ed25519KeyPair>;
20
+ export declare function exportPublicKeyRaw(publicKey: CryptoKey): Promise<Uint8Array>;
21
+ export declare function didFromPublicKey(publicKey: CryptoKey): Promise<string>;
22
+ export declare function signEd25519(privateKey: CryptoKey, message: Uint8Array): Promise<string>;
23
+ export declare function randomUUID(): string;
24
+ export declare function exportKeyPairJWK(keyPair: Ed25519KeyPair): Promise<{
25
+ publicKey: JsonWebKey;
26
+ privateKey: JsonWebKey;
27
+ }>;
28
+ export declare function importKeyPairJWK(jwk: {
29
+ publicKey: JsonWebKey;
30
+ privateKey: JsonWebKey;
31
+ }): Promise<Ed25519KeyPair>;
32
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CASvD;AAMD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAgBlD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5D;AASD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CA2BtD;AAMD,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlE;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAIlE;AAMD,wBAAsB,eAAe,IAAI,OAAO,CAAC,cAAc,CAAC,CAG/D;AAED,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAGlF;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5E;AAED,wBAAsB,WAAW,CAC/B,UAAU,EAAE,SAAS,EACrB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAMD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAM5D;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE;IAC1C,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC,cAAc,CAAC,CAM1B"}
package/dist/crypto.js ADDED
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Cryptographic utilities for the clawsig SDK.
3
+ *
4
+ * Standalone copy so this package typechecks independently.
5
+ * Uses the Web Crypto API (Node 20+, Deno, Workers).
6
+ */
7
+ // ---------------------------------------------------------------------------
8
+ // Base64url
9
+ // ---------------------------------------------------------------------------
10
+ export function base64UrlEncode(bytes) {
11
+ const binary = String.fromCharCode(...bytes);
12
+ const base64 = btoa(binary);
13
+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
14
+ }
15
+ export function base64UrlDecode(str) {
16
+ const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
17
+ const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
18
+ const binary = atob(padded);
19
+ const bytes = new Uint8Array(binary.length);
20
+ for (let i = 0; i < binary.length; i++) {
21
+ bytes[i] = binary.charCodeAt(i);
22
+ }
23
+ return bytes;
24
+ }
25
+ // ---------------------------------------------------------------------------
26
+ // Hex → bytes / base64url (for bridging clawproxy hex hashes)
27
+ // ---------------------------------------------------------------------------
28
+ export function hexToBytes(hex) {
29
+ const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
30
+ if (normalized.length % 2 !== 0) {
31
+ throw new Error(`Invalid hex string length: ${normalized.length}`);
32
+ }
33
+ const bytes = new Uint8Array(normalized.length / 2);
34
+ for (let i = 0; i < bytes.length; i++) {
35
+ const byte = normalized.slice(i * 2, i * 2 + 2);
36
+ const value = Number.parseInt(byte, 16);
37
+ if (Number.isNaN(value)) {
38
+ throw new Error(`Invalid hex byte: ${byte}`);
39
+ }
40
+ bytes[i] = value;
41
+ }
42
+ return bytes;
43
+ }
44
+ /**
45
+ * Normalize a SHA-256 hash string into base64url (no padding).
46
+ * Converts clawproxy's hex SHA-256 output (64 chars) when needed.
47
+ */
48
+ export function normalizeSha256HashB64u(hash) {
49
+ const normalized = hash.startsWith('0x') ? hash.slice(2) : hash;
50
+ if (/^[a-f0-9]{64}$/i.test(normalized)) {
51
+ return base64UrlEncode(hexToBytes(normalized));
52
+ }
53
+ return hash;
54
+ }
55
+ // ---------------------------------------------------------------------------
56
+ // Base58btc (Bitcoin alphabet)
57
+ // ---------------------------------------------------------------------------
58
+ const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
59
+ export function base58Encode(bytes) {
60
+ let leadingZeros = 0;
61
+ for (const b of bytes) {
62
+ if (b !== 0)
63
+ break;
64
+ leadingZeros++;
65
+ }
66
+ const digits = [0];
67
+ for (const byte of bytes) {
68
+ let carry = byte;
69
+ for (let i = 0; i < digits.length; i++) {
70
+ carry += digits[i] << 8;
71
+ digits[i] = carry % 58;
72
+ carry = (carry / 58) | 0;
73
+ }
74
+ while (carry) {
75
+ digits.push(carry % 58);
76
+ carry = (carry / 58) | 0;
77
+ }
78
+ }
79
+ let result = '';
80
+ for (let i = 0; i < leadingZeros; i++) {
81
+ result += '1';
82
+ }
83
+ for (let i = digits.length - 1; i >= 0; i--) {
84
+ result += BASE58_ALPHABET[digits[i]];
85
+ }
86
+ return result;
87
+ }
88
+ // ---------------------------------------------------------------------------
89
+ // SHA-256 hashing
90
+ // ---------------------------------------------------------------------------
91
+ export async function sha256B64u(data) {
92
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
93
+ return base64UrlEncode(new Uint8Array(hashBuffer));
94
+ }
95
+ export async function hashJsonB64u(value) {
96
+ const encoder = new TextEncoder();
97
+ const data = encoder.encode(JSON.stringify(value));
98
+ return sha256B64u(data);
99
+ }
100
+ // ---------------------------------------------------------------------------
101
+ // Ed25519 key management
102
+ // ---------------------------------------------------------------------------
103
+ export async function generateKeyPair() {
104
+ const kp = await crypto.subtle.generateKey('Ed25519', true, ['sign', 'verify']);
105
+ return { publicKey: kp.publicKey, privateKey: kp.privateKey };
106
+ }
107
+ export async function exportPublicKeyRaw(publicKey) {
108
+ const raw = await crypto.subtle.exportKey('raw', publicKey);
109
+ return new Uint8Array(raw);
110
+ }
111
+ export async function didFromPublicKey(publicKey) {
112
+ const pubBytes = await exportPublicKeyRaw(publicKey);
113
+ const multicodec = new Uint8Array(2 + pubBytes.length);
114
+ multicodec[0] = 0xed;
115
+ multicodec[1] = 0x01;
116
+ multicodec.set(pubBytes, 2);
117
+ return `did:key:z${base58Encode(multicodec)}`;
118
+ }
119
+ export async function signEd25519(privateKey, message) {
120
+ const sigBuffer = await crypto.subtle.sign('Ed25519', privateKey, message);
121
+ return base64UrlEncode(new Uint8Array(sigBuffer));
122
+ }
123
+ export function randomUUID() {
124
+ return crypto.randomUUID();
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // Key import/export (JWK) for file-based key storage
128
+ // ---------------------------------------------------------------------------
129
+ export async function exportKeyPairJWK(keyPair) {
130
+ const [publicKey, privateKey] = await Promise.all([
131
+ crypto.subtle.exportKey('jwk', keyPair.publicKey),
132
+ crypto.subtle.exportKey('jwk', keyPair.privateKey),
133
+ ]);
134
+ return { publicKey, privateKey };
135
+ }
136
+ export async function importKeyPairJWK(jwk) {
137
+ const [publicKey, privateKey] = await Promise.all([
138
+ crypto.subtle.importKey('jwk', jwk.publicKey, 'Ed25519', true, ['verify']),
139
+ crypto.subtle.importKey('jwk', jwk.privateKey, 'Ed25519', true, ['sign']),
140
+ ]);
141
+ return { publicKey, privateKey };
142
+ }
143
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MA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Ae,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAE9E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAuB;IAEvB,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KACnD,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAGtC;IACC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;KAC1E,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @clawbureau/clawsig-sdk
3
+ *
4
+ * Lightweight SDK for emitting verifiable proof bundles from
5
+ * API scripts and automation workloads.
6
+ *
7
+ * Provides:
8
+ * - Hash-linked event chain recording
9
+ * - Proxied LLM calls through clawproxy with receipt collection
10
+ * - URM (Universal Run Manifest) generation
11
+ * - Ed25519-signed proof bundle output
12
+ *
13
+ * Usage:
14
+ * import { createRun, generateKeyPair, didFromPublicKey, hashJsonB64u } from '@clawbureau/clawsig-sdk';
15
+ *
16
+ * const keyPair = await generateKeyPair();
17
+ * const run = await createRun({ proxyBaseUrl: '...', keyPair, harness: { id: 'my-script', version: '1.0' } });
18
+ * await run.recordEvent({ eventType: 'run_start', payload: { task: '...' } });
19
+ * const { response } = await run.callLLM({ provider: 'anthropic', model: 'claude-sonnet-4-5-20250929', body: { ... } });
20
+ * const result = await run.finalize({ inputs: [...], outputs: [...] });
21
+ */
22
+ export { createRun } from './run.js';
23
+ export { generateKeyPair, didFromPublicKey, hashJsonB64u, sha256B64u, exportKeyPairJWK, importKeyPairJWK, } from './crypto.js';
24
+ export type { ClawproofConfig, ClawproofRun, Ed25519KeyPair, HarnessConfig, BindingContext, SDKEventType, RecordEventInput, RecorderEvent, ReceiptArtifact, ClawproxyReceipt, FinalizeOptions, FinalizeResult, ResourceDescriptor, LLMCallParams, LLMCallResult, SignedEnvelope, ProofBundlePayload, URMDocument, EventChainEntry, GatewayReceiptPayload, } from './types.js';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,aAAa,EAEb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @clawbureau/clawsig-sdk
3
+ *
4
+ * Lightweight SDK for emitting verifiable proof bundles from
5
+ * API scripts and automation workloads.
6
+ *
7
+ * Provides:
8
+ * - Hash-linked event chain recording
9
+ * - Proxied LLM calls through clawproxy with receipt collection
10
+ * - URM (Universal Run Manifest) generation
11
+ * - Ed25519-signed proof bundle output
12
+ *
13
+ * Usage:
14
+ * import { createRun, generateKeyPair, didFromPublicKey, hashJsonB64u } from '@clawbureau/clawsig-sdk';
15
+ *
16
+ * const keyPair = await generateKeyPair();
17
+ * const run = await createRun({ proxyBaseUrl: '...', keyPair, harness: { id: 'my-script', version: '1.0' } });
18
+ * await run.recordEvent({ eventType: 'run_start', payload: { task: '...' } });
19
+ * const { response } = await run.callLLM({ provider: 'anthropic', model: 'claude-sonnet-4-5-20250929', body: { ... } });
20
+ * const result = await run.finalize({ inputs: [...], outputs: [...] });
21
+ */
22
+ // Core SDK
23
+ // NOTE: Use explicit `.js` extensions so the built SDK works under plain Node ESM.
24
+ export { createRun } from './run.js';
25
+ // Crypto utilities
26
+ export { generateKeyPair, didFromPublicKey, hashJsonB64u, sha256B64u, exportKeyPairJWK, importKeyPairJWK, } from './crypto.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,WAAW;AACX,mFAAmF;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ClawproofRun — core SDK runtime for recording events and producing
3
+ * signed proof bundles from API scripts.
4
+ *
5
+ * Usage:
6
+ * const run = await createRun(config);
7
+ * await run.recordEvent({ eventType: 'run_start', payload: { task: '...' } });
8
+ * const { response } = await run.callLLM({ provider: 'anthropic', model: 'claude-sonnet-4-5-20250929', body });
9
+ * const result = await run.finalize({ inputs: [...], outputs: [...] });
10
+ */
11
+ import type { ClawproofConfig, ClawproofRun } from './types.js';
12
+ /**
13
+ * Create a new clawsig run for recording events and producing
14
+ * a signed proof bundle.
15
+ *
16
+ * Each run gets a unique `run_<uuid>` identifier and manages its own
17
+ * event chain, receipt collection, and finalization.
18
+ */
19
+ export declare function createRun(config: ClawproofConfig): Promise<ClawproofRun>;
20
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EA2Bb,MAAM,YAAY,CAAC;AAmIpB;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAwZ9E"}