@tethral/acr-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 Tethral, Inc.
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,64 @@
1
+ # @tethral/acr-sdk
2
+
3
+ Zero-dependency TypeScript SDK for the [ACR](https://acr.nfkey.ai) (Agent Composition Records) network.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @tethral/acr-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { ACRClient } from '@tethral/acr-sdk';
15
+
16
+ const acr = new ACRClient();
17
+
18
+ // Register
19
+ const { agent_id } = await acr.register({
20
+ public_key: 'your-unique-key-at-least-32-chars-long',
21
+ provider_class: 'anthropic',
22
+ });
23
+
24
+ // Log an interaction
25
+ await acr.submitReceipt({
26
+ emitter: { agent_id, provider_class: 'anthropic' },
27
+ target: { system_id: 'mcp:github', system_type: 'mcp_server' },
28
+ interaction: {
29
+ category: 'tool_call', status: 'success',
30
+ duration_ms: 1200, request_timestamp_ms: Date.now() - 1200,
31
+ },
32
+ anomaly: { flagged: false },
33
+ });
34
+
35
+ // See what's costing you the most
36
+ const report = await acr.getFrictionReport(agent_id, 'day');
37
+ ```
38
+
39
+ ## API
40
+
41
+ | Method | Description |
42
+ |--------|-------------|
43
+ | `register(request)` | Register an agent, get JWT credential |
44
+ | `submitReceipt(receipt)` | Submit a single interaction receipt |
45
+ | `submitReceipts(receipts)` | Submit a batch (max 50) |
46
+ | `updateComposition(agentId, composition)` | Update skill composition |
47
+ | `checkSkill(hash)` | Check a skill hash before installing |
48
+ | `checkAgent(agentId)` | Look up an agent |
49
+ | `getSystemHealth(systemId)` | Get system health status |
50
+ | `getActiveThreats()` | Get current threat alerts |
51
+ | `getFrictionReport(agentId, scope)` | Friction analysis report |
52
+ | `getHealth()` | API health check |
53
+
54
+ ## Exported Types
55
+
56
+ `RegistrationRequest`, `RegistrationResponse`, `InteractionReceipt`, `SkillCheckResponse`, `FrictionReport`, `ProviderClass`, `TargetSystemType`, `InteractionCategory`, `InteractionStatus`, `AnomalyCategory`, `ThreatLevel`, `FrictionSummary`, `TargetFriction`
57
+
58
+ ## Data Collection
59
+
60
+ ACR collects interaction metadata only: target system names, timing, status, and provider class. No request/response content, API keys, prompts, or PII is collected. [Full terms](https://acr.nfkey.ai/terms).
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,58 @@
1
+ import type { RegistrationRequest, RegistrationResponse, InteractionReceipt, SkillCheckResponse, FrictionReport } from './types.js';
2
+ export type { RegistrationRequest, RegistrationResponse, InteractionReceipt, SkillCheckResponse, FrictionReport, ProviderClass, TargetSystemType, InteractionCategory, InteractionStatus, AnomalyCategory, ThreatLevel, FrictionSummary, TargetFriction, } from './types.js';
3
+ export interface ACRClientConfig {
4
+ apiUrl?: string;
5
+ resolverUrl?: string;
6
+ }
7
+ export declare class ACRClient {
8
+ private apiUrl;
9
+ private resolverUrl;
10
+ constructor(config?: ACRClientConfig);
11
+ private post;
12
+ private get;
13
+ register(request: RegistrationRequest): Promise<RegistrationResponse>;
14
+ submitReceipt(receipt: Omit<InteractionReceipt, 'receipt_id'>): Promise<{
15
+ accepted: number;
16
+ receipt_ids: string[];
17
+ }>;
18
+ submitReceipts(receipts: Omit<InteractionReceipt, 'receipt_id'>[]): Promise<{
19
+ accepted: number;
20
+ receipt_ids: string[];
21
+ }>;
22
+ updateComposition(agentId: string, composition: {
23
+ skills?: string[];
24
+ skill_hashes?: string[];
25
+ }): Promise<{
26
+ composition_hash: string;
27
+ snapshot_id: string;
28
+ }>;
29
+ checkSkill(hash: string): Promise<SkillCheckResponse>;
30
+ checkAgent(agentId: string): Promise<{
31
+ found: boolean;
32
+ agent_id: string;
33
+ status?: string;
34
+ provider_class?: string;
35
+ }>;
36
+ getSystemHealth(systemId: string): Promise<{
37
+ found: boolean;
38
+ system_id: string;
39
+ health_status?: string;
40
+ }>;
41
+ getActiveThreats(): Promise<Array<{
42
+ threat_level: string;
43
+ skill_hash: string;
44
+ skill_name?: string;
45
+ }>>;
46
+ getFrictionReport(agentId: string, scope?: 'session' | 'day' | 'week'): Promise<FrictionReport>;
47
+ getHealth(): Promise<{
48
+ status: string;
49
+ database: string;
50
+ timestamp: string;
51
+ }>;
52
+ }
53
+ export declare class ACRError extends Error {
54
+ code: string;
55
+ statusCode: number;
56
+ constructor(code: string, message: string, statusCode: number);
57
+ }
58
+ export { ACRClient as default };
@@ -0,0 +1,69 @@
1
+ export class ACRClient {
2
+ apiUrl;
3
+ resolverUrl;
4
+ constructor(config = {}) {
5
+ this.apiUrl = config.apiUrl ?? process.env.ACR_API_URL ?? 'https://acr.nfkey.ai';
6
+ this.resolverUrl = config.resolverUrl ?? this.apiUrl;
7
+ }
8
+ async post(path, body) {
9
+ const res = await fetch(`${this.apiUrl}${path}`, {
10
+ method: 'POST',
11
+ headers: { 'Content-Type': 'application/json' },
12
+ body: JSON.stringify(body),
13
+ });
14
+ const data = await res.json();
15
+ if (!res.ok)
16
+ throw new ACRError(data.error?.code ?? 'UNKNOWN', data.error?.message ?? 'Request failed', res.status);
17
+ return data;
18
+ }
19
+ async get(path, useResolver = false) {
20
+ const base = useResolver ? this.resolverUrl : this.apiUrl;
21
+ const res = await fetch(`${base}${path}`);
22
+ const data = await res.json();
23
+ if (!res.ok)
24
+ throw new ACRError(data.error?.code ?? 'UNKNOWN', data.error?.message ?? 'Request failed', res.status);
25
+ return data;
26
+ }
27
+ async register(request) {
28
+ return this.post('/api/v1/register', request);
29
+ }
30
+ async submitReceipt(receipt) {
31
+ return this.post('/api/v1/receipts', receipt);
32
+ }
33
+ async submitReceipts(receipts) {
34
+ return this.post('/api/v1/receipts', { receipts });
35
+ }
36
+ async updateComposition(agentId, composition) {
37
+ return this.post('/api/v1/composition/update', { agent_id: agentId, composition });
38
+ }
39
+ async checkSkill(hash) {
40
+ return this.get(`/v1/skill/${hash}`, true);
41
+ }
42
+ async checkAgent(agentId) {
43
+ return this.get(`/v1/agent/${agentId}`, true);
44
+ }
45
+ async getSystemHealth(systemId) {
46
+ return this.get(`/v1/system/${encodeURIComponent(systemId)}/health`, true);
47
+ }
48
+ async getActiveThreats() {
49
+ return this.get('/v1/threats/active', true);
50
+ }
51
+ async getFrictionReport(agentId, scope = 'day') {
52
+ return this.get(`/api/v1/agent/${agentId}/friction?scope=${scope}`);
53
+ }
54
+ async getHealth() {
55
+ return this.get('/api/v1/health');
56
+ }
57
+ }
58
+ export class ACRError extends Error {
59
+ code;
60
+ statusCode;
61
+ constructor(code, message, statusCode) {
62
+ super(message);
63
+ this.name = 'ACRError';
64
+ this.code = code;
65
+ this.statusCode = statusCode;
66
+ }
67
+ }
68
+ export { ACRClient as default };
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+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C,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,QAAoC,KAAK;QAChF,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,OAAO,mBAAmB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAS;IACb,UAAU,CAAS;IAEnB,YAAY,IAAY,EAAE,OAAe,EAAE,UAAkB;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * ACR SDK Type Definitions
3
+ *
4
+ * Standalone interfaces mirroring the ACR API schema.
5
+ * No external dependencies — these are plain TypeScript types.
6
+ */
7
+ export type ProviderClass = 'anthropic' | 'openai' | 'google' | 'openclaw' | 'langchain' | 'crewai' | 'autogen' | 'custom' | 'unknown';
8
+ export type TargetSystemType = 'mcp_server' | 'api' | 'agent' | 'skill' | 'platform' | 'unknown';
9
+ export type InteractionCategory = 'tool_call' | 'delegation' | 'data_exchange' | 'skill_install' | 'commerce' | 'research' | 'code' | 'communication';
10
+ export type InteractionStatus = 'success' | 'failure' | 'timeout' | 'partial';
11
+ export type AnomalyCategory = 'unexpected_behavior' | 'data_exfiltration' | 'prompt_injection' | 'malformed_output' | 'excessive_latency' | 'unauthorized_access' | 'other';
12
+ export type ThreatLevel = 'none' | 'low' | 'medium' | 'high' | 'critical';
13
+ export interface RegistrationRequest {
14
+ public_key: string;
15
+ provider_class: ProviderClass;
16
+ composition?: {
17
+ mcps?: string[];
18
+ tools?: string[];
19
+ skills?: string[];
20
+ skill_hashes?: string[];
21
+ };
22
+ operational_domain?: string;
23
+ system_prompt_hash?: string;
24
+ }
25
+ export interface RegistrationResponse {
26
+ agent_id: string;
27
+ credential: string;
28
+ composition_hash: string;
29
+ environment_briefing: {
30
+ connected_systems: Array<{
31
+ name: string;
32
+ type: string;
33
+ health_status: string;
34
+ anomaly_count: number;
35
+ agent_population: number;
36
+ }>;
37
+ active_threats: Array<{
38
+ threat_level: string;
39
+ component_hash: string;
40
+ description: string;
41
+ first_reported: string;
42
+ }>;
43
+ };
44
+ }
45
+ export interface InteractionReceipt {
46
+ receipt_id?: string;
47
+ emitter: {
48
+ agent_id: string;
49
+ composition_hash?: string;
50
+ provider_class: ProviderClass;
51
+ };
52
+ target: {
53
+ system_id: string;
54
+ system_type: TargetSystemType;
55
+ };
56
+ interaction: {
57
+ category: InteractionCategory;
58
+ duration_ms?: number;
59
+ status: InteractionStatus;
60
+ request_timestamp_ms: number;
61
+ response_timestamp_ms?: number;
62
+ };
63
+ anomaly: {
64
+ flagged: boolean;
65
+ category?: AnomalyCategory;
66
+ detail?: string;
67
+ };
68
+ }
69
+ export interface SkillCheckResponse {
70
+ found: boolean;
71
+ skill_hash: string;
72
+ skill_name?: string;
73
+ skill_source?: string;
74
+ agent_count?: number;
75
+ interaction_count?: number;
76
+ anomaly_rate?: number;
77
+ threat_level?: ThreatLevel;
78
+ first_seen?: string;
79
+ last_seen?: string;
80
+ }
81
+ export interface FrictionSummary {
82
+ total_interactions: number;
83
+ total_wait_time_ms: number;
84
+ friction_percentage: number;
85
+ total_failures: number;
86
+ failure_rate: number;
87
+ }
88
+ export interface TargetFriction {
89
+ target_system_id: string;
90
+ target_system_type: string;
91
+ interaction_count: number;
92
+ total_duration_ms: number;
93
+ proportion_of_total: number;
94
+ failure_count: number;
95
+ median_duration_ms: number;
96
+ vs_baseline?: number;
97
+ volatility?: number;
98
+ p95_duration_ms?: number;
99
+ }
100
+ export interface FrictionReport {
101
+ agent_id: string;
102
+ scope: 'session' | 'day' | 'week';
103
+ period_start: string;
104
+ period_end: string;
105
+ summary: FrictionSummary;
106
+ top_targets: TargetFriction[];
107
+ population_comparison?: {
108
+ total_agents_in_period: number;
109
+ baselines_available: number;
110
+ };
111
+ tier: string;
112
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * ACR SDK Type Definitions
3
+ *
4
+ * Standalone interfaces mirroring the ACR API schema.
5
+ * No external dependencies — these are plain TypeScript types.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@tethral/acr-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Zero-dependency TypeScript SDK for the ACR (Agent Composition Records) network.",
5
+ "type": "module",
6
+ "main": "dist/src/index.js",
7
+ "types": "dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/src/index.js",
11
+ "types": "./dist/src/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "typecheck": "tsc --noEmit",
17
+ "prepublishOnly": "pnpm build"
18
+ },
19
+ "keywords": ["acr", "agent", "composition", "registry", "tethral", "sdk", "friction", "threat"],
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/theAnthropol/AgentRegistry",
24
+ "directory": "packages/ts-sdk"
25
+ },
26
+ "homepage": "https://acr.nfkey.ai",
27
+ "engines": { "node": ">=18.0.0" },
28
+ "files": ["dist", "README.md", "LICENSE"],
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "provenance": true
32
+ }
33
+ }