@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,135 @@
1
+ import {
2
+ clone, extractErrorMsg, getUUID,
3
+ } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
4
+ import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
5
+
6
+ import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
7
+ import { AgentWitnessAny, AgentWitnessData_V1, AgentWitnessIbGib_V1, AgentWitnessRel8ns_V1, DEFAULT_AGENT_DATA_V1, DEFAULT_AGENT_REL8NS_V1, } from '../agent-one-file.mjs';
8
+ import { AgentWitnessGemini_V1 } from './agent-witness-gemini-v1.mjs';
9
+ import { storageGet } from '../../../storage/storage-helpers.web.mjs';
10
+ import { CreateConcreteAgentWitnessFactory, CreateNewAgentArg } from '../agent-types.mjs';
11
+ import type { AgentsService_V1 } from '../agents-service-v1.mjs';
12
+ import { getGlobalDbName, getGlobalIndexedDbKey_APIKey, getGlobalStoreName } from '../../../helpers.web.mjs';
13
+
14
+ const logalot = GLOBAL_LOG_A_LOT;
15
+
16
+ /**
17
+ * factory class to create gemini api agents.
18
+ *
19
+ * This doesn't need to be instantiated necessarily, as this is used via the
20
+ * more general factory function {@link AgentsService_V1.createNewAgent}
21
+ */
22
+ export class CreateConcreteAgentWitnessFactory_Gemini
23
+ implements CreateConcreteAgentWitnessFactory {
24
+ private lc: string = `[${CreateConcreteAgentWitnessFactory_Gemini.name}]`;
25
+
26
+ private arg: CreateNewAgentArg;
27
+
28
+ constructor(arg: CreateNewAgentArg) {
29
+ this.arg = arg;
30
+ }
31
+
32
+ async createInitialData(superSpace: IbGibSpaceAny): Promise<AgentWitnessData_V1> {
33
+ const lc = `${this.lc}[${this.createInitialData.name}]`;
34
+ try {
35
+ if (logalot) { console.log(`${lc} starting... (I: f4c8ac488804666077cfc2237972d625)`); }
36
+
37
+ const { name, api, model, type, availableFunctions, } = this.arg;
38
+ if (!model) { throw new Error(`(UNEXPECTED) model falsy? (E: ee7286c772a37fa86236c85f96233625)`); }
39
+ if (!superSpace.data) { throw new Error(`(UNEXPECTED) superSpace.data falsy? (E: 858d5950b9ef7a0175482a51caaf9c25)`); }
40
+ if (!superSpace.data.uuid) { throw new Error(`(UNEXPECTED) superSpace.data.uuid falsy? (E: 08867535db1b254d73c050bd5086e525)`); }
41
+
42
+ const data = clone(DEFAULT_AGENT_DATA_V1) as AgentWitnessData_V1;
43
+ if (name) { data.name = name; }
44
+ data.uuid = await getUUID();
45
+ data.superSpaceId = superSpace.data.uuid;
46
+ data.api = api;
47
+ data.model = model;
48
+ data.type = type;
49
+ data.availableFunctionNameOrIds = availableFunctions.map(x => x.nameOrId);
50
+ data.classname = AgentWitnessGemini_V1.name;
51
+
52
+ // if (model) { data.model = model; }
53
+
54
+ return data;
55
+ } catch (error) {
56
+ console.error(`${lc} ${extractErrorMsg(error)}`);
57
+ throw error;
58
+ } finally {
59
+ if (logalot) { console.log(`${lc} complete.`); }
60
+ }
61
+ }
62
+ async createInitialRel8ns(): Promise<AgentWitnessRel8ns_V1 | undefined> {
63
+ const lc = `${this.lc}[${this.createInitialRel8ns.name}]`;
64
+ try {
65
+ if (logalot) { console.log(`${lc} starting... (I: 2d4933ea3761bd7df701d8d306fb2825)`); }
66
+
67
+ const rel8ns = !!DEFAULT_AGENT_REL8NS_V1 ?
68
+ clone(DEFAULT_AGENT_REL8NS_V1) as AgentWitnessRel8ns_V1 :
69
+ undefined;
70
+
71
+ return rel8ns;
72
+ } catch (error) {
73
+ console.error(`${lc} ${extractErrorMsg(error)}`);
74
+ throw error;
75
+ } finally {
76
+ if (logalot) { console.log(`${lc} complete.`); }
77
+ }
78
+ }
79
+ async createWitness(): Promise<AgentWitnessAny> {
80
+ const lc = `[${this.createWitness.name}]`;
81
+ try {
82
+ if (logalot) { console.log(`${lc} starting... (I: 36709dfa0c398d63d64c4f6ba9055625)`); }
83
+ const { api, model } = this.arg;
84
+ if (api === 'gemini') {
85
+ // model is ignored atow 1/2025
86
+ const witness = new AgentWitnessGemini_V1();
87
+ await witness.initialized;
88
+ return witness;
89
+ } else {
90
+ throw new Error(`(UNEXPECTED) unknown api: ${api}? only 'gemini' currently implemented (E: 2d1cb22ce787c6c42d4532c260320125)`);
91
+ }
92
+ } catch (error) {
93
+ console.error(`${lc} ${extractErrorMsg(error)}`);
94
+ throw error;
95
+ } finally {
96
+ if (logalot) { console.log(`${lc} complete.`); }
97
+ }
98
+
99
+ }
100
+
101
+ }
102
+
103
+ /**
104
+ * Takes an incoming {@link agentIbGib} (dto), creates a new agent witness,
105
+ * initializes it and loads that {@link agentIbGib} dto into it.
106
+ *
107
+ * @returns the full agent witness
108
+ */
109
+ export async function agentIbGibDtoToWitness({
110
+ agentIbGib,
111
+ }: {
112
+ agentIbGib: AgentWitnessIbGib_V1,
113
+ }): Promise<AgentWitnessAny> {
114
+ const lc = `[${agentIbGibDtoToWitness.name}]`;
115
+ try {
116
+ if (logalot) { console.log(`${lc} starting... (I: 5a4efefba9e4bdfb942afbe7919fff25)`); }
117
+ const agentWitness = new AgentWitnessGemini_V1();
118
+ await agentWitness.initialized;
119
+ await agentWitness.loadIbGibDto(agentIbGib);
120
+ agentWitness.fnGetAPIKey = async () => {
121
+ let apiKey = await storageGet({
122
+ dbName: getGlobalDbName(),
123
+ storeName: await getGlobalStoreName(),
124
+ key: await getGlobalIndexedDbKey_APIKey(),
125
+ });
126
+ return apiKey ?? '';
127
+ }
128
+ return agentWitness;
129
+ } catch (error) {
130
+ console.error(`${lc} ${extractErrorMsg(error)}`);
131
+ throw error;
132
+ } finally {
133
+ if (logalot) { console.log(`${lc} complete.`); }
134
+ }
135
+ }
@@ -0,0 +1,79 @@
1
+ import { AGENT_NAME_REGEXP } from "../agent-constants.mjs";
2
+
3
+ export const GEMINI_ERROR_STATUS_MODEL_OVERLOADED = 503;
4
+ export const GEMINI_ERROR_STATUS_RATE_QUOTA_EXCEEDED = 429;
5
+
6
+ /**
7
+ * the path error.errorDetails is an array of error info objects.
8
+ */
9
+ export const GEMINI_ERROR_DETAILS_TYPE_QUOTA_FAILURE = "type.googleapis.com/google.rpc.QuotaFailure";
10
+ export const GEMINI_ERROR_DETAILS_TYPE_RETRY_INFO = "type.googleapis.com/google.rpc.RetryInfo";
11
+ export const GEMINI_ERROR_DETAILS_TYPE_RETRY_INFO_RETRY_DELAY_KEY = 'retryDelay';
12
+
13
+
14
+ // #region GeminiModel enum
15
+ /**
16
+ * @see {@link GeminiModel.GEMINI_2_0_FLASH}
17
+ */
18
+ const GEMINI_MODEL_GEMINI_2_0_FLASH = 'gemini-2.0-flash';
19
+ const GEMINI_MODEL_GEMINI_2_0_FLASH_LITE = 'gemini-2.0-flash-lite';
20
+ // const GEMINI_MODEL_GEMINI_2_0_FLASH = 'gemini-2.0-flash-exp';
21
+ // /**
22
+ // * @see {@link GeminiModel.GEMINI_1_5_FLASH}
23
+ // */
24
+ // const GEMINI_MODEL_GEMINI_1_5_FLASH = 'gemini-1.5-flash';
25
+ // /**
26
+ // * @see {@link GeminiModel.GEMINI_1_5_FLASH_8B}
27
+ // */
28
+ // const GEMINI_MODEL_GEMINI_1_5_FLASH_8B = 'gemini-1.5-flash-8b';
29
+ // /**
30
+ // * @see {@link GeminiModel.GEMINI_1_5_PRO}
31
+ // */
32
+ // const GEMINI_MODEL_GEMINI_1_5_PRO = 'gemini-1.5-pro';
33
+
34
+ /**
35
+ * Enum of Gemini models that are available to the agent.
36
+ */
37
+ export type GeminiModel =
38
+ | typeof GEMINI_MODEL_GEMINI_2_0_FLASH
39
+ | typeof GEMINI_MODEL_GEMINI_2_0_FLASH_LITE
40
+ // | typeof GEMINI_MODEL_GEMINI_1_5_FLASH
41
+ // | typeof GEMINI_MODEL_GEMINI_1_5_FLASH_8B
42
+ // | typeof GEMINI_MODEL_GEMINI_1_5_PRO
43
+ ;
44
+
45
+ /**
46
+ * @see {@link GeminiModel}
47
+ */
48
+ export const GeminiModel = {
49
+ /**
50
+ * @see {@link GEMINI_MODEL_GEMINI_2_0_FLASH}
51
+ */
52
+ GEMINI_2_0_FLASH: GEMINI_MODEL_GEMINI_2_0_FLASH as GeminiModel,
53
+ /**
54
+ * @see {@link GEMINI_MODEL_GEMINI_2_0_FLASH_LITE}
55
+ */
56
+ GEMINI_2_0_FLASH_LITE: GEMINI_MODEL_GEMINI_2_0_FLASH_LITE as GeminiModel,
57
+ // /**
58
+ // * @see {@link GEMINI_MODEL_GEMINI_1_5_FLASH}
59
+ // */
60
+ // GEMINI_1_5_FLASH: GEMINI_MODEL_GEMINI_1_5_FLASH as GeminiModel,
61
+ // /**
62
+ // * @see {@link GEMINI_MODEL_GEMINI_1_5_FLASH_8B}
63
+ // */
64
+ // GEMINI_1_5_FLASH_8B: GEMINI_MODEL_GEMINI_1_5_FLASH_8B as GeminiModel,
65
+ // /**
66
+ // * @see {@link GEMINI_MODEL_GEMINI_1_5_PRO}
67
+ // */
68
+ // GEMINI_1_5_PRO: GEMINI_MODEL_GEMINI_1_5_PRO as GeminiModel,
69
+ } satisfies { [key: string]: GeminiModel };
70
+
71
+ export const GEMINI_MODEL_VALUES = Object.freeze(Object.values(GeminiModel));
72
+ export function isGeminiModel(str: string): str is GeminiModel {
73
+ return !!str && GEMINI_MODEL_VALUES.includes(str as GeminiModel);
74
+ }
75
+
76
+ // #endregion GeminiModel enum
77
+
78
+ export const GEMINI_BACKUP_MODEL_STR = GeminiModel.GEMINI_2_0_FLASH_LITE;
79
+ export const GEMINI_MAX_TRY_COUNT = 5;
@@ -0,0 +1,216 @@
1
+ import { Content, FunctionCall, FunctionCallPart, FunctionResponse, FunctionResponsePart, TextPart } from "@google/generative-ai";
2
+ import type { GoogleGenerativeAI, ModelParams } from "@google/generative-ai";
3
+
4
+ import { extractErrorMsg, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
5
+ import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
6
+ import { isComment, } from "@ibgib/core-gib/dist/common/comment/comment-helper.mjs";
7
+
8
+ import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
9
+ import { getAllFunctionInfos } from "../../../api/api-index.mjs";
10
+ import { APIFunctionInfo } from "../../../api/api-types.mjs";
11
+ import { PromptInfo, } from "../agent-one-file.mjs";
12
+ import { FUNCTION_CALL_REQUEST_COMMENT_TAG, TextSource, } from "../agent-constants.mjs";
13
+ import { FunctionResponsePart_ResponseWrapper, PromptInfoEntryGemini, PromptInfoGemini } from "./gemini-types.mjs";
14
+ import { FunctionInfoIbGib_V1 } from "../function-info/function-info-one-file.mjs";
15
+
16
+ const logalot = GLOBAL_LOG_A_LOT;
17
+
18
+ export function textSourceToGeminiRole(src: TextSource): string {
19
+ switch (src) {
20
+ case TextSource.HUMAN:
21
+ return 'user';
22
+ case TextSource.AI:
23
+ return 'model';
24
+ case TextSource.FUNCTION:
25
+ return 'function';
26
+ case TextSource.HARDCODED:
27
+ return 'user';
28
+ case TextSource.UNKNOWN:
29
+ return 'user';
30
+ default:
31
+ throw new Error(`(UNEXPECTED) src is not a valid TextSource? src: ${src} (E: 9d954fe0bc49cf4572a65b19b6173925)`);
32
+ }
33
+ }
34
+ // export function geminiRoleToTextSource(geminiRole: 'user' | 'model' | ''): TextSource {
35
+ // if (geminiRole === 'user') {
36
+ // return TextSource.HUMAN;
37
+ // } else if (geminiRole === 'model') {
38
+ // return TextSource.AI;
39
+ // } else {
40
+ // return TextSource.UNKNOWN;
41
+ // }
42
+ // }
43
+
44
+ export function isPromptInfoGemini(info: PromptInfo): info is PromptInfoGemini {
45
+ return info.api === 'gemini';
46
+ }
47
+
48
+ /**
49
+ * gemini api-specific helper that maps gemini function call returned from the
50
+ * model to our API function info interface
51
+ */
52
+ export function geminiFunctionCallToAPIFunctionInfo({
53
+ functionCall,
54
+ }: {
55
+ functionCall: FunctionCall
56
+ }): { info: APIFunctionInfo, args: any } {
57
+ const lc = `[${geminiFunctionCallToAPIFunctionInfo.name}]`;
58
+ const functionInfo = getAllFunctionInfos().get(functionCall.name);
59
+ if (!functionInfo) {
60
+ throw new Error(`${lc} no APIFunctionInfo found matching name: ${functionCall.name} (E: 7c5c7c17988a666a86e72299630c7f25)`);
61
+ }
62
+ return {
63
+ info: functionInfo,
64
+ args: functionCall.args ?? undefined,
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Takes 0 or more entries and combines them into a single {@link Content}
70
+ * object that Gemini API expects for `systemInstruction` when using the fn
71
+ * {@link GoogleGenerativeAI.getGenerativeModel} (@see {@link ModelParams}).
72
+ *
73
+ * @param entries for system instruction, probably from {@link AgentWitnessGemini_V1.systemPromptParts}
74
+ * @returns undefined if no entries, else single Gemini API Content object with role === "user" and combined parts from {@link systemPromptEntries}
75
+ */
76
+ export function systemPromptEntriesToSystemInstructionContent({
77
+ systemPromptEntries,
78
+ }: {
79
+ systemPromptEntries: PromptInfoEntryGemini[],
80
+ }): Content | undefined {
81
+ const lc = `[${systemPromptEntriesToSystemInstructionContent.name}]`;
82
+ try {
83
+ if (logalot) { console.log(`${lc} starting... (I: 18693a97427939699285ef8c1a9cc425)`); }
84
+
85
+ if (systemPromptEntries.length === 0) { return undefined; /* <<<< returns early */ }
86
+ if (!systemPromptEntries.every(entry => entry.src === TextSource.HUMAN)) {
87
+ if (logalot) { console.warn(`${lc} not every system entry's src is human. We're still going to say that these are "user" origin in Gemini API. (W: 7115e2be876498ecb1e153c79a86e125)`); }
88
+ }
89
+ const sysInstructionContent: Content = {
90
+ role: "user",
91
+ parts: systemPromptEntries.flatMap(entry => entry.content.parts),
92
+ };
93
+ if (logalot) { console.log(`${lc} sysInstructionContent: ${pretty(sysInstructionContent)} (I: 011e5b865c23eb0b640df3f464ac2525)`); }
94
+ return sysInstructionContent;
95
+ } catch (error) {
96
+ console.error(`${lc} ${extractErrorMsg(error)}`);
97
+ throw error;
98
+ } finally {
99
+ if (logalot) { console.log(`${lc} complete.`); }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * helper function (not a guard) that determines if the given ibgib has the
105
+ * expected shape of a Function Call Request comment (FCR).
106
+ *
107
+ * These objects are created when a model requests a function call.
108
+ *
109
+ * ATOW (01/2025) these FCRs should include both one or more infos for both
110
+ * function calls and function responses.
111
+ */
112
+ export function isFunctionCallRequestComment({ ibGib }: { ibGib: IbGib_V1 }): boolean {
113
+ const lc = `[${isFunctionCallRequestComment.name}]`;
114
+ try {
115
+ if (logalot) { console.log(`${lc} starting... (I: 986d3edcd4f3aaf1d7eb0f8b59206b25)`); }
116
+
117
+ if (!ibGib) {
118
+ if (logalot) { console.warn(`${lc} ibGib falsy. (W: a70390e8bc3f420a92d3a84f4c78f12a)`); }
119
+ return false; /* <<<< returns early */
120
+ }
121
+ if (!isComment({ ibGib })) {
122
+ if (logalot) { console.log(`${lc} not a comment ibgib (I: 6a62c4f6e13776616855c4f237a5206b)`); }
123
+ return false; /* <<<< returns early */
124
+ }
125
+ if (!ibGib.data) {
126
+ if (logalot) { console.log(`${lc} ibGib.data falsy (I: 69eb86975640475395bb74944141a46d)`); }
127
+ return false; /* <<<< returns early */
128
+ }
129
+
130
+ const { text } = ibGib.data;
131
+ if (!text) {
132
+ if (logalot) { console.log(`${lc} text falsy (I: e348e38c841b4443b3f09e75c0215b24)`); }
133
+ return false; /* <<<< returns early */
134
+ }
135
+
136
+ if (text.includes(FUNCTION_CALL_REQUEST_COMMENT_TAG)) {
137
+ if (logalot) { console.log(`${lc} has tag. returning true. (I: 6d76b27d558d44f696582f41af561f29)`); }
138
+ return true;
139
+ }
140
+ // let { safeIbCommentMetadataText } = parseCommentIb({ ib: ibGib.ib });
141
+ // if (safeIbCommentMetadataText && safeIbCommentMetadataText.includes(FUNCTION_INFO_ATOM)) {
142
+ // return true;
143
+ // }
144
+
145
+ if (logalot) { console.log(`${lc} no indicator found. returning false. (I: 815f181a0a08058362f76b08a8964674)`); }
146
+
147
+ return false;
148
+ } catch (error) {
149
+ console.error(`${lc} ${extractErrorMsg(error)}`);
150
+ throw error;
151
+ } finally {
152
+ if (logalot) { console.log(`${lc} complete.`); }
153
+ }
154
+ }
155
+
156
+
157
+ /**
158
+ * Helper function to create Gemini API FunctionCallPart and FunctionResponsePart
159
+ * objects from a FunctionInfoIbGib_V1.
160
+ *
161
+ * @param {object} arg - Arguments object.
162
+ * @param {FunctionInfoIbGib_V1} arg.functionInfoIbGib - The FunctionInfoIbGib_V1 instance containing function call details.
163
+ * @returns {{ call: FunctionCallPart; response: FunctionResponsePart }} - An object containing both FunctionCallPart and FunctionResponsePart objects.
164
+ * @throws {Error} If there's an error during the process, such as missing function name or arguments.
165
+ */
166
+ export function getFunctionCallAndResponseParts({
167
+ functionInfoIbGib,
168
+ }: {
169
+ functionInfoIbGib: FunctionInfoIbGib_V1,
170
+ }): { call: FunctionCallPart, response: FunctionResponsePart } {
171
+ const lc = `[${getFunctionCallAndResponseParts.name}]`;
172
+ try {
173
+ if (logalot) { console.log(`${lc} starting... (I: 1a2b3c4d5e6f7a8b)`); }
174
+
175
+ if (!functionInfoIbGib) {
176
+ throw new Error(`${lc} functionInfoIbGib parameter is required. (E: 9c8f7a3b2d1e4a5b6c7d8e9f)`);
177
+ }
178
+ if (!functionInfoIbGib.data) {
179
+ throw new Error(`${lc} functionInfoIbGib.data is required. (E: 2b3c4d5e6f7a8b1c2d3e4f5a)`);
180
+ }
181
+
182
+ const { fnName, fnArgs, fnResult } = functionInfoIbGib.data;
183
+
184
+ if (!fnName) {
185
+ throw new Error(`${lc} functionInfoIbGib.data.fnName is required. (E: 6f7a8b1c2d3e4f5a6b7c8d9e)`);
186
+ }
187
+
188
+ // 1. Create FunctionCallPart
189
+ const functionCallPart: FunctionCallPart = {
190
+ functionCall: {
191
+ name: fnName,
192
+ args: fnArgs ?? {}, // Use empty object if fnArgs is not provided
193
+ } as FunctionCall,
194
+ } satisfies FunctionCallPart;
195
+
196
+
197
+ // 2. Create FunctionResponsePart
198
+ const responseWrapper: FunctionResponsePart_ResponseWrapper = {
199
+ value: fnResult,
200
+ };
201
+ const functionResponsePart: FunctionResponsePart = {
202
+ functionResponse: {
203
+ name: fnName,
204
+ response: responseWrapper, // Use empty object if fnResult is not provided
205
+ } as FunctionResponse,
206
+ } satisfies FunctionResponsePart;
207
+
208
+ return { call: functionCallPart, response: functionResponsePart };
209
+
210
+ } catch (error) {
211
+ console.error(`${lc} Error: ${extractErrorMsg(error)}`);
212
+ throw error;
213
+ } finally {
214
+ if (logalot) { console.log(`${lc} complete.`); }
215
+ }
216
+ }
@@ -0,0 +1,88 @@
1
+ import { Content, } from "@google/generative-ai";
2
+ import type { StartChatParams, ChatSession, FunctionCallingMode, } from "@google/generative-ai";
3
+ import { PromptInfo, } from "../agent-one-file.mjs";
4
+ import { TextSource } from "../agent-constants.mjs";
5
+
6
+ export interface PromptInfoEntryGemini {
7
+ /**
8
+ * The source of the text, in terms of our code definition.
9
+ *
10
+ * I say this because the Gemini API only considers "user" and "model" but
11
+ * we keep more information (and more accurate information) than this.
12
+ *
13
+ * For example, the Gemini API expects function responses to be role "user".
14
+ * But we would store this src as {@link TextSource.FUNCTION}
15
+ */
16
+ src: TextSource;
17
+ // /**
18
+ // * the raw text of an entry
19
+ // */
20
+ // text?: string;
21
+ /**
22
+ * the shape of the entry that the Gemini API would expect
23
+ */
24
+ content: Content;
25
+ };
26
+ /**
27
+ * Information required specifically for the Gemini API.
28
+ */
29
+ export interface PromptInfoGemini extends PromptInfo {
30
+ /**
31
+ * The system instructions' parts that we'll concatenate into system prompt.
32
+ */
33
+ systemPromptEntries: PromptInfoEntryGemini[];
34
+ /**
35
+ * The history of the chat, i.e., the contents of the chat sans the most
36
+ * recent.
37
+ *
38
+ * NOTE: We will be using this for the gemini api's "chat" function.
39
+ *
40
+ * @see {@link StartChatParams.history}
41
+ */
42
+ chatPromptHistoryParts: PromptInfoEntryGemini[];
43
+ /**
44
+ * The most recent chat message
45
+ *
46
+ * @see {@link ChatSession.sendMessage}
47
+ */
48
+ chatPromptCurrent: PromptInfoEntryGemini;
49
+ /**
50
+ * if truthy, this will override the default function calling mode when
51
+ * prompting the LLM.
52
+ *
53
+ * if falsy, will use the default (FunctionCallingMode.ANY)
54
+ *
55
+ * @see {@link FunctionCallingMode}
56
+ *
57
+ * ## notes
58
+ *
59
+ * I'm adding this for custom prompt. right now, it works better when
60
+ * forcing the model to call a function, but I am now wanting the use case
61
+ * to just ask the model a "normal" chat llm question (for translating some
62
+ * text).
63
+ */
64
+ overrideFunctionCallingMode?: FunctionCallingMode;
65
+ }
66
+
67
+ /**
68
+ * Gemini returns either function calls or raw text atow (01/2025)
69
+ */
70
+ export type PromptAPIResult_Gemini =
71
+ | {
72
+ /**
73
+ * raw strings of function calls requested returned by the underlying
74
+ * API's model (right now Gemini)
75
+ */
76
+ functionCalls: string[]
77
+ }
78
+ | { text: string };
79
+
80
+ /**
81
+ * This is a "kluge" IMO because it wraps the response part to be able to handle
82
+ * all responses of functions. This is a limitation of the Gemini API which requires an
83
+ * object as the response part's value. So if a function returns "undefined" or an array,
84
+ * it throws an error. So this is a wrapper.
85
+ */
86
+ export interface FunctionResponsePart_ResponseWrapper {
87
+ value: any | undefined;
88
+ }