@opena2a/aim-core 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/dist/audit.d.ts +8 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +135 -0
- package/dist/audit.js.map +1 -0
- package/dist/crypto.d.ts +5 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +47 -0
- package/dist/crypto.js.map +1 -0
- package/dist/identity.d.ts +12 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -0
- package/dist/policy.d.ts +10 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +133 -0
- package/dist/policy.js.map +1 -0
- package/dist/trust.d.ts +4 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +41 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AuditEvent, AuditEventInput, AuditReadOptions } from './types';
|
|
2
|
+
/** Append an audit event to the JSON-lines log */
|
|
3
|
+
export declare function logEvent(dataDir: string, event: AuditEventInput): AuditEvent;
|
|
4
|
+
/** Read audit events from the JSON-lines log */
|
|
5
|
+
export declare function readAuditLog(dataDir: string, options?: AuditReadOptions): AuditEvent[];
|
|
6
|
+
/** Check if the audit log exists and has entries */
|
|
7
|
+
export declare function hasAuditLog(dataDir: string): boolean;
|
|
8
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI7E,kDAAkD;AAClD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CA+D5E;AAED,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,gBAAgB,GACzB,UAAU,EAAE,CAsBd;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKpD"}
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.logEvent = logEvent;
|
|
37
|
+
exports.readAuditLog = readAuditLog;
|
|
38
|
+
exports.hasAuditLog = hasAuditLog;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const crypto = __importStar(require("crypto"));
|
|
42
|
+
const AUDIT_FILE = 'audit.jsonl';
|
|
43
|
+
/** Append an audit event to the JSON-lines log */
|
|
44
|
+
function logEvent(dataDir, event) {
|
|
45
|
+
const fullEvent = {
|
|
46
|
+
timestamp: new Date().toISOString(),
|
|
47
|
+
...event,
|
|
48
|
+
};
|
|
49
|
+
// Enforce per-field size limits to prevent DoS via oversized fields
|
|
50
|
+
const MAX_FIELD_SIZE = 4096;
|
|
51
|
+
if (fullEvent.plugin.length > MAX_FIELD_SIZE)
|
|
52
|
+
fullEvent.plugin = fullEvent.plugin.slice(0, MAX_FIELD_SIZE);
|
|
53
|
+
if (fullEvent.action.length > MAX_FIELD_SIZE)
|
|
54
|
+
fullEvent.action = fullEvent.action.slice(0, MAX_FIELD_SIZE);
|
|
55
|
+
if (fullEvent.target.length > MAX_FIELD_SIZE)
|
|
56
|
+
fullEvent.target = fullEvent.target.slice(0, MAX_FIELD_SIZE);
|
|
57
|
+
// Enforce per-event size limit (1MB) to prevent DoS via oversized metadata
|
|
58
|
+
const MAX_EVENT_SIZE = 1024 * 1024;
|
|
59
|
+
let serialized = JSON.stringify(fullEvent);
|
|
60
|
+
if (serialized.length > MAX_EVENT_SIZE) {
|
|
61
|
+
fullEvent.metadata = { _truncated: true, _reason: 'Event exceeded 1MB size limit' };
|
|
62
|
+
serialized = JSON.stringify(fullEvent);
|
|
63
|
+
}
|
|
64
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
65
|
+
const filePath = path.join(dataDir, AUDIT_FILE);
|
|
66
|
+
// Rotate if audit log exceeds 50MB, keep last 5 rotated logs
|
|
67
|
+
const MAX_AUDIT_SIZE = 50 * 1024 * 1024;
|
|
68
|
+
const MAX_ROTATED_LOGS = 5;
|
|
69
|
+
try {
|
|
70
|
+
const stat = fs.statSync(filePath);
|
|
71
|
+
if (stat.size > MAX_AUDIT_SIZE) {
|
|
72
|
+
const suffix = `${Date.now()}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;
|
|
73
|
+
const rotatedPath = `${filePath}.${suffix}`;
|
|
74
|
+
try {
|
|
75
|
+
fs.renameSync(filePath, rotatedPath);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Another process may have already rotated — safe to continue
|
|
79
|
+
}
|
|
80
|
+
// Clean up old rotated logs beyond the retention limit
|
|
81
|
+
try {
|
|
82
|
+
const dir = path.dirname(filePath);
|
|
83
|
+
const base = path.basename(filePath);
|
|
84
|
+
const rotated = fs.readdirSync(dir)
|
|
85
|
+
.filter((f) => f.startsWith(base + '.') && f !== base)
|
|
86
|
+
.sort()
|
|
87
|
+
.reverse();
|
|
88
|
+
for (const old of rotated.slice(MAX_ROTATED_LOGS)) {
|
|
89
|
+
try {
|
|
90
|
+
fs.unlinkSync(path.join(dir, old));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Individual file deletion is best-effort
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Cleanup is best-effort
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// File doesn't exist yet — will be created by appendFileSync
|
|
104
|
+
}
|
|
105
|
+
fs.appendFileSync(filePath, serialized + '\n', 'utf-8');
|
|
106
|
+
return fullEvent;
|
|
107
|
+
}
|
|
108
|
+
/** Read audit events from the JSON-lines log */
|
|
109
|
+
function readAuditLog(dataDir, options) {
|
|
110
|
+
const filePath = path.join(dataDir, AUDIT_FILE);
|
|
111
|
+
if (!fs.existsSync(filePath)) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
115
|
+
const lines = raw.trim().split('\n').filter(Boolean);
|
|
116
|
+
let events = lines.map((line) => JSON.parse(line));
|
|
117
|
+
if (options?.since) {
|
|
118
|
+
const sinceDate = new Date(options.since).getTime();
|
|
119
|
+
events = events.filter((e) => new Date(e.timestamp).getTime() > sinceDate);
|
|
120
|
+
}
|
|
121
|
+
if (options?.limit && options.limit > 0) {
|
|
122
|
+
// Return the most recent N events
|
|
123
|
+
events = events.slice(-options.limit);
|
|
124
|
+
}
|
|
125
|
+
return events;
|
|
126
|
+
}
|
|
127
|
+
/** Check if the audit log exists and has entries */
|
|
128
|
+
function hasAuditLog(dataDir) {
|
|
129
|
+
const filePath = path.join(dataDir, AUDIT_FILE);
|
|
130
|
+
if (!fs.existsSync(filePath))
|
|
131
|
+
return false;
|
|
132
|
+
const stat = fs.statSync(filePath);
|
|
133
|
+
return stat.size > 0;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,4BA+DC;AAGD,oCAyBC;AAGD,kCAKC;AA3GD,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AAGjC,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC,kDAAkD;AAClD,SAAgB,QAAQ,CAAC,OAAe,EAAE,KAAsB;IAC9D,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AAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,oDAAoD;AACpD,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Sign data with an Ed25519 secret key */
|
|
2
|
+
export declare function sign(data: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
|
3
|
+
/** Verify an Ed25519 detached signature */
|
|
4
|
+
export declare function verify(data: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean;
|
|
5
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,CAExE;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CACpB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,UAAU,GACpB,OAAO,CAET"}
|
package/dist/crypto.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.sign = sign;
|
|
37
|
+
exports.verify = verify;
|
|
38
|
+
const nacl = __importStar(require("tweetnacl"));
|
|
39
|
+
/** Sign data with an Ed25519 secret key */
|
|
40
|
+
function sign(data, secretKey) {
|
|
41
|
+
return nacl.sign.detached(data, secretKey);
|
|
42
|
+
}
|
|
43
|
+
/** Verify an Ed25519 detached signature */
|
|
44
|
+
function verify(data, signature, publicKey) {
|
|
45
|
+
return nacl.sign.detached.verify(data, signature, publicKey);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,oBAEC;AAGD,wBAMC;AAdD,gDAAkC;AAElC,2CAA2C;AAC3C,SAAgB,IAAI,CAAC,IAAgB,EAAE,SAAqB;IAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED,2CAA2C;AAC3C,SAAgB,MAAM,CACpB,IAAgB,EAChB,SAAqB,EACrB,SAAqB;IAErB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AIMIdentity, StoredIdentity } from './types';
|
|
2
|
+
/** Generate a new Ed25519 keypair and store it */
|
|
3
|
+
export declare function createIdentity(dataDir: string, agentName: string): StoredIdentity;
|
|
4
|
+
/** Load an existing identity from disk */
|
|
5
|
+
export declare function loadIdentity(dataDir: string): StoredIdentity | null;
|
|
6
|
+
/** Get or create the agent's identity. Returns the public-facing identity (no secret key). */
|
|
7
|
+
export declare function getOrCreateIdentity(dataDir: string, agentName: string): AIMIdentity;
|
|
8
|
+
/** Get the Ed25519 secret key as Uint8Array (for signing operations) */
|
|
9
|
+
export declare function getSecretKey(dataDir: string): Uint8Array | null;
|
|
10
|
+
/** Get the Ed25519 public key as Uint8Array (for verification) */
|
|
11
|
+
export declare function getPublicKey(dataDir: string): Uint8Array | null;
|
|
12
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAgB3D,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAmBjF;AAED,0CAA0C;AAC1C,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAYnE;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAanF;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAI/D;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAI/D"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createIdentity = createIdentity;
|
|
37
|
+
exports.loadIdentity = loadIdentity;
|
|
38
|
+
exports.getOrCreateIdentity = getOrCreateIdentity;
|
|
39
|
+
exports.getSecretKey = getSecretKey;
|
|
40
|
+
exports.getPublicKey = getPublicKey;
|
|
41
|
+
const nacl = __importStar(require("tweetnacl"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const IDENTITY_FILE = 'identity.json';
|
|
45
|
+
/** Derive a short agent ID from an Ed25519 public key */
|
|
46
|
+
function deriveAgentId(publicKey) {
|
|
47
|
+
// Use first 12 bytes of public key, base64url-encoded, prefixed with "aim_"
|
|
48
|
+
const idBytes = publicKey.slice(0, 12);
|
|
49
|
+
const b64 = Buffer.from(idBytes)
|
|
50
|
+
.toString('base64')
|
|
51
|
+
.replace(/\+/g, '-')
|
|
52
|
+
.replace(/\//g, '_')
|
|
53
|
+
.replace(/=+$/, '');
|
|
54
|
+
return `aim_${b64}`;
|
|
55
|
+
}
|
|
56
|
+
/** Generate a new Ed25519 keypair and store it */
|
|
57
|
+
function createIdentity(dataDir, agentName) {
|
|
58
|
+
const keypair = nacl.sign.keyPair();
|
|
59
|
+
const identity = {
|
|
60
|
+
agentId: deriveAgentId(keypair.publicKey),
|
|
61
|
+
publicKey: Buffer.from(keypair.publicKey).toString('base64'),
|
|
62
|
+
secretKey: Buffer.from(keypair.secretKey).toString('base64'),
|
|
63
|
+
agentName,
|
|
64
|
+
createdAt: new Date().toISOString(),
|
|
65
|
+
};
|
|
66
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
67
|
+
const identityPath = path.join(dataDir, IDENTITY_FILE);
|
|
68
|
+
const tmpPath = identityPath + '.tmp.' + process.pid;
|
|
69
|
+
fs.writeFileSync(tmpPath, JSON.stringify(identity, null, 2), 'utf-8');
|
|
70
|
+
try {
|
|
71
|
+
fs.chmodSync(tmpPath, 0o600);
|
|
72
|
+
}
|
|
73
|
+
catch { /* Windows */ }
|
|
74
|
+
fs.renameSync(tmpPath, identityPath);
|
|
75
|
+
return identity;
|
|
76
|
+
}
|
|
77
|
+
/** Load an existing identity from disk */
|
|
78
|
+
function loadIdentity(dataDir) {
|
|
79
|
+
const filePath = path.join(dataDir, IDENTITY_FILE);
|
|
80
|
+
if (!fs.existsSync(filePath)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
85
|
+
return JSON.parse(raw);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Get or create the agent's identity. Returns the public-facing identity (no secret key). */
|
|
92
|
+
function getOrCreateIdentity(dataDir, agentName) {
|
|
93
|
+
let stored = loadIdentity(dataDir);
|
|
94
|
+
if (!stored) {
|
|
95
|
+
stored = createIdentity(dataDir, agentName);
|
|
96
|
+
}
|
|
97
|
+
// Return public identity only (strip secret key)
|
|
98
|
+
return {
|
|
99
|
+
agentId: stored.agentId,
|
|
100
|
+
publicKey: stored.publicKey,
|
|
101
|
+
agentName: stored.agentName,
|
|
102
|
+
createdAt: stored.createdAt,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Get the Ed25519 secret key as Uint8Array (for signing operations) */
|
|
106
|
+
function getSecretKey(dataDir) {
|
|
107
|
+
const stored = loadIdentity(dataDir);
|
|
108
|
+
if (!stored)
|
|
109
|
+
return null;
|
|
110
|
+
return Buffer.from(stored.secretKey, 'base64');
|
|
111
|
+
}
|
|
112
|
+
/** Get the Ed25519 public key as Uint8Array (for verification) */
|
|
113
|
+
function getPublicKey(dataDir) {
|
|
114
|
+
const stored = loadIdentity(dataDir);
|
|
115
|
+
if (!stored)
|
|
116
|
+
return null;
|
|
117
|
+
return Buffer.from(stored.publicKey, 'base64');
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,wCAmBC;AAGD,oCAYC;AAGD,kDAaC;AAGD,oCAIC;AAGD,oCAIC;AApFD,gDAAkC;AAClC,uCAAyB;AACzB,2CAA6B;AAG7B,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,yDAAyD;AACzD,SAAS,aAAa,CAAC,SAAqB;IAC1C,4EAA4E;IAC5E,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;SAC7B,QAAQ,CAAC,QAAQ,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,OAAO,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,kDAAkD;AAClD,SAAgB,cAAc,CAAC,OAAe,EAAE,SAAiB;IAC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|
+
export type { AIMCoreOptions, AIMIdentity, StoredIdentity, AuditEvent, AuditEventInput, AuditReadOptions, CapabilityPolicy, CapabilityRule, TrustScore, TrustFactors, TrustHints, } from './types';
|
|
3
|
+
export { sign, verify } from './crypto';
|
|
4
|
+
export { createIdentity, loadIdentity, getOrCreateIdentity } from './identity';
|
|
5
|
+
export { logEvent, readAuditLog, hasAuditLog } from './audit';
|
|
6
|
+
export { loadPolicy, savePolicy, checkCapability, hasPolicy } from './policy';
|
|
7
|
+
export { calculateTrust } from './trust';
|
|
8
|
+
import type { AIMCoreOptions, AIMIdentity, AuditEvent, AuditEventInput, AuditReadOptions, CapabilityPolicy, TrustScore, TrustHints } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Main entry point for aim-core.
|
|
11
|
+
*
|
|
12
|
+
* Provides Ed25519 identity, local audit logging, capability policy enforcement,
|
|
13
|
+
* trust scoring, and cryptographic signing — all without a server or database.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AIMCore {
|
|
16
|
+
private readonly agentName;
|
|
17
|
+
private readonly dataDir;
|
|
18
|
+
private readonly serverUrl;
|
|
19
|
+
private cachedPolicy;
|
|
20
|
+
private trustHints;
|
|
21
|
+
constructor(options: AIMCoreOptions);
|
|
22
|
+
/** Get or create the agent's Ed25519 identity */
|
|
23
|
+
getIdentity(): AIMIdentity;
|
|
24
|
+
/** Check if a capability is allowed by the current policy */
|
|
25
|
+
checkCapability(capability: string, plugin?: string): boolean;
|
|
26
|
+
/** Load capability policy from YAML file */
|
|
27
|
+
loadPolicy(): CapabilityPolicy;
|
|
28
|
+
/** Save a capability policy to YAML file */
|
|
29
|
+
savePolicy(p: CapabilityPolicy): void;
|
|
30
|
+
/** Log an audit event to the local JSON-lines file */
|
|
31
|
+
logEvent(event: AuditEventInput): AuditEvent;
|
|
32
|
+
/** Read audit events from local log */
|
|
33
|
+
readAuditLog(options?: AuditReadOptions): AuditEvent[];
|
|
34
|
+
/** Calculate the agent's trust score based on current state */
|
|
35
|
+
calculateTrust(): TrustScore;
|
|
36
|
+
/** Provide hints from plugins to improve trust score accuracy */
|
|
37
|
+
setTrustHints(hints: TrustHints): void;
|
|
38
|
+
/** Sign data with the agent's Ed25519 private key */
|
|
39
|
+
sign(data: Uint8Array): Uint8Array;
|
|
40
|
+
/** Verify an Ed25519 signature against a public key */
|
|
41
|
+
verify(data: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean;
|
|
42
|
+
/** Get the data directory path */
|
|
43
|
+
getDataDir(): string;
|
|
44
|
+
private defaultDataDir;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,YAAY,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACX,MAAM,SAAS,CAAC;AAQjB;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,UAAU,CAAkB;gBAExB,OAAO,EAAE,cAAc;IAMnC,iDAAiD;IACjD,WAAW,IAAI,WAAW;IAI1B,6DAA6D;IAC7D,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAO7D,4CAA4C;IAC5C,UAAU,IAAI,gBAAgB;IAK9B,4CAA4C;IAC5C,UAAU,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAKrC,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU;IAI5C,uCAAuC;IACvC,YAAY,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,UAAU,EAAE;IAItD,+DAA+D;IAC/D,cAAc,IAAI,UAAU;IAK5B,iEAAiE;IACjE,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAItC,qDAAqD;IACrD,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAQlC,uDAAuD;IACvD,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO;IAI/E,kCAAkC;IAClC,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,cAAc;CAIvB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AIMCore = exports.calculateTrust = exports.hasPolicy = exports.checkCapability = exports.savePolicy = exports.loadPolicy = exports.hasAuditLog = exports.readAuditLog = exports.logEvent = exports.getOrCreateIdentity = exports.loadIdentity = exports.createIdentity = exports.verify = exports.sign = exports.VERSION = void 0;
|
|
37
|
+
exports.VERSION = '0.1.0';
|
|
38
|
+
// Re-export module functions for advanced usage
|
|
39
|
+
var crypto_1 = require("./crypto");
|
|
40
|
+
Object.defineProperty(exports, "sign", { enumerable: true, get: function () { return crypto_1.sign; } });
|
|
41
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return crypto_1.verify; } });
|
|
42
|
+
var identity_1 = require("./identity");
|
|
43
|
+
Object.defineProperty(exports, "createIdentity", { enumerable: true, get: function () { return identity_1.createIdentity; } });
|
|
44
|
+
Object.defineProperty(exports, "loadIdentity", { enumerable: true, get: function () { return identity_1.loadIdentity; } });
|
|
45
|
+
Object.defineProperty(exports, "getOrCreateIdentity", { enumerable: true, get: function () { return identity_1.getOrCreateIdentity; } });
|
|
46
|
+
var audit_1 = require("./audit");
|
|
47
|
+
Object.defineProperty(exports, "logEvent", { enumerable: true, get: function () { return audit_1.logEvent; } });
|
|
48
|
+
Object.defineProperty(exports, "readAuditLog", { enumerable: true, get: function () { return audit_1.readAuditLog; } });
|
|
49
|
+
Object.defineProperty(exports, "hasAuditLog", { enumerable: true, get: function () { return audit_1.hasAuditLog; } });
|
|
50
|
+
var policy_1 = require("./policy");
|
|
51
|
+
Object.defineProperty(exports, "loadPolicy", { enumerable: true, get: function () { return policy_1.loadPolicy; } });
|
|
52
|
+
Object.defineProperty(exports, "savePolicy", { enumerable: true, get: function () { return policy_1.savePolicy; } });
|
|
53
|
+
Object.defineProperty(exports, "checkCapability", { enumerable: true, get: function () { return policy_1.checkCapability; } });
|
|
54
|
+
Object.defineProperty(exports, "hasPolicy", { enumerable: true, get: function () { return policy_1.hasPolicy; } });
|
|
55
|
+
var trust_1 = require("./trust");
|
|
56
|
+
Object.defineProperty(exports, "calculateTrust", { enumerable: true, get: function () { return trust_1.calculateTrust; } });
|
|
57
|
+
const identity = __importStar(require("./identity"));
|
|
58
|
+
const audit = __importStar(require("./audit"));
|
|
59
|
+
const policy = __importStar(require("./policy"));
|
|
60
|
+
const trust = __importStar(require("./trust"));
|
|
61
|
+
const crypto = __importStar(require("./crypto"));
|
|
62
|
+
/**
|
|
63
|
+
* Main entry point for aim-core.
|
|
64
|
+
*
|
|
65
|
+
* Provides Ed25519 identity, local audit logging, capability policy enforcement,
|
|
66
|
+
* trust scoring, and cryptographic signing — all without a server or database.
|
|
67
|
+
*/
|
|
68
|
+
class AIMCore {
|
|
69
|
+
constructor(options) {
|
|
70
|
+
this.cachedPolicy = null;
|
|
71
|
+
this.trustHints = {};
|
|
72
|
+
this.agentName = options.agentName;
|
|
73
|
+
this.dataDir = options.dataDir ?? this.defaultDataDir();
|
|
74
|
+
this.serverUrl = options.serverUrl ?? '';
|
|
75
|
+
}
|
|
76
|
+
/** Get or create the agent's Ed25519 identity */
|
|
77
|
+
getIdentity() {
|
|
78
|
+
return identity.getOrCreateIdentity(this.dataDir, this.agentName);
|
|
79
|
+
}
|
|
80
|
+
/** Check if a capability is allowed by the current policy */
|
|
81
|
+
checkCapability(capability, plugin) {
|
|
82
|
+
if (!this.cachedPolicy) {
|
|
83
|
+
this.cachedPolicy = policy.loadPolicy(this.dataDir);
|
|
84
|
+
}
|
|
85
|
+
return policy.checkCapability(this.cachedPolicy, capability, plugin);
|
|
86
|
+
}
|
|
87
|
+
/** Load capability policy from YAML file */
|
|
88
|
+
loadPolicy() {
|
|
89
|
+
this.cachedPolicy = policy.loadPolicy(this.dataDir);
|
|
90
|
+
return this.cachedPolicy;
|
|
91
|
+
}
|
|
92
|
+
/** Save a capability policy to YAML file */
|
|
93
|
+
savePolicy(p) {
|
|
94
|
+
policy.savePolicy(this.dataDir, p);
|
|
95
|
+
this.cachedPolicy = p;
|
|
96
|
+
}
|
|
97
|
+
/** Log an audit event to the local JSON-lines file */
|
|
98
|
+
logEvent(event) {
|
|
99
|
+
return audit.logEvent(this.dataDir, event);
|
|
100
|
+
}
|
|
101
|
+
/** Read audit events from local log */
|
|
102
|
+
readAuditLog(options) {
|
|
103
|
+
return audit.readAuditLog(this.dataDir, options);
|
|
104
|
+
}
|
|
105
|
+
/** Calculate the agent's trust score based on current state */
|
|
106
|
+
calculateTrust() {
|
|
107
|
+
const hasId = identity.loadIdentity(this.dataDir) !== null;
|
|
108
|
+
return trust.calculateTrust(this.dataDir, hasId, this.trustHints);
|
|
109
|
+
}
|
|
110
|
+
/** Provide hints from plugins to improve trust score accuracy */
|
|
111
|
+
setTrustHints(hints) {
|
|
112
|
+
this.trustHints = { ...this.trustHints, ...hints };
|
|
113
|
+
}
|
|
114
|
+
/** Sign data with the agent's Ed25519 private key */
|
|
115
|
+
sign(data) {
|
|
116
|
+
const secretKey = identity.getSecretKey(this.dataDir);
|
|
117
|
+
if (!secretKey) {
|
|
118
|
+
throw new Error('No identity found. Call getIdentity() first to generate a keypair.');
|
|
119
|
+
}
|
|
120
|
+
return crypto.sign(data, secretKey);
|
|
121
|
+
}
|
|
122
|
+
/** Verify an Ed25519 signature against a public key */
|
|
123
|
+
verify(data, signature, publicKey) {
|
|
124
|
+
return crypto.verify(data, signature, publicKey);
|
|
125
|
+
}
|
|
126
|
+
/** Get the data directory path */
|
|
127
|
+
getDataDir() {
|
|
128
|
+
return this.dataDir;
|
|
129
|
+
}
|
|
130
|
+
defaultDataDir() {
|
|
131
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? '/tmp';
|
|
132
|
+
return `${home}/.opena2a/aim-core`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.AIMCore = AIMCore;
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC;AAiB/B,gDAAgD;AAChD,mCAAwC;AAA/B,8FAAA,IAAI,OAAA;AAAE,gGAAA,MAAM,OAAA;AACrB,uCAA+E;AAAtE,0GAAA,cAAc,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAC1D,iCAA8D;AAArD,iGAAA,QAAQ,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC5C,mCAA8E;AAArE,oGAAA,UAAU,OAAA;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,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC;QACnE,OAAO,GAAG,IAAI,oBAAoB,CAAC;IACrC,CAAC;CACF;AAlFD,0BAkFC"}
|
package/dist/policy.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CapabilityPolicy } from './types';
|
|
2
|
+
/** Load capability policy from YAML file, or return default */
|
|
3
|
+
export declare function loadPolicy(dataDir: string): CapabilityPolicy;
|
|
4
|
+
/** Save a capability policy to YAML file */
|
|
5
|
+
export declare function savePolicy(dataDir: string, policy: CapabilityPolicy): void;
|
|
6
|
+
/** Check if a capability is allowed by the policy */
|
|
7
|
+
export declare function checkCapability(policy: CapabilityPolicy, capability: string, plugin?: string): boolean;
|
|
8
|
+
/** Check if a policy file exists */
|
|
9
|
+
export declare function hasPolicy(dataDir: string): boolean;
|
|
10
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAC;AAUhE,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CA6B5D;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAM1E;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAeT;AAED,oCAAoC;AACpC,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAElD"}
|
package/dist/policy.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadPolicy = loadPolicy;
|
|
37
|
+
exports.savePolicy = savePolicy;
|
|
38
|
+
exports.checkCapability = checkCapability;
|
|
39
|
+
exports.hasPolicy = hasPolicy;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const yaml = __importStar(require("js-yaml"));
|
|
43
|
+
const POLICY_FILE = 'policy.yaml';
|
|
44
|
+
const DEFAULT_POLICY = {
|
|
45
|
+
version: '1',
|
|
46
|
+
defaultAction: 'deny',
|
|
47
|
+
rules: [],
|
|
48
|
+
};
|
|
49
|
+
/** Load capability policy from YAML file, or return default */
|
|
50
|
+
function loadPolicy(dataDir) {
|
|
51
|
+
const filePath = path.join(dataDir, POLICY_FILE);
|
|
52
|
+
if (!fs.existsSync(filePath)) {
|
|
53
|
+
return DEFAULT_POLICY;
|
|
54
|
+
}
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
58
|
+
parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return DEFAULT_POLICY;
|
|
62
|
+
}
|
|
63
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
64
|
+
return DEFAULT_POLICY;
|
|
65
|
+
}
|
|
66
|
+
// Reject prototype pollution attempts
|
|
67
|
+
const keys = Object.keys(parsed);
|
|
68
|
+
if (keys.includes('__proto__') || keys.includes('constructor') || keys.includes('prototype')) {
|
|
69
|
+
return DEFAULT_POLICY;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
version: String(parsed.version ?? '1'),
|
|
73
|
+
defaultAction: parsed.defaultAction === 'allow' ? 'allow' : 'deny',
|
|
74
|
+
rules: Array.isArray(parsed.rules) ? parsed.rules.map(parseRule) : [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Save a capability policy to YAML file */
|
|
78
|
+
function savePolicy(dataDir, policy) {
|
|
79
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
80
|
+
const filePath = path.join(dataDir, POLICY_FILE);
|
|
81
|
+
const tmpPath = filePath + '.tmp.' + process.pid;
|
|
82
|
+
fs.writeFileSync(tmpPath, yaml.dump(policy), 'utf-8');
|
|
83
|
+
fs.renameSync(tmpPath, filePath);
|
|
84
|
+
}
|
|
85
|
+
/** Check if a capability is allowed by the policy */
|
|
86
|
+
function checkCapability(policy, capability, plugin) {
|
|
87
|
+
for (const rule of policy.rules) {
|
|
88
|
+
if (matchesCapability(rule.capability, capability)) {
|
|
89
|
+
// If rule restricts to specific plugins, check plugin name
|
|
90
|
+
if (rule.plugins && rule.plugins.length > 0) {
|
|
91
|
+
if (!plugin || !rule.plugins.includes(plugin)) {
|
|
92
|
+
continue; // Rule doesn't apply to this plugin
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return rule.action === 'allow';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// No rule matched — use default
|
|
99
|
+
return policy.defaultAction === 'allow';
|
|
100
|
+
}
|
|
101
|
+
/** Check if a policy file exists */
|
|
102
|
+
function hasPolicy(dataDir) {
|
|
103
|
+
return fs.existsSync(path.join(dataDir, POLICY_FILE));
|
|
104
|
+
}
|
|
105
|
+
// --- Internal helpers ---
|
|
106
|
+
function parseRule(raw) {
|
|
107
|
+
const obj = raw;
|
|
108
|
+
return {
|
|
109
|
+
capability: String(obj.capability ?? '*'),
|
|
110
|
+
action: obj.action === 'allow' ? 'allow' : 'deny',
|
|
111
|
+
plugins: Array.isArray(obj.plugins) ? obj.plugins.map(String) : undefined,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Match a capability against a pattern.
|
|
116
|
+
* Supports:
|
|
117
|
+
* "*" → matches everything
|
|
118
|
+
* "db:*" → matches "db:read", "db:write", etc.
|
|
119
|
+
* "fs:write:*" → matches "fs:write:/tmp/foo", "fs:write:/var/log"
|
|
120
|
+
* "db:read" → exact match
|
|
121
|
+
*/
|
|
122
|
+
function matchesCapability(pattern, capability) {
|
|
123
|
+
if (pattern === '*')
|
|
124
|
+
return true;
|
|
125
|
+
if (pattern === capability)
|
|
126
|
+
return true;
|
|
127
|
+
if (pattern.endsWith(':*')) {
|
|
128
|
+
const prefix = pattern.slice(0, -1); // "db:" from "db:*"
|
|
129
|
+
return capability.startsWith(prefix) && capability.length > prefix.length;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,gCA6BC;AAGD,gCAMC;AAGD,0CAmBC;AAGD,8BAEC;AA/ED,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAGhC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,MAAM,cAAc,GAAqB;IACvC,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,MAAM;IACrB,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,+DAA+D;AAC/D,SAAgB,UAAU,CAAC,OAAe;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,IAAI,MAA2C,CAAC;IAChD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,CAAwC,CAAC;IACnG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAA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U;QAAE,OAAO,IAAI,CAAC;IAExC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;QACzD,OAAO,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/trust.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TrustScore, TrustHints } from './types';
|
|
2
|
+
/** Calculate trust score based on current state and plugin hints */
|
|
3
|
+
export declare function calculateTrust(dataDir: string, hasIdentity: boolean, hints?: TrustHints): TrustScore;
|
|
4
|
+
//# sourceMappingURL=trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../src/trust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgB,UAAU,EAAE,MAAM,SAAS,CAAC;AAgBpE,oEAAoE;AACpE,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,OAAO,EACpB,KAAK,CAAC,EAAE,UAAU,GACjB,UAAU,CAyBZ"}
|
package/dist/trust.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateTrust = calculateTrust;
|
|
4
|
+
const audit_1 = require("./audit");
|
|
5
|
+
const policy_1 = require("./policy");
|
|
6
|
+
/** Weight for each trust factor (must sum to 1.0) */
|
|
7
|
+
const WEIGHTS = {
|
|
8
|
+
identity: 0.20,
|
|
9
|
+
capabilities: 0.15,
|
|
10
|
+
auditLog: 0.10,
|
|
11
|
+
secretsManaged: 0.15,
|
|
12
|
+
configSigned: 0.10,
|
|
13
|
+
skillsVerified: 0.10,
|
|
14
|
+
networkControlled: 0.10,
|
|
15
|
+
heartbeatMonitored: 0.10,
|
|
16
|
+
};
|
|
17
|
+
/** Calculate trust score based on current state and plugin hints */
|
|
18
|
+
function calculateTrust(dataDir, hasIdentity, hints) {
|
|
19
|
+
const factors = {
|
|
20
|
+
identity: hasIdentity ? 1.0 : 0.0,
|
|
21
|
+
capabilities: (0, policy_1.hasPolicy)(dataDir) ? 1.0 : 0.0,
|
|
22
|
+
auditLog: (0, audit_1.hasAuditLog)(dataDir) ? 1.0 : 0.0,
|
|
23
|
+
secretsManaged: hints?.secretsManaged ? 1.0 : 0.0,
|
|
24
|
+
configSigned: hints?.configSigned ? 1.0 : 0.0,
|
|
25
|
+
skillsVerified: hints?.skillsVerified ? 1.0 : 0.0,
|
|
26
|
+
networkControlled: hints?.networkControlled ? 1.0 : 0.0,
|
|
27
|
+
heartbeatMonitored: hints?.heartbeatMonitored ? 1.0 : 0.0,
|
|
28
|
+
};
|
|
29
|
+
let overall = 0;
|
|
30
|
+
for (const [factor, weight] of Object.entries(WEIGHTS)) {
|
|
31
|
+
overall += factors[factor] * weight;
|
|
32
|
+
}
|
|
33
|
+
// Round to 2 decimal places
|
|
34
|
+
overall = Math.round(overall * 100) / 100;
|
|
35
|
+
return {
|
|
36
|
+
overall,
|
|
37
|
+
factors,
|
|
38
|
+
calculatedAt: new Date().toISOString(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.js","sourceRoot":"","sources":["../src/trust.ts"],"names":[],"mappings":";;AAiBA,wCA6BC;AA7CD,mCAAsC;AACtC,qCAAqC;AAErC,qDAAqD;AACrD,MAAM,OAAO,GAAuC;IAClD,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;IACd,cAAc,EA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GAAG,GAAG,CAAC;IAE1C,OAAO;QACL,OAAO;QACP,OAAO;QACP,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACvC,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Options for creating an AIMCore instance */
|
|
2
|
+
export interface AIMCoreOptions {
|
|
3
|
+
/** Human-readable agent name */
|
|
4
|
+
agentName: string;
|
|
5
|
+
/** Directory for identity keys, audit log, and config. Defaults to ~/.opena2a/aim-core */
|
|
6
|
+
dataDir?: string;
|
|
7
|
+
/** Optional AIM server URL for fleet reporting */
|
|
8
|
+
serverUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Ed25519 identity for an agent */
|
|
11
|
+
export interface AIMIdentity {
|
|
12
|
+
/** Agent's unique identifier (derived from public key) */
|
|
13
|
+
agentId: string;
|
|
14
|
+
/** Ed25519 public key (base64) */
|
|
15
|
+
publicKey: string;
|
|
16
|
+
/** Agent name from config */
|
|
17
|
+
agentName: string;
|
|
18
|
+
/** ISO timestamp of identity creation */
|
|
19
|
+
createdAt: string;
|
|
20
|
+
}
|
|
21
|
+
/** Stored identity (includes secret key — never exported via getIdentity) */
|
|
22
|
+
export interface StoredIdentity extends AIMIdentity {
|
|
23
|
+
/** Ed25519 secret key (base64) — 64 bytes: 32 private + 32 public */
|
|
24
|
+
secretKey: string;
|
|
25
|
+
}
|
|
26
|
+
/** A single audit event */
|
|
27
|
+
export interface AuditEvent {
|
|
28
|
+
/** ISO timestamp */
|
|
29
|
+
timestamp: string;
|
|
30
|
+
/** Plugin that generated the event */
|
|
31
|
+
plugin: string;
|
|
32
|
+
/** Action performed */
|
|
33
|
+
action: string;
|
|
34
|
+
/** Target resource */
|
|
35
|
+
target: string;
|
|
36
|
+
/** Result: allowed, denied, error */
|
|
37
|
+
result: 'allowed' | 'denied' | 'error';
|
|
38
|
+
/** Optional metadata */
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** Input for logging an event (timestamp is added automatically) */
|
|
42
|
+
export type AuditEventInput = Omit<AuditEvent, 'timestamp'>;
|
|
43
|
+
/** Options for reading audit events */
|
|
44
|
+
export interface AuditReadOptions {
|
|
45
|
+
/** Maximum number of events to return */
|
|
46
|
+
limit?: number;
|
|
47
|
+
/** Only return events after this ISO timestamp */
|
|
48
|
+
since?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Capability policy loaded from YAML */
|
|
51
|
+
export interface CapabilityPolicy {
|
|
52
|
+
/** Policy version */
|
|
53
|
+
version: string;
|
|
54
|
+
/** Default action when no rule matches */
|
|
55
|
+
defaultAction: 'allow' | 'deny';
|
|
56
|
+
/** Capability rules (evaluated in order, first match wins) */
|
|
57
|
+
rules: CapabilityRule[];
|
|
58
|
+
}
|
|
59
|
+
/** A single capability rule */
|
|
60
|
+
export interface CapabilityRule {
|
|
61
|
+
/** Capability pattern (e.g., "db:read", "net:*", "fs:write:/tmp/*") */
|
|
62
|
+
capability: string;
|
|
63
|
+
/** Action for this rule */
|
|
64
|
+
action: 'allow' | 'deny';
|
|
65
|
+
/** Optional: restrict to specific plugins */
|
|
66
|
+
plugins?: string[];
|
|
67
|
+
}
|
|
68
|
+
/** Trust score result */
|
|
69
|
+
export interface TrustScore {
|
|
70
|
+
/** Overall trust score (0-1) */
|
|
71
|
+
overall: number;
|
|
72
|
+
/** Individual factor scores */
|
|
73
|
+
factors: TrustFactors;
|
|
74
|
+
/** ISO timestamp of calculation */
|
|
75
|
+
calculatedAt: string;
|
|
76
|
+
}
|
|
77
|
+
/** Individual trust factor scores (each 0-1) */
|
|
78
|
+
export interface TrustFactors {
|
|
79
|
+
/** Identity verified (Ed25519 key exists and is valid) */
|
|
80
|
+
identity: number;
|
|
81
|
+
/** Capabilities declared and enforced */
|
|
82
|
+
capabilities: number;
|
|
83
|
+
/** Audit logging active */
|
|
84
|
+
auditLog: number;
|
|
85
|
+
/** Secrets managed (not hardcoded) */
|
|
86
|
+
secretsManaged: number;
|
|
87
|
+
/** Configuration signed */
|
|
88
|
+
configSigned: number;
|
|
89
|
+
/** Skills integrity verified */
|
|
90
|
+
skillsVerified: number;
|
|
91
|
+
/** Network access controlled */
|
|
92
|
+
networkControlled: number;
|
|
93
|
+
/** Heartbeat monitoring active */
|
|
94
|
+
heartbeatMonitored: number;
|
|
95
|
+
}
|
|
96
|
+
/** Hints provided by plugins to inform trust calculation */
|
|
97
|
+
export interface TrustHints {
|
|
98
|
+
secretsManaged?: boolean;
|
|
99
|
+
configSigned?: boolean;
|
|
100
|
+
skillsVerified?: boolean;
|
|
101
|
+
networkControlled?: boolean;
|
|
102
|
+
heartbeatMonitored?: boolean;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oCAAoC;AACpC,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6EAA6E;AAC7E,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B;AAC3B,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,MAAM,EAAE,MAAM,C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MAAM,CAAC;IACjB,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opena2a/aim-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lightweight agent identity library — Ed25519 identity, local audit log, capability policy, trust scoring. No server required.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"!dist/**/*.test.*",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"lint": "eslint src --ext .ts",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"js-yaml": "^4.1.1",
|
|
21
|
+
"tweetnacl": "^1.0.3"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/js-yaml": "^4.0.9",
|
|
25
|
+
"@types/node": "^20.0.0",
|
|
26
|
+
"typescript": "^5.3.3",
|
|
27
|
+
"vitest": "^3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"ai",
|
|
31
|
+
"agent",
|
|
32
|
+
"identity",
|
|
33
|
+
"ed25519",
|
|
34
|
+
"security",
|
|
35
|
+
"aim",
|
|
36
|
+
"opena2a"
|
|
37
|
+
],
|
|
38
|
+
"author": "OpenA2A",
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/opena2a-org/hackmyagent.git",
|
|
43
|
+
"directory": "packages/aim-core"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|