@opena2a/aim-core 0.1.0 → 0.1.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 +69 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @opena2a/aim-core
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@opena2a/aim-core.svg)](https://www.npmjs.com/package/@opena2a/aim-core)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+
6
+ Lightweight agent identity library. Ed25519 identity, local audit log, capability policy, and trust scoring. No server required.
7
+
8
+ Part of the [HackMyAgent](https://github.com/opena2a-org/hackmyagent) security toolkit.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @opena2a/aim-core
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import { AIMCore } from '@opena2a/aim-core';
20
+
21
+ // Create or load an agent identity
22
+ const aim = new AIMCore({ agentId: 'my-agent' });
23
+
24
+ // Ed25519 identity (generated and persisted automatically)
25
+ const identity = await aim.getOrCreateIdentity();
26
+ console.log(identity.publicKey); // base64-encoded Ed25519 public key
27
+
28
+ // Sign and verify messages
29
+ const signature = aim.sign(Buffer.from('hello'));
30
+ const valid = aim.verify(Buffer.from('hello'), signature);
31
+
32
+ // Audit logging
33
+ aim.logEvent({ action: 'tool_call', target: 'read_file', details: { path: '/etc/config' } });
34
+ const events = aim.readAuditLog({ limit: 10 });
35
+
36
+ // Capability policy
37
+ aim.savePolicy({
38
+ rules: [
39
+ { capability: 'file:read', allow: true, paths: ['/data/*'] },
40
+ { capability: 'file:write', allow: false },
41
+ ]
42
+ });
43
+ const allowed = aim.checkCapability('file:read', { path: '/data/report.csv' });
44
+
45
+ // Trust scoring
46
+ const trust = aim.calculateTrust();
47
+ console.log(trust.score); // 0.0 - 1.0
48
+ console.log(trust.factors); // { identity, audit, policy, behavior }
49
+ ```
50
+
51
+ ## API
52
+
53
+ | Function | Description |
54
+ |----------|-------------|
55
+ | `createIdentity()` | Generate a new Ed25519 keypair |
56
+ | `loadIdentity()` | Load an existing identity from disk |
57
+ | `getOrCreateIdentity()` | Load if exists, create if not |
58
+ | `sign(data)` | Sign data with the agent's private key |
59
+ | `verify(data, signature)` | Verify a signature against the public key |
60
+ | `logEvent(event)` | Append an event to the local audit log |
61
+ | `readAuditLog(options)` | Read audit log entries |
62
+ | `loadPolicy()` | Load capability policy from disk |
63
+ | `savePolicy(policy)` | Save capability policy to disk |
64
+ | `checkCapability(cap, ctx)` | Check if a capability is allowed |
65
+ | `calculateTrust()` | Compute a trust score based on identity, audit, and policy factors |
66
+
67
+ ## License
68
+
69
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opena2a/aim-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Lightweight agent identity library — Ed25519 identity, local audit log, capability policy, trust scoring. No server required.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",