holosphere 2.0.0-alpha0 → 2.0.0-alpha10
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/CHANGELOG.md +473 -0
- package/FEATURES.md +431 -0
- package/LICENSE +29 -42
- package/LICENSE-AGPL.md +180 -0
- package/README.md +97 -16
- 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/cdn/holosphere.min.js +55 -0
- package/dist/cdn/holosphere.min.js.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-DDGt_V9o.cjs +12 -0
- package/dist/index-DDGt_V9o.cjs.map +1 -0
- package/dist/index-DJXftyvB.js +39841 -0
- package/dist/index-DJXftyvB.js.map +1 -0
- package/dist/index-DMbdcMtK.cjs +18 -0
- package/dist/index-DMbdcMtK.cjs.map +1 -0
- package/dist/index-DeZ1xz_s.js +15104 -0
- package/dist/index-DeZ1xz_s.js.map +1 -0
- package/dist/indexeddb-storage-BFt6hMeF.js +176 -0
- package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
- package/dist/indexeddb-storage-BK5tv4Sh.cjs +2 -0
- package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
- package/dist/memory-storage-C9HuoL2E.js +91 -0
- package/dist/memory-storage-C9HuoL2E.js.map +1 -0
- package/dist/memory-storage-Dao7jfYG.cjs +2 -0
- package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
- package/dist/secp256k1-BbKzbLtD.cjs +12 -0
- package/dist/secp256k1-BbKzbLtD.cjs.map +1 -0
- package/dist/secp256k1-CreY7Pcl.js +1890 -0
- package/dist/secp256k1-CreY7Pcl.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/api/ai_aggregation.js.html +333 -0
- package/docs/api/ai_breakdown.js.html +524 -0
- package/docs/api/ai_classifier.js.html +231 -0
- package/docs/api/ai_council.js.html +246 -0
- package/docs/api/ai_embeddings.js.html +304 -0
- package/docs/api/ai_federation-ai.js.html +338 -0
- package/docs/api/ai_h3-ai.js.html +970 -0
- package/docs/api/ai_index.js.html +124 -0
- package/docs/api/ai_json-ops.js.html +241 -0
- package/docs/api/ai_llm-service.js.html +239 -0
- package/docs/api/ai_nl-query.js.html +236 -0
- package/docs/api/ai_relationships.js.html +367 -0
- package/docs/api/ai_schema-extractor.js.html +235 -0
- package/docs/api/ai_spatial.js.html +307 -0
- package/docs/api/ai_tts.js.html +214 -0
- package/docs/api/content_social-protocols.js.html +180 -0
- package/docs/api/core_holosphere.js.html +757 -0
- package/docs/api/crypto_nostr-utils.js.html +306 -0
- package/docs/api/crypto_secp256k1.js.html +267 -0
- package/docs/api/data/search.json +1 -0
- package/docs/api/federation_discovery.js.html +337 -0
- package/docs/api/federation_handshake.js.html +478 -0
- package/docs/api/federation_hologram.js.html +1053 -0
- package/docs/api/federation_registry.js.html +389 -0
- package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/api/global.html +3 -0
- package/docs/api/hierarchical_upcast.js.html +128 -0
- package/docs/api/index.html +265 -0
- package/docs/api/index.js.html +1868 -0
- package/docs/api/lib_ai-methods.js.html +660 -0
- package/docs/api/lib_contract-methods.js.html +445 -0
- package/docs/api/lib_errors.js.html +56 -0
- package/docs/api/lib_federation-methods.js.html +348 -0
- package/docs/api/lib_index.js.html +33 -0
- package/docs/api/module-ai.html +5 -0
- package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
- package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
- package/docs/api/module-ai_aggregation.html +3 -0
- package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
- package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
- package/docs/api/module-ai_breakdown.html +3 -0
- package/docs/api/module-ai_classifier-Classifier.html +6 -0
- package/docs/api/module-ai_classifier.Classifier.html +3 -0
- package/docs/api/module-ai_classifier.html +3 -0
- package/docs/api/module-ai_council-Council.html +6 -0
- package/docs/api/module-ai_council.Council.html +3 -0
- package/docs/api/module-ai_council.html +3 -0
- package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
- package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
- package/docs/api/module-ai_embeddings.html +3 -0
- package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
- package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
- package/docs/api/module-ai_federation-ai.html +3 -0
- package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
- package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
- package/docs/api/module-ai_h3-ai.html +3 -0
- package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
- package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
- package/docs/api/module-ai_json-ops.html +3 -0
- package/docs/api/module-ai_llm-service-LLMService.html +5 -0
- package/docs/api/module-ai_llm-service.LLMService.html +3 -0
- package/docs/api/module-ai_llm-service.html +3 -0
- package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
- package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
- package/docs/api/module-ai_nl-query.html +3 -0
- package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
- package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
- package/docs/api/module-ai_relationships.html +3 -0
- package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
- package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
- package/docs/api/module-ai_schema-extractor.html +3 -0
- package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
- package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
- package/docs/api/module-ai_spatial.html +3 -0
- package/docs/api/module-ai_tts-TTS.html +5 -0
- package/docs/api/module-ai_tts.TTS.html +3 -0
- package/docs/api/module-ai_tts.html +3 -0
- package/docs/api/module-content_social-protocols.html +3 -0
- package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
- package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
- package/docs/api/module-core_holosphere.html +3 -0
- package/docs/api/module-crypto_nostr-utils.html +3 -0
- package/docs/api/module-crypto_secp256k1.html +3 -0
- package/docs/api/module-federation_hologram.html +3 -0
- package/docs/api/module-hierarchical_upcast.html +3 -0
- package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
- package/docs/api/module-holosphere.html +3 -0
- package/docs/api/module-lib_ai-methods.html +3 -0
- package/docs/api/module-lib_contract-methods.html +3 -0
- package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors-ValidationError.html +3 -0
- package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors.ValidationError.html +3 -0
- package/docs/api/module-lib_errors.html +3 -0
- package/docs/api/module-lib_federation-methods.html +3 -0
- package/docs/api/module-lib_index.html +3 -0
- package/docs/api/module-schema_validator-ValidationError.html +3 -0
- package/docs/api/module-schema_validator.ValidationError.html +3 -0
- package/docs/api/module-schema_validator.html +3 -0
- package/docs/api/module-spatial_h3-operations.html +4 -0
- package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
- package/docs/api/module-storage_backend-factory.html +3 -0
- package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
- package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
- package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
- package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
- package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend.html +3 -0
- package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
- package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
- package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage.html +3 -0
- package/docs/api/module-storage_global-tables.html +3 -0
- package/docs/api/module-storage_gun-async.html +3 -0
- package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
- package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
- package/docs/api/module-storage_gun-auth.html +3 -0
- package/docs/api/module-storage_gun-federation.html +3 -0
- package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
- package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
- package/docs/api/module-storage_gun-references.html +3 -0
- package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
- package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
- package/docs/api/module-storage_gun-schema.html +3 -0
- package/docs/api/module-storage_gun-wrapper.html +11 -0
- package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
- package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
- package/docs/api/module-storage_indexeddb-storage.html +3 -0
- package/docs/api/module-storage_key-storage-simple.html +3 -0
- package/docs/api/module-storage_key-storage.html +4 -0
- package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
- package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
- package/docs/api/module-storage_memory-storage.html +3 -0
- package/docs/api/module-storage_migration-MigrationTool.html +6 -0
- package/docs/api/module-storage_migration.MigrationTool.html +3 -0
- package/docs/api/module-storage_migration.html +3 -0
- package/docs/api/module-storage_nostr-async.html +18 -0
- package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
- package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
- package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
- package/docs/api/module-storage_nostr-client.html +6 -0
- package/docs/api/module-storage_nostr-wrapper.html +3 -0
- package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
- package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
- package/docs/api/module-storage_outbox-queue.html +3 -0
- package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
- package/docs/api/module-storage_persistent-storage.html +4 -0
- package/docs/api/module-storage_sync-service-SyncService.html +5 -0
- package/docs/api/module-storage_sync-service.SyncService.html +3 -0
- package/docs/api/module-storage_sync-service.html +3 -0
- package/docs/api/module-storage_unified-storage.html +3 -0
- package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
- package/docs/api/module-subscriptions_manager.html +3 -0
- package/docs/api/schema_validator.js.html +113 -0
- package/docs/api/scripts/core.js +726 -0
- package/docs/api/scripts/core.min.js +23 -0
- package/docs/api/scripts/resize.js +90 -0
- package/docs/api/scripts/search.js +265 -0
- package/docs/api/scripts/search.min.js +6 -0
- package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/third-party/fuse.js +9 -0
- package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/api/scripts/third-party/hljs-original.js +5171 -0
- package/docs/api/scripts/third-party/hljs.js +1 -0
- package/docs/api/scripts/third-party/popper.js +5 -0
- package/docs/api/scripts/third-party/tippy.js +1 -0
- package/docs/api/scripts/third-party/tocbot.js +672 -0
- package/docs/api/scripts/third-party/tocbot.min.js +1 -0
- package/docs/api/spatial_h3-operations.js.html +129 -0
- package/docs/api/storage_backend-factory.js.html +133 -0
- package/docs/api/storage_backend-interface.js.html +164 -0
- package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
- package/docs/api/storage_backends_activitypub_server.js.html +678 -0
- package/docs/api/storage_backends_gundb-backend.js.html +878 -0
- package/docs/api/storage_backends_nostr-backend.js.html +254 -0
- package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
- package/docs/api/storage_filesystem-storage.js.html +207 -0
- package/docs/api/storage_global-tables.js.html +116 -0
- package/docs/api/storage_gun-async.js.html +344 -0
- package/docs/api/storage_gun-auth.js.html +376 -0
- package/docs/api/storage_gun-federation.js.html +788 -0
- package/docs/api/storage_gun-references.js.html +212 -0
- package/docs/api/storage_gun-schema.js.html +309 -0
- package/docs/api/storage_gun-wrapper.js.html +645 -0
- package/docs/api/storage_indexeddb-storage.js.html +224 -0
- package/docs/api/storage_key-storage-simple.js.html +102 -0
- package/docs/api/storage_key-storage.js.html +171 -0
- package/docs/api/storage_memory-storage.js.html +128 -0
- package/docs/api/storage_migration.js.html +354 -0
- package/docs/api/storage_nostr-async.js.html +1076 -0
- package/docs/api/storage_nostr-client.js.html +1598 -0
- package/docs/api/storage_nostr-wrapper.js.html +218 -0
- package/docs/api/storage_outbox-queue.js.html +248 -0
- package/docs/api/storage_persistent-storage.js.html +160 -0
- package/docs/api/storage_sync-service.js.html +201 -0
- package/docs/api/storage_unified-storage.js.html +157 -0
- package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/api/subscriptions_manager.js.html +162 -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/examples/holosphere-widget.js +1242 -0
- package/examples/widget-demo.html +274 -0
- package/examples/widget.html +703 -0
- package/jsdoc.json +26 -0
- package/package.json +25 -7
- package/src/ai/aggregation.js +13 -2
- package/src/ai/breakdown.js +12 -2
- package/src/ai/classifier.js +14 -3
- package/src/ai/council.js +22 -7
- package/src/ai/embeddings.js +37 -15
- package/src/ai/federation-ai.js +13 -2
- package/src/ai/h3-ai.js +14 -2
- package/src/ai/index.js +16 -7
- package/src/ai/json-ops.js +18 -5
- package/src/ai/llm-service.js +62 -31
- package/src/ai/nl-query.js +12 -2
- package/src/ai/relationships.js +13 -2
- package/src/ai/schema-extractor.js +24 -10
- package/src/ai/spatial.js +13 -2
- package/src/ai/tts.js +25 -8
- package/src/cdn-entry.js +22 -0
- package/src/content/social-protocols.js +34 -25
- package/src/contracts/abis/Appreciative.json +1280 -0
- package/src/contracts/abis/AppreciativeFactory.json +101 -0
- package/src/contracts/abis/Bundle.json +1438 -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 +403 -0
- package/src/contracts/deployer.js +500 -0
- package/src/contracts/event-listener.js +539 -0
- package/src/contracts/holon-contracts.js +359 -0
- package/src/contracts/index.js +82 -0
- package/src/contracts/networks.js +229 -0
- package/src/contracts/operations.js +687 -0
- package/src/contracts/queries.js +638 -0
- package/src/core/holosphere.js +487 -6
- package/src/crypto/nostr-utils.js +303 -0
- package/src/crypto/secp256k1.js +7 -2
- package/src/federation/handshake.js +475 -0
- package/src/federation/hologram.js +117 -3
- package/src/hierarchical/upcast.js +40 -25
- package/src/index.js +1501 -1909
- package/src/lib/ai-methods.js +657 -0
- package/src/lib/contract-methods.js +442 -0
- package/src/lib/errors.js +53 -0
- package/src/lib/federation-methods.js +345 -0
- package/src/lib/index.js +30 -0
- package/src/schema/validator.js +22 -3
- package/src/spatial/h3-operations.js +19 -3
- package/src/storage/backend-factory.js +7 -2
- package/src/storage/backend-interface.js +21 -2
- package/src/storage/backends/activitypub/server.js +25 -3
- package/src/storage/backends/activitypub-backend.js +25 -2
- package/src/storage/backends/gundb-backend.js +692 -50
- package/src/storage/backends/nostr-backend.js +116 -1
- package/src/storage/filesystem-storage-browser.js +42 -2
- package/src/storage/filesystem-storage.js +72 -5
- package/src/storage/global-tables.js +35 -3
- package/src/storage/gun-async.js +75 -15
- package/src/storage/gun-auth.js +373 -0
- package/src/storage/gun-federation.js +785 -0
- package/src/storage/gun-references.js +209 -0
- package/src/storage/gun-schema.js +306 -0
- package/src/storage/gun-wrapper.js +475 -54
- package/src/storage/indexeddb-storage.js +112 -13
- package/src/storage/key-storage-simple.js +32 -9
- package/src/storage/key-storage.js +45 -13
- package/src/storage/memory-storage.js +68 -2
- package/src/storage/migration.js +20 -7
- package/src/storage/nostr-async.js +412 -122
- package/src/storage/nostr-client.js +749 -76
- package/src/storage/nostr-wrapper.js +6 -2
- package/src/storage/outbox-queue.js +55 -18
- package/src/storage/persistent-storage.js +62 -14
- package/src/storage/sync-service.js +51 -17
- package/src/storage/unified-storage.js +154 -0
- package/src/subscriptions/manager.js +34 -17
- package/types/index.d.ts +133 -0
- package/vite.config.cdn.js +60 -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
- /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
- /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
package/jsdoc.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": {
|
|
3
|
+
"include": ["src"],
|
|
4
|
+
"includePattern": ".+\\.js$",
|
|
5
|
+
"excludePattern": "(node_modules|tests|contracts)"
|
|
6
|
+
},
|
|
7
|
+
"opts": {
|
|
8
|
+
"template": "node_modules/clean-jsdoc-theme",
|
|
9
|
+
"destination": "./docs/api",
|
|
10
|
+
"recurse": true,
|
|
11
|
+
"readme": "./README.md"
|
|
12
|
+
},
|
|
13
|
+
"plugins": ["plugins/markdown"],
|
|
14
|
+
"templates": {
|
|
15
|
+
"cleverLinks": true,
|
|
16
|
+
"monospaceLinks": true,
|
|
17
|
+
"default": {
|
|
18
|
+
"outputSourceFiles": true,
|
|
19
|
+
"includeDate": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"tags": {
|
|
23
|
+
"allowUnknownTags": true,
|
|
24
|
+
"dictionaries": ["jsdoc", "closure"]
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holosphere",
|
|
3
|
-
"version": "2.0.0-
|
|
4
|
-
"description": "Holonic geospatial communication infrastructure combining H3 hexagonal indexing with
|
|
3
|
+
"version": "2.0.0-alpha10",
|
|
4
|
+
"description": "Holonic geospatial communication infrastructure combining H3 hexagonal indexing with distributed P2P storage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"holosphere-activitypub": "
|
|
7
|
+
"holosphere-activitypub": "bin/holosphere-activitypub.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/cjs/holosphere.cjs",
|
|
10
10
|
"module": "./dist/esm/holosphere.js",
|
|
11
11
|
"browser": "./dist/cdn/holosphere.min.js",
|
|
12
|
-
"types": "./
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"import": "./dist/esm/holosphere.js",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "vite",
|
|
21
21
|
"build": "vite build",
|
|
22
|
+
"build:cdn": "vite build --config vite.config.cdn.js",
|
|
23
|
+
"build:all": "npm run build && npm run build:cdn",
|
|
24
|
+
"docs": "jsdoc -c jsdoc.json",
|
|
22
25
|
"test": "vitest run",
|
|
23
26
|
"test:watch": "vitest",
|
|
24
27
|
"test:coverage": "vitest run --coverage",
|
|
@@ -33,14 +36,27 @@
|
|
|
33
36
|
"distributed",
|
|
34
37
|
"holonic",
|
|
35
38
|
"federation",
|
|
36
|
-
"noosphere"
|
|
39
|
+
"noosphere",
|
|
40
|
+
"smart-contracts",
|
|
41
|
+
"ethereum",
|
|
42
|
+
"erc20",
|
|
43
|
+
"fractal"
|
|
37
44
|
],
|
|
38
|
-
"author": "",
|
|
39
|
-
"license": "
|
|
45
|
+
"author": "Roberto Valenti",
|
|
46
|
+
"license": "AGPL-3.0-or-later",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/liminalvillage/holosphere2.git"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/liminalvillage/holosphere2#readme",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/liminalvillage/holosphere2/issues"
|
|
54
|
+
},
|
|
40
55
|
"dependencies": {
|
|
41
56
|
"@noble/curves": "^1.3.0",
|
|
42
57
|
"ajv": "^8.12.0",
|
|
43
58
|
"dotenv": "^17.2.3",
|
|
59
|
+
"ethers": "^6.13.4",
|
|
44
60
|
"express": "^4.21.0",
|
|
45
61
|
"h3-js": "^4.1.0",
|
|
46
62
|
"nostr-tools": "^2.17.0",
|
|
@@ -52,7 +68,9 @@
|
|
|
52
68
|
},
|
|
53
69
|
"devDependencies": {
|
|
54
70
|
"@vitest/coverage-v8": "^1.3.0",
|
|
71
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
55
72
|
"eslint": "^8.57.0",
|
|
73
|
+
"jsdoc": "^4.0.4",
|
|
56
74
|
"prettier": "^3.2.5",
|
|
57
75
|
"terser": "^5.44.0",
|
|
58
76
|
"vite": "^5.1.0",
|
package/src/ai/aggregation.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview AI-assisted hierarchical data aggregation up the H3 holon tree.
|
|
3
|
+
* Provides smart upcast, summary generation, and temporal comparison across hierarchical levels.
|
|
4
|
+
* @module ai/aggregation
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
import * as h3 from 'h3-js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Service class for intelligent hierarchical data aggregation.
|
|
11
|
+
* Automatically summarizes data at each level and propagates insights up the H3 hierarchy,
|
|
12
|
+
* enabling multi-scale understanding of geographic data.
|
|
13
|
+
*
|
|
14
|
+
* @class SmartAggregation
|
|
15
|
+
* @example
|
|
16
|
+
* const aggregation = new SmartAggregation(llmService, holosphere);
|
|
17
|
+
* const upcast = await aggregation.smartUpcast(holonId, 'projects', { maxLevels: 3 });
|
|
18
|
+
* const summary = await aggregation.generateHolonSummary(holonId);
|
|
19
|
+
* const comparison = await aggregation.comparePeriods(holonId, 'events', period1, period2);
|
|
9
20
|
*/
|
|
10
21
|
export class SmartAggregation {
|
|
11
22
|
/**
|
package/src/ai/breakdown.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Recursive task decomposition system for breaking down complex tasks into manageable subtasks.
|
|
3
|
+
* Provides AI-powered hierarchical task breakdown with dependency tracking and progress monitoring.
|
|
4
|
+
* @module ai/breakdown
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for recursively decomposing tasks/quests into hierarchical subtasks.
|
|
9
|
+
* Uses AI to intelligently break down complex tasks while maintaining dependency relationships
|
|
10
|
+
* and enabling progress tracking across the task tree.
|
|
11
|
+
*
|
|
12
|
+
* @class TaskBreakdown
|
|
13
|
+
* @example
|
|
14
|
+
* const taskBreakdown = new TaskBreakdown(llmService, holosphere);
|
|
15
|
+
* const result = await taskBreakdown.breakdown(task, holonId, 'quests', { depth: 3 });
|
|
16
|
+
* const progress = await taskBreakdown.getProgress(holonId, 'quests', taskId);
|
|
7
17
|
*/
|
|
8
18
|
export class TaskBreakdown {
|
|
9
19
|
/**
|
package/src/ai/classifier.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview AI-powered content classification to appropriate data lenses.
|
|
3
|
+
* Provides automatic categorization, multi-label classification, and schema suggestion.
|
|
4
|
+
* @module ai/classifier
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for automatically classifying content into appropriate lenses.
|
|
9
|
+
* Uses AI to determine the best lens(es) for content storage and provides
|
|
10
|
+
* schema validation and suggestion capabilities.
|
|
11
|
+
*
|
|
12
|
+
* @class Classifier
|
|
13
|
+
* @example
|
|
14
|
+
* const classifier = new Classifier(llmService, holosphere);
|
|
15
|
+
* classifier.registerLens('projects', 'Community projects and initiatives');
|
|
16
|
+
* const result = await classifier.classifyToLens(content);
|
|
17
|
+
* await classifier.autoStore(holonId, content);
|
|
7
18
|
*/
|
|
8
19
|
export class Classifier {
|
|
9
20
|
/**
|
|
@@ -36,7 +47,7 @@ export class Classifier {
|
|
|
36
47
|
|
|
37
48
|
/**
|
|
38
49
|
* Register multiple lenses
|
|
39
|
-
* @param {Object
|
|
50
|
+
* @param {Object.<string, Object>} lenses - Map of lens names to config objects with description and optional schema
|
|
40
51
|
*/
|
|
41
52
|
registerLenses(lenses) {
|
|
42
53
|
for (const [name, config] of Object.entries(lenses)) {
|
package/src/ai/council.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Multi-perspective wisdom gathering from different viewpoints.
|
|
3
|
+
* Implements a council of perspectives to analyze questions from diverse angles.
|
|
4
|
+
* @module ai/council
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
|
-
// Default 12 perspectives based on HolonsBot
|
|
7
|
+
// Default 12 perspectives based on HolonsBot holistic framework
|
|
6
8
|
const DEFAULT_PERSPECTIVES = [
|
|
7
9
|
{ name: 'Values & Worldview', prompt: 'Answer from the embodied perspective of Values and Worldview - considering ethics, beliefs, culture, and meaning.' },
|
|
8
10
|
{ name: 'Health & Wellbeing', prompt: 'Answer from the embodied perspective of Health & Wellbeing - considering physical, mental, and social health.' },
|
|
@@ -19,7 +21,16 @@ const DEFAULT_PERSPECTIVES = [
|
|
|
19
21
|
];
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* Service class for gathering multi-perspective wisdom on questions and topics.
|
|
25
|
+
* Simulates a council of experts answering from diverse viewpoints,
|
|
26
|
+
* then synthesizes their responses into balanced insights.
|
|
27
|
+
*
|
|
28
|
+
* @class Council
|
|
29
|
+
* @example
|
|
30
|
+
* const council = new Council(llmService);
|
|
31
|
+
* const result = await council.ask("How should we approach climate change?");
|
|
32
|
+
* console.log(result.perspectives); // Array of perspective responses
|
|
33
|
+
* console.log(result.summary); // Synthesized wisdom
|
|
23
34
|
*/
|
|
24
35
|
export class Council {
|
|
25
36
|
/**
|
|
@@ -48,10 +59,14 @@ export class Council {
|
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
|
-
* Ask a question to the council
|
|
52
|
-
*
|
|
53
|
-
* @param {
|
|
54
|
-
* @
|
|
62
|
+
* Ask a question to the council and receive diverse perspective responses.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} question - Question to ask the council
|
|
65
|
+
* @param {Object} [options={}] - Options
|
|
66
|
+
* @param {boolean} [options.parallel=true] - Query perspectives in parallel or sequentially
|
|
67
|
+
* @param {boolean} [options.includeSummary=true] - Generate a synthesis summary
|
|
68
|
+
* @param {Array} [options.perspectives] - Override default perspectives
|
|
69
|
+
* @returns {Promise<{question: string, perspectives: Array, summary: string, timestamp: number}>} Council responses
|
|
55
70
|
*/
|
|
56
71
|
async ask(question, options = {}) {
|
|
57
72
|
const { parallel = true, includeSummary = true } = options;
|
package/src/ai/embeddings.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Vector embedding generation and semantic search functionality using OpenAI's text-embedding models.
|
|
3
|
+
* Provides methods for generating embeddings, calculating similarity, semantic search, and k-means clustering.
|
|
4
|
+
* @module ai/embeddings
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for vector embeddings and semantic operations.
|
|
9
|
+
* Supports single and batch embedding generation, cosine similarity calculations,
|
|
10
|
+
* semantic search across HoloSphere data, and k-means clustering.
|
|
11
|
+
*
|
|
12
|
+
* @class Embeddings
|
|
13
|
+
* @example
|
|
14
|
+
* const embeddings = new Embeddings(openaiClient, holosphere);
|
|
15
|
+
* const vector = await embeddings.embed("sample text");
|
|
16
|
+
* const results = await embeddings.semanticSearch("query", holon, lens);
|
|
7
17
|
*/
|
|
8
18
|
export class Embeddings {
|
|
9
19
|
/**
|
|
@@ -26,9 +36,11 @@ export class Embeddings {
|
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
|
-
* Generate embedding for text
|
|
39
|
+
* Generate a vector embedding for the given text.
|
|
40
|
+
*
|
|
30
41
|
* @param {string} text - Text to embed
|
|
31
|
-
* @returns {Promise<number[]>} Embedding vector
|
|
42
|
+
* @returns {Promise<number[]>} Embedding vector (1536 dimensions by default)
|
|
43
|
+
* @throws {Error} If embedding generation fails
|
|
32
44
|
*/
|
|
33
45
|
async embed(text) {
|
|
34
46
|
try {
|
|
@@ -62,10 +74,13 @@ export class Embeddings {
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
/**
|
|
65
|
-
* Calculate cosine similarity between two vectors
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
77
|
+
* Calculate cosine similarity between two embedding vectors.
|
|
78
|
+
* Returns a score between -1 and 1, where 1 indicates identical vectors.
|
|
79
|
+
*
|
|
80
|
+
* @param {number[]} vec1 - First embedding vector
|
|
81
|
+
* @param {number[]} vec2 - Second embedding vector
|
|
82
|
+
* @returns {number} Similarity score (0-1 for normalized vectors)
|
|
83
|
+
* @throws {Error} If vectors have different lengths
|
|
69
84
|
*/
|
|
70
85
|
cosineSimilarity(vec1, vec2) {
|
|
71
86
|
if (vec1.length !== vec2.length) {
|
|
@@ -124,12 +139,17 @@ export class Embeddings {
|
|
|
124
139
|
}
|
|
125
140
|
|
|
126
141
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
142
|
+
* Perform semantic search within a holon/lens using vector similarity.
|
|
143
|
+
* Returns items ranked by semantic similarity to the query.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} query - Natural language search query
|
|
129
146
|
* @param {string} holon - Holon identifier
|
|
130
147
|
* @param {string} lens - Lens name
|
|
131
|
-
* @param {Object} options - Search options
|
|
132
|
-
* @
|
|
148
|
+
* @param {Object} [options={}] - Search options
|
|
149
|
+
* @param {number} [options.limit=10] - Maximum results to return
|
|
150
|
+
* @param {number} [options.threshold=0.5] - Minimum similarity score (0-1)
|
|
151
|
+
* @returns {Promise<Array<{item: Object, similarity: number}>>} Results ranked by similarity descending
|
|
152
|
+
* @throws {Error} If HoloSphere instance not configured
|
|
133
153
|
*/
|
|
134
154
|
async semanticSearch(query, holon, lens, options = {}) {
|
|
135
155
|
if (!this.holosphere) {
|
|
@@ -180,10 +200,12 @@ export class Embeddings {
|
|
|
180
200
|
}
|
|
181
201
|
|
|
182
202
|
/**
|
|
183
|
-
* Cluster items by semantic similarity
|
|
203
|
+
* Cluster items by semantic similarity using k-means algorithm.
|
|
204
|
+
* Automatically generates embeddings for items that don't have them.
|
|
205
|
+
*
|
|
184
206
|
* @param {Object[]} items - Items to cluster
|
|
185
|
-
* @param {number} numClusters -
|
|
186
|
-
* @returns {Promise<Object[][]>}
|
|
207
|
+
* @param {number} [numClusters=5] - Target number of clusters
|
|
208
|
+
* @returns {Promise<Object[][]>} Array of clusters, each containing related items
|
|
187
209
|
*/
|
|
188
210
|
async cluster(items, numClusters = 5) {
|
|
189
211
|
// Get embeddings for items that don't have them
|
package/src/ai/federation-ai.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview AI-powered federation recommendations and network health analysis.
|
|
3
|
+
* Provides suggestions for federation partnerships, health monitoring, and network optimization.
|
|
4
|
+
* @module ai/federation-ai
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for analyzing and optimizing holon federation networks.
|
|
9
|
+
* Suggests federation partnerships based on content similarity, analyzes network health,
|
|
10
|
+
* identifies bridges between clusters, and recommends optimizations.
|
|
11
|
+
*
|
|
12
|
+
* @class FederationAdvisor
|
|
13
|
+
* @example
|
|
14
|
+
* const advisor = new FederationAdvisor(llmService, holosphere, embeddings);
|
|
15
|
+
* const suggestions = await advisor.suggestFederations(holonId, { candidateHolons });
|
|
16
|
+
* const health = await advisor.analyzeFederationHealth(holonId);
|
|
17
|
+
* const bridges = await advisor.findBridges(holonIds);
|
|
7
18
|
*/
|
|
8
19
|
export class FederationAdvisor {
|
|
9
20
|
/**
|
package/src/ai/h3-ai.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Geospatial intelligence for H3 hexagonal hierarchies.
|
|
3
|
+
* Provides AI-powered analysis of geographic data distribution, resolution suggestions,
|
|
4
|
+
* coverage analysis, and cross-resolution insights using the H3 geospatial indexing system.
|
|
5
|
+
* @module ai/h3-ai
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
import * as h3 from 'h3-js';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Service class for geospatial intelligence using H3 hexagonal hierarchies.
|
|
12
|
+
* Analyzes geographic data patterns, suggests optimal resolutions, identifies coverage gaps,
|
|
13
|
+
* and provides multi-scale geographic insights across H3's hierarchical grid system.
|
|
14
|
+
*
|
|
15
|
+
* @class H3AI
|
|
16
|
+
* @example
|
|
17
|
+
* const h3ai = new H3AI(llmService, holosphere);
|
|
18
|
+
* const resolution = await h3ai.suggestResolution(project);
|
|
19
|
+
* const coverage = await h3ai.analyzeCoverage(holonId, 'projects');
|
|
20
|
+
* const distribution = await h3ai.analyzeDistribution(holonId, 'events');
|
|
9
21
|
*/
|
|
10
22
|
export class H3AI {
|
|
11
23
|
/**
|
package/src/ai/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HoloSphere AI Module
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview HoloSphere AI Module - Comprehensive AI functionality using OpenAI.
|
|
3
|
+
* Provides unified access to all AI services including LLM, embeddings, semantic operations,
|
|
4
|
+
* spatial analysis, task breakdown, and relationship discovery.
|
|
5
|
+
* @module ai
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
// Import all modules for local use and re-export
|
|
@@ -41,12 +43,19 @@ export {
|
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
46
|
+
* Factory function to create all AI services with shared LLM instance.
|
|
47
|
+
* Provides a convenient way to initialize the complete AI stack with a single call.
|
|
48
|
+
*
|
|
45
49
|
* @param {string} apiKey - OpenAI API key
|
|
46
|
-
* @param {Object} holosphere - HoloSphere instance
|
|
47
|
-
* @param {Object} options - Configuration options
|
|
48
|
-
* @param {Object}
|
|
49
|
-
* @
|
|
50
|
+
* @param {Object} [holosphere=null] - HoloSphere instance for data operations
|
|
51
|
+
* @param {Object} [options={}] - Configuration options
|
|
52
|
+
* @param {Object} [options.llm] - LLM service configuration (model, maxTokens, temperature)
|
|
53
|
+
* @param {Object} [openaiClient=null] - Pre-created OpenAI client for embeddings/TTS
|
|
54
|
+
* @returns {Object} Object containing all initialized AI service instances
|
|
55
|
+
* @example
|
|
56
|
+
* const ai = createAIServices(apiKey, holosphere, { llm: { model: 'gpt-4o-mini' } });
|
|
57
|
+
* const summary = await ai.llm.summarize(text);
|
|
58
|
+
* const results = await ai.nlQuery.execute("find projects near Rome");
|
|
50
59
|
*/
|
|
51
60
|
export function createAIServices(apiKey, holosphere = null, options = {}, openaiClient = null) {
|
|
52
61
|
// Create shared LLM service
|
package/src/ai/json-ops.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview AI-assisted semantic operations on JSON structures.
|
|
3
|
+
* Provides fuzzy operations like merge, subtract, union, and transform that understand semantic meaning.
|
|
4
|
+
* @module ai/json-ops
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for semantic JSON manipulation using AI.
|
|
9
|
+
* Performs intelligent operations on JSON objects that go beyond simple structural merging,
|
|
10
|
+
* understanding semantic similarity and conceptual relationships between data.
|
|
11
|
+
*
|
|
12
|
+
* @class JSONOps
|
|
13
|
+
* @example
|
|
14
|
+
* const jsonOps = new JSONOps(llmService);
|
|
15
|
+
* const merged = await jsonOps.add(obj1, obj2);
|
|
16
|
+
* const diff = await jsonOps.difference(oldData, newData);
|
|
7
17
|
*/
|
|
8
18
|
export class JSONOps {
|
|
9
19
|
/**
|
|
@@ -14,11 +24,14 @@ export class JSONOps {
|
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
/**
|
|
17
|
-
* Semantically merge two JSON objects
|
|
27
|
+
* Semantically merge two JSON objects with intelligent deduplication.
|
|
28
|
+
* Combines information from both objects, resolving conflicts semantically.
|
|
29
|
+
*
|
|
18
30
|
* @param {Object} obj1 - First object
|
|
19
31
|
* @param {Object} obj2 - Second object
|
|
20
|
-
* @param {Object} options - Merge options
|
|
21
|
-
* @
|
|
32
|
+
* @param {Object} [options={}] - Merge options
|
|
33
|
+
* @param {boolean} [options.preferSecond=false] - Prefer second object's values in conflicts
|
|
34
|
+
* @returns {Promise<Object>} Merged object with combined information
|
|
22
35
|
*/
|
|
23
36
|
async add(obj1, obj2, options = {}) {
|
|
24
37
|
const systemPrompt = `You are a JSON merge expert. Semantically merge these two JSON objects.
|
package/src/ai/llm-service.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview Core OpenAI wrapper providing simple chat completions without Assistants API.
|
|
3
|
+
* @module ai/llm-service
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import OpenAI from 'openai';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Service class for interacting with OpenAI's chat completion API.
|
|
10
|
+
* Provides high-level methods for common LLM operations including summarization,
|
|
11
|
+
* analysis, categorization, translation, and structured JSON responses.
|
|
12
|
+
*
|
|
13
|
+
* @class LLMService
|
|
14
|
+
* @example
|
|
15
|
+
* const llm = new LLMService(apiKey, { model: 'gpt-4o-mini' });
|
|
16
|
+
* const summary = await llm.summarize(longText);
|
|
17
|
+
* const keywords = await llm.extractKeywords(text);
|
|
10
18
|
*/
|
|
11
19
|
export class LLMService {
|
|
12
20
|
/**
|
|
@@ -28,11 +36,16 @@ export class LLMService {
|
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
/**
|
|
31
|
-
* Send a message to the LLM
|
|
32
|
-
*
|
|
33
|
-
* @param {string}
|
|
34
|
-
* @param {
|
|
39
|
+
* Send a single-turn message to the LLM with system and user prompts.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} systemPrompt - System prompt defining role and behavior
|
|
42
|
+
* @param {string} userMessage - User message content
|
|
43
|
+
* @param {Object} [options={}] - Override options
|
|
44
|
+
* @param {string} [options.model] - Override model
|
|
45
|
+
* @param {number} [options.maxTokens] - Override max tokens
|
|
46
|
+
* @param {number} [options.temperature] - Override temperature
|
|
35
47
|
* @returns {Promise<string>} Response content
|
|
48
|
+
* @throws {Error} If LLM request fails
|
|
36
49
|
*/
|
|
37
50
|
async sendMessage(systemPrompt, userMessage, options = {}) {
|
|
38
51
|
try {
|
|
@@ -53,10 +66,15 @@ export class LLMService {
|
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
/**
|
|
56
|
-
* Send multiple messages
|
|
57
|
-
*
|
|
58
|
-
* @param {
|
|
69
|
+
* Send multiple messages in a conversation format.
|
|
70
|
+
*
|
|
71
|
+
* @param {Array<{role: string, content: string}>} messages - Array of message objects with role and content
|
|
72
|
+
* @param {Object} [options={}] - Override options
|
|
73
|
+
* @param {string} [options.model] - Override model
|
|
74
|
+
* @param {number} [options.maxTokens] - Override max tokens
|
|
75
|
+
* @param {number} [options.temperature] - Override temperature
|
|
59
76
|
* @returns {Promise<string>} Response content
|
|
77
|
+
* @throws {Error} If LLM chat fails
|
|
60
78
|
*/
|
|
61
79
|
async chat(messages, options = {}) {
|
|
62
80
|
try {
|
|
@@ -74,10 +92,13 @@ export class LLMService {
|
|
|
74
92
|
}
|
|
75
93
|
|
|
76
94
|
/**
|
|
77
|
-
*
|
|
95
|
+
* Generate a concise summary of text while preserving key information.
|
|
96
|
+
*
|
|
78
97
|
* @param {string} text - Text to summarize
|
|
79
|
-
* @param {Object} options -
|
|
80
|
-
* @
|
|
98
|
+
* @param {Object} [options={}] - Summarization options
|
|
99
|
+
* @param {number} [options.maxLength] - Maximum word count for summary
|
|
100
|
+
* @param {string} [options.style] - Summary style (e.g., 'bullet points', 'executive summary')
|
|
101
|
+
* @returns {Promise<string>} Summary text
|
|
81
102
|
*/
|
|
82
103
|
async summarize(text, options = {}) {
|
|
83
104
|
const systemPrompt = `You are a helpful assistant that summarizes text concisely while preserving key information. Keep summaries clear and focused.${
|
|
@@ -88,10 +109,11 @@ export class LLMService {
|
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
/**
|
|
91
|
-
* Analyze text from a specific perspective
|
|
112
|
+
* Analyze text from a specific perspective or aspect.
|
|
113
|
+
*
|
|
92
114
|
* @param {string} text - Text to analyze
|
|
93
|
-
* @param {string} aspect -
|
|
94
|
-
* @returns {Promise<string>}
|
|
115
|
+
* @param {string} aspect - Analysis aspect (e.g., 'sentiment', 'themes', 'tone', 'bias')
|
|
116
|
+
* @returns {Promise<string>} Structured analysis
|
|
95
117
|
*/
|
|
96
118
|
async analyze(text, aspect) {
|
|
97
119
|
const systemPrompt = `You are an expert analyst. Analyze the following text from the perspective of "${aspect}". Provide a clear, structured analysis.`;
|
|
@@ -99,10 +121,12 @@ export class LLMService {
|
|
|
99
121
|
}
|
|
100
122
|
|
|
101
123
|
/**
|
|
102
|
-
* Extract
|
|
124
|
+
* Extract key words and phrases from text.
|
|
125
|
+
*
|
|
103
126
|
* @param {string} text - Text to extract keywords from
|
|
104
|
-
* @param {number} maxKeywords - Maximum keywords
|
|
105
|
-
* @returns {Promise<string[]>} Array of
|
|
127
|
+
* @param {number} [maxKeywords=10] - Maximum number of keywords to extract
|
|
128
|
+
* @returns {Promise<string[]>} Array of keyword strings
|
|
129
|
+
* @throws {Error} If JSON parsing fails after retry attempts
|
|
106
130
|
*/
|
|
107
131
|
async extractKeywords(text, maxKeywords = 10) {
|
|
108
132
|
const systemPrompt = `Extract the ${maxKeywords} most important keywords or key phrases from the text. Return ONLY a JSON array of strings, nothing else. Example: ["keyword1", "keyword2"]`;
|
|
@@ -121,10 +145,11 @@ export class LLMService {
|
|
|
121
145
|
}
|
|
122
146
|
|
|
123
147
|
/**
|
|
124
|
-
* Categorize text into
|
|
148
|
+
* Categorize text into one of the provided categories with confidence score.
|
|
149
|
+
*
|
|
125
150
|
* @param {string} text - Text to categorize
|
|
126
|
-
* @param {string[]} categories - Available
|
|
127
|
-
* @returns {Promise<{category: string, confidence: number, reasoning: string}>}
|
|
151
|
+
* @param {string[]} categories - Available category options
|
|
152
|
+
* @returns {Promise<{category: string, confidence: number, reasoning: string}>} Categorization result
|
|
128
153
|
*/
|
|
129
154
|
async categorize(text, categories) {
|
|
130
155
|
const systemPrompt = `Categorize the following text into one of these categories: ${categories.join(', ')}.
|
|
@@ -144,9 +169,10 @@ Return ONLY a JSON object with: {"category": "chosen_category", "confidence": 0.
|
|
|
144
169
|
}
|
|
145
170
|
|
|
146
171
|
/**
|
|
147
|
-
* Translate text to target language
|
|
172
|
+
* Translate text to a target language.
|
|
173
|
+
*
|
|
148
174
|
* @param {string} text - Text to translate
|
|
149
|
-
* @param {string} targetLanguage - Target language
|
|
175
|
+
* @param {string} targetLanguage - Target language name (e.g., 'Spanish', 'French')
|
|
150
176
|
* @returns {Promise<string>} Translated text
|
|
151
177
|
*/
|
|
152
178
|
async translate(text, targetLanguage) {
|
|
@@ -155,10 +181,11 @@ Return ONLY a JSON object with: {"category": "chosen_category", "confidence": 0.
|
|
|
155
181
|
}
|
|
156
182
|
|
|
157
183
|
/**
|
|
158
|
-
* Generate questions about content
|
|
184
|
+
* Generate insightful questions about the content.
|
|
185
|
+
*
|
|
159
186
|
* @param {string} text - Text to generate questions about
|
|
160
|
-
* @param {number} count - Number of questions
|
|
161
|
-
* @returns {Promise<string[]>} Array of
|
|
187
|
+
* @param {number} [count=5] - Number of questions to generate
|
|
188
|
+
* @returns {Promise<string[]>} Array of question strings
|
|
162
189
|
*/
|
|
163
190
|
async generateQuestions(text, count = 5) {
|
|
164
191
|
const systemPrompt = `Generate ${count} insightful questions about the following text. Return ONLY a JSON array of question strings, nothing else. Example: ["Question 1?", "Question 2?"]`;
|
|
@@ -176,11 +203,15 @@ Return ONLY a JSON object with: {"category": "chosen_category", "confidence": 0.
|
|
|
176
203
|
}
|
|
177
204
|
|
|
178
205
|
/**
|
|
179
|
-
* Get JSON response from LLM
|
|
180
|
-
*
|
|
206
|
+
* Get a structured JSON response from the LLM with automatic parsing.
|
|
207
|
+
* Attempts to extract JSON from response even if surrounded by additional text.
|
|
208
|
+
*
|
|
209
|
+
* @param {string} systemPrompt - System prompt (JSON instruction will be appended)
|
|
181
210
|
* @param {string} userMessage - User message
|
|
182
|
-
* @param {Object} options -
|
|
183
|
-
* @
|
|
211
|
+
* @param {Object} [options={}] - Request options
|
|
212
|
+
* @param {number} [options.temperature=0.2] - Temperature (defaults to 0.2 for structured output)
|
|
213
|
+
* @returns {Promise<Object>} Parsed JSON object
|
|
214
|
+
* @throws {Error} If JSON parsing fails completely
|
|
184
215
|
*/
|
|
185
216
|
async getJSON(systemPrompt, userMessage, options = {}) {
|
|
186
217
|
const response = await this.sendMessage(
|
package/src/ai/nl-query.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Natural
|
|
2
|
+
* @fileoverview Natural language query interface for HoloSphere data.
|
|
3
|
+
* Converts natural language queries to structured filters and executes searches.
|
|
4
|
+
* @module ai/nl-query
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Service class for querying HoloSphere data using natural language.
|
|
9
|
+
* Translates natural language queries into structured filters with support for
|
|
10
|
+
* spatial, temporal, and field-based filtering.
|
|
11
|
+
*
|
|
12
|
+
* @class NLQuery
|
|
13
|
+
* @example
|
|
14
|
+
* const nlQuery = new NLQuery(llmService, holosphere);
|
|
15
|
+
* const results = await nlQuery.execute("find projects near Rome with more than 10 participants");
|
|
16
|
+
* const suggestions = await nlQuery.suggest({ holons: ['rome', 'milan'] });
|
|
7
17
|
*/
|
|
8
18
|
export class NLQuery {
|
|
9
19
|
/**
|