agents.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. Copyright 2026 LocoStack.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package locostack
  14. import (
  15. "github.com/LocoStack/loco-operator/api/v1alpha1"
  16. corev1 "k8s.io/api/core/v1"
  17. "k8s.io/utils/ptr"
  18. )
  19. var LocoAgentsTemplate = v1alpha1.Template{
  20. Name: "loco-agents",
  21. Spec: v1alpha1.TemplateSpec{
  22. Runtime: v1alpha1.RuntimeSpec{
  23. Name: "loco-simple-agent",
  24. Image: "locostack.com/loco-simple-agent:latest",
  25. Env: []corev1.EnvVar{
  26. {
  27. Name: "PORT",
  28. Value: "$(spec.runtime.port)",
  29. },
  30. },
  31. VolumeMounts: []corev1.VolumeMount{
  32. {
  33. Name: "config",
  34. MountPath: "/etc/locostack",
  35. ReadOnly: true,
  36. },
  37. {
  38. Name: "mcp-config",
  39. MountPath: "/etc/mcp",
  40. ReadOnly: true,
  41. },
  42. },
  43. Port: 8080,
  44. },
  45. SecurityContext: &corev1.PodSecurityContext{
  46. RunAsNonRoot: ptr.To(true),
  47. RunAsUser: ptr.To[int64](10001),
  48. RunAsGroup: ptr.To[int64](10001),
  49. FSGroup: ptr.To[int64](10001),
  50. SeccompProfile: &corev1.SeccompProfile{
  51. Type: corev1.SeccompProfileTypeRuntimeDefault,
  52. },
  53. SupplementalGroups: []int64{},
  54. },
  55. Volumes: []corev1.Volume{
  56. {
  57. Name: "config",
  58. VolumeSource: corev1.VolumeSource{
  59. Secret: &corev1.SecretVolumeSource{
  60. SecretName: "$(metadata.name)-config",
  61. },
  62. },
  63. },
  64. {
  65. Name: "mcp-config",
  66. VolumeSource: corev1.VolumeSource{
  67. Secret: &corev1.SecretVolumeSource{
  68. SecretName: "$(metadata.name)-mcp-config",
  69. },
  70. },
  71. },
  72. },
  73. },
  74. }
  75. // LambdagentTemplate implements the same LocoStack agent contract as
  76. // LocoAgentsTemplate, but backed by the lambdagent agent runtime image instead of
  77. // the TypeScript reference implementation. It exists as a separate template so it
  78. // can be selected independently in the UI; the component reconciler treats it
  79. // exactly like "loco-agents" (see ComponentReconciler.getComponentReconciler).
  80. var LambdagentTemplate = v1alpha1.Template{
  81. Name: "lambdagent",
  82. Spec: v1alpha1.TemplateSpec{
  83. Runtime: v1alpha1.RuntimeSpec{
  84. Name: "lambdagent",
  85. Image: "lambdagent-locostack:1.4.2",
  86. Env: []corev1.EnvVar{
  87. {
  88. Name: "PORT",
  89. Value: "$(spec.runtime.port)",
  90. },
  91. {
  92. Name: "AGENT_SERVICE_AGENT_ID",
  93. Value: "locostack:$(metadata.namespace):$(agentName)",
  94. },
  95. {
  96. Name: "AGENT_SERVICE_AGENT_UID",
  97. Value: "$(agentUid)",
  98. },
  99. {
  100. Name: "AGENT_SERVICE_SERVICE_INSTANCE_ID",
  101. ValueFrom: &corev1.EnvVarSource{
  102. FieldRef: &corev1.ObjectFieldSelector{
  103. FieldPath: "metadata.name",
  104. },
  105. },
  106. },
  107. {
  108. Name: "AGENT_SERVICE_AGENT_CONFIG",
  109. Value: "/etc/locostack/agent.yaml",
  110. },
  111. {
  112. Name: "AGENT_SERVICE_MCP_CONFIG",
  113. Value: "/etc/mcp/mcp.json",
  114. },
  115. {
  116. Name: "AGENT_SERVICE_DATA_DIR",
  117. Value: "/data/agent-service",
  118. },
  119. {
  120. Name: "AGENT_SERVICE_PATH_POLICY",
  121. Value: "managed",
  122. },
  123. {
  124. Name: "AGENT_SERVICE_ALLOW_WORKSPACE_OVERRIDE",
  125. Value: "false",
  126. },
  127. },
  128. VolumeMounts: []corev1.VolumeMount{
  129. {
  130. Name: "config",
  131. MountPath: "/etc/locostack",
  132. ReadOnly: true,
  133. },
  134. {
  135. Name: "mcp-config",
  136. MountPath: "/etc/mcp",
  137. ReadOnly: true,
  138. },
  139. {
  140. Name: "workspace",
  141. MountPath: "/data/agent-service",
  142. },
  143. },
  144. Port: 8080,
  145. },
  146. SecurityContext: &corev1.PodSecurityContext{
  147. RunAsNonRoot: ptr.To(true),
  148. RunAsUser: ptr.To[int64](10001),
  149. RunAsGroup: ptr.To[int64](10001),
  150. FSGroup: ptr.To[int64](10001),
  151. SeccompProfile: &corev1.SeccompProfile{
  152. Type: corev1.SeccompProfileTypeRuntimeDefault,
  153. },
  154. SupplementalGroups: []int64{},
  155. },
  156. Volumes: []corev1.Volume{
  157. {
  158. Name: "config",
  159. VolumeSource: corev1.VolumeSource{
  160. Secret: &corev1.SecretVolumeSource{
  161. SecretName: "$(metadata.name)-config",
  162. },
  163. },
  164. },
  165. {
  166. Name: "mcp-config",
  167. VolumeSource: corev1.VolumeSource{
  168. Secret: &corev1.SecretVolumeSource{
  169. SecretName: "$(metadata.name)-mcp-config",
  170. },
  171. },
  172. },
  173. {
  174. Name: "workspace",
  175. VolumeSource: corev1.VolumeSource{
  176. PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
  177. ClaimName: "$(metadata.name)-data",
  178. },
  179. },
  180. },
  181. },
  182. },
  183. }