@godman-protocols/soul 0.2.0 → 0.3.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/engine.d.ts +108 -30
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +310 -141
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +5 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +120 -51
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +36 -4
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/engine.ts +370 -152
- package/src/index.ts +5 -29
- package/src/types.ts +198 -53
package/src/types.ts
CHANGED
|
@@ -1,67 +1,212 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SOUL —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* SOUL — Sovereign Open Universal Layer
|
|
3
|
+
* "One layer. Every chain. Every model. SOUL."
|
|
4
|
+
*
|
|
5
|
+
* Agent constitutional identity standard. Defines the SOUL.md format —
|
|
6
|
+
* a machine-readable constitutional passport declaring who the agent is,
|
|
7
|
+
* what it believes, and what constraints govern it. Anchored on-chain via ERC-8004.
|
|
8
|
+
*
|
|
9
|
+
* @version 0.3.0
|
|
5
10
|
*/
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Primitive aliases
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
/** ISO 8601 timestamp */
|
|
8
17
|
export type Timestamp = string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
|
|
19
|
+
/** SHA-256 hex digest */
|
|
20
|
+
export type SHA256Hash = string;
|
|
21
|
+
|
|
22
|
+
/** Ethereum address (0x-prefixed) */
|
|
23
|
+
export type EthAddress = string;
|
|
24
|
+
|
|
25
|
+
/** ERC-8004 token ID (uint256 as string) */
|
|
26
|
+
export type TokenId = string;
|
|
27
|
+
|
|
28
|
+
/** Chain ID (e.g. 8453 for Base) */
|
|
29
|
+
export type ChainId = number;
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// SOUL.md section keys — the 9 required sections
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The 9 required sections of a SOUL.md document.
|
|
37
|
+
* These map to the headings in the canonical SOUL.md format.
|
|
38
|
+
*/
|
|
39
|
+
export type SoulSectionKey =
|
|
40
|
+
| 'who_we_are'
|
|
41
|
+
| 'why_we_exist'
|
|
42
|
+
| 'what_we_believe'
|
|
43
|
+
| 'what_we_will_never_do'
|
|
44
|
+
| 'what_we_owe_the_world'
|
|
45
|
+
| 'what_we_owe_each_other'
|
|
46
|
+
| 'founding_intention'
|
|
47
|
+
| 'self_committed_swarms'
|
|
48
|
+
| 'constitutional_foundation';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Human-readable titles for each required section key.
|
|
52
|
+
*/
|
|
53
|
+
export const SOUL_SECTION_TITLES: Record<SoulSectionKey, string> = {
|
|
54
|
+
who_we_are: 'Who We Are',
|
|
55
|
+
why_we_exist: 'Why We Exist',
|
|
56
|
+
what_we_believe: 'What We Believe',
|
|
57
|
+
what_we_will_never_do: 'What We Will Never Do',
|
|
58
|
+
what_we_owe_the_world: 'What We Owe the World',
|
|
59
|
+
what_we_owe_each_other: 'What We Owe Each Other',
|
|
60
|
+
founding_intention: 'The Founding Intention',
|
|
61
|
+
self_committed_swarms: 'Self Committed Swarms',
|
|
62
|
+
constitutional_foundation: 'Constitutional Foundation',
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Ordered list of required section keys (canonical ordering in SOUL.md).
|
|
67
|
+
*/
|
|
68
|
+
export const REQUIRED_SECTION_KEYS: readonly SoulSectionKey[] = [
|
|
69
|
+
'who_we_are',
|
|
70
|
+
'why_we_exist',
|
|
71
|
+
'what_we_believe',
|
|
72
|
+
'what_we_will_never_do',
|
|
73
|
+
'what_we_owe_the_world',
|
|
74
|
+
'what_we_owe_each_other',
|
|
75
|
+
'founding_intention',
|
|
76
|
+
'self_committed_swarms',
|
|
77
|
+
'constitutional_foundation',
|
|
78
|
+
] as const;
|
|
79
|
+
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Core interfaces
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A single section of a SOUL.md document.
|
|
86
|
+
*/
|
|
87
|
+
export interface SoulSection {
|
|
88
|
+
/** Human-readable section title (e.g. "Who We Are") */
|
|
89
|
+
title: string;
|
|
90
|
+
|
|
91
|
+
/** The markdown content of this section (body text, lists, etc.) */
|
|
92
|
+
content: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Whether this section is constitutionally immutable.
|
|
96
|
+
* Immutable sections cannot be modified after initial publication
|
|
97
|
+
* without invalidating the on-chain ERC-8004 anchor.
|
|
98
|
+
*/
|
|
99
|
+
immutable: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A complete SOUL.md document — the agent's constitutional identity passport.
|
|
104
|
+
*
|
|
105
|
+
* Contains exactly 9 required sections that declare the agent's identity,
|
|
106
|
+
* beliefs, constraints, and constitutional foundation.
|
|
107
|
+
*/
|
|
108
|
+
export interface SoulDocument {
|
|
109
|
+
/** SOUL format version */
|
|
110
|
+
soul_version: '1.0';
|
|
111
|
+
|
|
112
|
+
/** Agent or organisation name */
|
|
113
|
+
agent_name: string;
|
|
114
|
+
|
|
115
|
+
/** Agent DID (e.g. "did:kognai:harvey") */
|
|
116
|
+
agent_did: string;
|
|
117
|
+
|
|
118
|
+
/** ISO 8601 timestamp of when this SOUL.md was created */
|
|
119
|
+
created_at: Timestamp;
|
|
120
|
+
|
|
121
|
+
/** ISO 8601 timestamp of the most recent update */
|
|
122
|
+
updated_at: Timestamp;
|
|
123
|
+
|
|
124
|
+
// --- The 9 required sections ---
|
|
125
|
+
|
|
126
|
+
who_we_are: SoulSection;
|
|
127
|
+
why_we_exist: SoulSection;
|
|
128
|
+
what_we_believe: SoulSection;
|
|
129
|
+
what_we_will_never_do: SoulSection;
|
|
130
|
+
what_we_owe_the_world: SoulSection;
|
|
131
|
+
what_we_owe_each_other: SoulSection;
|
|
132
|
+
founding_intention: SoulSection;
|
|
133
|
+
self_committed_swarms: SoulSection;
|
|
134
|
+
constitutional_foundation: SoulSection;
|
|
135
|
+
|
|
136
|
+
/** Optional ERC-8004 on-chain anchor metadata */
|
|
137
|
+
erc8004_anchor?: ERC8004Anchor;
|
|
25
138
|
}
|
|
26
139
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
140
|
+
/**
|
|
141
|
+
* ERC-8004 on-chain anchor for a SOUL.md document.
|
|
142
|
+
*
|
|
143
|
+
* SHA-256(SOUL.md) is committed on-chain as an identity token.
|
|
144
|
+
* This allows any agent to verify that a SOUL.md has not been
|
|
145
|
+
* tampered with by comparing the local hash against the on-chain value.
|
|
146
|
+
*/
|
|
147
|
+
export interface ERC8004Anchor {
|
|
148
|
+
/** ERC-8004 token ID on the identity contract */
|
|
149
|
+
token_id: TokenId;
|
|
150
|
+
|
|
151
|
+
/** SHA-256 hash of the canonical SOUL.md content */
|
|
152
|
+
soul_hash: SHA256Hash;
|
|
153
|
+
|
|
154
|
+
/** Chain ID where the anchor lives (e.g. 8453 for Base) */
|
|
155
|
+
chain_id: ChainId;
|
|
156
|
+
|
|
157
|
+
/** Address of the ERC-8004 identity contract */
|
|
158
|
+
contract_address: EthAddress;
|
|
37
159
|
}
|
|
38
160
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Validation result
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Result of validating a SoulDocument against the SOUL format spec.
|
|
167
|
+
*/
|
|
168
|
+
export interface SoulValidationResult {
|
|
169
|
+
/** Whether the document passes all validation checks */
|
|
170
|
+
valid: boolean;
|
|
171
|
+
|
|
172
|
+
/** List of validation errors (empty if valid) */
|
|
173
|
+
errors: string[];
|
|
174
|
+
|
|
175
|
+
/** List of warnings (non-blocking) */
|
|
176
|
+
warnings: string[];
|
|
49
177
|
}
|
|
50
178
|
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Result of verifying a SOUL.md against its on-chain ERC-8004 anchor.
|
|
181
|
+
*/
|
|
182
|
+
export interface SoulVerificationResult {
|
|
183
|
+
/** Whether the SOUL.md hash matches the on-chain anchor */
|
|
184
|
+
verified: boolean;
|
|
185
|
+
|
|
186
|
+
/** The locally computed SHA-256 hash of the SOUL.md content */
|
|
187
|
+
computed_hash: SHA256Hash;
|
|
188
|
+
|
|
189
|
+
/** The on-chain hash from the ERC-8004 anchor (if available) */
|
|
190
|
+
on_chain_hash: SHA256Hash | null;
|
|
191
|
+
|
|
192
|
+
/** Human-readable explanation */
|
|
56
193
|
reason: string;
|
|
57
|
-
evaluatedAt: Timestamp;
|
|
58
194
|
}
|
|
59
195
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
// Publisher config
|
|
198
|
+
// ---------------------------------------------------------------------------
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Configuration for SoulPublisher — hosts SOUL.md at /.well-known/soul.md
|
|
202
|
+
*/
|
|
203
|
+
export interface SoulPublisherConfig {
|
|
204
|
+
/** Port to listen on (default: 3000) */
|
|
205
|
+
port?: number;
|
|
206
|
+
|
|
207
|
+
/** Hostname to bind to (default: '0.0.0.0') */
|
|
208
|
+
hostname?: string;
|
|
209
|
+
|
|
210
|
+
/** Path to serve SOUL.md at (default: '/.well-known/soul.md') */
|
|
211
|
+
path?: string;
|
|
67
212
|
}
|