@bolloon/bolloon-agent 0.1.35 → 0.1.37

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 (502) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/p2p-chat-tools.js +6 -6
  3. package/dist/agents/permission-mode.js +115 -0
  4. package/dist/agents/pi-sdk.js +435 -25
  5. package/dist/agents/pre-tool-validator.js +194 -0
  6. package/dist/agents/workflow-pivot-loop.js +113 -12
  7. package/dist/bollharness-integration/context-router.js +2 -2
  8. package/dist/bollharness-integration/guard-checker.js +1 -1
  9. package/dist/bootstrap/bootstrap.js +3 -0
  10. package/dist/bootstrap/context-collector.js +17 -1
  11. package/dist/bootstrap/context-hierarchy.js +218 -0
  12. package/dist/bootstrap/lifecycle-hooks.js +86 -24
  13. package/dist/bootstrap/project-context.js +10 -3
  14. package/dist/context-compaction/auto-compact.js +144 -0
  15. package/dist/context-compaction/budget-gate.js +28 -0
  16. package/dist/context-compaction/budget-reduce.js +35 -0
  17. package/dist/context-compaction/context-collapse.js +66 -0
  18. package/dist/context-compaction/index.js +21 -0
  19. package/dist/context-compaction/microcompact.js +51 -0
  20. package/dist/context-compaction/pipeline.js +123 -0
  21. package/dist/context-compaction/snip.js +45 -0
  22. package/dist/context-compaction/token-estimator.js +35 -0
  23. package/dist/context-compaction/types.js +19 -0
  24. package/dist/heartbeat/HealthMonitor.js +3 -2
  25. package/dist/index.js +38 -2
  26. package/dist/llm/llm-judgment-client.js +32 -30
  27. package/dist/llm/pi-ai.js +103 -16
  28. package/dist/llm/system-prompt/health.js +129 -0
  29. package/dist/llm/system-prompt/registry.js +246 -0
  30. package/dist/llm/system-prompt/strip-hibsml.js +51 -0
  31. package/dist/llm/tool-manifest/ask_user_input.js +35 -0
  32. package/dist/llm/tool-manifest/bash.js +23 -0
  33. package/dist/llm/tool-manifest/create_file.js +24 -0
  34. package/dist/llm/tool-manifest/fetch_sports_data.js +26 -0
  35. package/dist/llm/tool-manifest/image_search.js +24 -0
  36. package/dist/llm/tool-manifest/index.js +69 -0
  37. package/dist/llm/tool-manifest/mcp.js +43 -0
  38. package/dist/llm/tool-manifest/message_compose.js +31 -0
  39. package/dist/llm/tool-manifest/places.js +83 -0
  40. package/dist/llm/tool-manifest/present_files.js +21 -0
  41. package/dist/llm/tool-manifest/recipe.js +40 -0
  42. package/dist/llm/tool-manifest/recommend_apps.js +23 -0
  43. package/dist/llm/tool-manifest/str_replace.js +27 -0
  44. package/dist/llm/tool-manifest/types.js +7 -0
  45. package/dist/llm/tool-manifest/view.js +24 -0
  46. package/dist/llm/tool-manifest/weather.js +27 -0
  47. package/dist/llm/tool-manifest/web.js +51 -0
  48. package/dist/network/p2p-direct.js +23 -0
  49. package/dist/network/source-intent-broadcaster.js +203 -0
  50. package/dist/network/source-intent.js +100 -0
  51. package/dist/pi-ecosystem-judgment/adaptive-scan.js +48 -0
  52. package/dist/pi-ecosystem-judgment/injection-gate.js +54 -12
  53. package/dist/pi-ecosystem-judgment/value-injection.js +8 -2
  54. package/dist/security/context-router-tool.js +1 -1
  55. package/dist/security/input-scanner.js +223 -0
  56. package/dist/web/client.js +3089 -4458
  57. package/dist/web/index.html +58 -67
  58. package/dist/web/server.js +299 -117
  59. package/dist/web/style.css +531 -249
  60. package/dist/web/ui/message-renderer.js +352 -0
  61. package/dist/web/ui/step-timeline.js +279 -0
  62. package/package.json +2 -2
  63. package/.auto-evolve-calls +0 -1
  64. package/.last-auto-evolve-baseline +0 -1
  65. package/Bolloon.md +0 -103
  66. package/dist/agents/constraint-layer.js.map +0 -1
  67. package/dist/agents/pi-sdk.js.map +0 -1
  68. package/dist/agents/workflow-engine.js.map +0 -1
  69. package/dist/bollharness/src/index.js +0 -5
  70. package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +0 -6
  71. package/dist/bollharness/src/scripts/checks/check_api_types.js +0 -45
  72. package/dist/bollharness/src/scripts/checks/check_artifact_link.js +0 -146
  73. package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +0 -6
  74. package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +0 -6
  75. package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +0 -6
  76. package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +0 -6
  77. package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +0 -135
  78. package/dist/bollharness/src/scripts/checks/check_doc_links.js +0 -31
  79. package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +0 -6
  80. package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +0 -34
  81. package/dist/bollharness/src/scripts/checks/check_hook_installed.js +0 -63
  82. package/dist/bollharness/src/scripts/checks/check_issue_closure.js +0 -41
  83. package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +0 -6
  84. package/dist/bollharness/src/scripts/checks/check_security.js +0 -48
  85. package/dist/bollharness/src/scripts/checks/check_skill_parity.js +0 -6
  86. package/dist/bollharness/src/scripts/checks/check_versions.js +0 -6
  87. package/dist/bollharness/src/scripts/checks/finding.js +0 -13
  88. package/dist/bollharness/src/scripts/checks/next_decision_number.js +0 -20
  89. package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +0 -6
  90. package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +0 -8
  91. package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +0 -8
  92. package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +0 -8
  93. package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +0 -8
  94. package/dist/bollharness/src/scripts/context_router.js +0 -67
  95. package/dist/bollharness/src/scripts/deploy-guard.js +0 -157
  96. package/dist/bollharness/src/scripts/guard-feedback.js +0 -192
  97. package/dist/bollharness/src/scripts/guard_router.js +0 -158
  98. package/dist/bollharness/src/scripts/hooks/_hook_output.js +0 -6
  99. package/dist/bollharness/src/scripts/hooks/auto-python3.js +0 -6
  100. package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +0 -6
  101. package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +0 -6
  102. package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +0 -92
  103. package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +0 -63
  104. package/dist/bollharness/src/scripts/hooks/inbox-ack.js +0 -6
  105. package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +0 -6
  106. package/dist/bollharness/src/scripts/hooks/inbox-validate.js +0 -6
  107. package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +0 -6
  108. package/dist/bollharness/src/scripts/hooks/initializer-agent.js +0 -6
  109. package/dist/bollharness/src/scripts/hooks/loop-detection.js +0 -73
  110. package/dist/bollharness/src/scripts/hooks/owner-guard.js +0 -6
  111. package/dist/bollharness/src/scripts/hooks/precompact.js +0 -6
  112. package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +0 -6
  113. package/dist/bollharness/src/scripts/hooks/risk-tracker.js +0 -108
  114. package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +0 -6
  115. package/dist/bollharness/src/scripts/hooks/session-reflection.js +0 -7
  116. package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +0 -7
  117. package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +0 -7
  118. package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +0 -7
  119. package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +0 -157
  120. package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +0 -6
  121. package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +0 -10
  122. package/dist/bollharness/src/scripts/install/install-trust-token.js +0 -7
  123. package/dist/bollharness/src/scripts/install/multi_project_registry.js +0 -9
  124. package/dist/bollharness/src/scripts/install/phase2_auto.js +0 -21
  125. package/dist/bollharness/src/scripts/install/pre_commit_installer.js +0 -6
  126. package/dist/bollharness/src/scripts/install/tier_selector.js +0 -7
  127. package/dist/bollharness/src/scripts/install/transcript_miner.js +0 -7
  128. package/dist/bollharness/src/scripts/lib/claim_patterns.js +0 -10
  129. package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +0 -12
  130. package/dist/bollharness/src/scripts/sanitize.js +0 -6
  131. package/dist/bollharness-integration/context-router-judgment.js.map +0 -1
  132. package/dist/bollharness-integration/context-router.js.map +0 -1
  133. package/dist/bollharness-integration/gate-state-machine.js.map +0 -1
  134. package/dist/bollharness-integration/gate-transition-hooks.js.map +0 -1
  135. package/dist/bollharness-integration/guard-checker.js.map +0 -1
  136. package/dist/bollharness-integration/index.js.map +0 -1
  137. package/dist/bollharness-integration/integration.js.map +0 -1
  138. package/dist/bollharness-integration/llm/pi-ai.d.ts +0 -60
  139. package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +0 -153
  140. package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +0 -136
  141. package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +0 -117
  142. package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +0 -78
  143. package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +0 -139
  144. package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +0 -127
  145. package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +0 -95
  146. package/dist/bollharness-integration/skill-adapter.js.map +0 -1
  147. package/dist/constraint-runtime/src/_archive_helper.js +0 -9
  148. package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
  149. package/dist/constraint-runtime/src/agent/index.js +0 -1
  150. package/dist/constraint-runtime/src/assistant/index.js +0 -12
  151. package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
  152. package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
  153. package/dist/constraint-runtime/src/bridge/index.js +0 -12
  154. package/dist/constraint-runtime/src/buddy/index.js +0 -12
  155. package/dist/constraint-runtime/src/cli/index.js +0 -12
  156. package/dist/constraint-runtime/src/command_graph.js +0 -10
  157. package/dist/constraint-runtime/src/commands.js +0 -60
  158. package/dist/constraint-runtime/src/components/index.js +0 -12
  159. package/dist/constraint-runtime/src/constants/index.js +0 -12
  160. package/dist/constraint-runtime/src/constraint/budget.js +0 -22
  161. package/dist/constraint-runtime/src/constraint/budget.js.map +0 -1
  162. package/dist/constraint-runtime/src/constraint/index.js +0 -2
  163. package/dist/constraint-runtime/src/constraint/permission.js +0 -20
  164. package/dist/constraint-runtime/src/constraint/permission.js.map +0 -1
  165. package/dist/constraint-runtime/src/context.js +0 -30
  166. package/dist/constraint-runtime/src/coordinator/index.js +0 -12
  167. package/dist/constraint-runtime/src/cost_hook.js +0 -4
  168. package/dist/constraint-runtime/src/cost_tracker.js +0 -8
  169. package/dist/constraint-runtime/src/deferred_init.js +0 -10
  170. package/dist/constraint-runtime/src/direct_modes.js +0 -6
  171. package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
  172. package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
  173. package/dist/constraint-runtime/src/execution_registry.js +0 -44
  174. package/dist/constraint-runtime/src/history.js +0 -9
  175. package/dist/constraint-runtime/src/hooks/index.js +0 -12
  176. package/dist/constraint-runtime/src/index.js +0 -26
  177. package/dist/constraint-runtime/src/ink.js +0 -4
  178. package/dist/constraint-runtime/src/keybindings/index.js +0 -12
  179. package/dist/constraint-runtime/src/memdir/index.js +0 -12
  180. package/dist/constraint-runtime/src/migrations/index.js +0 -12
  181. package/dist/constraint-runtime/src/models.js +0 -1
  182. package/dist/constraint-runtime/src/models.js.map +0 -1
  183. package/dist/constraint-runtime/src/moreright/index.js +0 -12
  184. package/dist/constraint-runtime/src/native_ts/index.js +0 -12
  185. package/dist/constraint-runtime/src/output_styles/index.js +0 -12
  186. package/dist/constraint-runtime/src/parity_audit.js +0 -12
  187. package/dist/constraint-runtime/src/plugins/index.js +0 -12
  188. package/dist/constraint-runtime/src/port_manifest.js +0 -11
  189. package/dist/constraint-runtime/src/prefetch.js +0 -9
  190. package/dist/constraint-runtime/src/query.js +0 -1
  191. package/dist/constraint-runtime/src/remote/index.js +0 -12
  192. package/dist/constraint-runtime/src/remote_runtime.js +0 -9
  193. package/dist/constraint-runtime/src/runtime/index.js +0 -1
  194. package/dist/constraint-runtime/src/runtime/session.js +0 -35
  195. package/dist/constraint-runtime/src/schemas/index.js +0 -12
  196. package/dist/constraint-runtime/src/screens/index.js +0 -12
  197. package/dist/constraint-runtime/src/server/index.js +0 -12
  198. package/dist/constraint-runtime/src/services/index.js +0 -12
  199. package/dist/constraint-runtime/src/session_store.js +0 -22
  200. package/dist/constraint-runtime/src/setup.js +0 -30
  201. package/dist/constraint-runtime/src/skills/index.js +0 -1
  202. package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
  203. package/dist/constraint-runtime/src/state/index.js +0 -12
  204. package/dist/constraint-runtime/src/system_init.js +0 -20
  205. package/dist/constraint-runtime/src/thinking/engine.js +0 -42
  206. package/dist/constraint-runtime/src/thinking/index.js +0 -1
  207. package/dist/constraint-runtime/src/tool_pool.js +0 -8
  208. package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
  209. package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
  210. package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
  211. package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +0 -6
  212. package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +0 -6
  213. package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
  214. package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -6
  215. package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
  216. package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
  217. package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
  218. package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +0 -6
  219. package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
  220. package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
  221. package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
  222. package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
  223. package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +0 -29
  224. package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +0 -10
  225. package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +0 -13
  226. package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +0 -22
  227. package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +0 -25
  228. package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +0 -10
  229. package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +0 -25
  230. package/dist/constraint-runtime/src/tools.js +0 -80
  231. package/dist/constraint-runtime/src/transcript.js +0 -19
  232. package/dist/constraint-runtime/src/types/index.js +0 -12
  233. package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
  234. package/dist/constraint-runtime/src/utils/index.js +0 -12
  235. package/dist/constraint-runtime/src/vim/index.js +0 -12
  236. package/dist/constraint-runtime/src/voice/index.js +0 -12
  237. package/dist/constraints/index.js.map +0 -1
  238. package/dist/documents/reader.js.map +0 -1
  239. package/dist/llm/config-store.js.map +0 -1
  240. package/dist/llm/pi-ai.js.map +0 -1
  241. package/dist/network/agent-network.js.map +0 -1
  242. package/dist/network/iroh-integration.js.map +0 -1
  243. package/dist/network/iroh-transport.js.map +0 -1
  244. package/dist/network/p2p.js.map +0 -1
  245. package/dist/network/storage/adapters/json-adapter.js.map +0 -1
  246. package/dist/pi-ecosystem-colony/index.js.map +0 -1
  247. package/dist/pi-ecosystem-goals/index.js.map +0 -1
  248. package/dist/pi-ecosystem-judgment/decision.js.map +0 -1
  249. package/dist/pi-ecosystem-judgment/distillation.js.map +0 -1
  250. package/dist/pi-ecosystem-judgment/human-value-store.js.map +0 -1
  251. package/dist/pi-ecosystem-judgment/index.js.map +0 -1
  252. package/dist/pi-ecosystem-judgment/value-injection.js.map +0 -1
  253. package/dist/pi-ecosystem-mcp/index.js.map +0 -1
  254. package/dist/pi-ecosystem-subagents/index.js.map +0 -1
  255. package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +0 -1
  256. package/dist/social/ant-colony/PheromoneEngine.js.map +0 -1
  257. package/dist/social/ant-colony/types.js.map +0 -1
  258. package/dist/social/channels/ChannelManager.js.map +0 -1
  259. package/dist/social/channels/DiapChannelBridge.js.map +0 -1
  260. package/dist/social/channels/InterestMatcher.js.map +0 -1
  261. package/dist/social/channels/types.js.map +0 -1
  262. package/dist/social/global-shared-context.js.map +0 -1
  263. package/dist/social/heartbeat.js.map +0 -1
  264. package/lefthook.yml +0 -29
  265. package/scripts/auto-evolve-loop.ts +0 -376
  266. package/scripts/auto-evolve-oneshot.sh +0 -155
  267. package/scripts/auto-evolve-snapshot.sh +0 -136
  268. package/scripts/build-cli.js +0 -216
  269. package/scripts/build-web.ts +0 -82
  270. package/scripts/detect-schema-changes.sh +0 -48
  271. package/scripts/diff-reviewer.ts +0 -159
  272. package/scripts/postinstall.js +0 -153
  273. package/scripts/weekly-report.ts +0 -364
  274. package/src/agents/agent-manifest-protocol.ts +0 -117
  275. package/src/agents/constraint-layer.ts +0 -309
  276. package/src/agents/iroh-secret.ts +0 -32
  277. package/src/agents/p2p-chat-tools.ts +0 -383
  278. package/src/agents/p2p-document-tools.ts +0 -347
  279. package/src/agents/pi-sdk.ts +0 -2462
  280. package/src/agents/protocol.ts +0 -398
  281. package/src/agents/shell-guard.ts +0 -417
  282. package/src/agents/shell-tool.ts +0 -103
  283. package/src/agents/skill-loader.ts +0 -202
  284. package/src/agents/subagent-manager.ts +0 -553
  285. package/src/agents/workflow-engine.ts +0 -332
  286. package/src/agents/workflow-pivot-loop.ts +0 -675
  287. package/src/bollharness/.sanitize-report.json +0 -13
  288. package/src/bollharness/CLAUDE.md +0 -73
  289. package/src/bollharness/LICENSE +0 -21
  290. package/src/bollharness/README.md +0 -143
  291. package/src/bollharness/README.zh-CN.md +0 -131
  292. package/src/bollharness/package.json +0 -20
  293. package/src/bollharness/reference/SOURCE-COMMIT.txt +0 -3
  294. package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +0 -12
  295. package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +0 -27
  296. package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +0 -57
  297. package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
  298. package/src/bollharness/schemas/metrics-jsonl-allowlist.json +0 -67
  299. package/src/bollharness/scripts/checks/next_decision_number.sh +0 -48
  300. package/src/bollharness/scripts/ci/count-components.sh +0 -65
  301. package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
  302. package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
  303. package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
  304. package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
  305. package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
  306. package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
  307. package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
  308. package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
  309. package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
  310. package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
  311. package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
  312. package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -108
  313. package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
  314. package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
  315. package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
  316. package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
  317. package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
  318. package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
  319. package/src/bollharness/scripts/hooks/find-project-root.sh +0 -47
  320. package/src/bollharness/scripts/hooks/inbox-poll.sh +0 -78
  321. package/src/bollharness/scripts/hooks/precompact.sh +0 -56
  322. package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
  323. package/src/bollharness/scripts/sync-from-upstream.sh +0 -281
  324. package/src/bollharness/src/index.ts +0 -5
  325. package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +0 -11
  326. package/src/bollharness/src/scripts/checks/check_api_types.ts +0 -52
  327. package/src/bollharness/src/scripts/checks/check_artifact_link.ts +0 -156
  328. package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +0 -11
  329. package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +0 -11
  330. package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +0 -11
  331. package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +0 -11
  332. package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +0 -141
  333. package/src/bollharness/src/scripts/checks/check_doc_links.ts +0 -36
  334. package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +0 -11
  335. package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +0 -40
  336. package/src/bollharness/src/scripts/checks/check_hook_installed.ts +0 -70
  337. package/src/bollharness/src/scripts/checks/check_issue_closure.ts +0 -51
  338. package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +0 -11
  339. package/src/bollharness/src/scripts/checks/check_security.ts +0 -54
  340. package/src/bollharness/src/scripts/checks/check_skill_parity.ts +0 -11
  341. package/src/bollharness/src/scripts/checks/check_versions.ts +0 -11
  342. package/src/bollharness/src/scripts/checks/finding.ts +0 -35
  343. package/src/bollharness/src/scripts/checks/next_decision_number.ts +0 -24
  344. package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +0 -11
  345. package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +0 -14
  346. package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +0 -14
  347. package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +0 -14
  348. package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +0 -14
  349. package/src/bollharness/src/scripts/context_router.ts +0 -76
  350. package/src/bollharness/src/scripts/deploy-guard.ts +0 -182
  351. package/src/bollharness/src/scripts/guard-feedback.ts +0 -215
  352. package/src/bollharness/src/scripts/guard_router.ts +0 -194
  353. package/src/bollharness/src/scripts/hooks/_hook_output.js +0 -3
  354. package/src/bollharness/src/scripts/hooks/_hook_output.ts +0 -11
  355. package/src/bollharness/src/scripts/hooks/auto-python3.ts +0 -10
  356. package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +0 -10
  357. package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +0 -10
  358. package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +0 -111
  359. package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +0 -74
  360. package/src/bollharness/src/scripts/hooks/inbox-ack.ts +0 -10
  361. package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +0 -10
  362. package/src/bollharness/src/scripts/hooks/inbox-validate.ts +0 -10
  363. package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +0 -10
  364. package/src/bollharness/src/scripts/hooks/initializer-agent.ts +0 -10
  365. package/src/bollharness/src/scripts/hooks/loop-detection.ts +0 -83
  366. package/src/bollharness/src/scripts/hooks/owner-guard.ts +0 -10
  367. package/src/bollharness/src/scripts/hooks/precompact.ts +0 -10
  368. package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +0 -10
  369. package/src/bollharness/src/scripts/hooks/risk-tracker.ts +0 -121
  370. package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +0 -10
  371. package/src/bollharness/src/scripts/hooks/session-reflection.ts +0 -12
  372. package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +0 -12
  373. package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +0 -12
  374. package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +0 -12
  375. package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +0 -164
  376. package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +0 -10
  377. package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +0 -14
  378. package/src/bollharness/src/scripts/install/install-trust-token.ts +0 -13
  379. package/src/bollharness/src/scripts/install/multi_project_registry.ts +0 -13
  380. package/src/bollharness/src/scripts/install/phase2_auto.ts +0 -28
  381. package/src/bollharness/src/scripts/install/pre_commit_installer.ts +0 -10
  382. package/src/bollharness/src/scripts/install/tier_selector.ts +0 -10
  383. package/src/bollharness/src/scripts/install/transcript_miner.ts +0 -13
  384. package/src/bollharness/src/scripts/lib/claim_patterns.ts +0 -11
  385. package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +0 -13
  386. package/src/bollharness/src/scripts/sanitize.ts +0 -9
  387. package/src/bollharness/templates/persona/default.json +0 -19
  388. package/src/bollharness/templates/scaffold/.gitignore.append +0 -16
  389. package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
  390. package/src/bollharness-integration/channel-judgment-engine.ts +0 -634
  391. package/src/bollharness-integration/context-chain-router.ts +0 -474
  392. package/src/bollharness-integration/context-router-judgment.ts +0 -339
  393. package/src/bollharness-integration/context-router.ts +0 -583
  394. package/src/bollharness-integration/gate-state-machine.ts +0 -444
  395. package/src/bollharness-integration/gate-transition-hooks.ts +0 -137
  396. package/src/bollharness-integration/guard-checker.ts +0 -451
  397. package/src/bollharness-integration/index.ts +0 -195
  398. package/src/bollharness-integration/integration.ts +0 -538
  399. package/src/bollharness-integration/judgment-prompts.yaml +0 -535
  400. package/src/bollharness-integration/llm-judgment-engine.ts +0 -712
  401. package/src/bollharness-integration/skill-adapter.ts +0 -646
  402. package/src/bootstrap/bootstrap.ts +0 -132
  403. package/src/bootstrap/context-collector.ts +0 -342
  404. package/src/bootstrap/lifecycle-hooks.ts +0 -176
  405. package/src/bootstrap/project-context.ts +0 -163
  406. package/src/cli/interface.ts +0 -211
  407. package/src/cli-entry.ts +0 -304
  408. package/src/constraints/index.ts +0 -6
  409. package/src/documents/reader.ts +0 -85
  410. package/src/documents/store.ts +0 -252
  411. package/src/electron-preload.ts +0 -25
  412. package/src/electron.ts +0 -200
  413. package/src/heartbeat/DaemonManager.ts +0 -283
  414. package/src/heartbeat/HealthMonitor.ts +0 -316
  415. package/src/heartbeat/StartupVerifier.ts +0 -223
  416. package/src/heartbeat/Watchdog.ts +0 -208
  417. package/src/heartbeat/index.ts +0 -109
  418. package/src/heartbeat/self-improve-bus.ts +0 -110
  419. package/src/heartbeat/types.ts +0 -82
  420. package/src/index.ts +0 -1690
  421. package/src/llm/audio-config-store.ts +0 -246
  422. package/src/llm/config-store.ts +0 -400
  423. package/src/llm/llm-judgment-client.ts +0 -470
  424. package/src/llm/pi-ai.ts +0 -558
  425. package/src/llm/video-config-store.ts +0 -257
  426. package/src/network/agent-network.ts +0 -800
  427. package/src/network/hybrid-messenger.ts +0 -199
  428. package/src/network/iroh-bootstrap.ts +0 -57
  429. package/src/network/iroh-discovery.ts +0 -208
  430. package/src/network/iroh-integration.ts +0 -158
  431. package/src/network/iroh-transport.ts +0 -637
  432. package/src/network/known-peers.ts +0 -102
  433. package/src/network/p2p-direct.ts +0 -240
  434. package/src/network/p2p-secret.ts +0 -153
  435. package/src/network/p2p.ts +0 -964
  436. package/src/network/storage/adapters/json-adapter.ts +0 -454
  437. package/src/network/storage/index.ts +0 -203
  438. package/src/network/storage/types.ts +0 -166
  439. package/src/security/builtin-guards.ts +0 -162
  440. package/src/security/context-router-tool.ts +0 -122
  441. package/src/security/react-harness.ts +0 -177
  442. package/src/security/tool-gate.ts +0 -294
  443. package/src/social/ant-colony/index.js +0 -19
  444. package/src/social/channels/ChannelManager.ts +0 -485
  445. package/src/social/channels/DiapChannelBridge.ts +0 -501
  446. package/src/social/channels/InterestMatcher.ts +0 -189
  447. package/src/social/channels/agent-workflow-config.json +0 -214
  448. package/src/social/channels/agent-workflow-config.yaml +0 -334
  449. package/src/social/channels/channel-agent-session.ts +0 -407
  450. package/src/social/channels/channel-heartbeat-agent.ts +0 -622
  451. package/src/social/channels/diap-doc-parser.ts +0 -282
  452. package/src/social/channels/harness-workflow-integrator.ts +0 -594
  453. package/src/social/channels/index.ts +0 -22
  454. package/src/social/channels/types.ts +0 -115
  455. package/src/social/global-shared-context.ts +0 -506
  456. package/src/social/heartbeat.ts +0 -1057
  457. package/src/social/persona/enhanced-persona.ts +0 -359
  458. package/src/types.d.ts +0 -12
  459. package/src/utils/auto-evolve-policy.ts +0 -138
  460. package/src/utils/auto-update.ts +0 -482
  461. package/src/utils/clamp.ts +0 -5
  462. package/src/web/agent-delegate-server.ts +0 -148
  463. package/src/web/api-config.html +0 -520
  464. package/src/web/client.js +0 -4898
  465. package/src/web/components/p2p/P2PModal.tsx +0 -416
  466. package/src/web/components/p2p/index.ts +0 -566
  467. package/src/web/components/p2p/index.tsx +0 -297
  468. package/src/web/components/p2p/p2p-connection.ts +0 -338
  469. package/src/web/components/p2p/p2p-identity.ts +0 -92
  470. package/src/web/components/p2p/p2p-manager.ts +0 -147
  471. package/src/web/components/p2p/p2p-messages.ts +0 -219
  472. package/src/web/components/p2p/p2p-modal.ts +0 -685
  473. package/src/web/components/p2p/p2p-store-memory.ts +0 -162
  474. package/src/web/components/p2p/p2p-tools.ts +0 -315
  475. package/src/web/components/p2p/types.ts +0 -170
  476. package/src/web/components/wallet-viem.mjs +0 -118
  477. package/src/web/design.md +0 -99
  478. package/src/web/icons/apple-touch-icon.png +0 -0
  479. package/src/web/icons/favicon-16x16.png +0 -0
  480. package/src/web/icons/favicon-192x192.png +0 -0
  481. package/src/web/icons/favicon-32x32.png +0 -0
  482. package/src/web/icons/favicon-48x48.png +0 -0
  483. package/src/web/icons/favicon-512x512.png +0 -0
  484. package/src/web/icons/favicon.icns +0 -0
  485. package/src/web/icons/favicon.ico +0 -0
  486. package/src/web/icons/icon.png +0 -0
  487. package/src/web/icons/image.png +0 -0
  488. package/src/web/index.html +0 -382
  489. package/src/web/iroh-delegate-transport.ts +0 -139
  490. package/src/web/manifest.json +0 -21
  491. package/src/web/server.ts +0 -5571
  492. package/src/web/style.css +0 -4455
  493. package/staging/auto-evolve/clean-001/.review-verdict +0 -9
  494. package/staging/auto-evolve/clean-001/clean-001.patch +0 -14
  495. package/staging/auto-evolve/e2e-001/.patch-id +0 -1
  496. package/staging/auto-evolve/e2e-001/.review-verdict +0 -12
  497. package/staging/auto-evolve/e2e-001/e2e-001.patch +0 -11
  498. package/staging/auto-evolve/test-bad/.review-verdict +0 -12
  499. package/staging/auto-evolve/test-bad/test-bad.patch +0 -11
  500. package/tsconfig.cli.json +0 -16
  501. package/tsconfig.electron.json +0 -20
  502. package/tsconfig.json +0 -18
@@ -1,199 +0,0 @@
1
- import { irohTransport } from './iroh-transport.js';
2
- import { p2pNetwork, type PersistentPeerInfo } from './p2p.js';
3
-
4
- export type TransportType = 'hyperswarm' | 'iroh' | 'libp2p';
5
- export type MessagePriority = 'urgent' | 'normal' | 'bulk';
6
-
7
- export interface HybridMessage {
8
- type: string;
9
- payload: Uint8Array;
10
- from: string;
11
- transport?: TransportType;
12
- }
13
-
14
- export type HybridMessageHandler = (msg: HybridMessage) => void;
15
-
16
- export interface TransportConfig {
17
- preferIrohForLarge: boolean;
18
- largeThresholdBytes: number;
19
- enableRelay: boolean;
20
- }
21
-
22
- const DEFAULT_CONFIG: TransportConfig = {
23
- preferIrohForLarge: true,
24
- largeThresholdBytes: 64 * 1024,
25
- enableRelay: true,
26
- };
27
-
28
- export class HybridMessenger {
29
- private messageHandlers: Map<string, HybridMessageHandler> = new Map();
30
- private wildcardHandler: HybridMessageHandler | null = null;
31
- private config: TransportConfig;
32
- private irohEnabled: boolean = true;
33
-
34
- constructor(config: Partial<TransportConfig> = {}) {
35
- this.config = { ...DEFAULT_CONFIG, ...config };
36
- }
37
-
38
- private selectTransport(
39
- type: string,
40
- payloadSize: number,
41
- priority: MessagePriority = 'normal'
42
- ): TransportType {
43
- if (this.irohEnabled && this.shouldUseIroh(type, payloadSize, priority)) {
44
- return 'iroh';
45
- }
46
-
47
- if (priority === 'urgent' || type === 'relay') {
48
- return 'libp2p';
49
- }
50
-
51
- return 'hyperswarm';
52
- }
53
-
54
- private shouldUseIroh(
55
- type: string,
56
- payloadSize: number,
57
- priority: MessagePriority
58
- ): boolean {
59
- const bulkTypes = ['blob', 'stream', 'file', 'large-data'];
60
- if (bulkTypes.includes(type) || payloadSize > this.config.largeThresholdBytes) {
61
- return true;
62
- }
63
-
64
- if (priority === 'bulk' && payloadSize > 1024) {
65
- return true;
66
- }
67
-
68
- return false;
69
- }
70
-
71
- async sendMessage(
72
- targetId: string,
73
- type: string,
74
- payload: string | Uint8Array,
75
- options: {
76
- priority?: MessagePriority;
77
- preferTransport?: TransportType;
78
- relayAddr?: string;
79
- } = {}
80
- ): Promise<boolean> {
81
- const { priority = 'normal', preferTransport, relayAddr } = options;
82
-
83
- const payloadBytes = typeof payload === 'string'
84
- ? new TextEncoder().encode(payload)
85
- : payload;
86
-
87
- const transport = preferTransport || this.selectTransport(type, payloadBytes.length, priority);
88
-
89
- console.log(`[HybridMessenger] Sending "${type}" (${payloadBytes.length} bytes) via ${transport}`);
90
-
91
- switch (transport) {
92
- case 'iroh':
93
- return this.sendViaIroh(targetId, type, payloadBytes);
94
-
95
- case 'libp2p':
96
- return this.sendViaLibp2p(targetId, type, payloadBytes, relayAddr);
97
-
98
- case 'hyperswarm':
99
- default:
100
- return this.sendViaHyperswarm(targetId, type, payloadBytes);
101
- }
102
- }
103
-
104
- private async sendViaIroh(targetId: string, type: string, payload: Uint8Array): Promise<boolean> {
105
- try {
106
- return await irohTransport.sendMessage(targetId, type, payload);
107
- } catch (e) {
108
- console.warn('[HybridMessenger] iroh send failed:', e);
109
- return false;
110
- }
111
- }
112
-
113
- private async sendViaLibp2p(
114
- targetId: string,
115
- type: string,
116
- payload: Uint8Array,
117
- relayAddr?: string
118
- ): Promise<boolean> {
119
- try {
120
- await p2pNetwork.sendMessage(targetId, type, new TextDecoder().decode(payload));
121
- return true;
122
- } catch (e) {
123
- console.warn('[HybridMessenger] libp2p send failed:', e);
124
- return false;
125
- }
126
- }
127
-
128
- private async sendViaHyperswarm(targetId: string, type: string, payload: Uint8Array): Promise<boolean> {
129
- try {
130
- await p2pNetwork.sendMessage(targetId, type, new TextDecoder().decode(payload));
131
- return true;
132
- } catch (e) {
133
- console.warn('[HybridMessenger] Hyperswarm send failed:', e);
134
- return false;
135
- }
136
- }
137
-
138
- async broadcast(
139
- type: string,
140
- payload: string | Uint8Array,
141
- options: {
142
- priority?: MessagePriority;
143
- transport?: TransportType;
144
- } = {}
145
- ): Promise<void> {
146
- const { priority = 'normal', transport } = options;
147
-
148
- const payloadBytes = typeof payload === 'string'
149
- ? new TextEncoder().encode(payload)
150
- : payload;
151
-
152
- const selectedTransport = transport || this.selectTransport(type, payloadBytes.length, priority);
153
-
154
- if (selectedTransport === 'iroh') {
155
- await irohTransport.broadcast(type, payloadBytes);
156
- } else {
157
- await p2pNetwork.broadcast(type, new TextDecoder().decode(payloadBytes));
158
- }
159
- }
160
-
161
- onMessage(type: string, handler: HybridMessageHandler): void {
162
- this.messageHandlers.set(type, handler);
163
- }
164
-
165
- onWildcard(handler: HybridMessageHandler): void {
166
- this.wildcardHandler = handler;
167
- }
168
-
169
- dispatchMessage(msg: HybridMessage): void {
170
- const handler = this.messageHandlers.get(msg.type);
171
- if (handler) {
172
- handler(msg);
173
- } else if (this.wildcardHandler) {
174
- this.wildcardHandler(msg);
175
- }
176
- }
177
-
178
- setIrohEnabled(enabled: boolean): void {
179
- this.irohEnabled = enabled;
180
- }
181
-
182
- isIrohEnabled(): boolean {
183
- return this.irohEnabled;
184
- }
185
-
186
- getConfig(): TransportConfig {
187
- return { ...this.config };
188
- }
189
-
190
- setLargeThreshold(bytes: number): void {
191
- this.config.largeThresholdBytes = bytes;
192
- }
193
-
194
- setPreferIrohForLarge(enabled: boolean): void {
195
- this.config.preferIrohForLarge = enabled;
196
- }
197
- }
198
-
199
- export const hybridMessenger = new HybridMessenger();
@@ -1,57 +0,0 @@
1
- import { AgentAuthManager, KeyManager } from '@diap/sdk';
2
- import { irohTransport } from './iroh-transport.js';
3
-
4
- export async function bootstrapIroh(
5
- auth: AgentAuthManager,
6
- keyPair: Awaited<ReturnType<typeof KeyManager.generate>>,
7
- agentName: string
8
- ): Promise<string | null> {
9
- console.log('[Iroh] Starting iroh transport...');
10
-
11
- const node = await irohTransport.start();
12
- const nodeId = node.nodeId;
13
- console.log(`[Iroh] Node ID: ${nodeId}`);
14
-
15
- const services = [
16
- { serviceType: 'iroh', endpoint: nodeId },
17
- { serviceType: 'iroh-quic', endpoint: `iroh://${nodeId}` },
18
- ];
19
-
20
- try {
21
- const result = await auth.registerAgent(
22
- { name: agentName, services: services as any } as any,
23
- keyPair,
24
- nodeId
25
- );
26
- console.log(`[Iroh] Registered with DIAP: DID=${result.did.substring(0, 20)}...`);
27
- } catch (e) {
28
- console.warn('[Iroh] DIAP registration failed:', e);
29
- }
30
-
31
- irohTransport.onMessage('task', async (msg) => {
32
- console.log(`[Iroh] Received task from ${msg.from}: ${new TextDecoder().decode(msg.payload).substring(0, 50)}...`);
33
- });
34
-
35
- irohTransport.onMessage('relay', (msg) => {
36
- console.log(`[Iroh] Relay message from ${msg.from}`);
37
- });
38
-
39
- irohTransport.onMessage('blob', (msg) => {
40
- console.log(`[Iroh] Blob from ${msg.from}: ${msg.payload.length} bytes`);
41
- });
42
-
43
- return nodeId;
44
- }
45
-
46
- export async function connectToIrohPeer(targetNodeId: string, type: string, payload: string): Promise<boolean> {
47
- return irohTransport.sendMessage(targetNodeId, type, new TextEncoder().encode(payload));
48
- }
49
-
50
- export async function requestIrohPeer(targetNodeId: string, type: string, payload: string): Promise<string | null> {
51
- const response = await irohTransport.requestResponse(targetNodeId, type, new TextEncoder().encode(payload));
52
- return response ? new TextDecoder().decode(response) : null;
53
- }
54
-
55
- export function onIrohMessage(type: string, handler: (msg: { type: string; payload: Uint8Array; from: string }) => void): void {
56
- irohTransport.onMessage(type, handler);
57
- }
@@ -1,208 +0,0 @@
1
- import { AgentAuthManager, type AgentInfo, type KeyPair } from '@diap/sdk';
2
- import { irohTransport } from './iroh-transport.js';
3
-
4
- export interface DiscoveredAgent {
5
- did: string;
6
- name: string;
7
- peerId: string;
8
- irohNodeId: string | null;
9
- lastSeen: number;
10
- services: string[];
11
- }
12
-
13
- export interface IrohDiscoveryConfig {
14
- agentAuthManager: AgentAuthManager;
15
- keyPair: KeyPair;
16
- agentName: string;
17
- agentDescription?: string;
18
- agentTags?: string[];
19
- discoveryIntervalMs?: number;
20
- refreshIntervalMs?: number;
21
- }
22
-
23
- export class IrohDiscoveryService {
24
- private config: IrohDiscoveryConfig;
25
- private discoveredAgents: Map<string, DiscoveredAgent> = new Map();
26
- private ownIrohNodeId: string | null = null;
27
- private refreshTimer: ReturnType<typeof setInterval> | null = null;
28
- private discoveryTimer: ReturnType<typeof setInterval> | null = null;
29
- private isRegistered: boolean = false;
30
-
31
- constructor(config: IrohDiscoveryConfig) {
32
- this.config = {
33
- discoveryIntervalMs: 30000,
34
- refreshIntervalMs: 5 * 60 * 1000,
35
- ...config,
36
- };
37
- }
38
-
39
- async start(): Promise<string | null> {
40
- console.log('[IrohDiscovery] Starting...');
41
-
42
- const node = await irohTransport.start();
43
- this.ownIrohNodeId = node.nodeId;
44
- console.log('[IrohDiscovery] Iroh node ID:', this.ownIrohNodeId.substring(0, 16) + '...');
45
-
46
- await this.registerWithDIAP();
47
- this.isRegistered = true;
48
-
49
- this.startRefreshLoop();
50
- this.startDiscoveryLoop();
51
-
52
- return this.ownIrohNodeId;
53
- }
54
-
55
- private async registerWithDIAP(): Promise<void> {
56
- if (!this.ownIrohNodeId) return;
57
-
58
- try {
59
- const services = [
60
- { serviceType: 'iroh', endpoint: this.ownIrohNodeId },
61
- { serviceType: 'iroh-quic', endpoint: `iroh://${this.ownIrohNodeId}` },
62
- ];
63
-
64
- const agentInfo: AgentInfo = {
65
- name: this.config.agentName,
66
- services: services as any,
67
- description: this.config.agentDescription || 'Bolloon agent with iroh P2P',
68
- tags: this.config.agentTags || ['bolloon', 'iroh'],
69
- };
70
-
71
- await this.config.agentAuthManager.registerAgent(
72
- agentInfo,
73
- this.config.keyPair,
74
- this.ownIrohNodeId
75
- );
76
-
77
- console.log('[IrohDiscovery] Registered with DIAP');
78
- } catch (e) {
79
- console.warn('[IrohDiscovery] DIAP registration failed:', e);
80
- }
81
- }
82
-
83
- private startRefreshLoop(): void {
84
- this.refreshTimer = setInterval(async () => {
85
- if (!this.isRegistered) return;
86
- console.log('[IrohDiscovery] Refreshing DIAP registration...');
87
- await this.registerWithDIAP();
88
- }, this.config.refreshIntervalMs!);
89
- }
90
-
91
- private startDiscoveryLoop(): void {
92
- const interval = this.config.discoveryIntervalMs ?? 30000;
93
- this.discoveryTimer = setInterval(async () => {
94
- await this.discoverPeers();
95
- }, interval);
96
-
97
- setTimeout(() => this.discoverPeers(), 2000);
98
- }
99
-
100
- async discoverPeers(): Promise<DiscoveredAgent[]> {
101
- console.log('[IrohDiscovery] Discovering peers...');
102
-
103
- const now = Date.now();
104
- const staleThreshold = 10 * 60 * 1000;
105
-
106
- for (const [did, agent] of this.discoveredAgents) {
107
- if (now - agent.lastSeen > staleThreshold) {
108
- this.discoveredAgents.delete(did);
109
- }
110
- }
111
-
112
- console.log('[IrohDiscovery] Known agents:', this.discoveredAgents.size);
113
- return Array.from(this.discoveredAgents.values());
114
- }
115
-
116
- async discoverViaDIAP(): Promise<DiscoveredAgent[]> {
117
- console.log('[IrohDiscovery] Querying DIAP for agents...');
118
-
119
- const agents: DiscoveredAgent[] = [];
120
-
121
- try {
122
- const ipfsClient = (this.config.agentAuthManager as any).identityManager?.ipfsClient;
123
- if (ipfsClient) {
124
- console.log('[IrohDiscovery] IPFS client available for discovery');
125
- }
126
- } catch (e) {
127
- console.warn('[IrohDiscovery] DIAP discovery error:', e);
128
- }
129
-
130
- return agents;
131
- }
132
-
133
- addDiscoveredAgent(agent: DiscoveredAgent): void {
134
- const existing = this.discoveredAgents.get(agent.did);
135
- this.discoveredAgents.set(agent.did, {
136
- ...agent,
137
- lastSeen: Date.now(),
138
- irohNodeId: agent.irohNodeId || existing?.irohNodeId || null,
139
- });
140
- }
141
-
142
- getDiscoveredAgents(): DiscoveredAgent[] {
143
- return Array.from(this.discoveredAgents.values());
144
- }
145
-
146
- getAgentByDid(did: string): DiscoveredAgent | undefined {
147
- return this.discoveredAgents.get(did);
148
- }
149
-
150
- getAgentsWithIroh(): DiscoveredAgent[] {
151
- return Array.from(this.discoveredAgents.values()).filter(
152
- (a) => a.irohNodeId !== null
153
- );
154
- }
155
-
156
- getOwnIrohNodeId(): string | null {
157
- return this.ownIrohNodeId;
158
- }
159
-
160
- async connectToPeer(nodeId: string): Promise<boolean> {
161
- return irohTransport.connect(nodeId);
162
- }
163
-
164
- async connectToAllIrohPeers(): Promise<void> {
165
- const agents = this.getAgentsWithIroh();
166
- for (const agent of agents) {
167
- if (agent.irohNodeId && agent.irohNodeId !== this.ownIrohNodeId) {
168
- await this.connectToPeer(agent.irohNodeId);
169
- }
170
- }
171
- }
172
-
173
- async shutdown(): Promise<void> {
174
- this.isRegistered = false;
175
-
176
- if (this.refreshTimer) {
177
- clearInterval(this.refreshTimer);
178
- this.refreshTimer = null;
179
- }
180
-
181
- if (this.discoveryTimer) {
182
- clearInterval(this.discoveryTimer);
183
- this.discoveryTimer = null;
184
- }
185
-
186
- this.discoveredAgents.clear();
187
- await irohTransport.shutdown();
188
- console.log('[IrohDiscovery] Shut down');
189
- }
190
- }
191
-
192
- let discoveryInstance: IrohDiscoveryService | null = null;
193
-
194
- export async function startIrohDiscovery(
195
- config: IrohDiscoveryConfig
196
- ): Promise<IrohDiscoveryService> {
197
- if (discoveryInstance) {
198
- return discoveryInstance;
199
- }
200
-
201
- discoveryInstance = new IrohDiscoveryService(config);
202
- await discoveryInstance.start();
203
- return discoveryInstance;
204
- }
205
-
206
- export function getIrohDiscovery(): IrohDiscoveryService | null {
207
- return discoveryInstance;
208
- }
@@ -1,158 +0,0 @@
1
- import { irohTransport, type IrohMessage } from './iroh-transport.js';
2
- import { AgentAuthManager, KeyManager, type AgentInfo, type IdentityRegistration, type KeyPair } from '@diap/sdk';
3
-
4
- export interface IrohDiscoveryResult {
5
- did: string;
6
- name: string;
7
- irohNodeId: string;
8
- lastSeen: number;
9
- }
10
-
11
- export interface IrohIntegrationConfig {
12
- agentAuthManager: AgentAuthManager;
13
- keyPair: KeyPair;
14
- agentName: string;
15
- agentDescription?: string;
16
- agentTags?: string[];
17
- refreshIntervalMs?: number;
18
- discoveryIntervalMs?: number;
19
- }
20
-
21
- export class IrohIntegration {
22
- private config: IrohIntegrationConfig;
23
- private irohNodeId: string | null = null;
24
- private registration: IdentityRegistration | null = null;
25
- private messageHandlers: Map<string, (msg: IrohMessage, from: string) => void> = new Map();
26
- private discoveredPeers: Map<string, IrohDiscoveryResult> = new Map();
27
- private refreshTimer: ReturnType<typeof setInterval> | null = null;
28
- private connectedPeers: Set<string> = new Set();
29
-
30
- constructor(config: IrohIntegrationConfig) {
31
- this.config = {
32
- refreshIntervalMs: 5 * 60 * 1000,
33
- discoveryIntervalMs: 30 * 1000,
34
- ...config,
35
- };
36
- }
37
-
38
- async start(): Promise<string | null> {
39
- try {
40
- console.log('[IrohIntegration] Starting iroh transport...');
41
-
42
- const node = await irohTransport.start();
43
- this.irohNodeId = node.nodeId;
44
- console.log(`[IrohIntegration] Node ID: ${this.irohNodeId}`);
45
-
46
- irohTransport.onMessage('*', (msg) => {
47
- this.dispatchMessage(msg);
48
- });
49
-
50
- await this.registerWithDIAP();
51
- this.startRefreshLoop();
52
-
53
- console.log('[IrohIntegration] Started successfully');
54
- return this.irohNodeId;
55
- } catch (e) {
56
- console.error('[IrohIntegration] Failed to start:', e);
57
- return null;
58
- }
59
- }
60
-
61
- private async registerWithDIAP(): Promise<void> {
62
- if (!this.irohNodeId) {
63
- console.warn('[IrohIntegration] No iroh node ID');
64
- return;
65
- }
66
-
67
- try {
68
- const services = [
69
- { serviceType: 'iroh', endpoint: this.irohNodeId },
70
- { serviceType: 'iroh-quic', endpoint: `iroh://${this.irohNodeId}` },
71
- ];
72
-
73
- const agentInfo: AgentInfo = {
74
- name: this.config.agentName,
75
- services: services as any,
76
- description: this.config.agentDescription || 'Bolloon agent with iroh P2P',
77
- tags: this.config.agentTags || ['bolloon', 'iroh', 'p2p'],
78
- };
79
-
80
- this.registration = await this.config.agentAuthManager.registerAgent(
81
- agentInfo,
82
- this.config.keyPair,
83
- this.irohNodeId
84
- );
85
-
86
- console.log(`[IrohIntegration] DIAP registered: DID=${this.registration.did.substring(0, 20)}...`);
87
- } catch (e) {
88
- console.error('[IrohIntegration] DIAP registration failed:', e);
89
- }
90
- }
91
-
92
- private startRefreshLoop(): void {
93
- this.refreshTimer = setInterval(async () => {
94
- console.log('[IrohIntegration] Refreshing DIAP registration...');
95
- await this.registerWithDIAP();
96
- }, this.config.refreshIntervalMs!);
97
- }
98
-
99
- private dispatchMessage(msg: IrohMessage): void {
100
- const handler = this.messageHandlers.get(msg.type);
101
- if (handler) {
102
- handler(msg, msg.from);
103
- }
104
- }
105
-
106
- onMessage(type: string, handler: (msg: IrohMessage, from: string) => void): void {
107
- this.messageHandlers.set(type, handler);
108
- }
109
-
110
- async sendTo(targetNodeId: string, type: string, payload: Uint8Array): Promise<boolean> {
111
- return irohTransport.sendMessage(targetNodeId, type, payload);
112
- }
113
-
114
- async requestFrom(targetNodeId: string, type: string, payload: Uint8Array): Promise<Uint8Array | null> {
115
- return irohTransport.requestResponse(targetNodeId, type, payload);
116
- }
117
-
118
- getNodeId(): string | null {
119
- return this.irohNodeId;
120
- }
121
-
122
- getRegistration(): IdentityRegistration | null {
123
- return this.registration;
124
- }
125
-
126
- getConnectedPeers(): string[] {
127
- return Array.from(this.connectedPeers);
128
- }
129
-
130
- async shutdown(): Promise<void> {
131
- if (this.refreshTimer) {
132
- clearInterval(this.refreshTimer);
133
- this.refreshTimer = null;
134
- }
135
-
136
- await irohTransport.shutdown();
137
- console.log('[IrohIntegration] Shut down');
138
- }
139
- }
140
-
141
- let integrationInstance: IrohIntegration | null = null;
142
-
143
- export async function initIrohIntegration(
144
- config: IrohIntegrationConfig
145
- ): Promise<IrohIntegration> {
146
- if (integrationInstance) {
147
- console.log('[IrohIntegration] Already initialized');
148
- return integrationInstance;
149
- }
150
-
151
- integrationInstance = new IrohIntegration(config);
152
- await integrationInstance.start();
153
- return integrationInstance;
154
- }
155
-
156
- export function getIrohIntegration(): IrohIntegration | null {
157
- return integrationInstance;
158
- }