Add agent runtime infrastructure
- AgentEntities.xml: Entity extensions for agent tasks - AgentServices.xml: Agent runner, client, and queue services - AgentData.xml: Scheduled job, user, and AI config seed data
Showing
3 changed files
with
147 additions
and
0 deletions
data/AgentData.xml
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <entity-facade-xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 3 | xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd" type="seed"> | ||
| 4 | |||
| 5 | <!-- ========================================================= --> | ||
| 6 | <!-- Agent Runtime Scheduled Job --> | ||
| 7 | <!-- ========================================================= --> | ||
| 8 | |||
| 9 | <moqui.service.ScheduledJob | ||
| 10 | jobName="AgentQueuePoller" | ||
| 11 | description="Polls Agent Queue and processes pending tasks" | ||
| 12 | serviceName="AgentServices.poll#AgentQueue" | ||
| 13 | cronExpression="0/30 * * * * ?" | ||
| 14 | runAsUser="ADMIN" | ||
| 15 | paused="N"/> | ||
| 16 | |||
| 17 | <!-- ========================================================= --> | ||
| 18 | <!-- Agent User Account (for authentication) --> | ||
| 19 | <!-- ========================================================= --> | ||
| 20 | |||
| 21 | <moqui.security.UserAccount | ||
| 22 | userId="AGENT_CLAUDE" | ||
| 23 | username="agent-claude" | ||
| 24 | currentPassword="16ac58bbfa332c1c55bd98b53e60720bfa90d394" | ||
| 25 | passwordHashType="SHA" | ||
| 26 | enabled="Y" | ||
| 27 | description="Agent user for AI runtime"/> | ||
| 28 | |||
| 29 | <moqui.security.UserGroup userGroupId="AgentUsers" description="AI Agent Users"/> | ||
| 30 | <moqui.security.UserGroupMember userGroupId="AgentUsers" userId="AGENT_CLAUDE" fromDate="2026-02-04 00:00:00.000"/> | ||
| 31 | |||
| 32 | <!-- Agent users have permission to execute the delegation service --> | ||
| 33 | <moqui.security.ArtifactGroup artifactGroupId="AgentDelegationServices" description="Agent Tool Delegation Services"/> | ||
| 34 | <moqui.security.ArtifactGroupMember artifactGroupId="AgentDelegationServices" artifactName="AgentServices.call#McpToolWithDelegation" artifactTypeEnumId="AT_SERVICE"/> | ||
| 35 | <moqui.security.ArtifactAuthz userGroupId="AgentUsers" artifactGroupId="AgentDelegationServices" authzTypeEnumId="AUTHZT_ALLOW" authzActionEnumId="AUTHZA_ALL"/> | ||
| 36 | |||
| 37 | <!-- ========================================================= --> | ||
| 38 | <!-- Sample AI Configuration (for testing) --> | ||
| 39 | <!-- ========================================================= --> | ||
| 40 | |||
| 41 | <!-- Using localhost:11434 for Ollama (if available) --> | ||
| 42 | <!-- Or configure for your VLLM/OpenAI endpoint --> | ||
| 43 | <moqui.mcp.agent.ProductStoreAiConfig | ||
| 44 | productStoreId="POPCOMMERCE_RETAIL" | ||
| 45 | aiConfigId="DEFAULT" | ||
| 46 | serviceTypeEnumId="AistOllama" | ||
| 47 | description="Default AI Config for Testing (Ollama)" | ||
| 48 | endpointUrl="http://localhost:11434/v1" | ||
| 49 | modelName="llama3.2:3b" | ||
| 50 | temperature="0.7" | ||
| 51 | maxTokens="2048" | ||
| 52 | /> | ||
| 53 | |||
| 54 | </entity-facade-xml> |
entity/AgentEntities.xml
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 3 | xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-3.xsd"> | ||
| 4 | |||
| 5 | <!-- ========================================================= --> | ||
| 6 | <!-- System Message Extensions for Agent Tasks --> | ||
| 7 | <!-- ========================================================= --> | ||
| 8 | |||
| 9 | <extend-entity entity-name="SystemMessage" package="moqui.service.message"> | ||
| 10 | <field name="requestedByPartyId" type="id"> | ||
| 11 | <description>The human user (Party) who requested this agent task.</description> | ||
| 12 | </field> | ||
| 13 | <field name="effectiveUserId" type="id"> | ||
| 14 | <description>The UserAccount ID to impersonate during execution (RBAC context).</description> | ||
| 15 | </field> | ||
| 16 | <field name="productStoreId" type="id"> | ||
| 17 | <description>The context ProductStore for this task (determines AI config).</description> | ||
| 18 | </field> | ||
| 19 | <field name="aiConfigId" type="id"> | ||
| 20 | <description>Specific AI configuration used for this task.</description> | ||
| 21 | </field> | ||
| 22 | |||
| 23 | <relationship type="one" title="RequestedBy" related="mantle.party.Party"> | ||
| 24 | <key-map field-name="requestedByPartyId" related="partyId"/> | ||
| 25 | </relationship> | ||
| 26 | <!-- Note: effectiveUserId links to UserAccount, but we don't force FK to allow system users --> | ||
| 27 | <relationship type="one" related="mantle.product.store.ProductStore"> | ||
| 28 | <key-map field-name="productStoreId"/> | ||
| 29 | </relationship> | ||
| 30 | <relationship type="one" related="moqui.mcp.agent.ProductStoreAiConfig"> | ||
| 31 | <key-map field-name="productStoreId"/> | ||
| 32 | <key-map field-name="aiConfigId"/> | ||
| 33 | </relationship> | ||
| 34 | </extend-entity> | ||
| 35 | |||
| 36 | <!-- ========================================================= --> | ||
| 37 | <!-- AI Gateway Configuration (Per Store) --> | ||
| 38 | <!-- ========================================================= --> | ||
| 39 | |||
| 40 | <entity entity-name="ProductStoreAiConfig" package="moqui.mcp.agent"> | ||
| 41 | <description>Configures AI Service Providers (OpenAI, VLLM, etc.) per Product Store.</description> | ||
| 42 | |||
| 43 | <field name="productStoreId" type="id" is-pk="true"/> | ||
| 44 | <field name="aiConfigId" type="id" is-pk="true"/> | ||
| 45 | |||
| 46 | <field name="serviceTypeEnumId" type="id"/> | ||
| 47 | <field name="description" type="text-medium"/> | ||
| 48 | |||
| 49 | <!-- Connection Details --> | ||
| 50 | <field name="endpointUrl" type="text-medium"/> | ||
| 51 | <field name="apiKey" type="text-medium" encrypt="true"/> | ||
| 52 | <field name="organizationId" type="text-short"/> | ||
| 53 | |||
| 54 | <!-- Model Parameters --> | ||
| 55 | <field name="modelName" type="text-short"/> | ||
| 56 | <field name="temperature" type="number-decimal"/> | ||
| 57 | <field name="maxTokens" type="number-integer"/> | ||
| 58 | |||
| 59 | <!-- System Prompt Template --> | ||
| 60 | <field name="systemMessageId" type="id"> | ||
| 61 | <description>Template for the system prompt (instruction set)</description> | ||
| 62 | </field> | ||
| 63 | |||
| 64 | <relationship type="one" related="mantle.product.store.ProductStore"> | ||
| 65 | <key-map field-name="productStoreId"/> | ||
| 66 | </relationship> | ||
| 67 | <relationship type="one" title="AiServiceType" related="moqui.basic.Enumeration"> | ||
| 68 | <key-map field-name="serviceTypeEnumId" related="enumId"/> | ||
| 69 | </relationship> | ||
| 70 | <relationship type="one" title="PromptTemplate" related="moqui.service.message.SystemMessage"> | ||
| 71 | <key-map field-name="systemMessageId"/> | ||
| 72 | </relationship> | ||
| 73 | |||
| 74 | <seed-data> | ||
| 75 | <!-- AI Service Types --> | ||
| 76 | <moqui.basic.EnumerationType description="AI Service Type" enumTypeId="AiServiceType"/> | ||
| 77 | <moqui.basic.Enumeration enumId="AistOpenAi" description="OpenAI" enumTypeId="AiServiceType"/> | ||
| 78 | <moqui.basic.Enumeration enumId="AistVllm" description="VLLM (OpenAI Compatible)" enumTypeId="AiServiceType"/> | ||
| 79 | <moqui.basic.Enumeration enumId="AistAnthropic" description="Anthropic" enumTypeId="AiServiceType"/> | ||
| 80 | <moqui.basic.Enumeration enumId="AistOllama" description="Ollama" enumTypeId="AiServiceType"/> | ||
| 81 | |||
| 82 | <!-- Agent Task Message Type --> | ||
| 83 | <moqui.basic.Enumeration enumId="SmtyAgentTask" description="Agent Task" enumTypeId="SystemMessageType"/> | ||
| 84 | |||
| 85 | <!-- AI Product Store Settings --> | ||
| 86 | <moqui.basic.Enumeration enumId="AiEndpointUrl" description="AI Endpoint URL" enumTypeId="ProductStoreSettingType"/> | ||
| 87 | <moqui.basic.Enumeration enumId="AiApiKey" description="AI API Key" enumTypeId="ProductStoreSettingType"/> | ||
| 88 | <moqui.basic.Enumeration enumId="AiModelName" description="AI Model Name" enumTypeId="ProductStoreSettingType"/> | ||
| 89 | <moqui.basic.Enumeration enumId="AiTemperature" description="AI Temperature" enumTypeId="ProductStoreSettingType"/> | ||
| 90 | </seed-data> | ||
| 91 | </entity> | ||
| 92 | |||
| 93 | </entities> |
service/AgentServices.xml
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment