holosphere 2.0.0-alpha8 → 2.0.0-alpha9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/dist/cdn/holosphere.min.js +55 -0
  6. package/dist/cdn/holosphere.min.js.map +1 -0
  7. package/dist/cjs/holosphere.cjs +1 -1
  8. package/dist/esm/holosphere.js +1 -1
  9. package/dist/{index-CKffQDmQ.cjs → index-DDGt_V9o.cjs} +2 -2
  10. package/dist/{index-CKffQDmQ.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
  11. package/dist/{index-4XHHKe6S.js → index-DJXftyvB.js} +1905 -337
  12. package/dist/index-DJXftyvB.js.map +1 -0
  13. package/dist/{index-Dz5kOZMI.cjs → index-DMbdcMtK.cjs} +17 -4
  14. package/dist/index-DMbdcMtK.cjs.map +1 -0
  15. package/dist/{index-BjP1TXGz.js → index-DeZ1xz_s.js} +2 -2
  16. package/dist/{index-BjP1TXGz.js.map → index-DeZ1xz_s.js.map} +1 -1
  17. package/dist/{indexeddb-storage-lExjjFlV.js → indexeddb-storage-BFt6hMeF.js} +48 -4
  18. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  19. package/dist/{indexeddb-storage-DD7EFBVc.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
  20. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  21. package/dist/{memory-storage-C68adso2.js → memory-storage-C9HuoL2E.js} +44 -4
  22. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  23. package/dist/{memory-storage-DD_6yyXT.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
  24. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  25. package/dist/{secp256k1-DYELiqgx.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
  26. package/dist/{secp256k1-DYELiqgx.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
  27. package/dist/{secp256k1-OM8siPyy.js → secp256k1-CreY7Pcl.js} +2 -2
  28. package/dist/{secp256k1-OM8siPyy.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
  29. package/docs/api/ai_aggregation.js.html +333 -0
  30. package/docs/api/ai_breakdown.js.html +524 -0
  31. package/docs/api/ai_classifier.js.html +231 -0
  32. package/docs/api/ai_council.js.html +246 -0
  33. package/docs/api/ai_embeddings.js.html +304 -0
  34. package/docs/api/ai_federation-ai.js.html +338 -0
  35. package/docs/api/ai_h3-ai.js.html +970 -0
  36. package/docs/api/ai_index.js.html +124 -0
  37. package/docs/api/ai_json-ops.js.html +241 -0
  38. package/docs/api/ai_llm-service.js.html +239 -0
  39. package/docs/api/ai_nl-query.js.html +236 -0
  40. package/docs/api/ai_relationships.js.html +367 -0
  41. package/docs/api/ai_schema-extractor.js.html +235 -0
  42. package/docs/api/ai_spatial.js.html +307 -0
  43. package/docs/api/ai_tts.js.html +214 -0
  44. package/docs/api/content_social-protocols.js.html +180 -0
  45. package/docs/api/core_holosphere.js.html +757 -0
  46. package/docs/api/crypto_nostr-utils.js.html +306 -0
  47. package/docs/api/crypto_secp256k1.js.html +267 -0
  48. package/docs/api/data/search.json +1 -0
  49. package/docs/api/federation_discovery.js.html +337 -0
  50. package/docs/api/federation_handshake.js.html +478 -0
  51. package/docs/api/federation_hologram.js.html +1053 -0
  52. package/docs/api/federation_registry.js.html +389 -0
  53. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  54. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  55. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  56. package/docs/api/global.html +3 -0
  57. package/docs/api/hierarchical_upcast.js.html +128 -0
  58. package/docs/api/index.html +265 -0
  59. package/docs/api/index.js.html +1868 -0
  60. package/docs/api/lib_ai-methods.js.html +660 -0
  61. package/docs/api/lib_contract-methods.js.html +445 -0
  62. package/docs/api/lib_errors.js.html +56 -0
  63. package/docs/api/lib_federation-methods.js.html +348 -0
  64. package/docs/api/lib_index.js.html +33 -0
  65. package/docs/api/module-ai.html +5 -0
  66. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  67. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  68. package/docs/api/module-ai_aggregation.html +3 -0
  69. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  70. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  71. package/docs/api/module-ai_breakdown.html +3 -0
  72. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  73. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  74. package/docs/api/module-ai_classifier.html +3 -0
  75. package/docs/api/module-ai_council-Council.html +6 -0
  76. package/docs/api/module-ai_council.Council.html +3 -0
  77. package/docs/api/module-ai_council.html +3 -0
  78. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  79. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  80. package/docs/api/module-ai_embeddings.html +3 -0
  81. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  82. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  83. package/docs/api/module-ai_federation-ai.html +3 -0
  84. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  85. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  86. package/docs/api/module-ai_h3-ai.html +3 -0
  87. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  88. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  89. package/docs/api/module-ai_json-ops.html +3 -0
  90. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  91. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  92. package/docs/api/module-ai_llm-service.html +3 -0
  93. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  94. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  95. package/docs/api/module-ai_nl-query.html +3 -0
  96. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  97. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  98. package/docs/api/module-ai_relationships.html +3 -0
  99. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  100. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  101. package/docs/api/module-ai_schema-extractor.html +3 -0
  102. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  103. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  104. package/docs/api/module-ai_spatial.html +3 -0
  105. package/docs/api/module-ai_tts-TTS.html +5 -0
  106. package/docs/api/module-ai_tts.TTS.html +3 -0
  107. package/docs/api/module-ai_tts.html +3 -0
  108. package/docs/api/module-content_social-protocols.html +3 -0
  109. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  110. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  111. package/docs/api/module-core_holosphere.html +3 -0
  112. package/docs/api/module-crypto_nostr-utils.html +3 -0
  113. package/docs/api/module-crypto_secp256k1.html +3 -0
  114. package/docs/api/module-federation_hologram.html +3 -0
  115. package/docs/api/module-hierarchical_upcast.html +3 -0
  116. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  117. package/docs/api/module-holosphere.html +3 -0
  118. package/docs/api/module-lib_ai-methods.html +3 -0
  119. package/docs/api/module-lib_contract-methods.html +3 -0
  120. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  121. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  122. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  123. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  124. package/docs/api/module-lib_errors.html +3 -0
  125. package/docs/api/module-lib_federation-methods.html +3 -0
  126. package/docs/api/module-lib_index.html +3 -0
  127. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  128. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  129. package/docs/api/module-schema_validator.html +3 -0
  130. package/docs/api/module-spatial_h3-operations.html +4 -0
  131. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  132. package/docs/api/module-storage_backend-factory.html +3 -0
  133. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  134. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  135. package/docs/api/module-storage_backend-interface.html +3 -0
  136. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  137. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  138. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  139. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  140. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  141. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  142. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  143. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  144. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  145. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  146. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  147. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  148. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  149. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  150. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  151. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  152. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  153. package/docs/api/module-storage_filesystem-storage.html +3 -0
  154. package/docs/api/module-storage_global-tables.html +3 -0
  155. package/docs/api/module-storage_gun-async.html +3 -0
  156. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  157. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  158. package/docs/api/module-storage_gun-auth.html +3 -0
  159. package/docs/api/module-storage_gun-federation.html +3 -0
  160. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  161. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  162. package/docs/api/module-storage_gun-references.html +3 -0
  163. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  164. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  165. package/docs/api/module-storage_gun-schema.html +3 -0
  166. package/docs/api/module-storage_gun-wrapper.html +11 -0
  167. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  168. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  169. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  170. package/docs/api/module-storage_key-storage-simple.html +3 -0
  171. package/docs/api/module-storage_key-storage.html +4 -0
  172. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  173. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  174. package/docs/api/module-storage_memory-storage.html +3 -0
  175. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  176. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  177. package/docs/api/module-storage_migration.html +3 -0
  178. package/docs/api/module-storage_nostr-async.html +18 -0
  179. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  180. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  181. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  182. package/docs/api/module-storage_nostr-client.html +6 -0
  183. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  184. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  185. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  186. package/docs/api/module-storage_outbox-queue.html +3 -0
  187. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  188. package/docs/api/module-storage_persistent-storage.html +4 -0
  189. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  190. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  191. package/docs/api/module-storage_sync-service.html +3 -0
  192. package/docs/api/module-storage_unified-storage.html +3 -0
  193. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  194. package/docs/api/module-subscriptions_manager.html +3 -0
  195. package/docs/api/schema_validator.js.html +113 -0
  196. package/docs/api/scripts/core.js +726 -0
  197. package/docs/api/scripts/core.min.js +23 -0
  198. package/docs/api/scripts/resize.js +90 -0
  199. package/docs/api/scripts/search.js +265 -0
  200. package/docs/api/scripts/search.min.js +6 -0
  201. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  202. package/docs/api/scripts/third-party/fuse.js +9 -0
  203. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  204. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  205. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  206. package/docs/api/scripts/third-party/hljs.js +1 -0
  207. package/docs/api/scripts/third-party/popper.js +5 -0
  208. package/docs/api/scripts/third-party/tippy.js +1 -0
  209. package/docs/api/scripts/third-party/tocbot.js +672 -0
  210. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  211. package/docs/api/spatial_h3-operations.js.html +129 -0
  212. package/docs/api/storage_backend-factory.js.html +133 -0
  213. package/docs/api/storage_backend-interface.js.html +164 -0
  214. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  215. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  216. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  217. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  218. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  219. package/docs/api/storage_filesystem-storage.js.html +207 -0
  220. package/docs/api/storage_global-tables.js.html +116 -0
  221. package/docs/api/storage_gun-async.js.html +344 -0
  222. package/docs/api/storage_gun-auth.js.html +376 -0
  223. package/docs/api/storage_gun-federation.js.html +788 -0
  224. package/docs/api/storage_gun-references.js.html +212 -0
  225. package/docs/api/storage_gun-schema.js.html +309 -0
  226. package/docs/api/storage_gun-wrapper.js.html +645 -0
  227. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  228. package/docs/api/storage_key-storage-simple.js.html +102 -0
  229. package/docs/api/storage_key-storage.js.html +171 -0
  230. package/docs/api/storage_memory-storage.js.html +128 -0
  231. package/docs/api/storage_migration.js.html +354 -0
  232. package/docs/api/storage_nostr-async.js.html +1076 -0
  233. package/docs/api/storage_nostr-client.js.html +1598 -0
  234. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  235. package/docs/api/storage_outbox-queue.js.html +248 -0
  236. package/docs/api/storage_persistent-storage.js.html +160 -0
  237. package/docs/api/storage_sync-service.js.html +201 -0
  238. package/docs/api/storage_unified-storage.js.html +157 -0
  239. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  240. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  241. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  242. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  243. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  244. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  245. package/docs/api/subscriptions_manager.js.html +162 -0
  246. package/jsdoc.json +26 -0
  247. package/package.json +14 -3
  248. package/src/ai/aggregation.js +13 -2
  249. package/src/ai/breakdown.js +12 -2
  250. package/src/ai/classifier.js +14 -3
  251. package/src/ai/council.js +22 -7
  252. package/src/ai/embeddings.js +37 -15
  253. package/src/ai/federation-ai.js +13 -2
  254. package/src/ai/h3-ai.js +14 -2
  255. package/src/ai/index.js +16 -7
  256. package/src/ai/json-ops.js +18 -5
  257. package/src/ai/llm-service.js +62 -31
  258. package/src/ai/nl-query.js +12 -2
  259. package/src/ai/relationships.js +13 -2
  260. package/src/ai/schema-extractor.js +24 -10
  261. package/src/ai/spatial.js +13 -2
  262. package/src/ai/tts.js +25 -8
  263. package/src/content/social-protocols.js +34 -25
  264. package/src/contracts/chain-manager.js +68 -40
  265. package/src/contracts/deployer.js +70 -42
  266. package/src/contracts/event-listener.js +61 -29
  267. package/src/contracts/holon-contracts.js +46 -31
  268. package/src/contracts/index.js +5 -6
  269. package/src/contracts/networks.js +19 -14
  270. package/src/contracts/operations.js +58 -41
  271. package/src/contracts/queries.js +54 -20
  272. package/src/core/holosphere.js +35 -6
  273. package/src/crypto/nostr-utils.js +82 -76
  274. package/src/crypto/secp256k1.js +7 -2
  275. package/src/federation/handshake.js +7 -7
  276. package/src/federation/hologram.js +9 -1
  277. package/src/hierarchical/upcast.js +34 -20
  278. package/src/index.js +655 -5
  279. package/src/lib/ai-methods.js +352 -3
  280. package/src/lib/contract-methods.js +152 -3
  281. package/src/lib/errors.js +31 -1
  282. package/src/lib/federation-methods.js +110 -3
  283. package/src/lib/index.js +9 -5
  284. package/src/schema/validator.js +22 -3
  285. package/src/spatial/h3-operations.js +17 -1
  286. package/src/storage/backend-factory.js +7 -2
  287. package/src/storage/backend-interface.js +21 -2
  288. package/src/storage/backends/activitypub/server.js +25 -3
  289. package/src/storage/backends/activitypub-backend.js +25 -2
  290. package/src/storage/backends/gundb-backend.js +29 -2
  291. package/src/storage/backends/nostr-backend.js +116 -1
  292. package/src/storage/filesystem-storage-browser.js +42 -2
  293. package/src/storage/filesystem-storage.js +72 -5
  294. package/src/storage/global-tables.js +7 -2
  295. package/src/storage/gun-async.js +20 -11
  296. package/src/storage/gun-auth.js +15 -4
  297. package/src/storage/gun-federation.js +14 -5
  298. package/src/storage/gun-references.js +16 -5
  299. package/src/storage/gun-schema.js +25 -10
  300. package/src/storage/gun-wrapper.js +99 -36
  301. package/src/storage/indexeddb-storage.js +65 -4
  302. package/src/storage/key-storage-simple.js +32 -9
  303. package/src/storage/key-storage.js +45 -13
  304. package/src/storage/memory-storage.js +65 -4
  305. package/src/storage/migration.js +20 -7
  306. package/src/storage/nostr-async.js +157 -67
  307. package/src/storage/nostr-client.js +173 -49
  308. package/src/storage/nostr-wrapper.js +6 -2
  309. package/src/storage/outbox-queue.js +55 -18
  310. package/src/storage/persistent-storage.js +56 -13
  311. package/src/storage/sync-service.js +51 -17
  312. package/src/storage/unified-storage.js +7 -2
  313. package/src/subscriptions/manager.js +33 -16
  314. package/dist/index-4XHHKe6S.js.map +0 -1
  315. package/dist/index-Dz5kOZMI.cjs.map +0 -1
  316. package/dist/indexeddb-storage-DD7EFBVc.cjs.map +0 -1
  317. package/dist/indexeddb-storage-lExjjFlV.js.map +0 -1
  318. package/dist/memory-storage-C68adso2.js.map +0 -1
  319. package/dist/memory-storage-DD_6yyXT.cjs.map +0 -1
  320. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  321. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
package/src/ai/h3-ai.js CHANGED
@@ -1,11 +1,23 @@
1
1
  /**
2
- * H3 AI - Geospatial intelligence for H3 hexagonal hierarchies
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
- * H3 AI class for geospatial intelligence
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
- * Comprehensive AI functionality using OpenAI chat completions
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
- * Create all AI services with shared LLM instance
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 (optional)
47
- * @param {Object} options - Configuration options
48
- * @param {Object} openaiClient - Optional pre-created OpenAI client
49
- * @returns {Object} AI services
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
@@ -1,9 +1,19 @@
1
1
  /**
2
- * Fuzzy JSON Operations - AI-assisted semantic operations on JSON structures
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
- * JSON Operations class for semantic JSON manipulation
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
- * @returns {Promise<Object>} Merged object
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.
@@ -1,12 +1,20 @@
1
1
  /**
2
- * LLM Service - Core OpenAI wrapper for HoloSphere
3
- * Provides simple chat completions without Assistants API
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
- * LLM Service class for interacting with OpenAI
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
- * @param {string} systemPrompt - System prompt
33
- * @param {string} userMessage - User message
34
- * @param {Object} options - Override options
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 (conversation)
57
- * @param {Array<{role: string, content: string}>} messages - Messages array
58
- * @param {Object} options - Override options
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
- * Summarize text
95
+ * Generate a concise summary of text while preserving key information.
96
+ *
78
97
  * @param {string} text - Text to summarize
79
- * @param {Object} options - Options (maxLength, style)
80
- * @returns {Promise<string>} Summary
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 - Aspect to analyze (sentiment, themes, tone, etc.)
94
- * @returns {Promise<string>} Analysis
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 keywords from text
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 (default: 10)
105
- * @returns {Promise<string[]>} Array of keywords
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 given categories
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 categories
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 (default: 5)
161
- * @returns {Promise<string[]>} Array of questions
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
- * @param {string} systemPrompt - System prompt
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 - Options
183
- * @returns {Promise<Object>} Parsed JSON response
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(
@@ -1,9 +1,19 @@
1
1
  /**
2
- * Natural Language Query - Query HoloSphere data using natural language
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
- * NL Query class for natural language to structured query conversion
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
  /**
@@ -1,9 +1,20 @@
1
1
  /**
2
- * Relationship Discovery - Find hidden connections across data
2
+ * @fileoverview Discover hidden connections and relationships across data.
3
+ * Provides relationship discovery, graph building, pattern detection, and connection suggestions.
4
+ * @module ai/relationships
3
5
  */
4
6
 
5
7
  /**
6
- * Relationship Discovery class
8
+ * Service class for discovering hidden connections and relationships in data.
9
+ * Identifies thematic, entity, temporal, causal, and geographic relationships,
10
+ * builds relationship graphs, and suggests collaboration opportunities.
11
+ *
12
+ * @class RelationshipDiscovery
13
+ * @example
14
+ * const discovery = new RelationshipDiscovery(llmService, holosphere, embeddings);
15
+ * const relationships = await discovery.discoverRelationships(holonId, 'projects');
16
+ * const similar = await discovery.findSimilar(item, holonId, 'quests');
17
+ * const graph = await discovery.buildGraph(holonId, 'events');
7
18
  */
8
19
  export class RelationshipDiscovery {
9
20
  /**
@@ -1,9 +1,18 @@
1
1
  /**
2
- * Schema Extractor - Extract structured data from text using JSON schemas
2
+ * @fileoverview Extract structured data from unstructured text using JSON schemas.
3
+ * Provides schema-based data extraction, validation, and field completion.
4
+ * @module ai/schema-extractor
3
5
  */
4
6
 
5
7
  /**
6
- * Schema Extractor class
8
+ * Service class for extracting structured data from text using JSON schemas.
9
+ * Leverages LLM to parse unstructured content and map it to defined schemas.
10
+ *
11
+ * @class SchemaExtractor
12
+ * @example
13
+ * const extractor = new SchemaExtractor(llmService);
14
+ * const schema = { properties: { name: { type: "string" }, age: { type: "number" } } };
15
+ * const data = await extractor.extractToSchema(text, schema);
7
16
  */
8
17
  export class SchemaExtractor {
9
18
  /**
@@ -14,10 +23,13 @@ export class SchemaExtractor {
14
23
  }
15
24
 
16
25
  /**
17
- * Extract data from text based on JSON schema
18
- * @param {string} text - Text to extract from
19
- * @param {Object} schema - JSON schema defining expected structure
20
- * @param {Object} options - Extraction options
26
+ * Extract structured data from text according to a JSON schema.
27
+ * Uses LLM to intelligently parse unstructured text and map to schema fields.
28
+ *
29
+ * @param {string} text - Unstructured text to extract from
30
+ * @param {Object} schema - JSON schema defining target structure
31
+ * @param {Object} [options={}] - Extraction options
32
+ * @param {number} [options.maxTokens=2000] - Maximum tokens for response
21
33
  * @returns {Promise<Object>} Extracted data conforming to schema
22
34
  */
23
35
  async extractToSchema(text, schema, options = {}) {
@@ -157,10 +169,12 @@ Return JSON with ONLY the missing fields that you can extract. Do not modify exi
157
169
  }
158
170
 
159
171
  /**
160
- * Validate extracted data against schema
161
- * @param {Object} data - Extracted data
162
- * @param {Object} schema - JSON schema
163
- * @returns {{valid: boolean, errors: string[]}}
172
+ * Validate extracted data against a JSON schema.
173
+ * Performs basic type checking and required field validation.
174
+ *
175
+ * @param {Object} data - Extracted data to validate
176
+ * @param {Object} schema - JSON schema to validate against
177
+ * @returns {{valid: boolean, errors: string[]}} Validation result with error list
164
178
  */
165
179
  validateExtraction(data, schema) {
166
180
  const errors = [];
package/src/ai/spatial.js CHANGED
@@ -1,9 +1,20 @@
1
1
  /**
2
- * Spatial Analysis - AI-powered analysis of data patterns across geographic regions
2
+ * @fileoverview AI-powered spatial analysis of data patterns across geographic regions.
3
+ * Provides region analysis, comparison, trend detection, hotspot identification, and reporting.
4
+ * @module ai/spatial
3
5
  */
4
6
 
5
7
  /**
6
- * Spatial Analysis class
8
+ * Service class for analyzing spatial data patterns across geographic regions.
9
+ * Identifies trends, compares regions, finds hotspots, and generates comprehensive
10
+ * spatial reports using AI-driven analysis.
11
+ *
12
+ * @class SpatialAnalysis
13
+ * @example
14
+ * const spatial = new SpatialAnalysis(llmService, holosphere);
15
+ * const analysis = await spatial.analyzeRegion(holonId, 'projects', 'activity');
16
+ * const comparison = await spatial.compareRegions(holon1, holon2, 'quests');
17
+ * const trends = await spatial.spatialTrends(holonId, 'events', { start: '2024-01-01' });
7
18
  */
8
19
  export class SpatialAnalysis {
9
20
  /**
package/src/ai/tts.js CHANGED
@@ -1,9 +1,12 @@
1
1
  /**
2
- * Text-to-Speech - OpenAI TTS integration
2
+ * @fileoverview OpenAI text-to-speech integration for audio generation.
3
+ * Provides methods for converting text to speech with various voices and formats.
4
+ * @module ai/tts
3
5
  */
4
6
 
5
7
  /**
6
- * Available voices for TTS
8
+ * Available voice options for text-to-speech.
9
+ * @enum {string}
7
10
  */
8
11
  export const VOICES = {
9
12
  ALLOY: 'alloy',
@@ -15,7 +18,8 @@ export const VOICES = {
15
18
  };
16
19
 
17
20
  /**
18
- * Available TTS models
21
+ * Available TTS model options.
22
+ * @enum {string}
19
23
  */
20
24
  export const MODELS = {
21
25
  TTS_1: 'tts-1',
@@ -23,7 +27,14 @@ export const MODELS = {
23
27
  };
24
28
 
25
29
  /**
26
- * TTS class for text-to-speech conversion
30
+ * Service class for converting text to speech using OpenAI's TTS API.
31
+ * Supports multiple voices, output formats, and handles long text with automatic chunking.
32
+ *
33
+ * @class TTS
34
+ * @example
35
+ * const tts = new TTS(openaiClient);
36
+ * const audioBuffer = await tts.speak("Hello world", { voice: VOICES.NOVA });
37
+ * const dataUrl = await tts.speakDataUrl("Hello", { voice: VOICES.ECHO });
27
38
  */
28
39
  export class TTS {
29
40
  /**
@@ -36,10 +47,16 @@ export class TTS {
36
47
  }
37
48
 
38
49
  /**
39
- * Convert text to speech
40
- * @param {string} text - Text to convert
41
- * @param {Object} options - TTS options
42
- * @returns {Promise<Buffer>} Audio buffer (MP3)
50
+ * Convert text to speech audio.
51
+ *
52
+ * @param {string} text - Text to convert to speech
53
+ * @param {Object} [options={}] - TTS generation options
54
+ * @param {string} [options.voice] - Voice to use (from VOICES enum)
55
+ * @param {string} [options.model] - Model to use (from MODELS enum)
56
+ * @param {number} [options.speed=1.0] - Speech speed (0.25 to 4.0)
57
+ * @param {string} [options.responseFormat='mp3'] - Audio format (mp3, opus, aac, flac)
58
+ * @returns {Promise<Buffer>} Audio buffer
59
+ * @throws {Error} If TTS generation fails
43
60
  */
44
61
  async speak(text, options = {}) {
45
62
  const {
@@ -1,16 +1,20 @@
1
1
  /**
2
- * Social Protocol Adapters (Nostr, ActivityPub)
2
+ * @fileoverview Social protocol adapters for Nostr (NIP-01) and ActivityPub formats.
3
+ * Provides validation, transformation, and filtering utilities for social content integration.
4
+ * @module content/social-protocols
3
5
  */
4
6
 
5
7
  // Import ValidationError from the validator module
6
8
  import { ValidationError } from '../schema/validator.js';
7
9
 
8
10
  /**
9
- * Validate Nostr NIP-01 event format
10
- * @param {Object} event - Nostr event
11
- * @param {boolean} partial - Allow partial events (missing id, pubkey, sig)
12
- * @returns {boolean} True if valid
13
- * @throws {ValidationError} If strict validation fails
11
+ * Validate Nostr NIP-01 event format.
12
+ * Checks required fields (kind, tags, content, created_at) and optionally id, pubkey, sig.
13
+ * @param {Object} event - Nostr event object to validate
14
+ * @param {boolean} [partial=true] - Allow partial events (missing id, pubkey, sig for signing)
15
+ * @param {boolean} [throwOnError=false] - Throw ValidationError on failure instead of returning false
16
+ * @returns {boolean} True if valid, false otherwise (unless throwOnError is true)
17
+ * @throws {ValidationError} If validation fails and throwOnError is true
14
18
  */
15
19
  export function validateNostrEvent(event, partial = true, throwOnError = false) {
16
20
  if (!event || typeof event !== 'object') {
@@ -56,12 +60,13 @@ export function validateNostrEvent(event, partial = true, throwOnError = false)
56
60
  }
57
61
 
58
62
  /**
59
- * Validate ActivityPub object format
60
- * @param {Object} object - ActivityPub object
61
- * @param {boolean} throwOnError - Throw ValidationError on failure
62
- * @param {boolean} requireId - Require id field (default: false, will be auto-generated)
63
- * @returns {boolean} True if valid
64
- * @throws {ValidationError} If strict validation fails
63
+ * Validate ActivityPub object format.
64
+ * Checks for required @context and type fields, optionally validates id field.
65
+ * @param {Object} object - ActivityPub object to validate
66
+ * @param {boolean} [throwOnError=false] - Throw ValidationError on failure instead of returning false
67
+ * @param {boolean} [requireId=false] - Require id field (default: false, will be auto-generated)
68
+ * @returns {boolean} True if valid, false otherwise (unless throwOnError is true)
69
+ * @throws {ValidationError} If validation fails and throwOnError is true
65
70
  */
66
71
  export function validateActivityPubObject(object, throwOnError = false, requireId = false) {
67
72
  if (!object || typeof object !== 'object') {
@@ -85,9 +90,10 @@ export function validateActivityPubObject(object, throwOnError = false, requireI
85
90
  }
86
91
 
87
92
  /**
88
- * Transform Nostr event to HoloSphere format
89
- * @param {Object} event - Nostr event
90
- * @returns {Object} HoloSphere data object
93
+ * Transform Nostr event to HoloSphere storage format.
94
+ * Normalizes Nostr events and adds metadata for HoloSphere compatibility.
95
+ * @param {Object} event - Nostr NIP-01 event object
96
+ * @returns {Object} HoloSphere data object with protocol metadata
91
97
  */
92
98
  export function transformNostrEvent(event) {
93
99
  // Generate missing fields if needed
@@ -115,9 +121,10 @@ export function transformNostrEvent(event) {
115
121
  }
116
122
 
117
123
  /**
118
- * Transform ActivityPub object to HoloSphere format
124
+ * Transform ActivityPub object to HoloSphere storage format.
125
+ * Normalizes ActivityPub objects and adds metadata for HoloSphere compatibility.
119
126
  * @param {Object} object - ActivityPub object
120
- * @returns {Object} HoloSphere data object
127
+ * @returns {Object} HoloSphere data object with protocol metadata
121
128
  */
122
129
  export function transformActivityPubObject(object) {
123
130
  // Generate ID if not provided
@@ -139,10 +146,11 @@ export function transformActivityPubObject(object) {
139
146
  }
140
147
 
141
148
  /**
142
- * Filter social content by access level
143
- * @param {Object[]} content - Social content array
144
- * @param {string} accessLevel - Access level filter
145
- * @returns {Object[]} Filtered content
149
+ * Filter social content by access level.
150
+ * Returns items matching the specified access level or all items if no level specified.
151
+ * @param {Object[]} content - Array of social content items
152
+ * @param {string} accessLevel - Access level to filter by (e.g., 'public', 'private')
153
+ * @returns {Object[]} Filtered content array
146
154
  */
147
155
  export function filterByAccessLevel(content, accessLevel) {
148
156
  if (!accessLevel) return content;
@@ -153,10 +161,11 @@ export function filterByAccessLevel(content, accessLevel) {
153
161
  }
154
162
 
155
163
  /**
156
- * Filter social content by protocol
157
- * @param {Object[]} content - Social content array
158
- * @param {string} protocol - Protocol filter ('nostr' or 'activitypub')
159
- * @returns {Object[]} Filtered content
164
+ * Filter social content by protocol type.
165
+ * Returns items matching the specified protocol or all items if 'all' is specified.
166
+ * @param {Object[]} content - Array of social content items
167
+ * @param {string} protocol - Protocol to filter by ('nostr', 'activitypub', or 'all')
168
+ * @returns {Object[]} Filtered content array
160
169
  */
161
170
  export function filterByProtocol(content, protocol) {
162
171
  if (!protocol || protocol === 'all') return content;