happy2 0.0.13 → 0.0.15

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 (300) hide show
  1. package/package.json +1 -1
  2. package/packages/happy2-server/PLUGINS.md +202 -42
  3. package/packages/happy2-server/dist/index.d.ts +1 -0
  4. package/packages/happy2-server/dist/index.d.ts.map +1 -1
  5. package/packages/happy2-server/dist/index.js +1 -0
  6. package/packages/happy2-server/dist/index.js.map +1 -1
  7. package/packages/happy2-server/dist/modules/agent/agentChatGetContext.d.ts.map +1 -1
  8. package/packages/happy2-server/dist/modules/agent/agentChatGetContext.js +1 -1
  9. package/packages/happy2-server/dist/modules/agent/agentChatGetContext.js.map +1 -1
  10. package/packages/happy2-server/dist/modules/agent/agentConversationCreate.d.ts.map +1 -1
  11. package/packages/happy2-server/dist/modules/agent/agentConversationCreate.js +1 -1
  12. package/packages/happy2-server/dist/modules/agent/agentConversationCreate.js.map +1 -1
  13. package/packages/happy2-server/dist/modules/agent/agentCreate.d.ts.map +1 -1
  14. package/packages/happy2-server/dist/modules/agent/agentCreate.js +2 -2
  15. package/packages/happy2-server/dist/modules/agent/agentCreate.js.map +1 -1
  16. package/packages/happy2-server/dist/modules/agent/agentDefaultCreate.d.ts.map +1 -1
  17. package/packages/happy2-server/dist/modules/agent/agentDefaultCreate.js +1 -1
  18. package/packages/happy2-server/dist/modules/agent/agentDefaultCreate.js.map +1 -1
  19. package/packages/happy2-server/dist/modules/agent/agentImageCommitChange.js +1 -1
  20. package/packages/happy2-server/dist/modules/agent/agentImageCommitChange.js.map +1 -1
  21. package/packages/happy2-server/dist/modules/agent/agentImageCreate.d.ts +4 -3
  22. package/packages/happy2-server/dist/modules/agent/agentImageCreate.d.ts.map +1 -1
  23. package/packages/happy2-server/dist/modules/agent/agentImageCreate.js +73 -23
  24. package/packages/happy2-server/dist/modules/agent/agentImageCreate.js.map +1 -1
  25. package/packages/happy2-server/dist/modules/agent/agentImageDeactivate.d.ts +15 -0
  26. package/packages/happy2-server/dist/modules/agent/agentImageDeactivate.d.ts.map +1 -0
  27. package/packages/happy2-server/dist/modules/agent/agentImageDeactivate.js +92 -0
  28. package/packages/happy2-server/dist/modules/agent/agentImageDeactivate.js.map +1 -0
  29. package/packages/happy2-server/dist/modules/agent/agentImageDockerfileGetForHost.d.ts +12 -0
  30. package/packages/happy2-server/dist/modules/agent/agentImageDockerfileGetForHost.d.ts.map +1 -0
  31. package/packages/happy2-server/dist/modules/agent/agentImageDockerfileGetForHost.js +28 -0
  32. package/packages/happy2-server/dist/modules/agent/agentImageDockerfileGetForHost.js.map +1 -0
  33. package/packages/happy2-server/dist/modules/agent/agentImageFindDefinition.d.ts.map +1 -1
  34. package/packages/happy2-server/dist/modules/agent/agentImageFindDefinition.js +2 -2
  35. package/packages/happy2-server/dist/modules/agent/agentImageFindDefinition.js.map +1 -1
  36. package/packages/happy2-server/dist/modules/agent/agentImageGet.js +2 -2
  37. package/packages/happy2-server/dist/modules/agent/agentImageGet.js.map +1 -1
  38. package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.js +1 -1
  39. package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.js.map +1 -1
  40. package/packages/happy2-server/dist/modules/agent/agentImageGetReadyDefault.d.ts.map +1 -1
  41. package/packages/happy2-server/dist/modules/agent/agentImageGetReadyDefault.js +2 -2
  42. package/packages/happy2-server/dist/modules/agent/agentImageGetReadyDefault.js.map +1 -1
  43. package/packages/happy2-server/dist/modules/agent/agentImageList.d.ts.map +1 -1
  44. package/packages/happy2-server/dist/modules/agent/agentImageList.js +2 -1
  45. package/packages/happy2-server/dist/modules/agent/agentImageList.js.map +1 -1
  46. package/packages/happy2-server/dist/modules/agent/agentImageListForHost.d.ts +17 -0
  47. package/packages/happy2-server/dist/modules/agent/agentImageListForHost.d.ts.map +1 -0
  48. package/packages/happy2-server/dist/modules/agent/agentImageListForHost.js +38 -0
  49. package/packages/happy2-server/dist/modules/agent/agentImageListForHost.js.map +1 -0
  50. package/packages/happy2-server/dist/modules/agent/agentImageListRequestedBuildIds.d.ts.map +1 -1
  51. package/packages/happy2-server/dist/modules/agent/agentImageListRequestedBuildIds.js +2 -2
  52. package/packages/happy2-server/dist/modules/agent/agentImageListRequestedBuildIds.js.map +1 -1
  53. package/packages/happy2-server/dist/modules/agent/agentImageRequestBuild.js +3 -3
  54. package/packages/happy2-server/dist/modules/agent/agentImageRequestBuild.js.map +1 -1
  55. package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.d.ts +4 -3
  56. package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.d.ts.map +1 -1
  57. package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.js +10 -6
  58. package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.js.map +1 -1
  59. package/packages/happy2-server/dist/modules/agent/agentImageTakeBuild.js +2 -2
  60. package/packages/happy2-server/dist/modules/agent/agentImageTakeBuild.js.map +1 -1
  61. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.d.ts +4 -0
  62. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.d.ts.map +1 -0
  63. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.js +15 -0
  64. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.js.map +1 -0
  65. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.d.ts +2 -0
  66. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.d.ts.map +1 -0
  67. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.js +17 -0
  68. package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.js.map +1 -0
  69. package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.d.ts +23 -0
  70. package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.d.ts.map +1 -0
  71. package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.js +70 -0
  72. package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.js.map +1 -0
  73. package/packages/happy2-server/dist/modules/agents/service.d.ts +23 -6
  74. package/packages/happy2-server/dist/modules/agents/service.d.ts.map +1 -1
  75. package/packages/happy2-server/dist/modules/agents/service.js +21 -7
  76. package/packages/happy2-server/dist/modules/agents/service.js.map +1 -1
  77. package/packages/happy2-server/dist/modules/auth/tokens.d.ts +15 -0
  78. package/packages/happy2-server/dist/modules/auth/tokens.d.ts.map +1 -1
  79. package/packages/happy2-server/dist/modules/auth/tokens.js +74 -6
  80. package/packages/happy2-server/dist/modules/auth/tokens.js.map +1 -1
  81. package/packages/happy2-server/dist/modules/auth/tokens.test.js +57 -0
  82. package/packages/happy2-server/dist/modules/auth/tokens.test.js.map +1 -1
  83. package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.d.ts +19 -0
  84. package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.d.ts.map +1 -0
  85. package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.js +87 -0
  86. package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.js.map +1 -0
  87. package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.d.ts +15 -0
  88. package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.d.ts.map +1 -0
  89. package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.js +38 -0
  90. package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.js.map +1 -0
  91. package/packages/happy2-server/dist/modules/chat/chatAppendAudit.d.ts +1 -1
  92. package/packages/happy2-server/dist/modules/chat/chatAppendAudit.d.ts.map +1 -1
  93. package/packages/happy2-server/dist/modules/draft/draftList.d.ts +8 -0
  94. package/packages/happy2-server/dist/modules/draft/draftList.d.ts.map +1 -0
  95. package/packages/happy2-server/dist/modules/draft/draftList.js +27 -0
  96. package/packages/happy2-server/dist/modules/draft/draftList.js.map +1 -0
  97. package/packages/happy2-server/dist/modules/draft/draftUpdate.d.ts +16 -0
  98. package/packages/happy2-server/dist/modules/draft/draftUpdate.d.ts.map +1 -0
  99. package/packages/happy2-server/dist/modules/draft/draftUpdate.js +64 -0
  100. package/packages/happy2-server/dist/modules/draft/draftUpdate.js.map +1 -0
  101. package/packages/happy2-server/dist/modules/draft/types.d.ts +7 -0
  102. package/packages/happy2-server/dist/modules/draft/types.d.ts.map +1 -0
  103. package/packages/happy2-server/dist/modules/draft/types.js +2 -0
  104. package/packages/happy2-server/dist/modules/draft/types.js.map +1 -0
  105. package/packages/happy2-server/dist/modules/plugin/catalog.d.ts.map +1 -1
  106. package/packages/happy2-server/dist/modules/plugin/catalog.js +3 -3
  107. package/packages/happy2-server/dist/modules/plugin/catalog.js.map +1 -1
  108. package/packages/happy2-server/dist/modules/plugin/catalog.test.js +2 -2
  109. package/packages/happy2-server/dist/modules/plugin/catalog.test.js.map +1 -1
  110. package/packages/happy2-server/dist/modules/plugin/environmentManagementServer.test.d.ts +2 -0
  111. package/packages/happy2-server/dist/modules/plugin/environmentManagementServer.test.d.ts.map +1 -0
  112. package/packages/happy2-server/dist/modules/plugin/environmentManagementServer.test.js +183 -0
  113. package/packages/happy2-server/dist/modules/plugin/environmentManagementServer.test.js.map +1 -0
  114. package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.d.ts +5 -0
  115. package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.d.ts.map +1 -0
  116. package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.js +128 -0
  117. package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.js.map +1 -0
  118. package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.d.ts.map +1 -1
  119. package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js +10 -1
  120. package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js.map +1 -1
  121. package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.d.ts +3 -0
  122. package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.d.ts.map +1 -0
  123. package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.js +68 -0
  124. package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.js.map +1 -0
  125. package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.d.ts.map +1 -1
  126. package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js +10 -2
  127. package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js.map +1 -1
  128. package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts +19 -0
  129. package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts.map +1 -1
  130. package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js +1 -0
  131. package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js.map +1 -1
  132. package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.d.ts.map +1 -1
  133. package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js +4 -2
  134. package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js.map +1 -1
  135. package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js +14 -0
  136. package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js.map +1 -1
  137. package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.d.ts +345 -0
  138. package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.d.ts.map +1 -0
  139. package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.js +22 -0
  140. package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.js.map +1 -0
  141. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.d.ts +16 -0
  142. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.d.ts.map +1 -0
  143. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.js +73 -0
  144. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.js.map +1 -0
  145. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.test.d.ts +2 -0
  146. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.test.d.ts.map +1 -0
  147. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.test.js +37 -0
  148. package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.test.js.map +1 -0
  149. package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts +14 -1
  150. package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts.map +1 -1
  151. package/packages/happy2-server/dist/modules/plugin/packageStore.js +112 -1
  152. package/packages/happy2-server/dist/modules/plugin/packageStore.js.map +1 -1
  153. package/packages/happy2-server/dist/modules/plugin/packageStore.test.d.ts +2 -0
  154. package/packages/happy2-server/dist/modules/plugin/packageStore.test.d.ts.map +1 -0
  155. package/packages/happy2-server/dist/modules/plugin/packageStore.test.js +50 -0
  156. package/packages/happy2-server/dist/modules/plugin/packageStore.test.js.map +1 -0
  157. package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.d.ts +5 -0
  158. package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.d.ts.map +1 -0
  159. package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.js +26 -0
  160. package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.js.map +1 -0
  161. package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.d.ts.map +1 -1
  162. package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js +7 -3
  163. package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js.map +1 -1
  164. package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.d.ts +2 -0
  165. package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.d.ts.map +1 -0
  166. package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.js +44 -0
  167. package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.js.map +1 -0
  168. package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts +4 -2
  169. package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts.map +1 -1
  170. package/packages/happy2-server/dist/modules/plugin/pluginInstall.js +21 -4
  171. package/packages/happy2-server/dist/modules/plugin/pluginInstall.js.map +1 -1
  172. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.d.ts +7 -0
  173. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.d.ts.map +1 -0
  174. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.js +18 -0
  175. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.js.map +1 -0
  176. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.d.ts +13 -0
  177. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.d.ts.map +1 -0
  178. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.js +35 -0
  179. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.js.map +1 -0
  180. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.d.ts.map +1 -1
  181. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js +8 -2
  182. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js.map +1 -1
  183. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.d.ts +6 -0
  184. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.d.ts.map +1 -0
  185. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.js +17 -0
  186. package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.js.map +1 -0
  187. package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.d.ts +18 -0
  188. package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.d.ts.map +1 -0
  189. package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.js +92 -0
  190. package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.js.map +1 -0
  191. package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.d.ts +16 -0
  192. package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.d.ts.map +1 -0
  193. package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.js +71 -0
  194. package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.js.map +1 -0
  195. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.d.ts +21 -0
  196. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.d.ts.map +1 -0
  197. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.js +71 -0
  198. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.js.map +1 -0
  199. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.d.ts +12 -0
  200. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.d.ts.map +1 -0
  201. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.js +56 -0
  202. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.js.map +1 -0
  203. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.d.ts +11 -0
  204. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.d.ts.map +1 -0
  205. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.js +44 -0
  206. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.js.map +1 -0
  207. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.d.ts +10 -0
  208. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.d.ts.map +1 -0
  209. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.js +41 -0
  210. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.js.map +1 -0
  211. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.d.ts +26 -0
  212. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.d.ts.map +1 -0
  213. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.js +78 -0
  214. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.js.map +1 -0
  215. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.d.ts +25 -0
  216. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.d.ts.map +1 -0
  217. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.js +76 -0
  218. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.js.map +1 -0
  219. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.d.ts +11 -0
  220. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.d.ts.map +1 -0
  221. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.js +48 -0
  222. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.js.map +1 -0
  223. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.d.ts +12 -0
  224. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.d.ts.map +1 -0
  225. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.js +42 -0
  226. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.js.map +1 -0
  227. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.d.ts +5 -0
  228. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.d.ts.map +1 -0
  229. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.js +18 -0
  230. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.js.map +1 -0
  231. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.d.ts +4 -0
  232. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.d.ts.map +1 -0
  233. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.js +11 -0
  234. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.js.map +1 -0
  235. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.d.ts +5 -0
  236. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.d.ts.map +1 -0
  237. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.js +75 -0
  238. package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.js.map +1 -0
  239. package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.d.ts +12 -0
  240. package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.d.ts.map +1 -0
  241. package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.js +33 -0
  242. package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.js.map +1 -0
  243. package/packages/happy2-server/dist/modules/plugin/service.d.ts +108 -7
  244. package/packages/happy2-server/dist/modules/plugin/service.d.ts.map +1 -1
  245. package/packages/happy2-server/dist/modules/plugin/service.js +463 -26
  246. package/packages/happy2-server/dist/modules/plugin/service.js.map +1 -1
  247. package/packages/happy2-server/dist/modules/plugin/types.d.ts +75 -9
  248. package/packages/happy2-server/dist/modules/plugin/types.d.ts.map +1 -1
  249. package/packages/happy2-server/dist/modules/plugin/types.js +12 -0
  250. package/packages/happy2-server/dist/modules/plugin/types.js.map +1 -1
  251. package/packages/happy2-server/dist/modules/schema.d.ts +4526 -3290
  252. package/packages/happy2-server/dist/modules/schema.d.ts.map +1 -1
  253. package/packages/happy2-server/dist/modules/schema.js +49 -0
  254. package/packages/happy2-server/dist/modules/schema.js.map +1 -1
  255. package/packages/happy2-server/dist/modules/sync/syncGetDifference.d.ts.map +1 -1
  256. package/packages/happy2-server/dist/modules/sync/syncGetDifference.js +2 -0
  257. package/packages/happy2-server/dist/modules/sync/syncGetDifference.js.map +1 -1
  258. package/packages/happy2-server/dist/routes/collaboration.d.ts.map +1 -1
  259. package/packages/happy2-server/dist/routes/collaboration.js +38 -1
  260. package/packages/happy2-server/dist/routes/collaboration.js.map +1 -1
  261. package/packages/happy2-server/dist/routes/pluginHost.d.ts +4 -1
  262. package/packages/happy2-server/dist/routes/pluginHost.d.ts.map +1 -1
  263. package/packages/happy2-server/dist/routes/pluginHost.js +401 -6
  264. package/packages/happy2-server/dist/routes/pluginHost.js.map +1 -1
  265. package/packages/happy2-server/dist/routes/plugins.d.ts.map +1 -1
  266. package/packages/happy2-server/dist/routes/plugins.js +229 -3
  267. package/packages/happy2-server/dist/routes/plugins.js.map +1 -1
  268. package/packages/happy2-server/dist/server.d.ts +2 -0
  269. package/packages/happy2-server/dist/server.d.ts.map +1 -1
  270. package/packages/happy2-server/dist/server.js +9 -7
  271. package/packages/happy2-server/dist/server.js.map +1 -1
  272. package/packages/happy2-server/dist/web/assets/index-BT_VezYx.js +39 -0
  273. package/packages/happy2-server/dist/web/assets/{index-BaPUPGPe.css → index-Dys3sWv8.css} +1 -1
  274. package/packages/happy2-server/dist/web/index.html +2 -2
  275. package/packages/happy2-server/drizzle/0028_plugin_api_permissions.sql +1 -0
  276. package/packages/happy2-server/drizzle/0029_plugin_management_requests.sql +35 -0
  277. package/packages/happy2-server/drizzle/0030_personal_synced_drafts.sql +11 -0
  278. package/packages/happy2-server/drizzle/0031_agent_image_deactivation.sql +1 -0
  279. package/packages/happy2-server/drizzle/meta/_journal.json +28 -0
  280. package/packages/happy2-server/plugins/README.md +9 -3
  281. package/packages/happy2-server/plugins/chat-management/plugin.json +3 -3
  282. package/packages/happy2-server/plugins/chat-management/server.mjs +184 -17
  283. package/packages/happy2-server/plugins/environment-management/container/Dockerfile +6 -0
  284. package/packages/happy2-server/plugins/environment-management/plugin.json +17 -0
  285. package/packages/happy2-server/plugins/environment-management/plugin.png +0 -0
  286. package/packages/happy2-server/plugins/environment-management/server.mjs +234 -0
  287. package/packages/happy2-server/plugins/environment-management/skills/happy2-environment-management/SKILL.md +41 -0
  288. package/packages/happy2-server/plugins/plugin-developer/container/Dockerfile +6 -0
  289. package/packages/happy2-server/plugins/plugin-developer/plugin.json +17 -0
  290. package/packages/happy2-server/plugins/plugin-developer/plugin.png +0 -0
  291. package/packages/happy2-server/plugins/plugin-developer/server.mjs +155 -0
  292. package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/SKILL.md +59 -0
  293. package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/host-api.md +88 -0
  294. package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/installing.md +86 -0
  295. package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/package-format.md +140 -0
  296. package/packages/happy2-server/dist/modules/agent/agentChatGetIdBySession.d.ts +0 -7
  297. package/packages/happy2-server/dist/modules/agent/agentChatGetIdBySession.d.ts.map +0 -1
  298. package/packages/happy2-server/dist/modules/agent/agentChatGetIdBySession.js +0 -15
  299. package/packages/happy2-server/dist/modules/agent/agentChatGetIdBySession.js.map +0 -1
  300. package/packages/happy2-server/dist/web/assets/index-BnhFxR3U.js +0 -39
@@ -13,8 +13,8 @@
13
13
  background: #131217;
14
14
  }
15
15
  </style>
16
- <script type="module" crossorigin src="/assets/index-BnhFxR3U.js"></script>
17
- <link rel="stylesheet" crossorigin href="/assets/index-BaPUPGPe.css">
16
+ <script type="module" crossorigin src="/assets/index-BT_VezYx.js"></script>
17
+ <link rel="stylesheet" crossorigin href="/assets/index-Dys3sWv8.css">
18
18
  </head>
19
19
  <body>
20
20
  <div id="root"></div>
@@ -0,0 +1 @@
1
+ ALTER TABLE `plugin_installations` ADD `granted_permissions_json` text DEFAULT '[]' NOT NULL;
@@ -0,0 +1,35 @@
1
+ CREATE TABLE `plugin_management_requests` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `action` text NOT NULL,
4
+ `status` text DEFAULT 'pending' NOT NULL,
5
+ `chat_id` text NOT NULL,
6
+ `actor_user_id` text,
7
+ `agent_user_id` text,
8
+ `requester_installation_id` text,
9
+ `call_id` text NOT NULL,
10
+ `display_name` text NOT NULL,
11
+ `short_name` text NOT NULL,
12
+ `description` text NOT NULL,
13
+ `reason` text,
14
+ `source_kind` text,
15
+ `source_reference` text,
16
+ `package_digest` text,
17
+ `package_directory` text,
18
+ `target_installation_id` text,
19
+ `installation_id` text,
20
+ `resolved_by_user_id` text,
21
+ `resolved_at` text,
22
+ `last_error` text,
23
+ `sync_sequence` integer DEFAULT 0 NOT NULL,
24
+ `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
25
+ `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
26
+ FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE cascade,
27
+ FOREIGN KEY (`actor_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null,
28
+ FOREIGN KEY (`agent_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null,
29
+ FOREIGN KEY (`requester_installation_id`) REFERENCES `plugin_installations`(`id`) ON UPDATE no action ON DELETE set null,
30
+ FOREIGN KEY (`resolved_by_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
31
+ );
32
+ --> statement-breakpoint
33
+ CREATE INDEX `plugin_management_requests_chat_index` ON `plugin_management_requests` (`chat_id`,`created_at`);
34
+ --> statement-breakpoint
35
+ CREATE UNIQUE INDEX `plugin_management_requests_call_unique` ON `plugin_management_requests` (`requester_installation_id`,`call_id`,`action`);
@@ -0,0 +1,11 @@
1
+ CREATE TABLE `drafts` (
2
+ `user_id` text NOT NULL,
3
+ `chat_id` text NOT NULL,
4
+ `text` text DEFAULT '' NOT NULL,
5
+ `sync_sequence` integer DEFAULT 0 NOT NULL,
6
+ `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
7
+ `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
8
+ PRIMARY KEY(`user_id`, `chat_id`),
9
+ FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
10
+ FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE cascade
11
+ );
@@ -0,0 +1 @@
1
+ ALTER TABLE `agent_images` ADD `deleted_at` text;
@@ -197,6 +197,34 @@
197
197
  "when": 1784427000000,
198
198
  "tag": "0027_chat_agent_effort",
199
199
  "breakpoints": true
200
+ },
201
+ {
202
+ "idx": 28,
203
+ "version": "6",
204
+ "when": 1784430000000,
205
+ "tag": "0028_plugin_api_permissions",
206
+ "breakpoints": true
207
+ },
208
+ {
209
+ "idx": 29,
210
+ "version": "6",
211
+ "when": 1784433600000,
212
+ "tag": "0029_plugin_management_requests",
213
+ "breakpoints": true
214
+ },
215
+ {
216
+ "idx": 30,
217
+ "version": "6",
218
+ "when": 1784437200000,
219
+ "tag": "0030_personal_synced_drafts",
220
+ "breakpoints": true
221
+ },
222
+ {
223
+ "idx": 31,
224
+ "version": "6",
225
+ "when": 1784444400000,
226
+ "tag": "0031_agent_image_deactivation",
227
+ "breakpoints": true
200
228
  }
201
229
  ]
202
230
  }
@@ -4,6 +4,12 @@ Each child directory is one immutable, built-in plugin package. See
4
4
  [`../PLUGINS.md`](../PLUGINS.md) for the manifest and package contract.
5
5
 
6
6
  `hello` is the minimal built-in example with both a skill and a bundled stdio MCP
7
- tool. `chat-management` demonstrates a chat-scoped Plugin API capability without
8
- accepting a chat identifier from tool arguments. Product plugins should be added
9
- here as separate, reviewable changes.
7
+ tool. `chat-management` demonstrates installation-bound chat and referenced-user
8
+ capabilities: it updates the current chat, manages channel membership, and creates
9
+ private channels with either an informational opening message or an agent-triggering
10
+ prompt. `environment-management` lets agents inspect, build, select, and safely
11
+ deactivate Dockerfile-backed agent environments while retaining their manifests.
12
+ `plugin-developer` provides Happy2 plugin authoring/install documentation
13
+ and chat-scoped MCP tools that request administrator approval for linked install
14
+ or uninstall actions. Product plugins should be added here as separate,
15
+ reviewable changes.
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "displayName": "Chat Management",
5
5
  "shortName": "chat-management",
6
- "description": "Lets an agent update the title and description of its current chat.",
6
+ "description": "Lets an agent update its current chat, manage channel members, and create new channels with an initial people or agent message.",
7
7
  "variables": [],
8
8
  "container": {
9
9
  "dockerfile": "container/Dockerfile",
10
- "permissions": ["chats:update"]
10
+ "permissions": ["chats:update", "channels:manage"]
11
11
  },
12
12
  "mcp": {
13
13
  "type": "stdio",
@@ -1,6 +1,8 @@
1
1
  import { createInterface } from "node:readline";
2
+ import { randomUUID } from "node:crypto";
2
3
 
3
4
  const CHAT_META_KEY = "happy2/chat";
5
+ const USERS_META_KEY = "happy2/users";
4
6
  const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
5
7
 
6
8
  for await (const line of lines) {
@@ -32,7 +34,7 @@ async function handle(request) {
32
34
  result: {
33
35
  protocolVersion: request.params?.protocolVersion ?? "2025-06-18",
34
36
  capabilities: { tools: {} },
35
- serverInfo: { name: "happy2-chat-management", version: "1.0.0" },
37
+ serverInfo: { name: "happy2-chat-management", version: "1.1.0" },
36
38
  },
37
39
  };
38
40
  }
@@ -66,48 +68,213 @@ async function handle(request) {
66
68
  additionalProperties: false,
67
69
  },
68
70
  },
71
+ {
72
+ name: "channel_members_update",
73
+ title: "Add or remove channel members",
74
+ description:
75
+ "Adds or removes users from the current channel. This never changes direct-message membership. Identify users by the @username shown in the triggering conversation; only users supplied in Happy's signed metadata are available.",
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: {
79
+ addUsers: {
80
+ type: "array",
81
+ maxItems: 100,
82
+ uniqueItems: true,
83
+ items: { type: "string", minLength: 1 },
84
+ description: "Usernames (with or without @) to add.",
85
+ },
86
+ removeUsers: {
87
+ type: "array",
88
+ maxItems: 100,
89
+ uniqueItems: true,
90
+ items: { type: "string", minLength: 1 },
91
+ description: "Usernames (with or without @) to remove.",
92
+ },
93
+ },
94
+ anyOf: [{ required: ["addUsers"] }, { required: ["removeUsers"] }],
95
+ additionalProperties: false,
96
+ },
97
+ },
98
+ {
99
+ name: "channel_create",
100
+ title: "Create a channel",
101
+ description:
102
+ "Creates a private channel owned by the user who triggered this turn, adds selected referenced users, and optionally posts an initial message. An agents message starts the current agent working; a people message only shares context and does not trigger inference.",
103
+ inputSchema: {
104
+ type: "object",
105
+ properties: {
106
+ name: {
107
+ type: "string",
108
+ minLength: 1,
109
+ maxLength: 100,
110
+ description: "Channel title.",
111
+ },
112
+ description: {
113
+ type: "string",
114
+ minLength: 1,
115
+ maxLength: 500,
116
+ description: "Optional channel description.",
117
+ },
118
+ members: {
119
+ type: "array",
120
+ maxItems: 100,
121
+ uniqueItems: true,
122
+ items: { type: "string", minLength: 1 },
123
+ description:
124
+ "Referenced usernames (with or without @) to add. The triggering user is already the owner.",
125
+ },
126
+ initialMessage: {
127
+ type: "object",
128
+ properties: {
129
+ text: {
130
+ type: "string",
131
+ minLength: 1,
132
+ maxLength: 40000,
133
+ description:
134
+ "A copied or rephrased opening prompt or informational message.",
135
+ },
136
+ audience: {
137
+ type: "string",
138
+ enum: ["agents", "people"],
139
+ description:
140
+ "agents starts the current agent; people posts without inference.",
141
+ },
142
+ },
143
+ required: ["text", "audience"],
144
+ additionalProperties: false,
145
+ },
146
+ },
147
+ required: ["name"],
148
+ additionalProperties: false,
149
+ },
150
+ },
69
151
  ],
70
152
  },
71
153
  };
72
154
  }
73
155
  if (request.method === "tools/call" && request.params?.name === "chat_update")
74
156
  return { result: await updateChat(request.params) };
157
+ if (request.method === "tools/call" && request.params?.name === "channel_members_update")
158
+ return { result: await updateChannelMembers(request.params) };
159
+ if (request.method === "tools/call" && request.params?.name === "channel_create")
160
+ return { result: await createChannel(request.params) };
75
161
  return {
76
162
  error: { code: -32601, message: `Method not found: ${String(request.method)}` },
77
163
  };
78
164
  }
79
165
 
80
166
  async function updateChat(params) {
167
+ const { chat } = capabilityContext(params);
168
+ const input = params.arguments;
169
+ if (!input || typeof input !== "object" || Array.isArray(input))
170
+ throw new Error("A chat update is required.");
171
+ const result = await callHost("/chats/updateChat", chat.token, input);
172
+ return {
173
+ content: [
174
+ {
175
+ type: "text",
176
+ text: `Updated chat ${result.chat.id}.`,
177
+ },
178
+ ],
179
+ structuredContent: { chat: result.chat },
180
+ };
181
+ }
182
+
183
+ async function updateChannelMembers(params) {
184
+ const { chat, users } = capabilityContext(params);
185
+ const input = params.arguments;
186
+ if (!input || typeof input !== "object" || Array.isArray(input))
187
+ throw new Error("A channel membership update is required.");
188
+ const add = resolveUsers(input.addUsers ?? [], users, "addUsers");
189
+ const remove = resolveUsers(input.removeUsers ?? [], users, "removeUsers");
190
+ if (!add.length && !remove.length)
191
+ throw new Error("At least one user must be added or removed.");
192
+ const result = await callHost("/channels/updateMembers", chat.token, { add, remove });
193
+ return {
194
+ content: [
195
+ {
196
+ type: "text",
197
+ text: `Updated members of channel ${result.chatId}: added ${result.addedUserIds.length}, removed ${result.removedUserIds.length}.`,
198
+ },
199
+ ],
200
+ structuredContent: result,
201
+ };
202
+ }
203
+
204
+ async function createChannel(params) {
205
+ const { chat, users } = capabilityContext(params);
206
+ const input = params.arguments;
207
+ if (!input || typeof input !== "object" || Array.isArray(input))
208
+ throw new Error("A channel definition is required.");
209
+ const members = resolveUsers(input.members ?? [], users, "members");
210
+ const result = await callHost("/channels/createChannel", chat.token, {
211
+ ...input,
212
+ members,
213
+ idempotencyKey: randomUUID(),
214
+ });
215
+ return {
216
+ content: [
217
+ {
218
+ type: "text",
219
+ text: `Created channel ${result.chat.id}${result.initialMessage ? " and posted its initial message" : ""}.`,
220
+ },
221
+ ],
222
+ structuredContent: result,
223
+ };
224
+ }
225
+
226
+ function capabilityContext(params) {
81
227
  const chat = params?._meta?.[CHAT_META_KEY];
82
228
  if (!chat || typeof chat.id !== "string" || typeof chat.token !== "string")
83
229
  throw new Error("This tool must be called from an active Happy chat.");
230
+ const users = params?._meta?.[USERS_META_KEY];
231
+ if (!Array.isArray(users)) throw new Error("Happy did not provide referenced-user metadata.");
232
+ return { chat, users };
233
+ }
234
+
235
+ function resolveUsers(selectors, users, name) {
236
+ if (!Array.isArray(selectors)) throw new Error(`${name} must be an array.`);
237
+ const resolved = selectors.map((selector) => {
238
+ if (typeof selector !== "string" || !selector.trim())
239
+ throw new Error(`${name} must contain usernames.`);
240
+ const normalized = selector.trim().replace(/^@/, "").toLowerCase();
241
+ const matches = users.filter(
242
+ (user) =>
243
+ user &&
244
+ typeof user === "object" &&
245
+ (user.id === selector.trim() ||
246
+ (typeof user.username === "string" &&
247
+ user.username.toLowerCase() === normalized)),
248
+ );
249
+ if (matches.length !== 1)
250
+ throw new Error(`User ${selector} is not uniquely available in this turn.`);
251
+ const user = matches[0];
252
+ if (typeof user.id !== "string" || typeof user.token !== "string")
253
+ throw new Error(`User ${selector} has malformed capability metadata.`);
254
+ return { id: user.id, token: user.token };
255
+ });
256
+ if (new Set(resolved.map(({ id }) => id)).size !== resolved.length)
257
+ throw new Error(`${name} contains a duplicate user.`);
258
+ return resolved;
259
+ }
260
+
261
+ async function callHost(path, chatToken, body) {
84
262
  const apiUrl = process.env.HAPPY2_PLUGIN_API_URL;
85
263
  const runtimeToken = process.env.HAPPY2_PLUGIN_API_TOKEN;
86
264
  if (!apiUrl || !runtimeToken) throw new Error("The Happy Plugin API is unavailable.");
87
- const input = params.arguments;
88
- if (!input || typeof input !== "object" || Array.isArray(input))
89
- throw new Error("A chat update is required.");
90
- const response = await fetch(`${apiUrl}/chats/updateChat`, {
265
+ const response = await fetch(`${apiUrl}${path}`, {
91
266
  method: "POST",
92
267
  headers: {
93
268
  authorization: `Bearer ${runtimeToken}`,
94
269
  "content-type": "application/json",
95
- "x-happy2-chat-token": chat.token,
270
+ "x-happy2-chat-token": chatToken,
96
271
  },
97
- body: JSON.stringify(input),
272
+ body: JSON.stringify(body),
98
273
  });
99
274
  const result = await response.json().catch(() => undefined);
100
275
  if (!response.ok)
101
276
  throw new Error(
102
- typeof result?.message === "string" ? result.message : "The chat could not be updated.",
277
+ typeof result?.message === "string" ? result.message : "The chat action failed.",
103
278
  );
104
- return {
105
- content: [
106
- {
107
- type: "text",
108
- text: `Updated chat ${result.chat.id}.`,
109
- },
110
- ],
111
- structuredContent: { chat: result.chat },
112
- };
279
+ return result;
113
280
  }
@@ -0,0 +1,6 @@
1
+ FROM node:22-alpine
2
+
3
+ WORKDIR /plugin
4
+ COPY server.mjs /plugin/server.mjs
5
+
6
+ CMD ["sleep", "infinity"]
@@ -0,0 +1,17 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "version": "1.0.0",
4
+ "displayName": "Environment Management",
5
+ "shortName": "environment-management",
6
+ "description": "Lets an agent inspect, create, select, and safely deactivate Happy agent environments.",
7
+ "variables": [],
8
+ "container": {
9
+ "dockerfile": "container/Dockerfile",
10
+ "permissions": ["environments:read", "environments:manage", "environments:deactivate"]
11
+ },
12
+ "mcp": {
13
+ "type": "stdio",
14
+ "command": "node",
15
+ "args": ["/plugin/server.mjs"]
16
+ }
17
+ }
@@ -0,0 +1,234 @@
1
+ import { createInterface } from "node:readline";
2
+
3
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
4
+
5
+ for await (const line of lines) {
6
+ if (!line.trim()) continue;
7
+ let request;
8
+ try {
9
+ request = JSON.parse(line);
10
+ } catch {
11
+ continue;
12
+ }
13
+ if (request.id === undefined) continue;
14
+ const response = await handle(request).catch((error) => ({
15
+ result: {
16
+ isError: true,
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text:
21
+ error instanceof Error
22
+ ? error.message
23
+ : "The environment operation failed.",
24
+ },
25
+ ],
26
+ },
27
+ }));
28
+ process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id: request.id, ...response })}\n`);
29
+ }
30
+
31
+ async function handle(request) {
32
+ if (request.method === "initialize") {
33
+ return {
34
+ result: {
35
+ protocolVersion: request.params?.protocolVersion ?? "2025-06-18",
36
+ capabilities: { tools: {} },
37
+ serverInfo: { name: "happy2-environment-management", version: "1.0.0" },
38
+ },
39
+ };
40
+ }
41
+ if (request.method === "ping") return { result: {} };
42
+ if (request.method === "tools/list") return { result: { tools: toolDefinitions() } };
43
+ if (request.method !== "tools/call")
44
+ return {
45
+ error: { code: -32601, message: `Method not found: ${String(request.method)}` },
46
+ };
47
+ const input = request.params?.arguments ?? {};
48
+ switch (request.params?.name) {
49
+ case "happy2_environments_list":
50
+ return { result: await listEnvironments() };
51
+ case "happy2_environment_get_dockerfile":
52
+ return { result: await getDockerfile(input) };
53
+ case "happy2_environment_create":
54
+ return { result: await createEnvironment(input) };
55
+ case "happy2_environment_set_default":
56
+ return { result: await setDefaultEnvironment(input) };
57
+ case "happy2_environment_deactivate":
58
+ return { result: await deactivateEnvironment(input) };
59
+ default:
60
+ return {
61
+ error: {
62
+ code: -32601,
63
+ message: `Tool not found: ${String(request.params?.name)}`,
64
+ },
65
+ };
66
+ }
67
+ }
68
+
69
+ function toolDefinitions() {
70
+ const environmentId = {
71
+ type: "string",
72
+ minLength: 1,
73
+ maxLength: 128,
74
+ description: "The environment ID returned by happy2_environments_list or creation.",
75
+ };
76
+ return [
77
+ {
78
+ name: "happy2_environments_list",
79
+ title: "List agent environments",
80
+ description:
81
+ "Lists active and inactive Happy agent environments, their build status, and the current default environment.",
82
+ inputSchema: {
83
+ type: "object",
84
+ properties: {},
85
+ additionalProperties: false,
86
+ },
87
+ },
88
+ {
89
+ name: "happy2_environment_get_dockerfile",
90
+ title: "Read an environment Dockerfile",
91
+ description:
92
+ "Returns the retained immutable Dockerfile and active state for one Happy agent environment.",
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: { environmentId },
96
+ required: ["environmentId"],
97
+ additionalProperties: false,
98
+ },
99
+ },
100
+ {
101
+ name: "happy2_environment_create",
102
+ title: "Create or reactivate an agent environment",
103
+ description:
104
+ "Creates an immutable Happy agent environment and queues its Docker image build. The exact definition of an inactive environment is reactivated under the same ID and rebuilt. Creation returns before the build is ready.",
105
+ inputSchema: {
106
+ type: "object",
107
+ properties: {
108
+ name: {
109
+ type: "string",
110
+ minLength: 1,
111
+ maxLength: 100,
112
+ description: "A concise human-readable environment name.",
113
+ },
114
+ dockerfile: {
115
+ type: "string",
116
+ minLength: 1,
117
+ maxLength: 262144,
118
+ description: "The complete Dockerfile used to build the environment.",
119
+ },
120
+ },
121
+ required: ["name", "dockerfile"],
122
+ additionalProperties: false,
123
+ },
124
+ },
125
+ {
126
+ name: "happy2_environment_set_default",
127
+ title: "Set the default agent environment",
128
+ description:
129
+ "Selects a ready environment as the default for agents created in the future. Existing agents keep their assigned environment.",
130
+ inputSchema: {
131
+ type: "object",
132
+ properties: { environmentId },
133
+ required: ["environmentId"],
134
+ additionalProperties: false,
135
+ },
136
+ },
137
+ {
138
+ name: "happy2_environment_deactivate",
139
+ title: "Deactivate an unused agent environment",
140
+ description:
141
+ "Deactivates a custom environment only when it is unused. Happy permanently retains its manifest and Dockerfile so the same definition can be reactivated and rebuilt later.",
142
+ inputSchema: {
143
+ type: "object",
144
+ properties: { environmentId },
145
+ required: ["environmentId"],
146
+ additionalProperties: false,
147
+ },
148
+ },
149
+ ];
150
+ }
151
+
152
+ async function listEnvironments() {
153
+ const result = await callHost("/environments");
154
+ return toolResult(
155
+ `Found ${result.environments.length} agent environment${result.environments.length === 1 ? "" : "s"}.`,
156
+ result,
157
+ );
158
+ }
159
+
160
+ async function getDockerfile(input) {
161
+ const environmentId = requiredString(input, "environmentId");
162
+ const result = await callHost(`/environments/${encodeURIComponent(environmentId)}/dockerfile`);
163
+ return toolResult(`Read the Dockerfile for ${result.environment.name}.`, result);
164
+ }
165
+
166
+ async function createEnvironment(input) {
167
+ const name = requiredString(input, "name");
168
+ const dockerfile = requiredString(input, "dockerfile", false);
169
+ const result = await callHost("/environments/createEnvironment", {
170
+ method: "POST",
171
+ body: { name, dockerfile },
172
+ });
173
+ return toolResult(
174
+ `Environment ${result.environment.name} is active; its image build is ${result.environment.status}.`,
175
+ result,
176
+ );
177
+ }
178
+
179
+ async function setDefaultEnvironment(input) {
180
+ const environmentId = requiredString(input, "environmentId");
181
+ const result = await callHost(
182
+ `/environments/${encodeURIComponent(environmentId)}/setDefaultEnvironment`,
183
+ { method: "POST", body: {} },
184
+ );
185
+ return toolResult(`Set ${result.environment.name} as the default environment.`, result);
186
+ }
187
+
188
+ async function deactivateEnvironment(input) {
189
+ const environmentId = requiredString(input, "environmentId");
190
+ const result = await callHost(
191
+ `/environments/${encodeURIComponent(environmentId)}/deactivateEnvironment`,
192
+ { method: "POST", body: {} },
193
+ );
194
+ return toolResult(`Deactivated environment ${result.environmentId}.`, result);
195
+ }
196
+
197
+ function requiredString(input, name, trim = true) {
198
+ if (!input || typeof input !== "object" || Array.isArray(input))
199
+ throw new Error("Tool arguments must be an object.");
200
+ const value = input[name];
201
+ if (typeof value !== "string" || !value.trim())
202
+ throw new Error(`${name} must be a non-empty string.`);
203
+ return trim ? value.trim() : value;
204
+ }
205
+
206
+ function toolResult(text, structuredContent) {
207
+ return {
208
+ content: [{ type: "text", text }],
209
+ structuredContent,
210
+ };
211
+ }
212
+
213
+ async function callHost(path, options = {}) {
214
+ const apiUrl = process.env.HAPPY2_PLUGIN_API_URL;
215
+ const token = process.env.HAPPY2_PLUGIN_API_TOKEN;
216
+ if (!apiUrl || !token) throw new Error("Happy did not provide plugin host credentials.");
217
+ const response = await fetch(new URL(path, `${apiUrl}/`), {
218
+ method: options.method ?? "GET",
219
+ headers: {
220
+ authorization: `Bearer ${token}`,
221
+ ...(options.body === undefined ? {} : { "content-type": "application/json" }),
222
+ },
223
+ ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
224
+ });
225
+ const payload = await response.json().catch(() => undefined);
226
+ if (!response.ok) {
227
+ const message =
228
+ payload && typeof payload.message === "string"
229
+ ? payload.message
230
+ : `Happy environment API returned HTTP ${response.status}.`;
231
+ throw new Error(message);
232
+ }
233
+ return payload;
234
+ }