@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,574 @@
1
+ import { clone, extractErrorMsg, getTimestampInTicks } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
2
+ import { IbGib_V1, Rel8n } from "@ibgib/ts-gib/dist/V1/types.mjs";
3
+ import { getIbAndGib, getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
4
+ import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
5
+ import { isPrimitive } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
6
+ import { mut8 } from "@ibgib/ts-gib/dist/V1/transforms/mut8.mjs";
7
+ import { getSpecialConfigKey, getTjpAddr } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
8
+ import { execInSpaceWithLocking, persistTransformResult } from "@ibgib/core-gib/dist/witness/space/space-helper.mjs";
9
+ import { MetaspaceService } from "@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs";
10
+ import { IbGibSpaceAny } from "@ibgib/core-gib/dist/witness/space/space-base-v1.mjs";
11
+ import { SpecialIbGibType } from "@ibgib/core-gib/dist/common/other/other-types.mjs";
12
+
13
+ import { GLOBAL_LOG_A_LOT, } from "./constants.mjs";
14
+
15
+ const logalot = GLOBAL_LOG_A_LOT; // change this when you want to turn off verbose logging
16
+
17
+ export async function getTagsIbGib({
18
+ metaspace,
19
+ space,
20
+ }: {
21
+ metaspace: MetaspaceService,
22
+ space: IbGibSpaceAny | undefined,
23
+ }): Promise<IbGib_V1> {
24
+ const lc = `[${getTagsIbGib.name}]`;
25
+ try {
26
+ if (logalot) { console.log(`${lc} starting... (I: 2ccb79537a75e7896bace84e6c710d25)`); }
27
+
28
+ const tagsIbGib = await metaspace.getSpecialIbGib({ type: SpecialIbGibType.tags, space });
29
+ if (!tagsIbGib) { throw new Error(`tagsIbGib not found in metaspace. space: ${!!space ? space.ib : 'default local user space'} (E: 4734c510a411274315c0add8f70e1925)`); }
30
+
31
+ return tagsIbGib;
32
+ } catch (error) {
33
+ console.error(`${lc} ${extractErrorMsg(error)}`);
34
+ throw error;
35
+ } finally {
36
+ if (logalot) { console.log(`${lc} complete.`); }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * NOTE: This was originally written only for agents and I'm generalizing it to
42
+ * any "coupled" ibgib. The idea is that for local-space-specific ibgibs that
43
+ * are related to domain ibgibs, but where we don't want to modify the domain
44
+ * ibgib directly, we create this "coupled" ibgib. We then index it in a local
45
+ * space special (index) ibgib and associate it by tjpAddr.
46
+ *
47
+ * Generates a consistent special name for the agent index ibGib based on the
48
+ * domain ibGib's primitive ancestor's ib or the ibGibAddr's ib atom.
49
+ *
50
+ * RIGHT NOW I"M PRIORITIZING THE ATOM. I THINK IT ALWAYS RETURNS THE ATOM, I.E., THE FIRST SPACE-DELIMITED PIECE OF THE `ib`.
51
+ *
52
+ * I am doing this because the project ibgib actually forks from a comment
53
+ * ibgib, so its primitive ancestor is "comment^gib".
54
+ *
55
+ * ## notes
56
+ *
57
+ * We are trying to get a special ibgib index that maps from ibgibs (the domain)
58
+ * to what local agent is registered to handle that ibgib's timeline.
59
+ *
60
+ * Concretely, we're working on the project ibgibs and we need a way to get at
61
+ * the agent that is assigned to that project. But we can't just mut8 the
62
+ * project itself because this would cause issues once the project is spread out
63
+ * among multiple execution contexts (similar to "remotes" in git).
64
+ *
65
+ * So we will have a special ibgib registered with the local space which will
66
+ * act as this index that maps ibgib -> handling agent. This function helps get
67
+ * the *name* of that special indexing ibgib.
68
+ *
69
+ * This can be driven either by the ibgib itself, via the last primitive ancestor
70
+ * ibgib's address, or via the ib's atom (the first space-delimited term in the
71
+ * `ib` metadata).
72
+ *
73
+ * So if an ancestor is [comment^gib, specialComment^gib, specialComment
74
+ * abc123^ABC123.DEF456] (where the abc123 things are representative of the full
75
+ * hashes 64 characters long atow since we're using sha256), then the *last*
76
+ * primitive address is specialComment^gib.
77
+ */
78
+ export function getIndexNameFromIbGib({
79
+ scope,
80
+ ibGib,
81
+ ibGibAddr,
82
+ defaultNameIfError,
83
+ }: {
84
+ /**
85
+ * what kind of index are we talking in general?
86
+ */
87
+ scope: string,
88
+ ibGib?: IbGib_V1,
89
+ ibGibAddr?: IbGibAddr,
90
+ /**
91
+ * if truthy and an error is produced, then this will be returned.
92
+ */
93
+ defaultNameIfError?: string,
94
+ }): string {
95
+ const lc = `[${getIndexNameFromIbGib.name}]`;
96
+ try {
97
+ if (!ibGib && !ibGibAddr) { throw new Error(`${lc} Must provide either ibGib or ibGibAddr. (E: genuuid)`); }
98
+ if (scope.includes(' ')) {
99
+ console.warn(`${lc} scope includes one or more spaces. These will be converted to double underscores. (W: 1554a81454e8ae0a6858ea5dd17f8925)`);
100
+ scope = scope.replace(/ /g, '__');
101
+ }
102
+ /**
103
+ * note: non-alphanumerics are replaced with underscores
104
+ */
105
+ let primitiveAncestorIb: IbGibAddr | undefined = undefined;
106
+ let atom: string | undefined = undefined;
107
+ /**
108
+ * This is what we're trying to extract. once we have this, then we can
109
+ * simply append our index name, e.g. `${ancestorIbOrAtom}-agent-index`
110
+ */
111
+ let ancestorIbOrAtom: string | undefined = undefined;
112
+ if (ibGib) {
113
+ // go by the ibgib's full data
114
+ if (!ibGib.data) { throw new Error(`(UNEXPECTED) ibGib.data falsy? (E: genuuid)`); }
115
+ if (!ibGib.rel8ns) { throw new Error(`(UNEXPECTED) ibGib.rel8ns falsy? (E: genuuid)`); }
116
+ if (!ibGib.rel8ns.ancestor) { throw new Error(`(UNEXPECTED) ibGib.rel8ns.ancestor falsy? (E: genuuid)`); }
117
+ if (ibGib.rel8ns.ancestor.length === 0) {
118
+ throw new Error(`(UNEXPECTED) ibGib.rel8ns.ancestor.length === 0? there should be at least one ancestor (E: genuuid)`);
119
+ // this may turn into a warning later on down the road and return based on the ibGib's addr
120
+ }
121
+ if (ibGib && ibGibAddr) {
122
+ if (getIbGibAddr({ ibGib }) !== ibGibAddr) {
123
+ throw new Error(`(UNEXPECTED) both ibGib and ibGibAddr provided, but addr of ibGib doesn't equal ibGibAddr? (E: genuuid)`);
124
+ }
125
+ }
126
+
127
+ // const primitiveAncestor = getPrimitiveAncestor({ ibGib });
128
+ const primitiveAncestorAddrs =
129
+ ibGib.rel8ns.ancestor!.filter(x => isPrimitive({ gib: getIbAndGib({ ibGibAddr: x }).gib }));
130
+ if (primitiveAncestorAddrs.length === 0) {
131
+ debugger; // error no primitive ancestor addrs?
132
+ 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: genuuid)`)
133
+ }
134
+ const primitiveAncestorAddr = primitiveAncestorAddrs.at(-1)!;
135
+ primitiveAncestorIb =
136
+ getIbAndGib({ ibGibAddr: primitiveAncestorAddr }).ib;
137
+ // replace ALL spaces with underscores
138
+ ancestorIbOrAtom = primitiveAncestorIb;
139
+ }
140
+
141
+ // get the atom from the address
142
+ ibGibAddr ??= getIbGibAddr({ ibGib });
143
+
144
+ // try to get at it from the ibGibAddr
145
+ const { ib } = getIbAndGib({ ibGibAddr });
146
+ atom = (ib.split(' ').at(0) ?? '');
147
+
148
+ // at this point we have a raw atom and possibly a raw primitive
149
+ // ancestor ib. we want to compare the two, which usually should be the
150
+ // same (i think?). if different, warn and return
151
+ atom = atom.replace(/\W/g, '_');
152
+
153
+ primitiveAncestorIb ??= atom;
154
+ primitiveAncestorIb = primitiveAncestorIb.replace(/\W/g, '_');
155
+
156
+ if (!primitiveAncestorIb && !atom) {
157
+ throw new Error(`(UNEXPECTED) both primitiveAncestorIb and atom falsy? one should be truthy at this point. (E: genuuid)`);
158
+ }
159
+
160
+ // if (primitiveAncestorIb !== atom) {
161
+ // // warn and do per arg
162
+ // console.warn(`${lc} ibGib primitive ancestor ib (${primitiveAncestorIb}) doesn't match atom (${atom}). going with ancestorIbOrAtom: ${ancestorIbOrAtom} (W: genuuid)`);
163
+ // }
164
+ ancestorIbOrAtom = atom.toLowerCase();
165
+ if (logalot) { console.log(`${lc} ancestorIbOrAtom: ${ancestorIbOrAtom} (I: genuuid)`); }
166
+
167
+ /**
168
+ * I forgot, this cannot be kebab-cased because we only allow \w regexp
169
+ * on the special ibgib name. I don't remember the reasoning for this,
170
+ * may be arbitrary. But for now, going to change this to underscore,
171
+ * even though the atom or ancestor ib may have underscores in it. Ah
172
+ * well.
173
+ */
174
+ const indexName = `${ancestorIbOrAtom}_${scope}index`;
175
+ if (logalot) { console.log(`${lc} indexName: ${indexName} (I: genuuid)`); }
176
+ return indexName;
177
+ } catch (error) {
178
+ if (!!defaultNameIfError) {
179
+ console.warn(`${lc} error happened but defaultNameIfError (${defaultNameIfError}) provided. So will return this value. error that was thrown: ${extractErrorMsg(error)}`);
180
+ return defaultNameIfError;
181
+ } else {
182
+ console.error(`${lc} ${extractErrorMsg(error)}`);
183
+ throw error;
184
+ }
185
+ }
186
+ }
187
+
188
+ /**
189
+ * NOTE: This was originally written only for agents and I'm generalizing it to
190
+ * any "coupled" ibgib. The idea is that for local-space-specific ibgibs that
191
+ * are related to domain ibgibs, but where we don't want to modify the domain
192
+ * ibgib directly, we create this "coupled" ibgib. We then index it in a local
193
+ * space special (index) ibgib and associate it by tjpAddr.
194
+ * Retrieves the agent ibGib associated with a domain ibGib from the special agent index ibGib.
195
+ *
196
+ * may have to change this to require the ibgib, not give an optional
197
+ * domainIbGibAddr
198
+ */
199
+ export async function getLocalCoupledIbGibForDomainIbGib<TIbGib extends IbGib_V1>({
200
+ scope,
201
+ ibGib,
202
+ metaspace,
203
+ space,
204
+ skipGetLatest,
205
+ }: {
206
+ scope: string,
207
+ ibGib: IbGib_V1,
208
+ metaspace: MetaspaceService,
209
+ space: IbGibSpaceAny,
210
+ /**
211
+ * if true, will not call getLatest on the coupled ibgib if found.
212
+ */
213
+ skipGetLatest?: boolean,
214
+ }): Promise<TIbGib | undefined> {
215
+ const lc = `[${getLocalCoupledIbGibForDomainIbGib.name}]`;
216
+ try {
217
+ if (logalot) { console.log(`${lc} starting... (I: f19dc86aab380fe809aef27ccc7a7425)`); }
218
+
219
+ if (!scope) { throw new Error(`scope required to be a non-empty string (E: 73e702495c38c7d8747d1cf8850af825)`); }
220
+ if (!ibGib) { throw new Error(`ibGib required (E: genuuid)`); }
221
+
222
+ // Get the index name and domain TJP address
223
+ const indexSpecialIbGibType: SpecialIbGibType =
224
+ getIndexNameFromIbGib({ scope, ibGib, }) as SpecialIbGibType;
225
+
226
+ const domainTjpAddr = getTjpAddr({ ibGib, defaultIfNone: 'incomingAddr' })!;
227
+
228
+ // Get the index ibGib
229
+ const fn: () => Promise<TIbGib | undefined> = async () => {
230
+ const specialIndex = await metaspace.getSpecialIbGib({
231
+ type: indexSpecialIbGibType,
232
+ space,
233
+ initialize: false, // Do not create if it doesn't exist when retrieving
234
+ dontWarnIfNotExist: true, // Don't warn if the index doesn't exist
235
+ lock: true,
236
+ });
237
+
238
+ // If the index ibGib doesn't exist, nothing is registered for this domain ibgib
239
+ if (!specialIndex || !specialIndex.data) {
240
+ if (logalot) { console.log(`${lc} special ${scope} index ibGib not found for indexSpecialIbGibType (${indexSpecialIbGibType}). No coupled ibgib registered, returning undefined. (I: genuuid)`); }
241
+ return undefined; /* <<<< returns early */
242
+ }
243
+
244
+ // Get the address from the map
245
+ const coupleMap: { [tjpAddr: string]: IbGibAddr } =
246
+ specialIndex.data.coupleMap ??
247
+ specialIndex.data.agentMap ??
248
+ {};
249
+ const coupledAddr = coupleMap[domainTjpAddr];
250
+
251
+ if (!coupledAddr) {
252
+ if (logalot) { console.log(`${lc} No coupled ${scope} ibgib address found for domain ${domainTjpAddr} in the coupled index map. indexSpecialIbGibType: ${indexSpecialIbGibType}. returning undefined. (I: genuuid)`); }
253
+ return undefined; /* <<<< returns early */
254
+ }
255
+
256
+ let addrToGet = skipGetLatest ?
257
+ coupledAddr :
258
+ await metaspace.getLatestAddr({ addr: coupledAddr, space }) ?? coupledAddr;
259
+
260
+ let resGet = await metaspace.get({
261
+ addrs: [addrToGet],
262
+ space,
263
+ });
264
+
265
+ if (resGet.errorMsg || (resGet.ibGibs ?? []).length !== 1) {
266
+ throw new Error(`couldn't get latest coupled ibgib (${addrToGet}) for domain ${domainTjpAddr}. (E: 8aa7b25f5cd4ebadd8bf2f8807dfe825)`);
267
+ }
268
+
269
+ return resGet.ibGibs![0] as TIbGib;
270
+ }
271
+
272
+ const result = await execInSpaceWithLocking({
273
+ scope: indexSpecialIbGibType,
274
+ secondsValid: 180, // Example timeout
275
+ maxDelayMs: 100, // Example delay
276
+ maxLockAttempts: 1800, // Example attempts
277
+ space,
278
+ callerInstanceId: lc + getTimestampInTicks(),
279
+ fn,
280
+ });
281
+
282
+ return result;
283
+ } catch (error) {
284
+ console.error(`${lc} ${extractErrorMsg(error)}`);
285
+ throw error;
286
+ } finally {
287
+ if (logalot) { console.log(`${lc} complete.`); }
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Registers a domain ibGib with its associated agent ibGib in the special agent
293
+ * index ibGib. This creates or updates a mapping from the domain ibGib's TJP
294
+ * address to the agent's address.
295
+ *
296
+ * ## intent
297
+ *
298
+ * we want to rel8 ibgibs but not directly change the domain ibgib. Like if we
299
+ * have an ibgib that we want to collaborate on, we want a mechanism for the
300
+ * local space (later local user via keystone) to have settings, agents, etc.,
301
+ * for that domain ibgib. But each space has its own version, like a local/user
302
+ * settings vs. a workspace settings.
303
+ *
304
+ * So this gets/creates an index on the local space and associates the domain
305
+ * with the local.
306
+ *
307
+ * @example
308
+ * use this to couple a local agent to a domain ibgib or a local settings ibgib
309
+ * to a domain ibgib, that you do not want to share with others who will have
310
+ * their own versions.
311
+ */
312
+ export async function coupleDomainIbGibWithLocalIbGibViaIndex({
313
+ scope,
314
+ domainIbGib,
315
+ localIbGib,
316
+ metaspace,
317
+ space,
318
+ }: {
319
+ scope: string,
320
+ domainIbGib: IbGib_V1,
321
+ localIbGib: IbGib_V1,
322
+ metaspace: MetaspaceService,
323
+ space: IbGibSpaceAny,
324
+ }): Promise<void> {
325
+ const lc = `[${coupleDomainIbGibWithLocalIbGibViaIndex.name}]`;
326
+ try {
327
+ if (logalot) { console.log(`${lc} starting... (I: 217ae68e0c820e48f4c00409f7f14325)`); }
328
+
329
+ const indexSpecialIbGibType: SpecialIbGibType =
330
+ getIndexNameFromIbGib({ scope, ibGib: domainIbGib, });
331
+
332
+ const domainTjpAddr = getTjpAddr({ ibGib: domainIbGib });
333
+ const localAddr = getIbGibAddr({ ibGib: localIbGib });
334
+
335
+ if (!domainTjpAddr) { throw new Error(`${lc} Could not get TJP address for domain ibGib. (E: 35a4e8ac291b0b85cb958e28dd812f25)`); }
336
+ if (!localAddr) { throw new Error(`${lc} Could not get address for agent ibGib. (E: 2fce1187630b45934c4155a23204d125)`); }
337
+
338
+ const fn = async () => {
339
+
340
+ // Get or create the agent index ibGib
341
+ const agentSpecialIndex = await metaspace.getSpecialIbGib({
342
+ type: indexSpecialIbGibType,
343
+ space,
344
+ initialize: true, // Create if it doesn't exist
345
+ dontWarnIfNotExist: true,
346
+ lock: false,
347
+ });
348
+
349
+ if (!agentSpecialIndex) { throw new Error(`${lc} Could not get or create agent index ibGib.`); }
350
+
351
+ // Initialize data if it doesn't exist
352
+ if (!agentSpecialIndex.data) {
353
+ throw new Error(`(UNEXPECTED) agentSpecialIndex.data falsy? (E: 74299eed147debf6398ca37e7b8d5c25)`);
354
+ }
355
+
356
+ // Get the current mapping or initialize an empty one
357
+ const map = agentSpecialIndex.data.coupleMap ?? agentSpecialIndex.data.agentMap;
358
+ const coupleMap: { [tjpAddr: string]: IbGibAddr } =
359
+ !!map ? clone(map) : {};
360
+
361
+ // Update the mapping
362
+ const existingMappedAgentAddr = coupleMap[domainTjpAddr];
363
+ if (existingMappedAgentAddr) {
364
+ if (existingMappedAgentAddr === localAddr) {
365
+ if (logalot) { console.log(`${lc} domain ibGib (${domainTjpAddr}) already mapped to agent (${localAddr}). returning early (I: cb5d4dcef8cf14de7336120fb8ffef25)`); }
366
+ return; /* <<<< returns early */
367
+ } else {
368
+ console.warn(`${lc} domainTjpAddr (${domainTjpAddr}) already assigned to existingMappedAgentAddr (${existingMappedAgentAddr}). We will be changing to new localAddr (${localAddr}). (W: eb993e33f7731e570fa76f24a2d80625)`)
369
+ }
370
+ }
371
+ coupleMap[domainTjpAddr] = localAddr;
372
+
373
+ // Assign the updated map back to data Save the updated index ibGib.
374
+ // there is extra plumbing involved with special index ibgibs. see
375
+ // `rel8ToSpecialIbGib` for an example in
376
+ // libs/core-gib/src/witness/space/space-helper.mts
377
+ // await updateSpecialIndex({
378
+ // metaspace,
379
+ // type: indexSpecialIbGibType,
380
+ // dataToAddOrPatch: { coupleMap },
381
+ // space,
382
+ // });
383
+ const resNewSpecial = await mut8({
384
+ src: agentSpecialIndex,
385
+ dataToAddOrPatch: { coupleMap },
386
+ dna: false,
387
+ linkedRel8ns: [Rel8n.past],
388
+ nCounter: true,
389
+ });
390
+
391
+ const newSpecialIbGib = resNewSpecial.newIbGib;
392
+
393
+ // persist
394
+ await persistTransformResult({ resTransform: resNewSpecial, space });
395
+
396
+ // update the space ibgib which contains the special/config information
397
+ const configKey = getSpecialConfigKey({ type: indexSpecialIbGibType });
398
+ await metaspace.setConfigAddr({
399
+ key: configKey,
400
+ addr: getIbGibAddr({ ibGib: newSpecialIbGib }),
401
+ space,
402
+ });
403
+
404
+ await metaspace.registerNewIbGib({ ibGib: newSpecialIbGib, space, });
405
+ }
406
+
407
+ await execInSpaceWithLocking({
408
+ scope: indexSpecialIbGibType, // Use the special index type as the lock scope.
409
+ secondsValid: 60, // Example timeout
410
+ maxDelayMs: 100, // Example delay
411
+ maxLockAttempts: 600, // Example attempts
412
+ space,
413
+ // callerInstanceId: // You might need a way to generate a unique ID for the caller
414
+ fn,
415
+ });
416
+
417
+ if (logalot) { console.log(`${lc} Registered domain ${domainTjpAddr} with agent ${localAddr}`); }
418
+ } catch (error) {
419
+ console.error(`${lc} ${extractErrorMsg(error)}`);
420
+ throw error;
421
+ } finally {
422
+ if (logalot) { console.log(`${lc} complete.`); }
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Returns a function, that, as long as it continues to be invoked, will not
428
+ * be triggered. The function will be called after it stops being called for
429
+ * N milliseconds. If `immediate` is passed, trigger the function on the
430
+ * leading edge, instead of the trailing.
431
+ *
432
+ * @param func The function to debounce.
433
+ * @param wait The number of milliseconds to wait after the last call.
434
+ * @param immediate If true, trigger the function on the leading edge.
435
+ * @returns A debounced version of the function.
436
+ */
437
+ export function debounce<T extends (...args: any[]) => void>(
438
+ func: T,
439
+ wait: number,
440
+ immediate?: boolean
441
+ ): (...args: Parameters<T>) => void {
442
+ let timeout: ReturnType<typeof setTimeout> | null = null;
443
+
444
+ return function (this: any, ...args: Parameters<T>): void {
445
+ const context = this;
446
+
447
+ const later = function (): void {
448
+ timeout = null;
449
+ if (!immediate) {
450
+ func.apply(context, args);
451
+ }
452
+ };
453
+
454
+ const callNow = immediate && !timeout;
455
+
456
+ if (timeout) {
457
+ clearTimeout(timeout);
458
+ }
459
+
460
+ timeout = setTimeout(later, wait);
461
+
462
+ if (callNow) {
463
+ func.apply(context, args);
464
+ }
465
+ };
466
+ }
467
+
468
+ export function getMaskedSecret({ secret, countToShow }: { secret: string, countToShow: number }): string {
469
+ const lc = `[${getMaskedSecret.name}]`;
470
+ try {
471
+ if (logalot) { console.log(`${lc} starting... (I: 4d479c342b77f12568501c085b4b0425)`); }
472
+ if (secret) {
473
+ if (countToShow > secret.length) {
474
+ if (secret.length === 1) {
475
+ console.warn(`${lc} secret is one character? (W: genuuid)`);
476
+ return secret; // whatever
477
+ } else {
478
+ console.warn(`${lc} countToShow is longer than the entire secret! just showing the last two (W: genuuid)`);
479
+ return `****${secret.substring(secret.length - 2)}`;
480
+ }
481
+ } else {
482
+ // show the last countToShow
483
+ const secretMasked = `****${secret.substring(secret.length - countToShow)}`;
484
+ return secretMasked;
485
+ }
486
+ } else {
487
+ console.error(`${lc} secret falsy? empty? returning empty string. (E: genuuid)`);
488
+ return '';
489
+ }
490
+ } catch (error) {
491
+ console.error(`${lc} ${extractErrorMsg(error)}`);
492
+ throw error;
493
+ } finally {
494
+ if (logalot) { console.log(`${lc} complete.`); }
495
+ }
496
+ }
497
+
498
+ export function insertAt<T>({
499
+ newItems,
500
+ index,
501
+ targetArray,
502
+ }: {
503
+ newItems: T[],
504
+ index: number,
505
+ targetArray: T[],
506
+ }): T[] {
507
+ const lc = `[${insertAt.name}]`;
508
+ try {
509
+ if (logalot) { console.log(`${lc} starting... (I: 5fc3c84d9e08f4ee88978be8bd117a25)`); }
510
+
511
+ if (index < 0 || index >= targetArray.length) {
512
+ throw new Error(`index (${index}) is out of bounds for targetArray (length ${targetArray.length}) (E: genuuid)`);
513
+ }
514
+
515
+ const arrayCopy = [...targetArray];
516
+ arrayCopy.splice(index, 0, ...newItems);
517
+ return arrayCopy;
518
+ } catch (error) {
519
+ console.error(`${lc} ${extractErrorMsg(error)}`);
520
+ throw error;
521
+ } finally {
522
+ if (logalot) { console.log(`${lc} complete.`); }
523
+ }
524
+ }
525
+
526
+ export function deleteAt<T>({
527
+ targetArray,
528
+ index,
529
+ }: {
530
+ targetArray: T[],
531
+ index: number,
532
+ }): T[] {
533
+ const lc = `[${deleteAt.name}]`;
534
+ try {
535
+ if (logalot) { console.log(`${lc} starting... (I: 6f2df80039f897a0883714686af97925)`); }
536
+
537
+ if (index < 0 || index >= targetArray.length) {
538
+ throw new Error(`index (${index}) is out of bounds for targetArray (length ${targetArray.length}) (E: genuuid)`);
539
+ }
540
+
541
+ const arrayCopy = [...targetArray];
542
+ arrayCopy.splice(index, 1);
543
+ return arrayCopy;
544
+ } catch (error) {
545
+ console.error(`${lc} ${extractErrorMsg(error)}`);
546
+ throw error;
547
+ } finally {
548
+ if (logalot) { console.log(`${lc} complete.`); }
549
+ }
550
+ }
551
+
552
+ export function getShortenedStringWithEllipsis({
553
+ str,
554
+ maxChars,
555
+ }: {
556
+ str: string,
557
+ maxChars: number,
558
+ }): string {
559
+ const lc = `[${getShortenedStringWithEllipsis.name}]`;
560
+ try {
561
+ if (logalot) { console.log(`${lc} starting... (I: 228729c84d2805bc186e96c8cbc56825)`); }
562
+
563
+ if (str.length <= maxChars) {
564
+ return str;
565
+ } else {
566
+ return str.substring(0, maxChars - 1) + '…';
567
+ }
568
+ } catch (error) {
569
+ console.error(`${lc} ${extractErrorMsg(error)}`);
570
+ throw error;
571
+ } finally {
572
+ if (logalot) { console.log(`${lc} complete.`); }
573
+ }
574
+ }