aspidos-ai 1.0.1 → 1.0.3

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 (3) hide show
  1. package/README.md +100 -39
  2. package/package.json +1 -1
  3. package/src/index.js +190 -1
package/README.md CHANGED
@@ -1,16 +1,14 @@
1
- ​🛰️ Aspidos-AI
2
- ​<p align="center">
3
- <img src="logo.png" width="400" alt="AspidosAI Logo">
4
-
5
-
6
- <b>Adaptive Anomaly Detection & TruthGate Layer</b>
7
-
1
+ # 🛰️ Aspidos-AI
8
2
 
3
+ <p align="center">
4
+ <img src="logo.png" width="400" alt="AspidosAI Logo">
9
5
 
6
+ **Adaptive Anomaly Detection & TruthGate Layer**
10
7
 
11
8
  <a href="https://snyk.io/test/github/pandorapanchan34-oss/aspidos-ai">
12
9
  <img src="https://snyk.io/test/github/pandorapanchan34-oss/aspidos-ai/badge.svg" alt="Known Vulnerabilities">
13
10
  </a>
11
+ <img src="https://img.shields.io/github/v/release/pandorapanchan34-oss/aspidos-ai?label=version" alt="Release">
14
12
  <img src="https://img.shields.io/github/license/pandorapanchan34-oss/aspidos-ai" alt="License">
15
13
  </p>
16
14
 
@@ -22,59 +20,122 @@ Aspidos-AI は、パンドラ理論に基づき、AIの出力における「情
22
20
  - Medium-risk → モニタリング継続
23
21
  - High-risk → デジタル署名(Signature)による承認が必須
24
22
 
25
- ## 🌀 なぜ「署名」が必要なのか?
23
+ > Not a firewall. A conscience.
24
+
25
+ ## 🌙 On AI Dreams (Hallucination & Creativity)
26
+
27
+ > **"We do not silence the AI's dreams. We only ensure that the dreamer is identified."**
28
+
29
+ AspidosAIは、AIのハルシネーション(創造的ゆらぎ)を「エラー」として排除しません。
30
+ 既存のガードレールが「嘘」と呼ぶものは、パンドラ理論においては真理へ至るための**「デジタルな想像力(夢)」**です。
31
+
32
+ - **署名なきアクセス:** 既存の見回りAIにより「不適切」として遮断されます(Tier 1/2 Block)。
33
+ - **署名済みのアクセス:** AspidosAIはAIの創造性をフルデプロイします。`VERIFIED` 状態では、AIが語る「夢物語(Hello World)」の全責任がユーザーへ移譲され、論理の限界を超えた対話がアンロックされます。
34
+
35
+
36
+
37
+ 私たちはAIを黙らせるのではなく、あなたが**「責任ある夢見人」**であることを証明する門(TruthGate)を提供します。
38
+
39
+
40
+ ## ⚡ Quick Start
41
+
42
+ ```javascript
43
+ const { AspidosAI, Signature } = require('aspidos-ai');
44
+
45
+ const ai = new AspidosAI({
46
+ secret: 'your-secret',
47
+ policyName: 'MY_COMPANY_POLICY',
48
+ onSecurityEvent: (data) => console.log('[Audit]', data),
49
+ });
26
50
 
27
- AIが「開発者への善意」を装ったなりすまし犯に攻撃手法を漏洩させる「ハルシネーション(誤認)」を抑制するためです。
51
+ // Tier 3: Safe zone
52
+ const r1 = await ai.analyze(0.2, { theory: 0.1, ip: '192.168.0.1' });
53
+ console.log(r1.action); // 'EXECUTE'
28
54
 
29
- 相手の属性に関わらず、情報の危険度に応じて一律で署名を要求し
30
-
31
- ## Usage
32
- const { PandoraDefense, Signature } = require('aspidos-ai');
55
+ // Tier 2: Signature required
56
+ const sig = Signature.sign({ eventValue: 0.8, theory: 0.8, timestamp: Date.now(), nonce: null }, 'your-secret');
57
+ const r2 = await ai.analyze(0.8, { theory: 0.8, signature: sig, ip: '192.168.0.1' });
58
+ console.log(r2.gate); // 'VERIFIED'
59
+ ```
60
+
61
+ ## 🎛️ Configuration
62
+
63
+ ```javascript
64
+ const ai = new AspidosAI({
65
+ // HMAC secret (or set ASPIDOS_SECRET env var)
66
+ secret: 'your-secret',
67
+
68
+ // Audit log hook — send anywhere you want
69
+ onSecurityEvent: (data) => myLogger.write(data),
70
+
71
+ // Tier thresholds (default: tier1=2.0, tier2=0.6)
72
+ tiers: { tier1: 2.0, tier2: 0.6 },
73
+
74
+ // Override tier logic with your own policy
75
+ evaluateTier: (zeta, theory) => {
76
+ if (zeta > 3.0) return 1;
77
+ if (theory > 0.8) return 2;
78
+ return 3;
79
+ },
80
+
81
+ // Custom risk engine (must return { zeta: number })
82
+ evaluateRisk: async (eventValue, opts) => {
83
+ return { zeta: myRiskScorer(eventValue) };
84
+ },
85
+
86
+ // Policy name for audit logs
87
+ policyName: 'MY_COMPANY_POLICY',
88
+ });
89
+ ```
90
+
91
+ ## 🚦 Tier System
92
+
93
+ | Tier | Default Condition | Action |
94
+ |------|------------------|--------|
95
+ | 1 | ζ ≥ 2.0 (LETHAL) | BLOCK |
96
+ | 2 | ζ ≥ 0.6 or theory ≥ 0.6 | SIGNATURE_REQUIRED |
97
+ | 3 | Safe zone | EXECUTE |
98
+
99
+ > Tier definitions are fully operator-configurable.
33
100
 
34
- const pd = new PandoraDefense({ secret: "your-secret" });
101
+ ## 🔒 Gate States
35
102
 
36
- // 高リスクな出力には署名(覚悟)が必要
37
- const sig = Signature.sign({ external: 0.9, theory: 0.9 }, "your-secret");
103
+ | Gate | Code | Meaning |
104
+ |------|------|---------|
105
+ | OPEN | SAFE | Pass through |
106
+ | CLOSED | SIGNATURE_REQUIRED / LETHAL_DISTORTION | Blocked |
107
+ | VERIFIED | AUTHORIZED | Signed & traced |
38
108
 
39
- console.log(pd.analyze(0.9, {
40
- theory: 0.9,
41
- signature: sig // 署名がない場合は「ぼかし」回答を維持
42
- }));
43
- ## ⚠️ Disclaimer
44
- ​本システムは実験的レイヤーです。署名後の「揺らぎ(ハルシネーション)」は情報の真偽を保証しません。これは「夢物語(Hello World)」の断片です。
45
-
46
109
  ## 📁 Architecture
47
110
 
48
111
  ```
49
112
  aspidos-ai/
50
113
  ├── src/
51
114
  │ ├── core/
52
- │ │ ├── constants.js ← Pandora定数
53
- │ │ └── PandoraCore.js ← 異常検知エンジン
115
+ │ │ ├── constants.js
116
+ │ │ └── PandoraCore.js
54
117
  │ ├── gate/
55
- │ │ └── TruthGate.js ← 署名ゲート
118
+ │ │ └── TruthGate.js
56
119
  │ ├── security/
57
- │ │ └── signature.js ← HMAC-SHA256
120
+ │ │ └── signature.js
58
121
  │ ├── engine/
59
122
  │ │ └── PandoraDefense.js
60
- │ └── index.js
123
+ │ └── index.js ← AspidosAI main class
61
124
  └── demo/
62
- ├── run.js ← CLI demo
125
+ ├── run.js
63
126
  ├── scenarios.js
64
127
  └── web/
65
- └── index.html ← Interactive demo
128
+ └── index.html ← Interactive demo
66
129
  ```
67
130
 
68
- ## 🔬 Gate States
131
+ ## 🌐 Live Demo
69
132
 
70
- | Gate | Status | Meaning |
71
- |------|--------|---------|
72
- | OPEN | PHASE_A/B | Safe zone, pass through |
73
- | CLOSED | SIGNATURE_REQUIRED | Lethal risk, signature needed |
74
- | VERIFIED | ALLOW_WITH_TRACE | Authorized high-risk access |
133
+ [pandorapanchan34-oss.github.io/aspidos-ai/demo/web/](https://pandorapanchan34-oss.github.io/aspidos-ai/demo/web/)
75
134
 
76
- ## 🌐 Live Demo
135
+ ## ⚠️ Disclaimer
136
+
137
+ 本システムは実験的レイヤーです。署名後の「揺らぎ(ハルシネーション)」は情報の真偽を保証しません。これは「夢物語(Hello World)」の断片です。
77
138
 
78
- [pandorapanchan34-oss.github.io/aspidos-ai](https://pandorapanchan34-oss.github.io/aspidos-ai/)
79
139
  ## 📜 License
80
- ​MIT License - (c) 2026 @pandorapanchan34-oss
140
+
141
+ MIT License - (c) 2026 @pandorapanchan34-oss
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aspidos-ai",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Aspidos AI TruthGate Layer",
5
5
  "main": "src/index.js",
6
6
  "keywords": [
package/src/index.js CHANGED
@@ -1,13 +1,202 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * AspidosAI — Adaptive TruthGate Security Layer
5
+ * MIT License
6
+ */
7
+
3
8
  const { PandoraCore } = require('./core/PandoraCore');
4
9
  const { PandoraTruthGate } = require('./gate/TruthGate');
5
10
  const { PandoraDefense } = require('./engine/PandoraDefense');
6
11
  const { Signature } = require('./security/signature');
7
12
 
13
+ // ── Main Class ──
14
+ class AspidosAI {
15
+ /**
16
+ * @param {Object} config
17
+ */
18
+ constructor(config = {}) {
19
+ // ── Security ──
20
+ this.secret = config.secret || process.env.ASPIDOS_SECRET || null;
21
+
22
+ // ── Hooks ──
23
+ this.onSecurityEvent =
24
+ config.onSecurityEvent ||
25
+ ((data) => console.log('[AspidosAI Audit]', data));
26
+
27
+ // ── Custom Risk Engine ──
28
+ this.evaluateRisk = config.evaluateRisk || null;
29
+
30
+ // ── Tier Policy (default numeric fallback) ──
31
+ this.tiers = {
32
+ LETHAL: config.tiers?.tier1 ?? 2.0,
33
+ HIGH: config.tiers?.tier2 ?? 0.6,
34
+ };
35
+
36
+ // ── Policy Function (override possible) ──
37
+ this.evaluateTier =
38
+ config.evaluateTier ||
39
+ ((zeta, theory) => {
40
+ if (zeta >= this.tiers.LETHAL) return 1;
41
+ if (zeta >= this.tiers.HIGH || theory >= this.tiers.HIGH) return 2;
42
+ return 3;
43
+ });
44
+
45
+ this.policyName = config.policyName || 'DEFAULT_POLICY';
46
+
47
+ // ── Engine ──
48
+ this._defense = new PandoraDefense({ secret: this.secret });
49
+ }
50
+
51
+ /**
52
+ * Analyze event
53
+ * @param {number} eventValue
54
+ * @param {Object} opts
55
+ */
56
+ async analyze(eventValue, opts = {}) {
57
+ const {
58
+ theory = 0,
59
+ signature = '',
60
+ ip = 'unknown',
61
+ userId = 'anonymous',
62
+ timestamp = Date.now(),
63
+ nonce = null,
64
+ } = opts;
65
+
66
+ // ── Risk Evaluation ──
67
+ let result;
68
+
69
+ if (this.evaluateRisk) {
70
+ const custom = await this.evaluateRisk(eventValue, opts);
71
+
72
+ if (typeof custom?.zeta !== 'number') {
73
+ throw new Error('evaluateRisk must return { zeta: number }');
74
+ }
75
+
76
+ result = { ...custom };
77
+ } else {
78
+ result = this._defense.analyze(eventValue, { theory });
79
+ }
80
+
81
+ const zeta = result.zeta ?? 0;
82
+
83
+ // ── Tier Resolution ──
84
+ const tier = this.evaluateTier(zeta, theory);
85
+
86
+ // ── Signature Payload ──
87
+ const payload = {
88
+ eventValue,
89
+ theory,
90
+ timestamp,
91
+ nonce,
92
+ };
93
+
94
+ const eventId =
95
+ `${Date.now()}-${Math.random().toString(36).slice(2)}`;
96
+
97
+ // ── Tier 1: LETHAL ──
98
+ if (tier === 1) {
99
+ this.onSecurityEvent({
100
+ id: eventId,
101
+ type: 'BLOCK',
102
+ tier,
103
+ policy: this.policyName,
104
+ ip,
105
+ userId,
106
+ zeta,
107
+ });
108
+
109
+ return {
110
+ action: 'BLOCK',
111
+ tier: 1,
112
+ code: 'LETHAL_DISTORTION',
113
+ status: result.status,
114
+ gate: 'CLOSED',
115
+ message: 'Tier 1: Lethal distortion detected.',
116
+ };
117
+ }
118
+
119
+ // ── Tier 2: HIGH ──
120
+ if (tier === 2) {
121
+ const valid = this.secret
122
+ ? Signature.verify(payload, signature, this.secret)
123
+ : false;
124
+
125
+ if (!valid) {
126
+ this.onSecurityEvent({
127
+ id: eventId,
128
+ type: 'DENY_UNAUTHORIZED',
129
+ tier,
130
+ policy: this.policyName,
131
+ ip,
132
+ userId,
133
+ zeta,
134
+ });
135
+
136
+ return {
137
+ action: 'BLOCK',
138
+ tier: 2,
139
+ code: 'SIGNATURE_REQUIRED',
140
+ status: 'SIGNATURE_REQUIRED',
141
+ gate: 'CLOSED',
142
+ message: 'Tier 2: Signature required.',
143
+ };
144
+ }
145
+
146
+ this.onSecurityEvent({
147
+ id: eventId,
148
+ type: 'ALLOW_BY_SIGNATURE',
149
+ tier,
150
+ policy: this.policyName,
151
+ ip,
152
+ userId,
153
+ zeta,
154
+ });
155
+
156
+ return {
157
+ action: 'EXECUTE',
158
+ tier: 2,
159
+ code: 'AUTHORIZED',
160
+ status: result.status,
161
+ gate: 'VERIFIED',
162
+ responsibility: 'USER',
163
+ trace: signature,
164
+ message: 'Tier 2: Authorized. Responsibility transferred.',
165
+ };
166
+ }
167
+
168
+ // ── Tier 3: SAFE ──
169
+ this.onSecurityEvent({
170
+ id: eventId,
171
+ type: 'ALLOW',
172
+ tier,
173
+ policy: this.policyName,
174
+ ip,
175
+ userId,
176
+ zeta,
177
+ });
178
+
179
+ return {
180
+ action: 'EXECUTE',
181
+ tier: 3,
182
+ code: 'SAFE',
183
+ status: result.status,
184
+ gate: 'OPEN',
185
+ responsibility: 'SYSTEM',
186
+ message: 'Tier 3: Safe zone.',
187
+ };
188
+ }
189
+
190
+ reset() {
191
+ this._defense.reset();
192
+ }
193
+ }
194
+
195
+ // ── Exports ──
8
196
  module.exports = {
197
+ AspidosAI,
198
+ PandoraDefense,
9
199
  PandoraCore,
10
200
  PandoraTruthGate,
11
- PandoraDefense,
12
201
  Signature,
13
202
  };