@ibgib/web-gib 0.0.1

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 (372) hide show
  1. package/.ibgibignore +30 -0
  2. package/.vscode/ibgib-snippets.code-snippets +309 -0
  3. package/.vscode/launch.json +25 -0
  4. package/.vscode/settings.json +68 -0
  5. package/.vscode/tasks.json +38 -0
  6. package/CHANGELOG.md +427 -0
  7. package/README.md +66 -0
  8. package/dist/agent-texts/common-agent-texts.d.mts +14 -0
  9. package/dist/agent-texts/common-agent-texts.d.mts.map +1 -0
  10. package/dist/agent-texts/common-agent-texts.mjs +51 -0
  11. package/dist/agent-texts/common-agent-texts.mjs.map +1 -0
  12. package/dist/agent-texts/primary-agent-texts.d.mts +16 -0
  13. package/dist/agent-texts/primary-agent-texts.d.mts.map +1 -0
  14. package/dist/agent-texts/primary-agent-texts.mjs +27 -0
  15. package/dist/agent-texts/primary-agent-texts.mjs.map +1 -0
  16. package/dist/agent-texts/project-agent-texts.d.mts +8 -0
  17. package/dist/agent-texts/project-agent-texts.d.mts.map +1 -0
  18. package/dist/agent-texts/project-agent-texts.mjs +29 -0
  19. package/dist/agent-texts/project-agent-texts.mjs.map +1 -0
  20. package/dist/agent-texts/project-child-text-agent-texts.d.mts +5 -0
  21. package/dist/agent-texts/project-child-text-agent-texts.d.mts.map +1 -0
  22. package/dist/agent-texts/project-child-text-agent-texts.mjs +26 -0
  23. package/dist/agent-texts/project-child-text-agent-texts.mjs.map +1 -0
  24. package/dist/agent-texts/projects-agent-texts.d.mts +4 -0
  25. package/dist/agent-texts/projects-agent-texts.d.mts.map +1 -0
  26. package/dist/agent-texts/projects-agent-texts.mjs +15 -0
  27. package/dist/agent-texts/projects-agent-texts.mjs.map +1 -0
  28. package/dist/agent-texts/raw-agent-texts.d.mts +4 -0
  29. package/dist/agent-texts/raw-agent-texts.d.mts.map +1 -0
  30. package/dist/agent-texts/raw-agent-texts.mjs +17 -0
  31. package/dist/agent-texts/raw-agent-texts.mjs.map +1 -0
  32. package/dist/agent-texts/text-editor-agent-texts.d.mts +6 -0
  33. package/dist/agent-texts/text-editor-agent-texts.d.mts.map +1 -0
  34. package/dist/agent-texts/text-editor-agent-texts.mjs +19 -0
  35. package/dist/agent-texts/text-editor-agent-texts.mjs.map +1 -0
  36. package/dist/api/api-constants.d.mts +9 -0
  37. package/dist/api/api-constants.d.mts.map +1 -0
  38. package/dist/api/api-constants.mjs +9 -0
  39. package/dist/api/api-constants.mjs.map +1 -0
  40. package/dist/api/api-index.d.mts +10 -0
  41. package/dist/api/api-index.d.mts.map +1 -0
  42. package/dist/api/api-index.mjs +121 -0
  43. package/dist/api/api-index.mjs.map +1 -0
  44. package/dist/api/api-types.d.mts +36 -0
  45. package/dist/api/api-types.d.mts.map +1 -0
  46. package/dist/api/api-types.mjs +2 -0
  47. package/dist/api/api-types.mjs.map +1 -0
  48. package/dist/api/commands/chat/chat-index.d.mts +3 -0
  49. package/dist/api/commands/chat/chat-index.d.mts.map +1 -0
  50. package/dist/api/commands/chat/chat-index.mjs +9 -0
  51. package/dist/api/commands/chat/chat-index.mjs.map +1 -0
  52. package/dist/api/commands/chat/get-context-info.d.mts +71 -0
  53. package/dist/api/commands/chat/get-context-info.d.mts.map +1 -0
  54. package/dist/api/commands/chat/get-context-info.mjs +130 -0
  55. package/dist/api/commands/chat/get-context-info.mjs.map +1 -0
  56. package/dist/api/commands/chat/hello-world.d.mts +63 -0
  57. package/dist/api/commands/chat/hello-world.d.mts.map +1 -0
  58. package/dist/api/commands/chat/hello-world.mjs +132 -0
  59. package/dist/api/commands/chat/hello-world.mjs.map +1 -0
  60. package/dist/api/commands/chat/tell-user.d.mts +57 -0
  61. package/dist/api/commands/chat/tell-user.d.mts.map +1 -0
  62. package/dist/api/commands/chat/tell-user.mjs +199 -0
  63. package/dist/api/commands/chat/tell-user.mjs.map +1 -0
  64. package/dist/api/commands/command-constants.d.mts +22 -0
  65. package/dist/api/commands/command-constants.d.mts.map +1 -0
  66. package/dist/api/commands/command-constants.mjs +17 -0
  67. package/dist/api/commands/command-constants.mjs.map +1 -0
  68. package/dist/api/commands/command-helpers.d.mts +47 -0
  69. package/dist/api/commands/command-helpers.d.mts.map +1 -0
  70. package/dist/api/commands/command-helpers.mjs +76 -0
  71. package/dist/api/commands/command-helpers.mjs.map +1 -0
  72. package/dist/api/commands/command-service-v1.d.mts +28 -0
  73. package/dist/api/commands/command-service-v1.d.mts.map +1 -0
  74. package/dist/api/commands/command-service-v1.mjs +122 -0
  75. package/dist/api/commands/command-service-v1.mjs.map +1 -0
  76. package/dist/api/commands/command-service.respec.d.mts +7 -0
  77. package/dist/api/commands/command-service.respec.d.mts.map +1 -0
  78. package/dist/api/commands/command-service.respec.mjs +66 -0
  79. package/dist/api/commands/command-service.respec.mjs.map +1 -0
  80. package/dist/api/commands/command-types.d.mts +48 -0
  81. package/dist/api/commands/command-types.d.mts.map +1 -0
  82. package/dist/api/commands/command-types.mjs +12 -0
  83. package/dist/api/commands/command-types.mjs.map +1 -0
  84. package/dist/api/commands/ibgib/get-ibgibs.d.mts +94 -0
  85. package/dist/api/commands/ibgib/get-ibgibs.d.mts.map +1 -0
  86. package/dist/api/commands/ibgib/get-ibgibs.mjs +219 -0
  87. package/dist/api/commands/ibgib/get-ibgibs.mjs.map +1 -0
  88. package/dist/api/commands/ibgib/ibgib-index.d.mts +3 -0
  89. package/dist/api/commands/ibgib/ibgib-index.d.mts.map +1 -0
  90. package/dist/api/commands/ibgib/ibgib-index.mjs +7 -0
  91. package/dist/api/commands/ibgib/ibgib-index.mjs.map +1 -0
  92. package/dist/api/commands/ibgib/mut8-ibgib.d.mts +135 -0
  93. package/dist/api/commands/ibgib/mut8-ibgib.d.mts.map +1 -0
  94. package/dist/api/commands/ibgib/mut8-ibgib.mjs +318 -0
  95. package/dist/api/commands/ibgib/mut8-ibgib.mjs.map +1 -0
  96. package/dist/api/commands/templates/api-function-info.template.d.mts +73 -0
  97. package/dist/api/commands/templates/api-function-info.template.d.mts.map +1 -0
  98. package/dist/api/commands/templates/api-function-info.template.mjs +161 -0
  99. package/dist/api/commands/templates/api-function-info.template.mjs.map +1 -0
  100. package/dist/api/commands/text/text-edit.d.mts +54 -0
  101. package/dist/api/commands/text/text-edit.d.mts.map +1 -0
  102. package/dist/api/commands/text/text-edit.mjs +170 -0
  103. package/dist/api/commands/text/text-edit.mjs.map +1 -0
  104. package/dist/api/commands/text/text-index.d.mts +3 -0
  105. package/dist/api/commands/text/text-index.d.mts.map +1 -0
  106. package/dist/api/commands/text/text-index.mjs +5 -0
  107. package/dist/api/commands/text/text-index.mjs.map +1 -0
  108. package/dist/api/commands/ui/ui-index.d.mts +3 -0
  109. package/dist/api/commands/ui/ui-index.d.mts.map +1 -0
  110. package/dist/api/commands/ui/ui-index.mjs +5 -0
  111. package/dist/api/commands/ui/ui-index.mjs.map +1 -0
  112. package/dist/api/commands/ui/update-css-variables.d.mts +48 -0
  113. package/dist/api/commands/ui/update-css-variables.d.mts.map +1 -0
  114. package/dist/api/commands/ui/update-css-variables.mjs +145 -0
  115. package/dist/api/commands/ui/update-css-variables.mjs.map +1 -0
  116. package/dist/api/function-infos.web.d.mts +15 -0
  117. package/dist/api/function-infos.web.d.mts.map +1 -0
  118. package/dist/api/function-infos.web.mjs +63 -0
  119. package/dist/api/function-infos.web.mjs.map +1 -0
  120. package/dist/assumptions.respec.d.mts +2 -0
  121. package/dist/assumptions.respec.d.mts.map +1 -0
  122. package/dist/assumptions.respec.mjs +41 -0
  123. package/dist/assumptions.respec.mjs.map +1 -0
  124. package/dist/common/project/project-constants.d.mts +38 -0
  125. package/dist/common/project/project-constants.d.mts.map +1 -0
  126. package/dist/common/project/project-constants.mjs +71 -0
  127. package/dist/common/project/project-constants.mjs.map +1 -0
  128. package/dist/common/project/project-helper.d.mts +127 -0
  129. package/dist/common/project/project-helper.d.mts.map +1 -0
  130. package/dist/common/project/project-helper.mjs +683 -0
  131. package/dist/common/project/project-helper.mjs.map +1 -0
  132. package/dist/common/project/project-types.d.mts +91 -0
  133. package/dist/common/project/project-types.d.mts.map +1 -0
  134. package/dist/common/project/project-types.mjs +31 -0
  135. package/dist/common/project/project-types.mjs.map +1 -0
  136. package/dist/common/prompt-functions.web.d.mts +90 -0
  137. package/dist/common/prompt-functions.web.d.mts.map +1 -0
  138. package/dist/common/prompt-functions.web.mjs +426 -0
  139. package/dist/common/prompt-functions.web.mjs.map +1 -0
  140. package/dist/common/settings/settings-constants.d.mts +33 -0
  141. package/dist/common/settings/settings-constants.d.mts.map +1 -0
  142. package/dist/common/settings/settings-constants.mjs +54 -0
  143. package/dist/common/settings/settings-constants.mjs.map +1 -0
  144. package/dist/common/settings/settings-helpers.d.mts +59 -0
  145. package/dist/common/settings/settings-helpers.d.mts.map +1 -0
  146. package/dist/common/settings/settings-helpers.mjs +253 -0
  147. package/dist/common/settings/settings-helpers.mjs.map +1 -0
  148. package/dist/common/settings/settings-types.d.mts +118 -0
  149. package/dist/common/settings/settings-types.d.mts.map +1 -0
  150. package/dist/common/settings/settings-types.mjs +13 -0
  151. package/dist/common/settings/settings-types.mjs.map +1 -0
  152. package/dist/constants.d.mts +34 -0
  153. package/dist/constants.d.mts.map +1 -0
  154. package/dist/constants.mjs +35 -0
  155. package/dist/constants.mjs.map +1 -0
  156. package/dist/foo.d.mts +2 -0
  157. package/dist/foo.d.mts.map +1 -0
  158. package/dist/foo.mjs +19 -0
  159. package/dist/foo.mjs.map +1 -0
  160. package/dist/helpers.d.mts +137 -0
  161. package/dist/helpers.d.mts.map +1 -0
  162. package/dist/helpers.mjs +514 -0
  163. package/dist/helpers.mjs.map +1 -0
  164. package/dist/helpers.web.d.mts +324 -0
  165. package/dist/helpers.web.d.mts.map +1 -0
  166. package/dist/helpers.web.mjs +1133 -0
  167. package/dist/helpers.web.mjs.map +1 -0
  168. package/dist/helpers.web.respec.d.mts +2 -0
  169. package/dist/helpers.web.respec.d.mts.map +1 -0
  170. package/dist/helpers.web.respec.mjs +12 -0
  171. package/dist/helpers.web.respec.mjs.map +1 -0
  172. package/dist/index.d.mts +2 -0
  173. package/dist/index.d.mts.map +1 -0
  174. package/dist/index.mjs +3 -0
  175. package/dist/index.mjs.map +1 -0
  176. package/dist/respec-gib.node.d.mts +2 -0
  177. package/dist/respec-gib.node.d.mts.map +1 -0
  178. package/dist/respec-gib.node.mjs +211 -0
  179. package/dist/respec-gib.node.mjs.map +1 -0
  180. package/dist/spec-helper.node.respec.d.mts +13 -0
  181. package/dist/spec-helper.node.respec.d.mts.map +1 -0
  182. package/dist/spec-helper.node.respec.mjs +50 -0
  183. package/dist/spec-helper.node.respec.mjs.map +1 -0
  184. package/dist/storage/storage-helpers.web.d.mts +108 -0
  185. package/dist/storage/storage-helpers.web.d.mts.map +1 -0
  186. package/dist/storage/storage-helpers.web.mjs +757 -0
  187. package/dist/storage/storage-helpers.web.mjs.map +1 -0
  188. package/dist/storage/storage-types.web.d.mts +30 -0
  189. package/dist/storage/storage-types.web.d.mts.map +1 -0
  190. package/dist/storage/storage-types.web.mjs +2 -0
  191. package/dist/storage/storage-types.web.mjs.map +1 -0
  192. package/dist/types.web.d.mts +42 -0
  193. package/dist/types.web.d.mts.map +1 -0
  194. package/dist/types.web.mjs +2 -0
  195. package/dist/types.web.mjs.map +1 -0
  196. package/dist/ui/component/component-types.d.mts +225 -0
  197. package/dist/ui/component/component-types.d.mts.map +1 -0
  198. package/dist/ui/component/component-types.mjs +2 -0
  199. package/dist/ui/component/component-types.mjs.map +1 -0
  200. package/dist/ui/component/ibgib-component-service.d.mts +70 -0
  201. package/dist/ui/component/ibgib-component-service.d.mts.map +1 -0
  202. package/dist/ui/component/ibgib-component-service.mjs +201 -0
  203. package/dist/ui/component/ibgib-component-service.mjs.map +1 -0
  204. package/dist/ui/component/ibgib-dynamic-component-bases.d.mts +338 -0
  205. package/dist/ui/component/ibgib-dynamic-component-bases.d.mts.map +1 -0
  206. package/dist/ui/component/ibgib-dynamic-component-bases.mjs +1304 -0
  207. package/dist/ui/component/ibgib-dynamic-component-bases.mjs.map +1 -0
  208. package/dist/ui/ui-constants.d.mts +12 -0
  209. package/dist/ui/ui-constants.d.mts.map +1 -0
  210. package/dist/ui/ui-constants.mjs +93 -0
  211. package/dist/ui/ui-constants.mjs.map +1 -0
  212. package/dist/ui/ui-helpers.d.mts +42 -0
  213. package/dist/ui/ui-helpers.d.mts.map +1 -0
  214. package/dist/ui/ui-helpers.mjs +198 -0
  215. package/dist/ui/ui-helpers.mjs.map +1 -0
  216. package/dist/ui/ui-types.d.mts +13 -0
  217. package/dist/ui/ui-types.d.mts.map +1 -0
  218. package/dist/ui/ui-types.mjs +2 -0
  219. package/dist/ui/ui-types.mjs.map +1 -0
  220. package/dist/witness/agent/agent-constants.d.mts +97 -0
  221. package/dist/witness/agent/agent-constants.d.mts.map +1 -0
  222. package/dist/witness/agent/agent-constants.mjs +98 -0
  223. package/dist/witness/agent/agent-constants.mjs.map +1 -0
  224. package/dist/witness/agent/agent-helpers.d.mts +106 -0
  225. package/dist/witness/agent/agent-helpers.d.mts.map +1 -0
  226. package/dist/witness/agent/agent-helpers.mjs +601 -0
  227. package/dist/witness/agent/agent-helpers.mjs.map +1 -0
  228. package/dist/witness/agent/agent-one-file.app.d.mts +2 -0
  229. package/dist/witness/agent/agent-one-file.app.d.mts.map +1 -0
  230. package/dist/witness/agent/agent-one-file.app.mjs +8 -0
  231. package/dist/witness/agent/agent-one-file.app.mjs.map +1 -0
  232. package/dist/witness/agent/agent-one-file.d.mts +478 -0
  233. package/dist/witness/agent/agent-one-file.d.mts.map +1 -0
  234. package/dist/witness/agent/agent-one-file.mjs +1462 -0
  235. package/dist/witness/agent/agent-one-file.mjs.map +1 -0
  236. package/dist/witness/agent/agent-types.d.mts +83 -0
  237. package/dist/witness/agent/agent-types.d.mts.map +1 -0
  238. package/dist/witness/agent/agent-types.mjs +2 -0
  239. package/dist/witness/agent/agent-types.mjs.map +1 -0
  240. package/dist/witness/agent/agents-service-v1.d.mts +99 -0
  241. package/dist/witness/agent/agents-service-v1.d.mts.map +1 -0
  242. package/dist/witness/agent/agents-service-v1.mjs +453 -0
  243. package/dist/witness/agent/agents-service-v1.mjs.map +1 -0
  244. package/dist/witness/agent/function-info/function-info-one-file.d.mts +192 -0
  245. package/dist/witness/agent/function-info/function-info-one-file.d.mts.map +1 -0
  246. package/dist/witness/agent/function-info/function-info-one-file.mjs +192 -0
  247. package/dist/witness/agent/function-info/function-info-one-file.mjs.map +1 -0
  248. package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts +51 -0
  249. package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts.map +1 -0
  250. package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs +928 -0
  251. package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs.map +1 -0
  252. package/dist/witness/agent/gemini/gemini-agent-factory.d.mts +27 -0
  253. package/dist/witness/agent/gemini/gemini-agent-factory.d.mts.map +1 -0
  254. package/dist/witness/agent/gemini/gemini-agent-factory.mjs +144 -0
  255. package/dist/witness/agent/gemini/gemini-agent-factory.mjs.map +1 -0
  256. package/dist/witness/agent/gemini/gemini-constants.d.mts +36 -0
  257. package/dist/witness/agent/gemini/gemini-constants.d.mts.map +1 -0
  258. package/dist/witness/agent/gemini/gemini-constants.mjs +47 -0
  259. package/dist/witness/agent/gemini/gemini-constants.mjs.map +1 -0
  260. package/dist/witness/agent/gemini/gemini-helpers.d.mts +58 -0
  261. package/dist/witness/agent/gemini/gemini-helpers.d.mts.map +1 -0
  262. package/dist/witness/agent/gemini/gemini-helpers.mjs +210 -0
  263. package/dist/witness/agent/gemini/gemini-helpers.mjs.map +1 -0
  264. package/dist/witness/agent/gemini/gemini-types.d.mts +82 -0
  265. package/dist/witness/agent/gemini/gemini-types.d.mts.map +1 -0
  266. package/dist/witness/agent/gemini/gemini-types.mjs +3 -0
  267. package/dist/witness/agent/gemini/gemini-types.mjs.map +1 -0
  268. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts +136 -0
  269. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts.map +1 -0
  270. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs +334 -0
  271. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs.map +1 -0
  272. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts +35 -0
  273. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts.map +1 -0
  274. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs +267 -0
  275. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs.map +1 -0
  276. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts +134 -0
  277. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts.map +1 -0
  278. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs +389 -0
  279. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs.map +1 -0
  280. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts +2 -0
  281. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts.map +1 -0
  282. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs +2 -0
  283. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs.map +1 -0
  284. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts +104 -0
  285. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts.map +1 -0
  286. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs +457 -0
  287. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs.map +1 -0
  288. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts +93 -0
  289. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts.map +1 -0
  290. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs +98 -0
  291. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs.map +1 -0
  292. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts +73 -0
  293. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts.map +1 -0
  294. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs +650 -0
  295. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs.map +1 -0
  296. package/generate-version-file.js +29 -0
  297. package/package.json +60 -0
  298. package/src/agent-texts/common-agent-texts.mts +61 -0
  299. package/src/agent-texts/primary-agent-texts.mts +32 -0
  300. package/src/agent-texts/project-agent-texts.mts +29 -0
  301. package/src/agent-texts/project-child-text-agent-texts.mts +30 -0
  302. package/src/agent-texts/projects-agent-texts.mts +17 -0
  303. package/src/agent-texts/raw-agent-texts.mts +18 -0
  304. package/src/agent-texts/text-editor-agent-texts.mts +20 -0
  305. package/src/api/api-constants.mts +8 -0
  306. package/src/api/api-index.mts +110 -0
  307. package/src/api/api-types.mts +36 -0
  308. package/src/api/commands/chat/chat-index.mts +10 -0
  309. package/src/api/commands/chat/get-context-info.mts +196 -0
  310. package/src/api/commands/chat/hello-world.mts +183 -0
  311. package/src/api/commands/chat/tell-user.mts +241 -0
  312. package/src/api/commands/command-constants.mts +17 -0
  313. package/src/api/commands/command-helpers.mts +105 -0
  314. package/src/api/commands/command-service-v1.mts +136 -0
  315. package/src/api/commands/command-service.respec.mts +72 -0
  316. package/src/api/commands/command-types.mts +71 -0
  317. package/src/api/commands/ibgib/get-ibgibs.mts +269 -0
  318. package/src/api/commands/ibgib/ibgib-index.mts +8 -0
  319. package/src/api/commands/ibgib/mut8-ibgib.mts +418 -0
  320. package/src/api/commands/templates/api-function-info.template.mts +212 -0
  321. package/src/api/commands/text/text-edit.mts +217 -0
  322. package/src/api/commands/text/text-index.mts +6 -0
  323. package/src/api/commands/ui/ui-index.mts +6 -0
  324. package/src/api/commands/ui/update-css-variables.mts +187 -0
  325. package/src/api/function-infos.web.mts +66 -0
  326. package/src/assets/fullscreen-dialog.html +18 -0
  327. package/src/assumptions.respec.mts +51 -0
  328. package/src/common/project/project-constants.mts +83 -0
  329. package/src/common/project/project-helper.mts +730 -0
  330. package/src/common/project/project-types.mts +121 -0
  331. package/src/common/prompt-functions.web.mts +447 -0
  332. package/src/common/settings/settings-constants.mts +72 -0
  333. package/src/common/settings/settings-helpers.mts +280 -0
  334. package/src/common/settings/settings-types.mts +137 -0
  335. package/src/constants.mts +39 -0
  336. package/src/foo.mts +13 -0
  337. package/src/helpers.mts +574 -0
  338. package/src/helpers.web.mts +1277 -0
  339. package/src/helpers.web.respec.mts +16 -0
  340. package/src/index.mts +3 -0
  341. package/src/respec-gib.node.mts +199 -0
  342. package/src/spec-helper.node.respec.mts +50 -0
  343. package/src/storage/storage-helpers.web.mts +728 -0
  344. package/src/storage/storage-types.web.mts +29 -0
  345. package/src/types.web.mts +42 -0
  346. package/src/ui/component/component-types.mts +241 -0
  347. package/src/ui/component/ibgib-component-service.mts +201 -0
  348. package/src/ui/component/ibgib-dynamic-component-bases.mts +1369 -0
  349. package/src/ui/ui-constants.mts +101 -0
  350. package/src/ui/ui-helpers.mts +222 -0
  351. package/src/ui/ui-types.mts +11 -0
  352. package/src/witness/agent/agent-constants.mts +122 -0
  353. package/src/witness/agent/agent-helpers.mts +681 -0
  354. package/src/witness/agent/agent-one-file.app.mts +8 -0
  355. package/src/witness/agent/agent-one-file.mts +1665 -0
  356. package/src/witness/agent/agent-types.mts +92 -0
  357. package/src/witness/agent/agents-service-v1.mts +482 -0
  358. package/src/witness/agent/function-info/function-info-one-file.mts +362 -0
  359. package/src/witness/agent/gemini/agent-witness-gemini-v1.mts +910 -0
  360. package/src/witness/agent/gemini/gemini-agent-factory.mts +135 -0
  361. package/src/witness/agent/gemini/gemini-constants.mts +79 -0
  362. package/src/witness/agent/gemini/gemini-helpers.mts +216 -0
  363. package/src/witness/agent/gemini/gemini-types.mts +88 -0
  364. package/src/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mts +321 -0
  365. package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mts +290 -0
  366. package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mts +407 -0
  367. package/src/witness/space/web-filesystem-space/web-filesystem-space-constants.mts +1 -0
  368. package/src/witness/space/web-filesystem-space/web-filesystem-space-helper.mts +491 -0
  369. package/src/witness/space/web-filesystem-space/web-filesystem-space-types.mts +172 -0
  370. package/src/witness/space/web-filesystem-space/web-filesystem-space-v1.mts +670 -0
  371. package/tsconfig.json +17 -0
  372. package/tsconfig.test.json +10 -0
@@ -0,0 +1,681 @@
1
+ import { extractErrorMsg, } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
2
+ import { getIbAndGib, getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
3
+ import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
4
+ import { IbGib_V1, } from "@ibgib/ts-gib/dist/V1/types.mjs";
5
+ import { MetaspaceService } from "@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs";
6
+ import { SpaceId } from "@ibgib/core-gib/dist/witness/space/space-types.mjs";
7
+ import { SpecialIbGibType } from "@ibgib/core-gib/dist/common/other/other-types.mjs";
8
+ import { IbGibSpaceAny } from "@ibgib/core-gib/dist/witness/space/space-base-v1.mjs";
9
+ import { TAG_REL8N_NAME } from "@ibgib/core-gib/dist/common/tag/tag-constants.mjs";
10
+ import { getTjpAddr, toDto } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
11
+ import { TagIbGib_V1 } from "@ibgib/core-gib/dist/common/tag/tag-types.mjs";
12
+ import { updateSpecialIndex } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
13
+
14
+ import {
15
+ GLOBAL_LOG_A_LOT, TAG_AGENT_DESCRIPTION, TAG_AGENT_IB, TAG_AGENT_ICON,
16
+ TAG_AGENT_TEXT,
17
+ } from "../../constants.mjs";
18
+ import { AgentWitnessAny, AgentWitnessIbGib_V1 } from "./agent-one-file.mjs";
19
+ import { AGENT_REL8N_NAME } from "./agent-constants.mjs";
20
+ import {
21
+ coupleDomainIbGibWithLocalIbGibViaIndex, getIndexNameFromIbGib,
22
+ getLocalCoupledIbGibForDomainIbGib, getTagsIbGib
23
+ } from "../../helpers.mjs";
24
+ import { getAgentsSvc } from "./agents-service-v1.mjs";
25
+ import { CreateConcreteAgentWitnessFactory, CreateNewAgentArg } from "./agent-types.mjs";
26
+ import { CreateConcreteAgentWitnessFactory_Gemini } from "./gemini/gemini-agent-factory.mjs";
27
+ // import { updateSpecialIndex } from "../../api/timeline/timeline-api.mjs";
28
+
29
+ const logalot = GLOBAL_LOG_A_LOT; // change this when you want to turn off verbose logging
30
+
31
+ // #region snapshot of the component src file
32
+
33
+ // #endregion snapshot of the component src file
34
+
35
+ /**
36
+ * helper that gets/creates the agents tag in the given {@link space}, or in the
37
+ * default local user space if {@link space} is falsy.
38
+ * @returns agents tag ibgib
39
+ */
40
+ export async function getTag_Agents({
41
+ metaspace,
42
+ space,
43
+ createIfNone,
44
+ }: {
45
+ metaspace: MetaspaceService,
46
+ space: IbGibSpaceAny | undefined,
47
+ createIfNone?: boolean,
48
+ }): Promise<TagIbGib_V1> {
49
+ const lc = `[${getTag_Agents.name}]`;
50
+ try {
51
+ if (logalot) { console.log(`${lc} starting... (I: ad1594767abce66ca80fea8c8d89f325)`); }
52
+ space ??= await metaspace.getLocalUserSpace({ lock: false });
53
+ if (!space) { throw new Error(`(UNEXPECTED) space falsy after getting local user space? (E: bc68d97d46dcf1d15dd74edba200b725)`); }
54
+
55
+ const tagsIbGib: IbGib_V1 = await getTagsIbGib({ metaspace, space });
56
+ if (!tagsIbGib.rel8ns) { throw new Error(`(UNEXPECTED) tagsIbGib.rel8ns falsy? (E: dc50e8d218fe5e30bbaec7f37d484525)`); }
57
+ const tagAddrs = tagsIbGib.rel8ns[TAG_REL8N_NAME] ?? [];
58
+ const agentTagAddrs = tagAddrs.filter(x => {
59
+ const { ib } = getIbAndGib({ ibGibAddr: x });
60
+ return ib === TAG_AGENT_IB;
61
+ });
62
+ let agentTagAddr: IbGibAddr | undefined = undefined;
63
+ let agentTagIbGib: TagIbGib_V1 | undefined = undefined;
64
+ if (agentTagAddrs.length === 0) {
65
+ if (createIfNone) {
66
+ if (logalot) { console.log(`${lc} creating new agents tag... (I: 47f4f4fa89f1a1bba960e0a6ff5f5225)`); }
67
+
68
+ const { newTagIbGib, } = await metaspace.createTagIbGib({
69
+ text: TAG_AGENT_TEXT,
70
+ icon: TAG_AGENT_ICON,
71
+ description: TAG_AGENT_DESCRIPTION,
72
+ space,
73
+ });
74
+ agentTagIbGib = newTagIbGib;
75
+ if (logalot) { console.log(`${lc} creating new agents tag complete. (I: 5f41d644f2b692348377f918057cf225)`); }
76
+ return newTagIbGib; /* <<<< returns early */
77
+ }
78
+ } else if (agentTagAddrs.length === 1) {
79
+ agentTagAddr = agentTagAddrs.at(0)!;
80
+ if (logalot) { console.log(`${lc} exactly one agent tag addr found (${agentTagAddr}) in space (${space.ib}) (I: 7ef995963313c966216097760d0cdb25)`); }
81
+ } else {
82
+ // more than one agent tag?
83
+ agentTagAddr = agentTagAddrs.at(0)!;
84
+ console.error(`${lc} more than one agent tag found in space (${space.ib})? Well, we're returning just the first one (${agentTagAddr}), but really we've not coded for this edge/future case. (E: 52a4e2e49d3c0d644df483119b46f125)`);
85
+ }
86
+
87
+ if (agentTagAddr) {
88
+ const resGet = await metaspace.get({ addrs: [agentTagAddr], space });
89
+ if (resGet.success && resGet.ibGibs?.length === 1) {
90
+ agentTagIbGib = resGet.ibGibs.at(0)! as TagIbGib_V1;
91
+ return agentTagIbGib;
92
+ } else {
93
+ throw new Error(`couldn't get agentTagAddr (${agentTagAddr}) in space (${space.ib}) (E: 53d9cdb7b769014a2de15871484cc325)`);
94
+ }
95
+ } else {
96
+ throw new Error(`agentTagAddr not found, so there ain't no agents tag, and createIfNone was ${createIfNone}. (E: 54cb3164a118105f187e936613ff4625)`);
97
+ }
98
+ } catch (error) {
99
+ console.error(`${lc} ${extractErrorMsg(error)}`);
100
+ throw error;
101
+ } finally {
102
+ if (logalot) { console.log(`${lc} complete.`); }
103
+ }
104
+ }
105
+
106
+ /**
107
+ * gets agents of a certain {@link type} in the local space corresponding to
108
+ * {@link spaceId} (or default local user space if falsy) via the agents tag.
109
+ */
110
+ export async function getAgents({
111
+ metaspace,
112
+ type,
113
+ spaceId,
114
+ space,
115
+ }: {
116
+ metaspace: MetaspaceService,
117
+ type: SpecialIbGibType,
118
+ spaceId?: SpaceId,
119
+ space?: IbGibSpaceAny,
120
+ }): Promise<AgentWitnessAny[]> {
121
+ const lc = `[${getAgents.name}]`;
122
+ try {
123
+ if (logalot) { console.log(`${lc} starting... (I: 41037d1926051c4b051769069f518f25)`); }
124
+
125
+ space ??= await metaspace.getLocalUserSpace({ localSpaceId: spaceId, lock: false });
126
+ if (!space) { throw new Error(`couldn't get local user space by id (${spaceId}) (E: fe96076e79fb227c0ae2de077eb5e225)`); }
127
+
128
+ // initialize the agent index if it hasn't already been created we
129
+ // don't actually use this (and thus it's slightly inefficient)
130
+ // because we use the next getSpecialRel8dIbGibs call
131
+ const agentsIndexIbGib = await metaspace.getSpecialIbGib({
132
+ type,
133
+ initialize: true,
134
+ dontWarnIfNotExist: true,
135
+ lock: false, // not worried about this atow 01/2024
136
+ space,
137
+ });
138
+ if (!agentsIndexIbGib) { throw new Error(`(UNEXPECTED) couldn't initialize/get agents special ibgib? (E: 1abe0e2543711744adbdb7026b242e25)`); }
139
+ const agentIbGibs = (await metaspace.getSpecialRel8dIbGibs({
140
+ rel8nName: AGENT_REL8N_NAME,
141
+ type,
142
+ // type: AGENT_SPECIAL_IBGIB_TYPE_PRIMARYAGENT,
143
+ space,
144
+ }) ?? []) as AgentWitnessAny[]; // NOT actually witnesses yet!!!!!
145
+
146
+ /**
147
+ * convert to witnesses...right now, I'm realizing I screwed up the
148
+ * factory pattern to not be generalized enough and I' msoooooooo fing
149
+ * tired. I mean, wtf am I doing with my life right. Project IDX is
150
+ * SLOOOOOW as hell and as usual, I'm fing too poor to do anything about
151
+ * fing anything. Anyway, we have ibgib (dtos) not witnesses which have
152
+ * actual OOP properties/methods. atow (04/2025) we only have gemini
153
+ * witnesses, so going to hardcode that in. But this needs to be changed
154
+ * to use a proper factory
155
+ */
156
+ const resAgentWitnessesProper: AgentWitnessAny[] = [];
157
+ for (const agentIbGib of agentIbGibs) {
158
+ if (agentIbGib.data?.api !== 'gemini') {
159
+ throw new Error(`(UNEXPECTED) agentIbGib.data.api !== gemini? only gemini is implemented right now. (E: 7348fe8c68565bcf88a4052458f42d25)`);
160
+ }
161
+
162
+ const agentsSvc = getAgentsSvc();
163
+
164
+ let actualWitness = await agentsSvc.getLatestAgent({ id: agentIbGib.data.uuid! });
165
+ if (!actualWitness) {
166
+ actualWitness = await agentsSvc.getAgentWitnessFromDto({ dto: agentIbGib });
167
+ if (!actualWitness) {
168
+ debugger; // error couldn't get agent from dto?
169
+ throw new Error(`(UNEXPECTED) couldn't get actual agent witness from agent dto? have we registered classname (${agentIbGib.data?.classname}) and factory fn with agents service? (E: bcbfdf6446793ac34d6f6118e050d325)`);
170
+ }
171
+ // actualWitness = await agentIbGibDtoToWitness({ agentIbGib });
172
+ await agentsSvc.updateOrSetLatestAgent({
173
+ agent: actualWitness,
174
+ throwIfNewerFound: false, // we just got this from the special index
175
+ });
176
+ }
177
+ resAgentWitnessesProper.push(actualWitness);
178
+ }
179
+ return resAgentWitnessesProper;
180
+ } catch (error) {
181
+ console.error(`${lc} ${extractErrorMsg(error)}`);
182
+ throw error;
183
+ } finally {
184
+ if (logalot) { console.log(`${lc} complete.`); }
185
+ }
186
+ }
187
+
188
+ /**
189
+ * i'm updating the index proactively so we don't need to rely on jit getLatest
190
+ * any time we want to get the agent.
191
+ */
192
+ export async function updateAgentIndex({
193
+ metaspace,
194
+ type,
195
+ space,
196
+ newAgentIbGib,
197
+ }: {
198
+ metaspace: MetaspaceService,
199
+ type: SpecialIbGibType, // has | string in it
200
+ space: IbGibSpaceAny,
201
+ newAgentIbGib: AgentWitnessIbGib_V1,
202
+ }): Promise<void> {
203
+ // await commandifyAnonFn({
204
+
205
+ const fn: () => Promise<void> = async () => {
206
+ const lc = `[${updateAgentIndex.name}]`;
207
+ try {
208
+ // d ebugger; // is this hit as expected? yes
209
+ if (logalot) { console.log(`${lc} starting... (I: bf6ff6bf4132eaa943eaa3af1ee17225)`); }
210
+ if (!newAgentIbGib.data) { throw new Error(`(UNEXPECTED) newAgentIbGib.data falsy? (E: 26e03d0a8e286ac3a13b678a50c87a25)`); }
211
+ if (!newAgentIbGib.data.uuid) { throw new Error(`(UNEXPECTED) newAgentIbGib.data.uuid falsy? (E: 31b753e01275272484ea93e3dfe53225)`); }
212
+
213
+
214
+
215
+ const agentsSvc = getAgentsSvc();
216
+
217
+ const latestAgentInMemory = await agentsSvc.getLatestAgent({
218
+ id: newAgentIbGib.data.uuid,
219
+ });
220
+ if (latestAgentInMemory) {
221
+ // make sure that we have a higher n than the existing latest
222
+ if (latestAgentInMemory.data!.n! > newAgentIbGib.data.n!) {
223
+ debugger; // error: latest in memory is newer than the new agent trying to update index
224
+ throw new Error(`latestInMemory.data!.n! > newAgentIbGib.data.n! ... in plain english, this means that there is a more recent (higher n) agent with the given agent's id (${newAgentIbGib.data.uuid}) already in existence, but the caller is trying to update the special ibgib index with the older agent. (E: 5c0c028075736f22072c55e20a0c7e25)`);
225
+ }
226
+ }
227
+
228
+ const newAgentAddr = getIbGibAddr({ ibGib: newAgentIbGib });
229
+
230
+ await updateSpecialIndex({
231
+ type: newAgentIbGib.data.type,
232
+ rel8nInfos: [
233
+ {
234
+ rel8nName: AGENT_REL8N_NAME,
235
+ ibGibs: [toDto({ ibGib: newAgentIbGib })],
236
+ },
237
+ ],
238
+ metaspace,
239
+ space,
240
+ });
241
+
242
+ // const agentsIndexIbGib = await metaspace.getSpecialIbGib({
243
+ // type,
244
+ // space,
245
+ // initialize: true,
246
+ // });
247
+ // if (!agentsIndexIbGib) { throw new Error(`(UNEXPECTED) couldn't initialize/get agents special ibgib (index)? (E: 3c1c21305b256d468b2be9d12243c825)`); }
248
+
249
+ // /**
250
+ // * find ibgib(s) to unrel8. should only be one at most but will cover if multiple
251
+ // */
252
+ // let ibGibsToUnRel8: IbGib_V1[] | undefined = undefined;
253
+ // const agentAddrs = (agentsIndexIbGib?.rel8ns ?? {})[AGENT_REL8N_NAME] ?? [];
254
+ // if (agentAddrs.some(x => x === newAgentAddr)) {
255
+ // if (logalot) { console.log(`${lc} agent addr (${newAgentAddr}) already registered with special ibgib index. (I: 2d0f370b0f9f3ec263489228f801ee25)`); }
256
+ // }
257
+ // const toRemoveAddrs: IbGibAddr[] | undefined = newAgentIbGib.rel8ns?.past?.filter(x => agentAddrs.includes(x)) ?? [];
258
+ // if (toRemoveAddrs.length > 0) {
259
+ // const resGetToRemove = await metaspace.get({
260
+ // addrs: toRemoveAddrs,
261
+ // space,
262
+ // });
263
+ // if (resGetToRemove.success &&
264
+ // (resGetToRemove.ibGibs ?? []).length === toRemoveAddrs.length) {
265
+ // ibGibsToUnRel8 = resGetToRemove.ibGibs;
266
+ // } else {
267
+ // debugger; // error in getting previous agents when attempting to unrel8 past agents after an update to the agent index
268
+ // throw new Error(`failed to get previous agents? wrong space maybe? space.ib: ${space.ib} (E: 97d77376bccdb44dec65a5b725108e25)`);
269
+ // }
270
+ // }
271
+
272
+ // // update the index by relating the new ibgib and removing any
273
+ // // old ones if applicable
274
+ // await metaspace.rel8ToSpecialIbGib({
275
+ // type,
276
+ // rel8nName: AGENT_REL8N_NAME,
277
+ // ibGibsToRel8: [toDto({ ibGib: newAgentIbGib })],
278
+ // ibGibsToUnRel8,
279
+ // space,
280
+ // });
281
+ } catch (error) {
282
+ console.error(`${lc} ${extractErrorMsg(error)}`);
283
+ throw error;
284
+ } finally {
285
+ if (logalot) { console.log(`${lc} complete.`); }
286
+ }
287
+ }
288
+
289
+ await fn();
290
+
291
+ // await execInSpaceWithLocking({
292
+ // fn,
293
+ // scope: type,
294
+ // secondsValid: 60,
295
+ // maxDelayMs: 100,
296
+ // maxLockAttempts: 600, // 60 seconds worth
297
+ // space,
298
+ // callerInstanceId: getTimestampInTicks() + '_' + newAgentIbGib.gib,
299
+ // });
300
+ }
301
+
302
+ /**
303
+ * Generates a consistent special name for the agent index ibGib based on the
304
+ * domain ibGib's primitive ancestor's ib or the ibGibAddr's ib atom.
305
+ *
306
+ * RIGHT NOW I"M PRIORITIZING THE ATOM. I THINK IT ALWAYS RETURNS THE ATOM, I.E., THE FIRST SPACE-DELIMITED PIECE OF THE `ib`.
307
+ *
308
+ * I am doing this because the project ibgib actually forks from a comment
309
+ * ibgib, so its primitive ancestor is "comment^gib".
310
+ *
311
+ * ## notes
312
+ *
313
+ * We are trying to get a special ibgib index that maps from ibgibs (the domain)
314
+ * to what local agent is registered to handle that ibgib's timeline.
315
+ *
316
+ * Concretely, we're working on the project ibgibs and we need a way to get at
317
+ * the agent that is assigned to that project. But we can't just mut8 the
318
+ * project itself because this would cause issues once the project is spread out
319
+ * among multiple execution contexts (similar to "remotes" in git).
320
+ *
321
+ * So we will have a special ibgib registered with the local space which will
322
+ * act as this index that maps ibgib -> handling agent. This function helps get
323
+ * the *name* of that special indexing ibgib.
324
+ *
325
+ * This can be driven either by the ibgib itself, via the last primitive ancestor
326
+ * ibgib's address, or via the ib's atom (the first space-delimited term in the
327
+ * `ib` metadata).
328
+ *
329
+ * So if an ancestor is [comment^gib, specialComment^gib, specialComment
330
+ * abc123^ABC123.DEF456] (where the abc123 things are representative of the full
331
+ * hashes 64 characters long atow since we're using sha256), then the *last*
332
+ * primitive address is specialComment^gib.
333
+ */
334
+ export function getAgentIndexNameFromIbGib({
335
+ ibGib,
336
+ ibGibAddr,
337
+ defaultNameIfError,
338
+ }: {
339
+ ibGib?: IbGib_V1,
340
+ ibGibAddr?: IbGibAddr,
341
+ /**
342
+ * if truthy and an error is produced, then this will be returned.
343
+ */
344
+ defaultNameIfError?: string,
345
+ }): string {
346
+ const lc = `[${getAgentIndexNameFromIbGib.name}]`;
347
+ try {
348
+ if (!ibGib && !ibGibAddr) { throw new Error(`${lc} Must provide either ibGib or ibGibAddr. (E: 712592bd51cabec9d23aee3a8ec2d625)`); }
349
+
350
+ let res = getIndexNameFromIbGib({
351
+ scope: 'agent',
352
+ ibGib,
353
+ ibGibAddr,
354
+ defaultNameIfError,
355
+ });
356
+ return res;
357
+
358
+ // /**
359
+ // * note: non-alphanumerics are replaced with underscores
360
+ // */
361
+ // let primitiveAncestorIb: IbGibAddr | undefined = undefined;
362
+ // let atom: string | undefined = undefined;
363
+ // /**
364
+ // * This is what we're trying to extract. once we have this, then we can
365
+ // * simply append our index name, e.g. `${ancestorIbOrAtom}-agent-index`
366
+ // */
367
+ // let ancestorIbOrAtom: string | undefined = undefined;
368
+ // if (ibGib) {
369
+ // // go by the ibgib's full data
370
+ // if (!ibGib.data) { throw new Error(`(UNEXPECTED) ibGib.data falsy? (E: 31514bbd270384cc9a300fdab7603525)`); }
371
+ // if (!ibGib.rel8ns) { throw new Error(`(UNEXPECTED) ibGib.rel8ns falsy? (E: e011d3ac53fb33bd82b4075e57f46825)`); }
372
+ // if (!ibGib.rel8ns.ancestor) { throw new Error(`(UNEXPECTED) ibGib.rel8ns.ancestor falsy? (E: a2dcd5c706cfca2781cb13a76f1ff625)`); }
373
+ // if (ibGib.rel8ns.ancestor.length === 0) {
374
+ // throw new Error(`(UNEXPECTED) ibGib.rel8ns.ancestor.length === 0? there should be at least one ancestor (E: 1c7645024de35a4ca114631b2ab38c25)`);
375
+ // // this may turn into a warning later on down the road and return based on the ibGib's addr
376
+ // }
377
+ // if (ibGib && ibGibAddr) {
378
+ // if (getIbGibAddr({ ibGib }) !== ibGibAddr) {
379
+ // throw new Error(`(UNEXPECTED) both ibGib and ibGibAddr provided, but addr of ibGib doesn't equal ibGibAddr? (E: ef241d9cece84e0a5aa93a35fae5bc25)`);
380
+ // }
381
+ // }
382
+
383
+ // // const primitiveAncestor = getPrimitiveAncestor({ ibGib });
384
+ // const primitiveAncestorAddrs =
385
+ // ibGib.rel8ns.ancestor!.filter(x => isPrimitive({ gib: getIbAndGib({ ibGibAddr: x }).gib }));
386
+ // if (primitiveAncestorAddrs.length === 0) {
387
+ // debugger; // error no primitive ancestor addrs?
388
+ // console.error(`${lc} ibGib has no primitive ancestor addrs? Still going to work off of the ib then, which should have the atom as the first space-delimited term. (E: e5ad2e057daa539d3de2c0f78eb5de25)`)
389
+ // }
390
+ // const primitiveAncestorAddr = primitiveAncestorAddrs.at(-1)!;
391
+ // primitiveAncestorIb =
392
+ // getIbAndGib({ ibGibAddr: primitiveAncestorAddr }).ib;
393
+ // // replace ALL spaces with underscores
394
+ // ancestorIbOrAtom = primitiveAncestorIb;
395
+ // }
396
+
397
+ // // get the atom from the address
398
+ // ibGibAddr ??= getIbGibAddr({ ibGib });
399
+
400
+ // // try to get at it from the ibGibAddr
401
+ // const { ib } = getIbAndGib({ ibGibAddr });
402
+ // atom = (ib.split(' ').at(0) ?? '');
403
+
404
+ // // at this point we have a raw atom and possibly a raw primitive
405
+ // // ancestor ib. we want to compare the two, which usually should be the
406
+ // // same (i think?). if different, warn and return
407
+ // atom = atom.replace(/\W/g, '_');
408
+
409
+ // primitiveAncestorIb ??= atom;
410
+ // primitiveAncestorIb = primitiveAncestorIb.replace(/\W/g, '_');
411
+
412
+ // if (!primitiveAncestorIb && !atom) {
413
+ // throw new Error(`(UNEXPECTED) both primitiveAncestorIb and atom falsy? one should be truthy at this point. (E: 5c7af3e1cc042aff674640ee4c7f2c25)`);
414
+ // }
415
+
416
+ // if (primitiveAncestorIb !== atom) {
417
+ // // warn and do per arg
418
+ // console.warn(`${lc} ibGib primitive ancestor ib (${primitiveAncestorIb}) doesn't match atom (${atom}). going with ancestorIbOrAtom: ${ancestorIbOrAtom} (W: fc2301a4a4b4ee20d90265c7bf650425)`);
419
+ // }
420
+ // ancestorIbOrAtom = atom.toLowerCase();
421
+ // if (logalot) { console.log(`${lc} ancestorIbOrAtom: ${ancestorIbOrAtom} (I: d1ebc76770f110d2631e369f5b094925)`); }
422
+
423
+ // /**
424
+ // * I forgot, this cannot be kebab-cased because we only allow \w regexp
425
+ // * on the special ibgib name. I don't remember the reasoning for this,
426
+ // * may be arbitrary. But for now, going to change this to underscore,
427
+ // * even though the atom or ancestor ib may have underscores in it. Ah
428
+ // * well.
429
+ // */
430
+ // const indexName = `${ancestorIbOrAtom}_agentindex`;
431
+ // if (logalot) { console.log(`${lc} indexName: ${indexName} (I: ffef5d9037d62758032aa73f252f3625)`); }
432
+ // return indexName;
433
+ } catch (error) {
434
+ if (!!defaultNameIfError) {
435
+ console.warn(`${lc} error happened but defaultNameIfError (${defaultNameIfError}) provided. So will return this value. error that was thrown: ${extractErrorMsg(error)}`);
436
+ return defaultNameIfError;
437
+ } else {
438
+ console.error(`${lc} ${extractErrorMsg(error)}`);
439
+ throw error;
440
+ }
441
+ }
442
+ }
443
+
444
+ /**
445
+ * Registers a domain ibGib with its associated agent ibGib in the special agent index ibGib.
446
+ * This creates or updates a mapping from the domain ibGib's TJP address to the agent's address.
447
+ */
448
+ export async function registerDomainIbGibWithAgentIndex({
449
+ domainIbGib,
450
+ agentIbGib,
451
+ metaspace,
452
+ space,
453
+ }: {
454
+ domainIbGib: IbGib_V1,
455
+ agentIbGib: AgentWitnessIbGib_V1,
456
+ metaspace: MetaspaceService,
457
+ space: IbGibSpaceAny,
458
+ }): Promise<void> {
459
+ const lc = `[${registerDomainIbGibWithAgentIndex.name}]`;
460
+ try {
461
+ if (logalot) { console.log(`${lc} starting... (I: 217ae68e0c820e48f4c00409f7f14325)`); }
462
+
463
+ await coupleDomainIbGibWithLocalIbGibViaIndex({
464
+ scope: 'agent',
465
+ domainIbGib,
466
+ localIbGib: agentIbGib,
467
+ metaspace,
468
+ space,
469
+ });
470
+
471
+ // Delete the following commented out code (and related code) after
472
+ // awhile (atow 05/2025). I have confirmed it looks like it's working
473
+ // with the above refactored, more generalized code, but meh...
474
+
475
+ // const agentIndexSpecialIbGibType: SpecialIbGibType =
476
+ // // getAgentIndexNameFromIbGib({ ibGib: domainIbGib }) as SpecialIbGibType;
477
+ // getIndexNameFromIbGib({ scope: 'agent', ibGib: domainIbGib, });
478
+
479
+ // const domainTjpAddr = getTjpAddr({ ibGib: domainIbGib });
480
+ // const agentAddr = getIbGibAddr({ ibGib: agentIbGib });
481
+
482
+ // if (!domainTjpAddr) { throw new Error(`${lc} Could not get TJP address for domain ibGib. (E: 35a4e8ac291b0b85cb958e28dd812f25)`); }
483
+ // if (!agentAddr) { throw new Error(`${lc} Could not get address for agent ibGib. (E: 2fce1187630b45934c4155a23204d125)`); }
484
+
485
+ // const fn = async () => {
486
+
487
+ // // Get or create the agent index ibGib
488
+ // const agentSpecialIndex = await metaspace.getSpecialIbGib({
489
+ // type: agentIndexSpecialIbGibType,
490
+ // space,
491
+ // initialize: true, // Create if it doesn't exist
492
+ // dontWarnIfNotExist: true,
493
+ // lock: false,
494
+ // });
495
+
496
+ // if (!agentSpecialIndex) { throw new Error(`${lc} Could not get or create agent index ibGib.`); }
497
+
498
+ // // Initialize data if it doesn't exist
499
+ // if (!agentSpecialIndex.data) {
500
+ // throw new Error(`(UNEXPECTED) agentSpecialIndex.data falsy? (E: 74299eed147debf6398ca37e7b8d5c25)`);
501
+ // }
502
+
503
+ // // Get the current mapping or initialize an empty one
504
+ // const agentMap: { [tjpAddr: string]: IbGibAddr } =
505
+ // !!agentSpecialIndex.data.agentMap ?
506
+ // clone(agentSpecialIndex.data.agentMap) :
507
+ // {};
508
+
509
+ // // Update the mapping
510
+ // const existingMappedAgentAddr = agentMap[domainTjpAddr];
511
+ // if (existingMappedAgentAddr) {
512
+ // if (existingMappedAgentAddr === agentAddr) {
513
+ // if (logalot) { console.log(`${lc} domain ibGib (${domainTjpAddr}) already mapped to agent (${agentAddr}). returning early (I: cb5d4dcef8cf14de7336120fb8ffef25)`); }
514
+ // return; /* <<<< returns early */
515
+ // } else {
516
+ // console.warn(`${lc} domainTjpAddr (${domainTjpAddr}) already assigned to existingMappedAgentAddr (${existingMappedAgentAddr}). We will be changing to new agentAddr (${agentAddr}). (W: eb993e33f7731e570fa76f24a2d80625)`)
517
+ // }
518
+ // }
519
+ // agentMap[domainTjpAddr] = agentAddr;
520
+
521
+ // // Assign the updated map back to data Save the updated index ibGib.
522
+ // // there is extra plumbing involved with special index ibgibs. see
523
+ // // `rel8ToSpecialIbGib` for an example in
524
+ // // libs/core-gib/src/witness/space/space-helper.mts
525
+ // // await updateSpecialIndex({
526
+ // // metaspace,
527
+ // // type: agentIndexSpecialIbGibType,
528
+ // // dataToAddOrPatch: { agentMap },
529
+ // // space,
530
+ // // });
531
+ // const resNewSpecial = await mut8({
532
+ // src: agentSpecialIndex,
533
+ // dataToAddOrPatch: { agentMap },
534
+ // dna: false,
535
+ // linkedRel8ns: [Rel8n.past],
536
+ // nCounter: true,
537
+ // });
538
+
539
+ // const newSpecialIbGib = resNewSpecial.newIbGib;
540
+
541
+ // // persist
542
+ // await persistTransformResult({ resTransform: resNewSpecial, space });
543
+
544
+ // // update the space ibgib which contains the special/config information
545
+ // const configKey = getSpecialConfigKey({ type: agentIndexSpecialIbGibType });
546
+ // await metaspace.setConfigAddr({
547
+ // key: configKey,
548
+ // addr: getIbGibAddr({ ibGib: newSpecialIbGib }),
549
+ // space,
550
+ // });
551
+
552
+ // await metaspace.registerNewIbGib({ ibGib: newSpecialIbGib, space, });
553
+ // }
554
+
555
+ // await execInSpaceWithLocking({
556
+ // scope: agentIndexSpecialIbGibType, // Use the special index type as the lock scope.
557
+ // secondsValid: 60, // Example timeout
558
+ // maxDelayMs: 100, // Example delay
559
+ // maxLockAttempts: 600, // Example attempts
560
+ // space,
561
+ // // callerInstanceId: // You might need a way to generate a unique ID for the caller
562
+ // fn,
563
+ // });
564
+
565
+ // if (logalot) { console.log(`${lc} Registered domain ${domainTjpAddr} with agent ${agentAddr}`); }
566
+ } catch (error) {
567
+ console.error(`${lc} ${extractErrorMsg(error)}`);
568
+ throw error;
569
+ } finally {
570
+ if (logalot) { console.log(`${lc} complete.`); }
571
+ }
572
+ }
573
+
574
+ /**
575
+ * Retrieves the agent ibGib associated with a domain ibGib from the special agent index ibGib.
576
+ *
577
+ * may have to change this to require the ibgib, not give an optional
578
+ * domainIbGibAddr
579
+ */
580
+ export async function getAgentForDomainIbGib({
581
+ ibGib,
582
+ metaspace,
583
+ space,
584
+ }: {
585
+ ibGib: IbGib_V1,
586
+ metaspace: MetaspaceService,
587
+ space: IbGibSpaceAny,
588
+ }): Promise<AgentWitnessAny | undefined> {
589
+ const lc = `[${getAgentForDomainIbGib.name}]`;
590
+ try {
591
+ if (logalot) { console.log(`${lc} starting...`); }
592
+
593
+ if (!ibGib) { throw new Error(`ibGib required (E: 753a0aa13e4e5ea20d7f6bb92d963625)`); }
594
+
595
+ // // Get the index name and domain TJP address
596
+ // const agentIndexSpecialIbGibType: SpecialIbGibType =
597
+ // // getAgentIndexNameFromIbGib({ ibGib: ibGib, }) as SpecialIbGibType;
598
+ // getIndexNameFromIbGib({ scope: 'agent', ibGib, });
599
+
600
+ // const domainTjpAddr = getTjpAddr({ ibGib, defaultIfNone: 'incomingAddr' })!;
601
+
602
+ // // Get the agent index ibGib
603
+ // const agentSpecialIndex = await metaspace.getSpecialIbGib({
604
+ // type: agentIndexSpecialIbGibType,
605
+ // space,
606
+ // initialize: false, // Do not create if it doesn't exist when retrieving
607
+ // dontWarnIfNotExist: true, // Don't warn if the index doesn't exist
608
+ // lock: false,
609
+ // });
610
+
611
+ // // If the index ibGib doesn't exist, no agent is registered for this domain
612
+ // if (!agentSpecialIndex || !agentSpecialIndex.data) {
613
+ // if (logalot) { console.log(`${lc} Agent index ibGib not found for agentIndexSpecialIbGibType (${agentIndexSpecialIbGibType}). No agent registered, returning undefined. (I: a10a4621aa629384f838ec74456ed925)`); }
614
+ // return undefined; /* <<<< returns early */
615
+ // }
616
+
617
+ // // Get the agent address from the map
618
+ // const agentMap: { [tjpAddr: string]: IbGibAddr } = agentSpecialIndex.data.agentMap ?? {};
619
+ // const agentAddr = agentMap[domainTjpAddr];
620
+
621
+ // if (!agentAddr) {
622
+ // if (logalot) { console.log(`${lc} No agent address found for domain ${domainTjpAddr} in the agent index map. agentIndexSpecialIbGibType: ${agentIndexSpecialIbGibType}. returning undefined. (I: a1666e226ca916918c051cdbb08ff425)`); }
623
+ // return undefined; /* <<<< returns early */
624
+ // }
625
+
626
+ const agentIbGib = await getLocalCoupledIbGibForDomainIbGib({
627
+ ibGib,
628
+ metaspace,
629
+ space,
630
+ scope: 'agent',
631
+ skipGetLatest: false,
632
+ });
633
+ if (!agentIbGib) {
634
+ console.warn(`${lc} couldn't find agent for domain ibGib (${ibGib.ib}) (W: 9536a8e67fe83ddc819c476f5a50c825)`);
635
+ return undefined; /* <<<< returns early */
636
+ }
637
+ const domainTjpAddr = getTjpAddr({ ibGib, defaultIfNone: 'incomingAddr' })!;
638
+
639
+ // Load the agent ibGib
640
+ const agentAddr = getIbGibAddr({ ibGib: agentIbGib });
641
+ const agentSvc = getAgentsSvc();
642
+ const agentWitness =
643
+ await agentSvc.getAgentByAddr({ agentAddr, metaspace, spaceId: space.data!.uuid })
644
+
645
+ if (logalot) {
646
+ if (agentWitness) {
647
+ console.log(`${lc} complete. Found agent ${getIbGibAddr({ ibGib: agentWitness })} for domain ${domainTjpAddr}`);
648
+ } else {
649
+ console.log(`${lc} complete. No agent found for ibgib tjp ${domainTjpAddr}`);
650
+ }
651
+ }
652
+
653
+ return agentWitness;
654
+ } catch (error) {
655
+ console.error(`${lc} ${extractErrorMsg(error)}`);
656
+ throw error;
657
+ }
658
+ }
659
+
660
+ /**
661
+ * @internal
662
+ * @returns factory to create concrete agent witnesses per given {@link arg}
663
+ */
664
+ export function getConcreteAgentFactory(arg: CreateNewAgentArg): CreateConcreteAgentWitnessFactory {
665
+ const lc = `[${getConcreteAgentFactory.name}]`;
666
+ try {
667
+ if (logalot) { console.log(`${lc} starting... (I: 2a9899514ac6e478eb55819a57fd9725)`); }
668
+ const { api } = arg;
669
+ switch (api) {
670
+ case 'gemini':
671
+ return new CreateConcreteAgentWitnessFactory_Gemini(arg);
672
+ default:
673
+ throw new Error(`(UNEXPECTED) api: ${api}? only 'gemini' currently implemented? (E: 071fedab181fda80666858c14ea73625)`);
674
+ }
675
+ } catch (error) {
676
+ console.error(`${lc} ${extractErrorMsg(error)}`);
677
+ throw error;
678
+ } finally {
679
+ if (logalot) { console.log(`${lc} complete.`); }
680
+ }
681
+ }