holosphere 2.0.0-alpha1 → 2.0.0-alpha4
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/2019-D2OG2idw.js +6680 -0
- package/dist/2019-D2OG2idw.js.map +1 -0
- package/dist/2019-EION3wKo.cjs +8 -0
- package/dist/2019-EION3wKo.cjs.map +1 -0
- package/dist/_commonjsHelpers-C37NGDzP.cjs +2 -0
- package/dist/_commonjsHelpers-C37NGDzP.cjs.map +1 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +7 -0
- package/dist/_commonjsHelpers-CUmg6egw.js.map +1 -0
- package/dist/browser-BSniCNqO.js +3058 -0
- package/dist/browser-BSniCNqO.js.map +1 -0
- package/dist/browser-Cq59Ij19.cjs +2 -0
- package/dist/browser-Cq59Ij19.cjs.map +1 -0
- package/dist/cjs/holosphere.cjs +2 -0
- package/dist/cjs/holosphere.cjs.map +1 -0
- package/dist/esm/holosphere.js +53 -0
- package/dist/esm/holosphere.js.map +1 -0
- package/dist/index-BB_vVJgv.cjs +5 -0
- package/dist/index-BB_vVJgv.cjs.map +1 -0
- package/dist/index-CBitK71M.cjs +12 -0
- package/dist/index-CBitK71M.cjs.map +1 -0
- package/dist/index-CV0eOogK.js +37423 -0
- package/dist/index-CV0eOogK.js.map +1 -0
- package/dist/index-Cz-PLCUR.js +15104 -0
- package/dist/index-Cz-PLCUR.js.map +1 -0
- package/dist/indexeddb-storage-CRsZyB2f.cjs +2 -0
- package/dist/indexeddb-storage-CRsZyB2f.cjs.map +1 -0
- package/dist/indexeddb-storage-DZaGlY_a.js +132 -0
- package/dist/indexeddb-storage-DZaGlY_a.js.map +1 -0
- package/dist/memory-storage-BkUi6sZG.js +51 -0
- package/dist/memory-storage-BkUi6sZG.js.map +1 -0
- package/dist/memory-storage-C0DuUsdY.cjs +2 -0
- package/dist/memory-storage-C0DuUsdY.cjs.map +1 -0
- package/dist/secp256k1-0kPdAVkK.cjs +12 -0
- package/dist/secp256k1-0kPdAVkK.cjs.map +1 -0
- package/dist/secp256k1-DN4FVXcv.js +1890 -0
- package/dist/secp256k1-DN4FVXcv.js.map +1 -0
- package/docs/CONTRACTS.md +797 -0
- package/docs/FOSDEM_PROPOSAL.md +388 -0
- package/docs/LOCALFIRST.md +266 -0
- package/docs/contracts/api-interface.md +793 -0
- package/docs/data-model.md +476 -0
- package/docs/gun-async-usage.md +338 -0
- package/docs/plan.md +349 -0
- package/docs/quickstart.md +674 -0
- package/docs/research.md +362 -0
- package/docs/spec.md +244 -0
- package/docs/storage-backends.md +326 -0
- package/docs/tasks.md +947 -0
- package/examples/demo.html +47 -0
- package/package.json +10 -5
- package/src/contracts/abis/Appreciative.json +1280 -0
- package/src/contracts/abis/AppreciativeFactory.json +101 -0
- package/src/contracts/abis/Bundle.json +1435 -0
- package/src/contracts/abis/BundleFactory.json +106 -0
- package/src/contracts/abis/Holon.json +881 -0
- package/src/contracts/abis/Holons.json +330 -0
- package/src/contracts/abis/Managed.json +1262 -0
- package/src/contracts/abis/ManagedFactory.json +149 -0
- package/src/contracts/abis/Membrane.json +261 -0
- package/src/contracts/abis/Splitter.json +1624 -0
- package/src/contracts/abis/SplitterFactory.json +220 -0
- package/src/contracts/abis/TestToken.json +321 -0
- package/src/contracts/abis/Zoned.json +1461 -0
- package/src/contracts/abis/ZonedFactory.json +154 -0
- package/src/contracts/chain-manager.js +375 -0
- package/src/contracts/deployer.js +443 -0
- package/src/contracts/event-listener.js +507 -0
- package/src/contracts/holon-contracts.js +344 -0
- package/src/contracts/index.js +83 -0
- package/src/contracts/networks.js +224 -0
- package/src/contracts/operations.js +670 -0
- package/src/contracts/queries.js +589 -0
- package/src/core/holosphere.js +453 -1
- package/src/crypto/nostr-utils.js +263 -0
- package/src/federation/handshake.js +455 -0
- package/src/federation/hologram.js +1 -1
- package/src/hierarchical/upcast.js +6 -5
- package/src/index.js +463 -1939
- package/src/lib/ai-methods.js +308 -0
- package/src/lib/contract-methods.js +293 -0
- package/src/lib/errors.js +23 -0
- package/src/lib/federation-methods.js +238 -0
- package/src/lib/index.js +26 -0
- package/src/spatial/h3-operations.js +2 -2
- package/src/storage/backends/gundb-backend.js +377 -46
- package/src/storage/global-tables.js +28 -1
- package/src/storage/gun-auth.js +303 -0
- package/src/storage/gun-federation.js +776 -0
- package/src/storage/gun-references.js +198 -0
- package/src/storage/gun-schema.js +291 -0
- package/src/storage/gun-wrapper.js +347 -31
- package/src/storage/indexeddb-storage.js +49 -11
- package/src/storage/memory-storage.js +5 -0
- package/src/storage/nostr-async.js +45 -23
- package/src/storage/nostr-client.js +11 -5
- package/src/storage/persistent-storage.js +6 -1
- package/src/storage/unified-storage.js +119 -0
- package/src/subscriptions/manager.js +1 -1
- package/types/index.d.ts +133 -0
- package/tests/unit/ai/aggregation.test.js +0 -295
- package/tests/unit/ai/breakdown.test.js +0 -446
- package/tests/unit/ai/classifier.test.js +0 -294
- package/tests/unit/ai/council.test.js +0 -262
- package/tests/unit/ai/embeddings.test.js +0 -384
- package/tests/unit/ai/federation-ai.test.js +0 -344
- package/tests/unit/ai/h3-ai.test.js +0 -458
- package/tests/unit/ai/index.test.js +0 -304
- package/tests/unit/ai/json-ops.test.js +0 -307
- package/tests/unit/ai/llm-service.test.js +0 -390
- package/tests/unit/ai/nl-query.test.js +0 -383
- package/tests/unit/ai/relationships.test.js +0 -311
- package/tests/unit/ai/schema-extractor.test.js +0 -384
- package/tests/unit/ai/spatial.test.js +0 -279
- package/tests/unit/ai/tts.test.js +0 -279
- package/tests/unit/content.test.js +0 -332
- package/tests/unit/contract/core.test.js +0 -88
- package/tests/unit/contract/crypto.test.js +0 -198
- package/tests/unit/contract/data.test.js +0 -223
- package/tests/unit/contract/federation.test.js +0 -181
- package/tests/unit/contract/hierarchical.test.js +0 -113
- package/tests/unit/contract/schema.test.js +0 -114
- package/tests/unit/contract/social.test.js +0 -217
- package/tests/unit/contract/spatial.test.js +0 -110
- package/tests/unit/contract/subscriptions.test.js +0 -128
- package/tests/unit/contract/utils.test.js +0 -159
- package/tests/unit/core.test.js +0 -152
- package/tests/unit/crypto.test.js +0 -328
- package/tests/unit/federation.test.js +0 -234
- package/tests/unit/gun-async.test.js +0 -252
- package/tests/unit/hierarchical.test.js +0 -399
- package/tests/unit/integration/scenario-01-geographic-storage.test.js +0 -74
- package/tests/unit/integration/scenario-02-federation.test.js +0 -76
- package/tests/unit/integration/scenario-03-subscriptions.test.js +0 -102
- package/tests/unit/integration/scenario-04-validation.test.js +0 -129
- package/tests/unit/integration/scenario-05-hierarchy.test.js +0 -125
- package/tests/unit/integration/scenario-06-social.test.js +0 -135
- package/tests/unit/integration/scenario-07-persistence.test.js +0 -130
- package/tests/unit/integration/scenario-08-authorization.test.js +0 -161
- package/tests/unit/integration/scenario-09-cross-dimensional.test.js +0 -139
- package/tests/unit/integration/scenario-10-cross-holosphere-capabilities.test.js +0 -357
- package/tests/unit/integration/scenario-11-cross-holosphere-federation.test.js +0 -410
- package/tests/unit/integration/scenario-12-capability-federated-read.test.js +0 -719
- package/tests/unit/performance/benchmark.test.js +0 -85
- package/tests/unit/schema.test.js +0 -213
- package/tests/unit/spatial.test.js +0 -158
- package/tests/unit/storage.test.js +0 -195
- package/tests/unit/subscriptions.test.js +0 -328
- package/tests/unit/test-data-permanence-debug.js +0 -197
- package/tests/unit/test-data-permanence.js +0 -340
- package/tests/unit/test-key-persistence-fixed.js +0 -148
- package/tests/unit/test-key-persistence.js +0 -172
- package/tests/unit/test-relay-permanence.js +0 -376
- package/tests/unit/test-second-node.js +0 -95
- package/tests/unit/test-simple-write.js +0 -89
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Methods Mixin
|
|
3
|
+
* All AI-powered operations for HoloSphere
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Mixin that adds AI methods to a HoloSphere class
|
|
8
|
+
* @param {Class} Base - Base class to extend
|
|
9
|
+
* @returns {Class} Extended class with AI methods
|
|
10
|
+
*/
|
|
11
|
+
export function withAIMethods(Base) {
|
|
12
|
+
return class extends Base {
|
|
13
|
+
_requireAI() {
|
|
14
|
+
if (!this._ai) {
|
|
15
|
+
throw new Error('AI services not initialized. Provide openaiKey in config.');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// --- Core LLM Methods ---
|
|
20
|
+
|
|
21
|
+
async summarize(text, options = {}) {
|
|
22
|
+
this._requireAI();
|
|
23
|
+
return this._ai.llm.summarize(text, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async analyze(text, aspect, options = {}) {
|
|
27
|
+
this._requireAI();
|
|
28
|
+
return this._ai.llm.analyze(text, aspect, options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async extractKeywords(text, options = {}) {
|
|
32
|
+
this._requireAI();
|
|
33
|
+
return this._ai.llm.extractKeywords(text, options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async categorize(text, categories, options = {}) {
|
|
37
|
+
this._requireAI();
|
|
38
|
+
return this._ai.llm.categorize(text, categories, options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async translate(text, targetLanguage, options = {}) {
|
|
42
|
+
this._requireAI();
|
|
43
|
+
return this._ai.llm.translate(text, targetLanguage, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async generateQuestions(text, options = {}) {
|
|
47
|
+
this._requireAI();
|
|
48
|
+
return this._ai.llm.generateQuestions(text, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// --- Schema Extraction ---
|
|
52
|
+
|
|
53
|
+
async extractToSchema(text, lensName, options = {}) {
|
|
54
|
+
this._requireAI();
|
|
55
|
+
const schemaObj = await this.getSchema(lensName);
|
|
56
|
+
if (!schemaObj) {
|
|
57
|
+
throw new Error(`No schema found for lens: ${lensName}`);
|
|
58
|
+
}
|
|
59
|
+
return this._ai.schemaExtractor.extractToSchema(text, schemaObj, options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- Fuzzy JSON Operations ---
|
|
63
|
+
|
|
64
|
+
async jsonAdd(obj1, obj2, options = {}) {
|
|
65
|
+
this._requireAI();
|
|
66
|
+
return this._ai.jsonOps.add(obj1, obj2, options);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async jsonSubtract(obj1, obj2, options = {}) {
|
|
70
|
+
this._requireAI();
|
|
71
|
+
return this._ai.jsonOps.subtract(obj1, obj2, options);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async jsonUnion(obj1, obj2, options = {}) {
|
|
75
|
+
this._requireAI();
|
|
76
|
+
return this._ai.jsonOps.union(obj1, obj2, options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async jsonDifference(obj1, obj2, options = {}) {
|
|
80
|
+
this._requireAI();
|
|
81
|
+
return this._ai.jsonOps.difference(obj1, obj2, options);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async jsonConcatenate(obj1, obj2, options = {}) {
|
|
85
|
+
this._requireAI();
|
|
86
|
+
return this._ai.jsonOps.concatenate(obj1, obj2, options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// --- Embeddings & Semantic Search ---
|
|
90
|
+
|
|
91
|
+
async embed(text) {
|
|
92
|
+
this._requireAI();
|
|
93
|
+
return this._ai.embeddings.embed(text);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async semanticSearch(query, holonId, lensName, options = {}) {
|
|
97
|
+
this._requireAI();
|
|
98
|
+
return this._ai.embeddings.semanticSearch(query, holonId, lensName, options);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async storeWithEmbedding(holonId, lensName, data, textField = 'description') {
|
|
102
|
+
this._requireAI();
|
|
103
|
+
return this._ai.embeddings.storeWithEmbedding(holonId, lensName, data, textField);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// --- Multi-Perspective Council ---
|
|
107
|
+
|
|
108
|
+
async askCouncil(question, options = {}) {
|
|
109
|
+
this._requireAI();
|
|
110
|
+
return this._ai.council.ask(question, options);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async askCouncilCustom(question, perspectives, options = {}) {
|
|
114
|
+
this._requireAI();
|
|
115
|
+
return this._ai.council.askCustom(question, perspectives, options);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// --- Text-to-Speech ---
|
|
119
|
+
|
|
120
|
+
async textToSpeech(text, voice = 'nova', options = {}) {
|
|
121
|
+
this._requireAI();
|
|
122
|
+
return this._ai.tts.speak(text, voice, options);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async textToSpeechBase64(text, voice = 'nova', options = {}) {
|
|
126
|
+
this._requireAI();
|
|
127
|
+
return this._ai.tts.speakBase64(text, voice, options);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --- Natural Language Queries ---
|
|
131
|
+
|
|
132
|
+
async nlQuery(query, holonId = null, lensName = null, options = {}) {
|
|
133
|
+
this._requireAI();
|
|
134
|
+
return this._ai.nlQuery.execute(query, holonId, lensName, options);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async parseNLQuery(query) {
|
|
138
|
+
this._requireAI();
|
|
139
|
+
return this._ai.nlQuery.parse(query);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// --- Auto-Classification ---
|
|
143
|
+
|
|
144
|
+
async classifyToLens(content, options = {}) {
|
|
145
|
+
this._requireAI();
|
|
146
|
+
return this._ai.classifier.classifyToLens(content, options);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async autoStore(holonId, content, options = {}) {
|
|
150
|
+
this._requireAI();
|
|
151
|
+
return this._ai.classifier.autoStore(holonId, content, options);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
registerLensForClassification(lensName, description, keywords = []) {
|
|
155
|
+
this._requireAI();
|
|
156
|
+
this._ai.classifier.registerLens(lensName, description, keywords);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// --- Spatial Analysis ---
|
|
160
|
+
|
|
161
|
+
async analyzeRegion(holonId, lensName = null, aspect = null, options = {}) {
|
|
162
|
+
this._requireAI();
|
|
163
|
+
return this._ai.spatial.analyzeRegion(holonId, lensName, aspect, options);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async compareRegions(holon1, holon2, lensName = null) {
|
|
167
|
+
this._requireAI();
|
|
168
|
+
return this._ai.spatial.compareRegions(holon1, holon2, lensName);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async spatialTrends(holonId, lensName, timeRange = null) {
|
|
172
|
+
this._requireAI();
|
|
173
|
+
return this._ai.spatial.spatialTrends(holonId, lensName, timeRange);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// --- Smart Aggregation ---
|
|
177
|
+
|
|
178
|
+
async smartUpcast(holonId, lensName, options = {}) {
|
|
179
|
+
this._requireAI();
|
|
180
|
+
return this._ai.aggregation.smartUpcast(holonId, lensName, options);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async generateHolonSummary(holonId) {
|
|
184
|
+
this._requireAI();
|
|
185
|
+
return this._ai.aggregation.generateHolonSummary(holonId);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// --- Federation Advisor ---
|
|
189
|
+
|
|
190
|
+
async suggestFederations(holonId, options = {}) {
|
|
191
|
+
this._requireAI();
|
|
192
|
+
return this._ai.federationAdvisor.suggestFederations(holonId, options);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async analyzeFederationHealth(holonId) {
|
|
196
|
+
this._requireAI();
|
|
197
|
+
return this._ai.federationAdvisor.analyzeFederationHealth(holonId);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async optimizeFederation(holonId) {
|
|
201
|
+
this._requireAI();
|
|
202
|
+
return this._ai.federationAdvisor.optimizeFederation(holonId);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// --- Relationship Discovery ---
|
|
206
|
+
|
|
207
|
+
async discoverRelationships(holonId, lensName = null) {
|
|
208
|
+
this._requireAI();
|
|
209
|
+
return this._ai.relationships.discoverRelationships(holonId, lensName);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async findSimilar(item, holonId, lensName = null, options = {}) {
|
|
213
|
+
this._requireAI();
|
|
214
|
+
return this._ai.relationships.findSimilar(item, holonId, lensName, options);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async buildRelationshipGraph(holonId, lensName) {
|
|
218
|
+
this._requireAI();
|
|
219
|
+
return this._ai.relationships.buildGraph(holonId, lensName);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async suggestConnections(item, holonId, lensName) {
|
|
223
|
+
this._requireAI();
|
|
224
|
+
return this._ai.relationships.suggestConnections(item, holonId, lensName);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// --- Task Breakdown ---
|
|
228
|
+
|
|
229
|
+
async breakdown(item, holonId, lensName, options = {}) {
|
|
230
|
+
this._requireAI();
|
|
231
|
+
return this._ai.taskBreakdown.breakdown(item, holonId, lensName, options);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async suggestBreakdownStrategy(item) {
|
|
235
|
+
this._requireAI();
|
|
236
|
+
return this._ai.taskBreakdown.suggestStrategy(item);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
flattenBreakdown(breakdownResult) {
|
|
240
|
+
this._requireAI();
|
|
241
|
+
return this._ai.taskBreakdown.flatten(breakdownResult);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
getBreakdownDependencyOrder(breakdownResult) {
|
|
245
|
+
this._requireAI();
|
|
246
|
+
return this._ai.taskBreakdown.getDependencyOrder(breakdownResult);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async getBreakdownProgress(holonId, lensName, itemId) {
|
|
250
|
+
this._requireAI();
|
|
251
|
+
return this._ai.taskBreakdown.getProgress(holonId, lensName, itemId);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// --- H3 Geospatial AI ---
|
|
255
|
+
|
|
256
|
+
async suggestH3Resolution(item, options = {}) {
|
|
257
|
+
this._requireAI();
|
|
258
|
+
return this._ai.h3ai.suggestResolution(item, options);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async analyzeH3Distribution(holonId, lensName, options = {}) {
|
|
262
|
+
this._requireAI();
|
|
263
|
+
return this._ai.h3ai.analyzeDistribution(holonId, lensName, options);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async findH3NeighborRelevance(holonId, lensName, options = {}) {
|
|
267
|
+
this._requireAI();
|
|
268
|
+
return this._ai.h3ai.findNeighborRelevance(holonId, lensName, options);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async suggestGeographicScope(item, holonId, lensName, options = {}) {
|
|
272
|
+
this._requireAI();
|
|
273
|
+
return this._ai.h3ai.suggestGeographicScope(item, holonId, lensName, options);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async analyzeH3Coverage(holonId, lensName, options = {}) {
|
|
277
|
+
this._requireAI();
|
|
278
|
+
return this._ai.h3ai.analyzeCoverage(holonId, lensName, options);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async crossH3ResolutionInsights(holonId, lensName, options = {}) {
|
|
282
|
+
this._requireAI();
|
|
283
|
+
return this._ai.h3ai.crossResolutionInsights(holonId, lensName, options);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async suggestH3Migration(item, holonId, lensName, options = {}) {
|
|
287
|
+
this._requireAI();
|
|
288
|
+
return this._ai.h3ai.suggestMigration(item, holonId, lensName, options);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async generateH3Report(holonId, options = {}) {
|
|
292
|
+
this._requireAI();
|
|
293
|
+
return this._ai.h3ai.generateGeographicReport(holonId, options);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async findH3Clusters(holonId, lensName, options = {}) {
|
|
297
|
+
this._requireAI();
|
|
298
|
+
return this._ai.h3ai.findGeographicClusters(holonId, lensName, options);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async analyzeH3Impact(item, holonId, lensName, options = {}) {
|
|
302
|
+
this._requireAI();
|
|
303
|
+
return this._ai.h3ai.analyzeGeographicImpact(item, holonId, lensName, options);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export default withAIMethods;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Methods Mixin
|
|
3
|
+
* All blockchain contract operations for HoloSphere
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ChainManager } from '../contracts/chain-manager.js';
|
|
7
|
+
import { ContractDeployer } from '../contracts/deployer.js';
|
|
8
|
+
import { HolonContracts } from '../contracts/holon-contracts.js';
|
|
9
|
+
import * as networks from '../contracts/networks.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mixin that adds contract methods to a HoloSphere class
|
|
13
|
+
* @param {Class} Base - Base class to extend
|
|
14
|
+
* @returns {Class} Extended class with contract methods
|
|
15
|
+
*/
|
|
16
|
+
export function withContractMethods(Base) {
|
|
17
|
+
return class extends Base {
|
|
18
|
+
hasContracts() {
|
|
19
|
+
return this._contracts !== null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_requireContracts() {
|
|
23
|
+
if (!this._contracts) {
|
|
24
|
+
throw new Error('Contracts not initialized. Call initContracts() first.');
|
|
25
|
+
}
|
|
26
|
+
return this._contracts;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async initContracts(config) {
|
|
30
|
+
const chainManager = new ChainManager(config);
|
|
31
|
+
const connectionInfo = await chainManager.connect(
|
|
32
|
+
config.network,
|
|
33
|
+
config.privateKey,
|
|
34
|
+
config.rpcUrl
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const deployer = new ContractDeployer(chainManager);
|
|
38
|
+
const holonContracts = new HolonContracts(chainManager, deployer);
|
|
39
|
+
|
|
40
|
+
this._contracts = {
|
|
41
|
+
chainManager,
|
|
42
|
+
deployer,
|
|
43
|
+
holonContracts,
|
|
44
|
+
network: config.network
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
...connectionInfo,
|
|
49
|
+
address: config.privateKey ? await chainManager.getAddress() : null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async initContractsBrowser(network) {
|
|
54
|
+
const chainManager = new ChainManager();
|
|
55
|
+
const connectionInfo = await chainManager.connectBrowser(network);
|
|
56
|
+
|
|
57
|
+
const deployer = new ContractDeployer(chainManager);
|
|
58
|
+
const holonContracts = new HolonContracts(chainManager, deployer);
|
|
59
|
+
|
|
60
|
+
this._contracts = {
|
|
61
|
+
chainManager,
|
|
62
|
+
deployer,
|
|
63
|
+
holonContracts,
|
|
64
|
+
network: chainManager.networkName
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return connectionInfo;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async deployContracts(options = {}) {
|
|
71
|
+
const { deployer } = this._requireContracts();
|
|
72
|
+
return deployer.deployAll(options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
loadDeployedContracts(addresses) {
|
|
76
|
+
const { deployer } = this._requireContracts();
|
|
77
|
+
deployer.loadDeployedAddresses(addresses);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getDeployedContracts() {
|
|
81
|
+
const { deployer } = this._requireContracts();
|
|
82
|
+
return deployer.getDeployedAddresses();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async deployHolonContract(holonId, type = 'Splitter', options = {}) {
|
|
86
|
+
const { holonContracts } = this._requireContracts();
|
|
87
|
+
return holonContracts.deploy(holonId, type, options);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async linkHolonContract(holonId, contractAddress, type = 'Splitter') {
|
|
91
|
+
const { holonContracts } = this._requireContracts();
|
|
92
|
+
return holonContracts.link(holonId, contractAddress, type);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async unlinkHolonContract(holonId) {
|
|
96
|
+
const { holonContracts } = this._requireContracts();
|
|
97
|
+
return holonContracts.unlink(holonId);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getHolonContract(holonId) {
|
|
101
|
+
if (!this._contracts) return null;
|
|
102
|
+
return this._contracts.holonContracts.getContract(holonId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getHolonContractAddress(holonId) {
|
|
106
|
+
if (!this._contracts) return null;
|
|
107
|
+
return this._contracts.holonContracts.getAddress(holonId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
hasHolonContract(holonId) {
|
|
111
|
+
if (!this._contracts) return false;
|
|
112
|
+
return this._contracts.holonContracts.hasContract(holonId);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
listHolonContracts() {
|
|
116
|
+
if (!this._contracts) return [];
|
|
117
|
+
return this._contracts.holonContracts.listAll();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getHolonOperations(holonId) {
|
|
121
|
+
const { holonContracts } = this._requireContracts();
|
|
122
|
+
return holonContracts.requireOperations(holonId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ========== MEMBER MANAGEMENT ==========
|
|
126
|
+
|
|
127
|
+
async contractAddMember(holonId, userId) {
|
|
128
|
+
return this.getHolonOperations(holonId).addMember(userId);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async contractAddMembers(holonId, userIds) {
|
|
132
|
+
return this.getHolonOperations(holonId).addMembers(userIds);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async contractIsMember(holonId, userId) {
|
|
136
|
+
return this.getHolonOperations(holonId).isMember(userId);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ========== FUND DISTRIBUTION ==========
|
|
140
|
+
|
|
141
|
+
async contractReward(holonId, tokenAddress, amount) {
|
|
142
|
+
return this.getHolonOperations(holonId).reward(tokenAddress, amount);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async contractRewardEth(holonId, amount) {
|
|
146
|
+
return this.getHolonOperations(holonId).rewardEth(amount);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async contractSendEth(holonId, amount) {
|
|
150
|
+
return this.getHolonOperations(holonId).sendEth(amount);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async contractClaim(holonId, userId, beneficiaryAddress) {
|
|
154
|
+
return this.getHolonOperations(holonId).claim(userId, beneficiaryAddress);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async contractGetEthBalance(holonId, userId) {
|
|
158
|
+
return this.getHolonOperations(holonId).getEthBalance(userId);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async contractGetTokenBalance(holonId, userId, tokenAddress) {
|
|
162
|
+
return this.getHolonOperations(holonId).getTokenBalance(userId, tokenAddress);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ========== SPLITTER OPERATIONS ==========
|
|
166
|
+
|
|
167
|
+
async contractSetSplit(holonId, internalPct, externalPct) {
|
|
168
|
+
return this.getHolonOperations(holonId).setContractSplit(internalPct, externalPct);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async contractGetSplit(holonId) {
|
|
172
|
+
return this.getHolonOperations(holonId).getContractSplit();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async contractCreateManaged(holonId, creatorUserId, name) {
|
|
176
|
+
return this.getHolonOperations(holonId).createManagedContract(creatorUserId, name);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async contractCreateZoned(holonId, creatorUserId, name, nZones = 6) {
|
|
180
|
+
return this.getHolonOperations(holonId).createZonedContract(creatorUserId, name, nZones);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async contractGetChildContracts(holonId) {
|
|
184
|
+
return this.getHolonOperations(holonId).getChildContracts();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ========== MANAGED OPERATIONS ==========
|
|
188
|
+
|
|
189
|
+
async contractSetAppreciation(holonId, userIds, amounts) {
|
|
190
|
+
return this.getHolonOperations(holonId).setAppreciation(userIds, amounts);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async contractGetAppreciation(holonId, userId) {
|
|
194
|
+
return this.getHolonOperations(holonId).getAppreciation(userId);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async contractGetTotalAppreciation(holonId) {
|
|
198
|
+
return this.getHolonOperations(holonId).getTotalAppreciation();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ========== ZONED OPERATIONS ==========
|
|
202
|
+
|
|
203
|
+
async contractAddToZone(holonId, senderUserId, userId, zone) {
|
|
204
|
+
return this.getHolonOperations(holonId).addToZone(senderUserId, userId, zone);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async contractRemoveFromZone(holonId, senderUserId, userId) {
|
|
208
|
+
return this.getHolonOperations(holonId).removeFromZone(senderUserId, userId);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async contractGetZone(holonId, userId) {
|
|
212
|
+
return this.getHolonOperations(holonId).getZone(userId);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async contractSetZoneParams(holonId, senderUserId, a, b, c) {
|
|
216
|
+
return this.getHolonOperations(holonId).setZoneParameters(senderUserId, a, b, c);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ========== APPRECIATIVE OPERATIONS ==========
|
|
220
|
+
|
|
221
|
+
async contractAppreciate(holonId, fromUserId, toUserId, amount) {
|
|
222
|
+
return this.getHolonOperations(holonId).appreciate(fromUserId, toUserId, amount);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async contractGetAppreciationGiven(holonId, userId) {
|
|
226
|
+
return this.getHolonOperations(holonId).getAppreciationGiven(userId);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async contractGetAppreciationReceived(holonId, userId) {
|
|
230
|
+
return this.getHolonOperations(holonId).getAppreciationReceived(userId);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ========== BUNDLE OPERATIONS ==========
|
|
234
|
+
|
|
235
|
+
async contractSetSteepness(holonId, steepness) {
|
|
236
|
+
return this.getHolonOperations(holonId).setSteepness(steepness);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async contractGetSteepness(holonId) {
|
|
240
|
+
return this.getHolonOperations(holonId).getSteepness();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async contractSetInteriorSplit(holonId, userIds, percentages) {
|
|
244
|
+
return this.getHolonOperations(holonId).setInteriorSplit(userIds, percentages);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ========== GOVERNANCE ==========
|
|
248
|
+
|
|
249
|
+
async contractStartElection(holonId) {
|
|
250
|
+
return this.getHolonOperations(holonId).startElection();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async contractNominate(holonId) {
|
|
254
|
+
return this.getHolonOperations(holonId).nominateSelf();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async contractVote(holonId, nomineeAddress) {
|
|
258
|
+
return this.getHolonOperations(holonId).vote(nomineeAddress);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async contractFinalizeElection(holonId) {
|
|
262
|
+
return this.getHolonOperations(holonId).finalizeElection();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ========== READ-ONLY QUERIES ==========
|
|
266
|
+
|
|
267
|
+
async contractGetName(holonId) {
|
|
268
|
+
return this.getHolonOperations(holonId).getName();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async contractGetOwner(holonId) {
|
|
272
|
+
return this.getHolonOperations(holonId).getOwner();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async contractGetBotAddress(holonId) {
|
|
276
|
+
return this.getHolonOperations(holonId).getBotAddress();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async contractGetTotalDeposited(holonId, tokenAddress) {
|
|
280
|
+
return this.getHolonOperations(holonId).getTotalDeposited(tokenAddress);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
getNetworkUtils() {
|
|
284
|
+
return networks;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getChainManager() {
|
|
288
|
+
return this._contracts?.chainManager || null;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export default withContractMethods;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HoloSphere Error Classes
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export class AuthorizationError extends Error {
|
|
6
|
+
constructor(message, requiredPermission = null) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'AuthorizationError';
|
|
9
|
+
this.requiredPermission = requiredPermission;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ValidationError extends Error {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'ValidationError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
AuthorizationError,
|
|
22
|
+
ValidationError
|
|
23
|
+
};
|