@agentlang/agentmanager 0.0.3
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.
- package/README.md +122 -0
- package/apps/agentcraft/README.md +237 -0
- package/apps/agentcraft/src/agentcraft-core.module.ts +40 -0
- package/apps/agentcraft/src/app.module.ts +28 -0
- package/apps/agentcraft/src/architect/architect.controller.ts +69 -0
- package/apps/agentcraft/src/architect/architect.module.ts +11 -0
- package/apps/agentcraft/src/architect/architect.service.ts +193 -0
- package/apps/agentcraft/src/architect/architect.store.ts +63 -0
- package/apps/agentcraft/src/architect/dto/ingest-signal.dto.ts +20 -0
- package/apps/agentcraft/src/architect/interfaces/architect.interfaces.ts +20 -0
- package/apps/agentcraft/src/autonomous/autonomous.controller.ts +92 -0
- package/apps/agentcraft/src/autonomous/autonomous.module.ts +9 -0
- package/apps/agentcraft/src/autonomous/autonomous.service.ts +160 -0
- package/apps/agentcraft/src/autonomous/dto/run-autonomous.dto.ts +16 -0
- package/apps/agentcraft/src/autonomous/dto/watch-kb.dto.ts +16 -0
- package/apps/agentcraft/src/config/configuration.ts +74 -0
- package/apps/agentcraft/src/health/health.controller.ts +22 -0
- package/apps/agentcraft/src/health/health.module.ts +9 -0
- package/apps/agentcraft/src/main.ts +53 -0
- package/apps/agentcraft/src/resolver/dto/create-resolver.dto.ts +14 -0
- package/apps/agentcraft/src/resolver/dto/install-registry.dto.ts +10 -0
- package/apps/agentcraft/src/resolver/dto/search-registry-query.dto.ts +10 -0
- package/apps/agentcraft/src/resolver/dto/submit-action.dto.ts +4 -0
- package/apps/agentcraft/src/resolver/resolver-session.store.ts +39 -0
- package/apps/agentcraft/src/resolver/resolver.controller.ts +86 -0
- package/apps/agentcraft/src/resolver/resolver.module.ts +10 -0
- package/apps/agentcraft/src/resolver/resolver.service.ts +128 -0
- package/apps/agentcraft/src/sessions/dto/create-session.dto.ts +12 -0
- package/apps/agentcraft/src/sessions/dto/submit-action.dto.ts +1 -0
- package/apps/agentcraft/src/sessions/dto/submit-idea.dto.ts +8 -0
- package/apps/agentcraft/src/sessions/session.store.ts +39 -0
- package/apps/agentcraft/src/sessions/sessions.controller.ts +87 -0
- package/apps/agentcraft/src/sessions/sessions.module.ts +10 -0
- package/apps/agentcraft/src/sessions/sessions.service.ts +277 -0
- package/apps/agentcraft/tsconfig.app.json +8 -0
- package/apps/agentmanager/README.md +141 -0
- package/apps/agentmanager/src/agentmanager-core.module.ts +45 -0
- package/apps/agentmanager/src/app.module.ts +26 -0
- package/apps/agentmanager/src/config/configuration.ts +63 -0
- package/apps/agentmanager/src/deployments/deployments.controller.ts +21 -0
- package/apps/agentmanager/src/deployments/deployments.module.ts +10 -0
- package/apps/agentmanager/src/deployments/deployments.service.ts +166 -0
- package/apps/agentmanager/src/deployments/errors/deployment.errors.ts +13 -0
- package/apps/agentmanager/src/deployments/interfaces/deployment.interfaces.ts +25 -0
- package/apps/agentmanager/src/discovery/discovery.controller.ts +14 -0
- package/apps/agentmanager/src/discovery/discovery.module.ts +36 -0
- package/apps/agentmanager/src/discovery/discovery.service.ts +174 -0
- package/apps/agentmanager/src/discovery/dto/discover.dto.ts +8 -0
- package/apps/agentmanager/src/discovery/interfaces/discovery.interfaces.ts +22 -0
- package/apps/agentmanager/src/discovery/llm/anthropic-llm.service.ts +67 -0
- package/apps/agentmanager/src/discovery/llm/llm-provider.interface.ts +17 -0
- package/apps/agentmanager/src/discovery/llm/llm.errors.ts +7 -0
- package/apps/agentmanager/src/discovery/llm/openai-llm.service.ts +67 -0
- package/apps/agentmanager/src/employee-code/dto/put-config.dto.ts +8 -0
- package/apps/agentmanager/src/employee-code/dto/put-module.dto.ts +8 -0
- package/apps/agentmanager/src/employee-code/dto/put-package.dto.ts +13 -0
- package/apps/agentmanager/src/employee-code/employee-code.controller.ts +114 -0
- package/apps/agentmanager/src/employee-code/employee-code.module.ts +10 -0
- package/apps/agentmanager/src/employee-code/employee-code.service.ts +55 -0
- package/apps/agentmanager/src/employees/dto/register-employee.dto.ts +9 -0
- package/apps/agentmanager/src/employees/employees.controller.ts +53 -0
- package/apps/agentmanager/src/employees/employees.module.ts +10 -0
- package/apps/agentmanager/src/employees/employees.service.ts +29 -0
- package/apps/agentmanager/src/health/health.controller.ts +22 -0
- package/apps/agentmanager/src/health/health.module.ts +9 -0
- package/apps/agentmanager/src/inbox/dto/list-messages-query.dto.ts +12 -0
- package/apps/agentmanager/src/inbox/dto/push-message.dto.ts +55 -0
- package/apps/agentmanager/src/inbox/dto/respond-message.dto.ts +9 -0
- package/apps/agentmanager/src/inbox/inbox.controller.ts +87 -0
- package/apps/agentmanager/src/inbox/inbox.module.ts +10 -0
- package/apps/agentmanager/src/inbox/inbox.service.ts +209 -0
- package/apps/agentmanager/src/main.ts +53 -0
- package/apps/agentmanager/src/projects/dto/create-project.dto.ts +10 -0
- package/apps/agentmanager/src/projects/projects.controller.ts +47 -0
- package/apps/agentmanager/src/projects/projects.module.ts +10 -0
- package/apps/agentmanager/src/projects/projects.service.ts +24 -0
- package/apps/agentmanager/tsconfig.app.json +8 -0
- package/apps/fabric/Dockerfile +22 -0
- package/apps/fabric/docker-compose.yml +14 -0
- package/apps/fabric/ecosystem.config.cjs +17 -0
- package/apps/fabric/src/ai-agent/ai-agent.module.ts +43 -0
- package/apps/fabric/src/ai-agent/ai-agent.service.ts +374 -0
- package/apps/fabric/src/ai-agent/probe-investigation.types.ts +24 -0
- package/apps/fabric/src/app.module.ts +40 -0
- package/apps/fabric/src/auth/current-user.decorator.ts +11 -0
- package/apps/fabric/src/auth/request-user.ts +4 -0
- package/apps/fabric/src/config/configuration.ts +266 -0
- package/apps/fabric/src/database/entities/deployment-event.entity.ts +33 -0
- package/apps/fabric/src/database/entities/environment.entity.ts +25 -0
- package/apps/fabric/src/database/entities/index.ts +25 -0
- package/apps/fabric/src/database/entities/project.entity.ts +25 -0
- package/apps/fabric/src/database/entities/runtime.entity.ts +55 -0
- package/apps/fabric/src/database/entities/user-config.entity.ts +22 -0
- package/apps/fabric/src/database/entities/version.entity.ts +22 -0
- package/apps/fabric/src/database/migrations-data-source.ts +27 -0
- package/apps/fabric/src/deployment-events/deployment-events.controller.ts +27 -0
- package/apps/fabric/src/deployment-events/deployment-events.module.ts +11 -0
- package/apps/fabric/src/deployment-events/deployment-events.service.ts +58 -0
- package/apps/fabric/src/deployment-events/deployment-events.store.ts +162 -0
- package/apps/fabric/src/deployment-events/deployment-events.types.ts +24 -0
- package/apps/fabric/src/employees/dto/deploy.dto.ts +71 -0
- package/apps/fabric/src/employees/employees.controller.ts +217 -0
- package/apps/fabric/src/employees/employees.module.ts +32 -0
- package/apps/fabric/src/employees/employees.service.ts +1333 -0
- package/apps/fabric/src/employees/employees.types.ts +69 -0
- package/apps/fabric/src/employees/errors/employee-deployment.errors.ts +80 -0
- package/apps/fabric/src/employees/runtime.store.ts +304 -0
- package/apps/fabric/src/environments/dto/environment.dto.ts +26 -0
- package/apps/fabric/src/environments/environments.controller.ts +48 -0
- package/apps/fabric/src/environments/environments.module.ts +11 -0
- package/apps/fabric/src/environments/environments.service.ts +92 -0
- package/apps/fabric/src/environments/environments.store.ts +146 -0
- package/apps/fabric/src/environments/environments.types.ts +11 -0
- package/apps/fabric/src/environments/errors/environment.errors.ts +14 -0
- package/apps/fabric/src/fabric-core.module.ts +48 -0
- package/apps/fabric/src/health/health.controller.ts +19 -0
- package/apps/fabric/src/health/health.module.ts +12 -0
- package/apps/fabric/src/health/provider-health.indicator.ts +33 -0
- package/apps/fabric/src/healthcheck/healthcheck.module.ts +24 -0
- package/apps/fabric/src/healthcheck/healthcheck.service.ts +494 -0
- package/apps/fabric/src/logs/logs.module.ts +10 -0
- package/apps/fabric/src/logs/logs.service.ts +149 -0
- package/apps/fabric/src/main.ts +57 -0
- package/apps/fabric/src/notifications/notifications.module.ts +23 -0
- package/apps/fabric/src/notifications/notifications.service.ts +141 -0
- package/apps/fabric/src/project-source/errors/project-source.errors.ts +8 -0
- package/apps/fabric/src/project-source/project-source.module.ts +8 -0
- package/apps/fabric/src/project-source/project-source.service.ts +75 -0
- package/apps/fabric/src/project-source/project-source.types.ts +5 -0
- package/apps/fabric/src/projects/dto/project.dto.ts +25 -0
- package/apps/fabric/src/projects/errors/project.errors.ts +17 -0
- package/apps/fabric/src/projects/projects-data.service.ts +60 -0
- package/apps/fabric/src/projects/projects.controller.ts +92 -0
- package/apps/fabric/src/projects/projects.module.ts +20 -0
- package/apps/fabric/src/projects/projects.service.ts +323 -0
- package/apps/fabric/src/projects/projects.store.ts +142 -0
- package/apps/fabric/src/projects/projects.types.ts +9 -0
- package/apps/fabric/src/providers/docker-provider.ts +141 -0
- package/apps/fabric/src/providers/eks-provider.ts +279 -0
- package/apps/fabric/src/providers/pm2-provider.ts +205 -0
- package/apps/fabric/src/providers/port-allocator.ts +57 -0
- package/apps/fabric/src/providers/provider-factory.ts +32 -0
- package/apps/fabric/src/providers/provider.interface.ts +50 -0
- package/apps/fabric/src/providers/providers.module.ts +26 -0
- package/apps/fabric/src/provisioners/cognito-provisioner.service.ts +168 -0
- package/apps/fabric/src/provisioners/postgres-provisioner.service.ts +124 -0
- package/apps/fabric/src/provisioners/provisioners.module.ts +40 -0
- package/apps/fabric/src/user-config/user-config.module.ts +9 -0
- package/apps/fabric/src/user-config/user-config.service.ts +54 -0
- package/apps/fabric/src/user-config/user-config.store.ts +120 -0
- package/apps/fabric/src/user-config/user-config.types.ts +11 -0
- package/apps/fabric/src/versions/versions.controller.ts +24 -0
- package/apps/fabric/src/versions/versions.module.ts +11 -0
- package/apps/fabric/src/versions/versions.service.ts +65 -0
- package/apps/fabric/src/versions/versions.store.ts +160 -0
- package/apps/fabric/src/versions/versions.types.ts +12 -0
- package/apps/fabric/src/watcher/deployment-watcher.module.ts +22 -0
- package/apps/fabric/src/watcher/deployment-watcher.service.ts +92 -0
- package/apps/fabric/src/watcher/pod-probe.service.ts +231 -0
- package/apps/fabric/tsconfig.app.json +8 -0
- package/apps/integrations/prisma/.integrations/integrations.sqlite +0 -0
- package/apps/integrations/prisma/prisma.config.ts +8 -0
- package/apps/integrations/prisma/prisma.sqlite.config.ts +8 -0
- package/apps/integrations/prisma/schema.postgres.prisma +27 -0
- package/apps/integrations/prisma/schema.sqlite.prisma +27 -0
- package/apps/integrations/scripts/prepare-db.cjs +92 -0
- package/apps/integrations/src/api/auth-flow.controller.ts +39 -0
- package/apps/integrations/src/api/connections.controller.ts +26 -0
- package/apps/integrations/src/api/health.controller.ts +34 -0
- package/apps/integrations/src/api/providers.controller.ts +60 -0
- package/apps/integrations/src/api/tenant-config.controller.ts +62 -0
- package/apps/integrations/src/app.module.ts +38 -0
- package/apps/integrations/src/config/configuration.ts +134 -0
- package/apps/integrations/src/generated/prisma-postgres/browser.ts +24 -0
- package/apps/integrations/src/generated/prisma-postgres/client.ts +46 -0
- package/apps/integrations/src/generated/prisma-postgres/commonInputTypes.ts +297 -0
- package/apps/integrations/src/generated/prisma-postgres/enums.ts +15 -0
- package/apps/integrations/src/generated/prisma-postgres/internal/class.ts +204 -0
- package/apps/integrations/src/generated/prisma-postgres/internal/prismaNamespace.ts +794 -0
- package/apps/integrations/src/generated/prisma-postgres/internal/prismaNamespaceBrowser.ts +126 -0
- package/apps/integrations/src/generated/prisma-postgres/models/IntegrationEntity.ts +1273 -0
- package/apps/integrations/src/generated/prisma-postgres/models.ts +12 -0
- package/apps/integrations/src/generated/prisma-sqlite/browser.ts +24 -0
- package/apps/integrations/src/generated/prisma-sqlite/client.ts +46 -0
- package/apps/integrations/src/generated/prisma-sqlite/commonInputTypes.ts +278 -0
- package/apps/integrations/src/generated/prisma-sqlite/enums.ts +15 -0
- package/apps/integrations/src/generated/prisma-sqlite/internal/class.ts +204 -0
- package/apps/integrations/src/generated/prisma-sqlite/internal/prismaNamespace.ts +770 -0
- package/apps/integrations/src/generated/prisma-sqlite/internal/prismaNamespaceBrowser.ts +123 -0
- package/apps/integrations/src/generated/prisma-sqlite/models/IntegrationEntity.ts +1271 -0
- package/apps/integrations/src/generated/prisma-sqlite/models.ts +12 -0
- package/apps/integrations/src/integrations-core.module.ts +52 -0
- package/apps/integrations/src/main.ts +63 -0
- package/apps/integrations/src/modules/auth-flow/auth-flow.module.ts +21 -0
- package/apps/integrations/src/modules/auth-flow/auth-flow.service.ts +275 -0
- package/apps/integrations/src/modules/auth-flow/dto/auth-flow.dto.ts +36 -0
- package/apps/integrations/src/modules/auth-flow/scheduler.service.ts +73 -0
- package/apps/integrations/src/modules/connections/connections.module.ts +11 -0
- package/apps/integrations/src/modules/connections/connections.service.ts +109 -0
- package/apps/integrations/src/modules/credentials/credentials.module.ts +11 -0
- package/apps/integrations/src/modules/credentials/encryption.service.ts +71 -0
- package/apps/integrations/src/modules/credentials/token-store.service.ts +82 -0
- package/apps/integrations/src/modules/discovery/discovery.module.ts +8 -0
- package/apps/integrations/src/modules/discovery/oidc-discovery.service.ts +114 -0
- package/apps/integrations/src/modules/platform/metadata-store.service.ts +337 -0
- package/apps/integrations/src/modules/platform/platform.module.ts +8 -0
- package/apps/integrations/src/modules/platform/platform.types.ts +10 -0
- package/apps/integrations/src/modules/platform/resilient-fetch.ts +53 -0
- package/apps/integrations/src/modules/providers/base/api-key.provider.ts +43 -0
- package/apps/integrations/src/modules/providers/base/basic-auth.provider.ts +44 -0
- package/apps/integrations/src/modules/providers/base/oauth2.provider.ts +233 -0
- package/apps/integrations/src/modules/providers/base/oidc.provider.ts +87 -0
- package/apps/integrations/src/modules/providers/builtin/google-drive.provider.ts +40 -0
- package/apps/integrations/src/modules/providers/dto/provider.dto.ts +53 -0
- package/apps/integrations/src/modules/providers/provider.factory.ts +68 -0
- package/apps/integrations/src/modules/providers/provider.registry.ts +123 -0
- package/apps/integrations/src/modules/providers/provider.types.ts +185 -0
- package/apps/integrations/src/modules/providers/providers.module.ts +34 -0
- package/apps/integrations/src/modules/tenant-config/dto/tenant-config.dto.ts +28 -0
- package/apps/integrations/src/modules/tenant-config/tenant-config.module.ts +11 -0
- package/apps/integrations/src/modules/tenant-config/tenant-config.service.ts +212 -0
- package/apps/integrations/tsconfig.app.json +8 -0
- package/apps/knowledge/prisma/prisma.config.ts +8 -0
- package/apps/knowledge/prisma/schema.postgres.prisma +29 -0
- package/apps/knowledge/prisma/schema.sqlite.prisma +29 -0
- package/apps/knowledge/scripts/prepare-db.cjs +72 -0
- package/apps/knowledge/src/api/auth.controller.ts +54 -0
- package/apps/knowledge/src/api/connections.controller.ts +99 -0
- package/apps/knowledge/src/api/documents.controller.ts +45 -0
- package/apps/knowledge/src/api/graph.controller.ts +67 -0
- package/apps/knowledge/src/api/health.controller.ts +39 -0
- package/apps/knowledge/src/api/ingestion.controller.ts +45 -0
- package/apps/knowledge/src/api/knowledge-query.controller.ts +27 -0
- package/apps/knowledge/src/api/oauth.controller.ts +38 -0
- package/apps/knowledge/src/api/recommendations.controller.ts +63 -0
- package/apps/knowledge/src/api/scheduler.controller.ts +32 -0
- package/apps/knowledge/src/api/topics.controller.ts +46 -0
- package/apps/knowledge/src/app.module.ts +68 -0
- package/apps/knowledge/src/config/configuration.ts +149 -0
- package/apps/knowledge/src/generated/prisma-postgres/browser.ts +24 -0
- package/apps/knowledge/src/generated/prisma-postgres/client.ts +46 -0
- package/apps/knowledge/src/generated/prisma-postgres/commonInputTypes.ts +297 -0
- package/apps/knowledge/src/generated/prisma-postgres/enums.ts +15 -0
- package/apps/knowledge/src/generated/prisma-postgres/internal/class.ts +204 -0
- package/apps/knowledge/src/generated/prisma-postgres/internal/prismaNamespace.ts +795 -0
- package/apps/knowledge/src/generated/prisma-postgres/internal/prismaNamespaceBrowser.ts +127 -0
- package/apps/knowledge/src/generated/prisma-postgres/models/KnowledgeEntity.ts +1301 -0
- package/apps/knowledge/src/generated/prisma-postgres/models.ts +12 -0
- package/apps/knowledge/src/generated/prisma-sqlite/browser.ts +24 -0
- package/apps/knowledge/src/generated/prisma-sqlite/client.ts +46 -0
- package/apps/knowledge/src/generated/prisma-sqlite/commonInputTypes.ts +278 -0
- package/apps/knowledge/src/generated/prisma-sqlite/enums.ts +15 -0
- package/apps/knowledge/src/generated/prisma-sqlite/internal/class.ts +204 -0
- package/apps/knowledge/src/generated/prisma-sqlite/internal/prismaNamespace.ts +771 -0
- package/apps/knowledge/src/generated/prisma-sqlite/internal/prismaNamespaceBrowser.ts +124 -0
- package/apps/knowledge/src/generated/prisma-sqlite/models/KnowledgeEntity.ts +1299 -0
- package/apps/knowledge/src/generated/prisma-sqlite/models.ts +12 -0
- package/apps/knowledge/src/main.ts +48 -0
- package/apps/knowledge/src/modules/auth/auth.module.ts +8 -0
- package/apps/knowledge/src/modules/auth/auth.service.ts +290 -0
- package/apps/knowledge/src/modules/documents/documents.module.ts +12 -0
- package/apps/knowledge/src/modules/documents/documents.service.ts +179 -0
- package/apps/knowledge/src/modules/documents/dto/document.dto.ts +68 -0
- package/apps/knowledge/src/modules/graph/graph.module.ts +10 -0
- package/apps/knowledge/src/modules/graph/graph.service.ts +223 -0
- package/apps/knowledge/src/modules/ingestion/dto/ingestion.dto.ts +58 -0
- package/apps/knowledge/src/modules/ingestion/ingestion-workflows.service.ts +246 -0
- package/apps/knowledge/src/modules/ingestion/ingestion.module.ts +14 -0
- package/apps/knowledge/src/modules/ingestion/ingestion.service.ts +619 -0
- package/apps/knowledge/src/modules/oauth-bridge/oauth-bridge.module.ts +8 -0
- package/apps/knowledge/src/modules/oauth-bridge/oauth-bridge.service.ts +135 -0
- package/apps/knowledge/src/modules/platform/metadata-store.service.ts +314 -0
- package/apps/knowledge/src/modules/platform/platform.module.ts +9 -0
- package/apps/knowledge/src/modules/platform/platform.types.ts +23 -0
- package/apps/knowledge/src/modules/platform/vector-store.service.ts +235 -0
- package/apps/knowledge/src/modules/recommendations/recommendations.module.ts +10 -0
- package/apps/knowledge/src/modules/recommendations/recommendations.service.ts +121 -0
- package/apps/knowledge/src/modules/storage/storage.module.ts +8 -0
- package/apps/knowledge/src/modules/storage/storage.service.ts +150 -0
- package/apps/knowledge/src/modules/sync/scheduler.service.ts +175 -0
- package/apps/knowledge/src/modules/sync/sync.module.ts +11 -0
- package/apps/knowledge/src/modules/topics/dto/topic.dto.ts +50 -0
- package/apps/knowledge/src/modules/topics/topics.module.ts +10 -0
- package/apps/knowledge/src/modules/topics/topics.service.ts +86 -0
- package/apps/knowledge/tsconfig.app.json +8 -0
- package/apps/monolith/src/app.module.ts +75 -0
- package/apps/monolith/src/config/configuration.ts +93 -0
- package/apps/monolith/src/health/health.controller.ts +22 -0
- package/apps/monolith/src/health/health.module.ts +9 -0
- package/apps/monolith/src/main.ts +56 -0
- package/apps/monolith/tsconfig.app.json +8 -0
- package/libs/agentcraft/src/agentcraft.module.d.ts +12 -0
- package/libs/agentcraft/src/agentcraft.module.js +142 -0
- package/libs/agentcraft/src/agentcraft.module.js.map +1 -0
- package/libs/agentcraft/src/agentcraft.module.ts +161 -0
- package/libs/agentcraft/src/constants.d.ts +2 -0
- package/libs/agentcraft/src/constants.js +6 -0
- package/libs/agentcraft/src/constants.js.map +1 -0
- package/libs/agentcraft/src/constants.ts +2 -0
- package/libs/agentcraft/src/dto/submit-action.dto.ts +20 -0
- package/libs/agentcraft/src/errors/domain.error.d.ts +8 -0
- package/libs/agentcraft/src/errors/domain.error.js +27 -0
- package/libs/agentcraft/src/errors/domain.error.js.map +1 -0
- package/libs/agentcraft/src/errors/domain.error.ts +14 -0
- package/libs/agentcraft/src/errors/llm.errors.d.ts +10 -0
- package/libs/agentcraft/src/errors/llm.errors.js +26 -0
- package/libs/agentcraft/src/errors/llm.errors.js.map +1 -0
- package/libs/agentcraft/src/errors/llm.errors.ts +19 -0
- package/libs/agentcraft/src/index.d.ts +64 -0
- package/libs/agentcraft/src/index.js +195 -0
- package/libs/agentcraft/src/index.js.map +1 -0
- package/libs/agentcraft/src/index.ts +171 -0
- package/libs/agentcraft/src/instructions/step6-data-model.ts +181 -0
- package/libs/agentcraft/src/instructions/step7-workflows.ts +544 -0
- package/libs/agentcraft/src/instructions/step8-agents.ts +114 -0
- package/libs/agentcraft/src/interfaces/llm-provider.interface.d.ts +16 -0
- package/libs/agentcraft/src/interfaces/llm-provider.interface.js +3 -0
- package/libs/agentcraft/src/interfaces/llm-provider.interface.js.map +1 -0
- package/libs/agentcraft/src/interfaces/llm-provider.interface.ts +18 -0
- package/libs/agentcraft/src/prompts/assembly.prompt.ts +104 -0
- package/libs/agentcraft/src/prompts/codegen.prompt.ts +162 -0
- package/libs/agentcraft/src/prompts/decomposition.prompt.ts +32 -0
- package/libs/agentcraft/src/prompts/examples-provider.ts +63 -0
- package/libs/agentcraft/src/prompts/planning.prompt.ts +52 -0
- package/libs/agentcraft/src/prompts/resolver.prompt.ts +364 -0
- package/libs/agentcraft/src/prompts/semantics-guide.ts +134 -0
- package/libs/agentcraft/src/services/anthropic-craft-llm.service.ts +186 -0
- package/libs/agentcraft/src/services/anthropic-llm.service.d.ts +9 -0
- package/libs/agentcraft/src/services/anthropic-llm.service.js +90 -0
- package/libs/agentcraft/src/services/anthropic-llm.service.js.map +1 -0
- package/libs/agentcraft/src/services/anthropic-llm.service.ts +61 -0
- package/libs/agentcraft/src/services/api-adapter.service.d.ts +65 -0
- package/libs/agentcraft/src/services/api-adapter.service.js +167 -0
- package/libs/agentcraft/src/services/api-adapter.service.js.map +1 -0
- package/libs/agentcraft/src/services/api-adapter.service.ts +186 -0
- package/libs/agentcraft/src/services/architect-loop.service.d.ts +16 -0
- package/libs/agentcraft/src/services/architect-loop.service.js +92 -0
- package/libs/agentcraft/src/services/architect-loop.service.js.map +1 -0
- package/libs/agentcraft/src/services/architect-loop.service.ts +407 -0
- package/libs/agentcraft/src/services/autonomous-runner.service.ts +178 -0
- package/libs/agentcraft/src/services/craft-config.service.d.ts +11 -0
- package/libs/agentcraft/src/services/craft-config.service.js +127 -0
- package/libs/agentcraft/src/services/craft-config.service.js.map +1 -0
- package/libs/agentcraft/src/services/craft-config.service.ts +92 -0
- package/libs/agentcraft/src/services/craft-llm-adapter.service.d.ts +12 -0
- package/libs/agentcraft/src/services/craft-llm-adapter.service.js +73 -0
- package/libs/agentcraft/src/services/craft-llm-adapter.service.js.map +1 -0
- package/libs/agentcraft/src/services/craft-llm-adapter.service.ts +52 -0
- package/libs/agentcraft/src/services/decomposer.service.ts +115 -0
- package/libs/agentcraft/src/services/design-generator.service.ts +672 -0
- package/libs/agentcraft/src/services/executor.service.ts +452 -0
- package/libs/agentcraft/src/services/kb-watcher.service.ts +150 -0
- package/libs/agentcraft/src/services/openai-llm.service.d.ts +9 -0
- package/libs/agentcraft/src/services/openai-llm.service.js +91 -0
- package/libs/agentcraft/src/services/openai-llm.service.js.map +1 -0
- package/libs/agentcraft/src/services/openai-llm.service.ts +61 -0
- package/libs/agentcraft/src/services/output-parser.service.d.ts +9 -0
- package/libs/agentcraft/src/services/output-parser.service.js +80 -0
- package/libs/agentcraft/src/services/output-parser.service.js.map +1 -0
- package/libs/agentcraft/src/services/output-parser.service.ts +68 -0
- package/libs/agentcraft/src/services/pipeline-state.service.d.ts +19 -0
- package/libs/agentcraft/src/services/pipeline-state.service.js +134 -0
- package/libs/agentcraft/src/services/pipeline-state.service.js.map +1 -0
- package/libs/agentcraft/src/services/pipeline-state.service.ts +108 -0
- package/libs/agentcraft/src/services/pipeline-steps.service.d.ts +10 -0
- package/libs/agentcraft/src/services/pipeline-steps.service.js +147 -0
- package/libs/agentcraft/src/services/pipeline-steps.service.js.map +1 -0
- package/libs/agentcraft/src/services/pipeline-steps.service.ts +126 -0
- package/libs/agentcraft/src/services/planner.service.ts +189 -0
- package/libs/agentcraft/src/services/readme-generator.service.ts +229 -0
- package/libs/agentcraft/src/services/registry-client.service.d.ts +14 -0
- package/libs/agentcraft/src/services/registry-client.service.js +158 -0
- package/libs/agentcraft/src/services/registry-client.service.js.map +1 -0
- package/libs/agentcraft/src/services/registry-client.service.ts +139 -0
- package/libs/agentcraft/src/services/requirements-generator.service.ts +238 -0
- package/libs/agentcraft/src/services/spec-fetcher.service.d.ts +3 -0
- package/libs/agentcraft/src/services/spec-fetcher.service.js +46 -0
- package/libs/agentcraft/src/services/spec-fetcher.service.js.map +1 -0
- package/libs/agentcraft/src/services/spec-fetcher.service.ts +21 -0
- package/libs/agentcraft/src/services/ui-blueprint-generator.service.ts +387 -0
- package/libs/agentcraft/src/types/architect.types.ts +156 -0
- package/libs/agentcraft/src/types/autonomous.types.ts +71 -0
- package/libs/agentcraft/src/types/llm.types.d.ts +26 -0
- package/libs/agentcraft/src/types/llm.types.js +3 -0
- package/libs/agentcraft/src/types/llm.types.js.map +1 -0
- package/libs/agentcraft/src/types/llm.types.ts +60 -0
- package/libs/agentcraft/src/types/pipeline.types.d.ts +55 -0
- package/libs/agentcraft/src/types/pipeline.types.js +37 -0
- package/libs/agentcraft/src/types/pipeline.types.js.map +1 -0
- package/libs/agentcraft/src/types/pipeline.types.ts +61 -0
- package/libs/agentcraft/src/types/resolver.types.d.ts +27 -0
- package/libs/agentcraft/src/types/resolver.types.js +3 -0
- package/libs/agentcraft/src/types/resolver.types.js.map +1 -0
- package/libs/agentcraft/src/types/resolver.types.ts +22 -0
- package/libs/agentcraft/src/types/signal.types.d.ts +16 -0
- package/libs/agentcraft/src/types/signal.types.js +3 -0
- package/libs/agentcraft/src/types/signal.types.js.map +1 -0
- package/libs/agentcraft/src/types/signal.types.ts +18 -0
- package/libs/agentcraft/src/utils/kb-loader.ts +67 -0
- package/libs/agentcraft/src/utils/output-writer.ts +71 -0
- package/libs/agentcraft/src/utils/spec-fetcher.ts +20 -0
- package/libs/agentcraft/src/utils/spec-trimmer.ts +280 -0
- package/libs/agentcraft/src/utils/text-utils.ts +49 -0
- package/libs/agentcraft/src/utils/validator.ts +231 -0
- package/libs/agentcraft/tsconfig.lib.json +9 -0
- package/libs/auth/src/auth.guard.ts +188 -0
- package/libs/auth/src/auth.module.ts +11 -0
- package/libs/auth/src/index.ts +3 -0
- package/libs/auth/src/public.decorator.ts +5 -0
- package/libs/auth/tsconfig.lib.json +9 -0
- package/libs/common/src/database/data-source.service.ts +75 -0
- package/libs/common/src/database/database-connection.holder.ts +41 -0
- package/libs/common/src/database/database.config.ts +14 -0
- package/libs/common/src/database/database.module.ts +42 -0
- package/libs/common/src/database/embedded-database.service.ts +120 -0
- package/libs/common/src/database/file-store.factory.ts +20 -0
- package/libs/common/src/database/file-store.ts +47 -0
- package/libs/common/src/errors/domain.error.ts +11 -0
- package/libs/common/src/filters/domain-exception.filter.ts +62 -0
- package/libs/common/src/index.ts +15 -0
- package/libs/common/src/interceptors/logging.interceptor.ts +60 -0
- package/libs/common/tsconfig.lib.json +9 -0
- package/libs/project-provider/src/constants.d.ts +7 -0
- package/libs/project-provider/src/constants.js +18 -0
- package/libs/project-provider/src/constants.js.map +1 -0
- package/libs/project-provider/src/constants.ts +7 -0
- package/libs/project-provider/src/errors/domain.error.d.ts +4 -0
- package/libs/project-provider/src/errors/domain.error.js +13 -0
- package/libs/project-provider/src/errors/domain.error.js.map +1 -0
- package/libs/project-provider/src/errors/domain.error.ts +1 -0
- package/libs/project-provider/src/errors/employee-code.errors.d.ts +13 -0
- package/libs/project-provider/src/errors/employee-code.errors.js +42 -0
- package/libs/project-provider/src/errors/employee-code.errors.js.map +1 -0
- package/libs/project-provider/src/errors/employee-code.errors.ts +37 -0
- package/libs/project-provider/src/errors/inbox.errors.d.ts +13 -0
- package/libs/project-provider/src/errors/inbox.errors.js +36 -0
- package/libs/project-provider/src/errors/inbox.errors.js.map +1 -0
- package/libs/project-provider/src/errors/inbox.errors.ts +31 -0
- package/libs/project-provider/src/errors/registry.errors.d.ts +16 -0
- package/libs/project-provider/src/errors/registry.errors.js +46 -0
- package/libs/project-provider/src/errors/registry.errors.js.map +1 -0
- package/libs/project-provider/src/errors/registry.errors.ts +40 -0
- package/libs/project-provider/src/index.d.ts +67 -0
- package/libs/project-provider/src/index.js +220 -0
- package/libs/project-provider/src/index.js.map +1 -0
- package/libs/project-provider/src/index.ts +82 -0
- package/libs/project-provider/src/interfaces/employee-code-provider.interface.d.ts +36 -0
- package/libs/project-provider/src/interfaces/employee-code-provider.interface.js +3 -0
- package/libs/project-provider/src/interfaces/employee-code-provider.interface.js.map +1 -0
- package/libs/project-provider/src/interfaces/employee-code-provider.interface.ts +37 -0
- package/libs/project-provider/src/interfaces/inbox-client.interface.d.ts +3 -0
- package/libs/project-provider/src/interfaces/inbox-client.interface.js +3 -0
- package/libs/project-provider/src/interfaces/inbox-client.interface.js.map +1 -0
- package/libs/project-provider/src/interfaces/inbox-client.interface.ts +3 -0
- package/libs/project-provider/src/interfaces/inbox-handler.interface.ts +10 -0
- package/libs/project-provider/src/interfaces/knowledge-base.interface.d.ts +5 -0
- package/libs/project-provider/src/interfaces/knowledge-base.interface.js +3 -0
- package/libs/project-provider/src/interfaces/knowledge-base.interface.js.map +1 -0
- package/libs/project-provider/src/interfaces/knowledge-base.interface.ts +6 -0
- package/libs/project-provider/src/interfaces/registry-provider.interface.d.ts +24 -0
- package/libs/project-provider/src/interfaces/registry-provider.interface.js +3 -0
- package/libs/project-provider/src/interfaces/registry-provider.interface.js.map +1 -0
- package/libs/project-provider/src/interfaces/registry-provider.interface.ts +36 -0
- package/libs/project-provider/src/project-provider.module.d.ts +10 -0
- package/libs/project-provider/src/project-provider.module.js +137 -0
- package/libs/project-provider/src/project-provider.module.js.map +1 -0
- package/libs/project-provider/src/project-provider.module.ts +119 -0
- package/libs/project-provider/src/services/al-parser.service.d.ts +6 -0
- package/libs/project-provider/src/services/al-parser.service.js +103 -0
- package/libs/project-provider/src/services/al-parser.service.js.map +1 -0
- package/libs/project-provider/src/services/al-parser.service.ts +92 -0
- package/libs/project-provider/src/services/direct-inbox-client.service.ts +24 -0
- package/libs/project-provider/src/services/file-knowledge-base.service.d.ts +8 -0
- package/libs/project-provider/src/services/file-knowledge-base.service.js +158 -0
- package/libs/project-provider/src/services/file-knowledge-base.service.js.map +1 -0
- package/libs/project-provider/src/services/file-knowledge-base.service.ts +81 -0
- package/libs/project-provider/src/services/filesystem-employee-code.service.d.ts +49 -0
- package/libs/project-provider/src/services/filesystem-employee-code.service.js +227 -0
- package/libs/project-provider/src/services/filesystem-employee-code.service.js.map +1 -0
- package/libs/project-provider/src/services/filesystem-employee-code.service.ts +220 -0
- package/libs/project-provider/src/services/filesystem-registry.service.d.ts +34 -0
- package/libs/project-provider/src/services/filesystem-registry.service.js +231 -0
- package/libs/project-provider/src/services/filesystem-registry.service.js.map +1 -0
- package/libs/project-provider/src/services/filesystem-registry.service.ts +271 -0
- package/libs/project-provider/src/services/http-inbox-client.service.d.ts +7 -0
- package/libs/project-provider/src/services/http-inbox-client.service.js +66 -0
- package/libs/project-provider/src/services/http-inbox-client.service.js.map +1 -0
- package/libs/project-provider/src/services/http-inbox-client.service.ts +29 -0
- package/libs/project-provider/src/services/noop-inbox-client.service.d.ts +4 -0
- package/libs/project-provider/src/services/noop-inbox-client.service.js +32 -0
- package/libs/project-provider/src/services/noop-inbox-client.service.js.map +1 -0
- package/libs/project-provider/src/services/noop-inbox-client.service.ts +9 -0
- package/libs/project-provider/src/types/messaging.types.d.ts +49 -0
- package/libs/project-provider/src/types/messaging.types.js +11 -0
- package/libs/project-provider/src/types/messaging.types.js.map +1 -0
- package/libs/project-provider/src/types/messaging.types.ts +59 -0
- package/libs/project-provider/src/types/project.types.d.ts +44 -0
- package/libs/project-provider/src/types/project.types.js +3 -0
- package/libs/project-provider/src/types/project.types.js.map +1 -0
- package/libs/project-provider/src/types/project.types.ts +58 -0
- package/libs/project-provider/tsconfig.lib.json +9 -0
- package/nest-cli.json +114 -0
- package/package.json +206 -0
- package/scripts/agentmanager.mjs +1126 -0
- package/scripts/monolith-daemon-run.mjs +77 -0
- package/scripts/monolith-daemon-run.sh +27 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { Injectable, Inject, Optional, Logger } from '@nestjs/common';
|
|
2
|
+
import { CRAFT_LLM_PROVIDER } from '../constants';
|
|
3
|
+
import { CraftLlmProvider } from '../interfaces/llm-provider.interface';
|
|
4
|
+
import type { ToolDefinition } from '../types/llm.types';
|
|
5
|
+
import {
|
|
6
|
+
DecompositionResult,
|
|
7
|
+
RequirementsResult,
|
|
8
|
+
DesignResult,
|
|
9
|
+
AppSpec,
|
|
10
|
+
EntitySpec,
|
|
11
|
+
RelationshipSpec,
|
|
12
|
+
WorkflowSpec,
|
|
13
|
+
EventSpec,
|
|
14
|
+
AgentSpec,
|
|
15
|
+
FeatureAnnotation,
|
|
16
|
+
} from '../types/architect.types';
|
|
17
|
+
import { kebabToPascalCase, pascalToKebabCase } from '../utils/text-utils';
|
|
18
|
+
import { SEMANTICS_GUIDE } from '../prompts/semantics-guide';
|
|
19
|
+
|
|
20
|
+
const FEATURE_ANNOTATION_SCHEMA = {
|
|
21
|
+
type: 'object',
|
|
22
|
+
required: ['feature', 'rationale'],
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
properties: {
|
|
25
|
+
feature: { type: 'string' },
|
|
26
|
+
rationale: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'Why this feature is needed for this construct',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const ENTITY_SCHEMA = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
required: ['name', 'description'],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
properties: {
|
|
38
|
+
name: { type: 'string', description: 'PascalCase entity name' },
|
|
39
|
+
description: { type: 'string' },
|
|
40
|
+
features: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: {
|
|
43
|
+
...FEATURE_ANNOTATION_SCHEMA,
|
|
44
|
+
properties: {
|
|
45
|
+
...FEATURE_ANNOTATION_SCHEMA.properties,
|
|
46
|
+
feature: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
enum: [
|
|
49
|
+
'audit',
|
|
50
|
+
'fullTextSearch',
|
|
51
|
+
'rbac',
|
|
52
|
+
'triggers',
|
|
53
|
+
'compositeUnique',
|
|
54
|
+
'computedFields',
|
|
55
|
+
'actions',
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const RELATIONSHIP_SCHEMA = {
|
|
65
|
+
type: 'object',
|
|
66
|
+
required: ['name', 'between', 'type', 'kind', 'rationale'],
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
properties: {
|
|
69
|
+
name: { type: 'string' },
|
|
70
|
+
between: {
|
|
71
|
+
type: 'array',
|
|
72
|
+
items: { type: 'string' },
|
|
73
|
+
minItems: 2,
|
|
74
|
+
maxItems: 2,
|
|
75
|
+
},
|
|
76
|
+
type: { type: 'string', enum: ['one_one', 'one_many', 'many_many'] },
|
|
77
|
+
kind: { type: 'string', enum: ['contains', 'between'] },
|
|
78
|
+
rationale: { type: 'string' },
|
|
79
|
+
roleAliases: {
|
|
80
|
+
type: 'array',
|
|
81
|
+
items: { type: 'string' },
|
|
82
|
+
minItems: 2,
|
|
83
|
+
maxItems: 2,
|
|
84
|
+
},
|
|
85
|
+
hasSchema: { type: 'boolean' },
|
|
86
|
+
hasSchemaRationale: { type: 'string' },
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const EVENT_SCHEMA = {
|
|
91
|
+
type: 'object',
|
|
92
|
+
required: ['name', 'public', 'description'],
|
|
93
|
+
additionalProperties: false,
|
|
94
|
+
properties: {
|
|
95
|
+
name: { type: 'string' },
|
|
96
|
+
public: { type: 'boolean' },
|
|
97
|
+
description: { type: 'string' },
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const TRIGGER_ON_SCHEMA = {
|
|
102
|
+
type: 'object',
|
|
103
|
+
required: ['timing', 'operation', 'entity'],
|
|
104
|
+
additionalProperties: false,
|
|
105
|
+
properties: {
|
|
106
|
+
timing: { type: 'string', enum: ['before', 'after'] },
|
|
107
|
+
operation: { type: 'string', enum: ['create', 'update', 'delete'] },
|
|
108
|
+
entity: { type: 'string' },
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const WORKFLOW_SCHEMA = {
|
|
113
|
+
type: 'object',
|
|
114
|
+
required: ['name', 'description', 'dataTouched'],
|
|
115
|
+
additionalProperties: false,
|
|
116
|
+
properties: {
|
|
117
|
+
name: { type: 'string' },
|
|
118
|
+
description: { type: 'string' },
|
|
119
|
+
dataTouched: { type: 'array', items: { type: 'string' } },
|
|
120
|
+
triggerOn: { ...TRIGGER_ON_SCHEMA },
|
|
121
|
+
withRole: { type: 'string' },
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const AGENT_SCHEMA = {
|
|
126
|
+
type: 'object',
|
|
127
|
+
required: ['name', 'description', 'tools', 'goal'],
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
properties: {
|
|
130
|
+
name: { type: 'string' },
|
|
131
|
+
description: { type: 'string' },
|
|
132
|
+
goal: { type: 'string' },
|
|
133
|
+
tools: { type: 'array', items: { type: 'string' } },
|
|
134
|
+
capabilities: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
items: {
|
|
137
|
+
...FEATURE_ANNOTATION_SCHEMA,
|
|
138
|
+
properties: {
|
|
139
|
+
...FEATURE_ANNOTATION_SCHEMA.properties,
|
|
140
|
+
feature: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
enum: [
|
|
143
|
+
'responseSchema',
|
|
144
|
+
'documents',
|
|
145
|
+
'stateless',
|
|
146
|
+
'validation',
|
|
147
|
+
'scratch',
|
|
148
|
+
'compact',
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const APP_SPEC_SCHEMA = {
|
|
158
|
+
type: 'object',
|
|
159
|
+
required: [
|
|
160
|
+
'appName',
|
|
161
|
+
'moduleName',
|
|
162
|
+
'entities',
|
|
163
|
+
'relationships',
|
|
164
|
+
'events',
|
|
165
|
+
'workflows',
|
|
166
|
+
'agents',
|
|
167
|
+
],
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
properties: {
|
|
170
|
+
appName: { type: 'string' },
|
|
171
|
+
moduleName: { type: 'string' },
|
|
172
|
+
entities: { type: 'array', items: ENTITY_SCHEMA },
|
|
173
|
+
relationships: { type: 'array', items: RELATIONSHIP_SCHEMA },
|
|
174
|
+
events: { type: 'array', items: EVENT_SCHEMA },
|
|
175
|
+
workflows: { type: 'array', items: WORKFLOW_SCHEMA },
|
|
176
|
+
agents: { type: 'array', items: AGENT_SCHEMA },
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
@Injectable()
|
|
181
|
+
export class DesignGeneratorService {
|
|
182
|
+
private readonly logger = new Logger(DesignGeneratorService.name);
|
|
183
|
+
|
|
184
|
+
private readonly designTool: ToolDefinition = {
|
|
185
|
+
name: 'produce_design',
|
|
186
|
+
description:
|
|
187
|
+
'Produce the structured design allocating entities, relationships, events, workflows, and agents to exactly one app each.',
|
|
188
|
+
inputSchema: {
|
|
189
|
+
type: 'object',
|
|
190
|
+
required: ['baseline', 'subApps'],
|
|
191
|
+
additionalProperties: false,
|
|
192
|
+
properties: {
|
|
193
|
+
baseline: APP_SPEC_SCHEMA,
|
|
194
|
+
subApps: { type: 'array', items: APP_SPEC_SCHEMA },
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
constructor(
|
|
200
|
+
@Inject(CRAFT_LLM_PROVIDER)
|
|
201
|
+
@Optional()
|
|
202
|
+
private readonly llm: CraftLlmProvider | null,
|
|
203
|
+
) {}
|
|
204
|
+
|
|
205
|
+
async generateDesign(
|
|
206
|
+
kbContent: string,
|
|
207
|
+
projectName: string,
|
|
208
|
+
decomposition: DecompositionResult,
|
|
209
|
+
requirements?: RequirementsResult,
|
|
210
|
+
): Promise<DesignResult> {
|
|
211
|
+
if (!this.llm) throw new Error('LLM provider not configured');
|
|
212
|
+
|
|
213
|
+
this.logger.log(`Generating design for "${projectName}"`);
|
|
214
|
+
const baselineAppName = requirements?.baseline.appName;
|
|
215
|
+
const systemPrompt = this.buildDesignPrompt(
|
|
216
|
+
projectName,
|
|
217
|
+
decomposition,
|
|
218
|
+
baselineAppName,
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const userParts = [`## Knowledge Base\n\n${kbContent}`];
|
|
222
|
+
if (requirements) {
|
|
223
|
+
userParts.push('', '## Detailed Requirements Per App', '');
|
|
224
|
+
userParts.push(`### Baseline: ${requirements.baseline.appName}`);
|
|
225
|
+
userParts.push(requirements.baseline.requirements);
|
|
226
|
+
for (const sub of requirements.subApps) {
|
|
227
|
+
userParts.push('', `### Sub-app: ${sub.appName}`);
|
|
228
|
+
userParts.push(sub.requirements);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const response = await this.llm.chat({
|
|
233
|
+
system: systemPrompt,
|
|
234
|
+
messages: [{ role: 'user', content: userParts.join('\n') }],
|
|
235
|
+
maxTokens: 64000,
|
|
236
|
+
tools: [this.designTool],
|
|
237
|
+
toolChoice: { type: 'tool', name: 'produce_design' },
|
|
238
|
+
cacheControl: true,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
this.logger.log(
|
|
242
|
+
`LLM response received (toolCalls: ${response.toolCalls?.length ?? 0}, truncated: ${response.truncated ?? false})`,
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
if (response.truncated) {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`Design generation was truncated (output tokens: ${response.usage?.outputTokens ?? '?'}).`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const toolCall = response.toolCalls?.[0];
|
|
252
|
+
if (toolCall) {
|
|
253
|
+
this.logger.log('Parsing design from tool call');
|
|
254
|
+
return this.parseToolCallInput(
|
|
255
|
+
toolCall.input,
|
|
256
|
+
projectName,
|
|
257
|
+
decomposition,
|
|
258
|
+
baselineAppName,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Fallback: parse text
|
|
263
|
+
const text = response.content
|
|
264
|
+
.filter((b) => b.type === 'text')
|
|
265
|
+
.map((b) => b.text)
|
|
266
|
+
.join('');
|
|
267
|
+
return this.parseDesignResponse(
|
|
268
|
+
text,
|
|
269
|
+
projectName,
|
|
270
|
+
decomposition,
|
|
271
|
+
baselineAppName,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private buildDesignPrompt(
|
|
276
|
+
projectName: string,
|
|
277
|
+
decomposition: DecompositionResult,
|
|
278
|
+
baselineAppName?: string,
|
|
279
|
+
): string {
|
|
280
|
+
const baseAppName = baselineAppName ?? kebabToPascalCase(projectName);
|
|
281
|
+
const baseModuleName = `${baseAppName}.core`;
|
|
282
|
+
|
|
283
|
+
const subAppEntries = decomposition.subApps
|
|
284
|
+
.map((s) => ` - "${s.name}" (module: ${s.name}.core): ${s.description}`)
|
|
285
|
+
.join('\n');
|
|
286
|
+
|
|
287
|
+
return `You are an application architect. You have already decomposed an application into a baseline data model and sub-apps. Now you must produce a detailed design — a structured allocation of every entity, relationship, event, workflow, and agent to exactly one app, with design rationale.
|
|
288
|
+
|
|
289
|
+
${SEMANTICS_GUIDE}
|
|
290
|
+
|
|
291
|
+
## Decomposition
|
|
292
|
+
|
|
293
|
+
**Baseline**: ${decomposition.baselineDescription}
|
|
294
|
+
|
|
295
|
+
**Sub-apps**:
|
|
296
|
+
${subAppEntries}
|
|
297
|
+
|
|
298
|
+
## Rules
|
|
299
|
+
|
|
300
|
+
1. Every entity, relationship, event, workflow, and agent must belong to exactly ONE app — no duplication across apps.
|
|
301
|
+
2. The **baseline app** ("${baseAppName}", module \`${baseModuleName}\`) contains ONLY shared entities and relationships. No events, no workflows, no agents.
|
|
302
|
+
3. Each **sub-app** contains its own LOCAL entities, relationships, events, workflows, and agents.
|
|
303
|
+
4. If a sub-app needs a baseline entity, it references it — it does NOT get a copy.
|
|
304
|
+
5. Entity names must be PascalCase.
|
|
305
|
+
6. Event names must be PascalCase.
|
|
306
|
+
7. Agent names must be PascalCase ending in "Agent".
|
|
307
|
+
8. Relationship names must be PascalCase.
|
|
308
|
+
9. For event-driven workflows, the workflow name must match the event name exactly. For lifecycle trigger workflows, provide \`triggerOn\`.
|
|
309
|
+
10. For each relationship, choose \`contains\` or \`between\` and explain WHY.
|
|
310
|
+
11. For each workflow, describe what it does and which entities it reads/writes.
|
|
311
|
+
12. For each agent, provide a goal explaining its high-level objective.
|
|
312
|
+
13. For agent tools, list entity names, relationship names, and event names the agent needs.
|
|
313
|
+
14. For each entity, include \`features\` if it needs entity-level capabilities.
|
|
314
|
+
15. For self-referencing relationships, provide \`roleAliases\`.
|
|
315
|
+
16. If a workflow requires role-based access control, provide \`withRole\`.
|
|
316
|
+
17. For each agent, include \`capabilities\` if it needs special features.
|
|
317
|
+
|
|
318
|
+
Call the \`produce_design\` tool with the complete design.`;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private parseToolCallInput(
|
|
322
|
+
input: unknown,
|
|
323
|
+
projectName: string,
|
|
324
|
+
decomposition: DecompositionResult,
|
|
325
|
+
baselineAppName?: string,
|
|
326
|
+
): DesignResult {
|
|
327
|
+
if (!input || typeof input !== 'object') {
|
|
328
|
+
throw new Error('Design tool call input is not an object.');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const obj = input as Record<string, unknown>;
|
|
332
|
+
const baseAppName = baselineAppName ?? kebabToPascalCase(projectName);
|
|
333
|
+
const baseline = this.parseAppSpec(
|
|
334
|
+
obj.baseline,
|
|
335
|
+
baseAppName,
|
|
336
|
+
`${baseAppName}.core`,
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const subAppsRaw = obj.subApps ?? obj.sub_apps ?? obj.subapps;
|
|
340
|
+
if (!Array.isArray(subAppsRaw)) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
`Design tool call must include a subApps array. Got keys: ${Object.keys(obj).join(', ')}`,
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const subApps: AppSpec[] = subAppsRaw.map((s: unknown, i: number) => {
|
|
347
|
+
const fallbackName = decomposition.subApps[i]?.name ?? `SubApp${i + 1}`;
|
|
348
|
+
return this.parseAppSpec(s, fallbackName, `${fallbackName}.core`);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
return { baseline, subApps };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
parseDesignResponse(
|
|
355
|
+
response: string,
|
|
356
|
+
projectName: string,
|
|
357
|
+
decomposition: DecompositionResult,
|
|
358
|
+
baselineAppName?: string,
|
|
359
|
+
): DesignResult {
|
|
360
|
+
let json = response.trim();
|
|
361
|
+
json = json.replace(/^```(?:json)?\s*\n?/i, '').replace(/\n?```\s*$/i, '');
|
|
362
|
+
const braceIdx = json.indexOf('{');
|
|
363
|
+
if (braceIdx > 0) json = json.slice(braceIdx);
|
|
364
|
+
|
|
365
|
+
let parsed: unknown;
|
|
366
|
+
try {
|
|
367
|
+
parsed = JSON.parse(json);
|
|
368
|
+
} catch {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`Failed to parse design JSON from LLM response.\nResponse starts with: ${response.slice(0, 200)}`,
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return this.parseToolCallInput(
|
|
375
|
+
parsed,
|
|
376
|
+
projectName,
|
|
377
|
+
decomposition,
|
|
378
|
+
baselineAppName,
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private parseAppSpec(
|
|
383
|
+
raw: unknown,
|
|
384
|
+
fallbackName: string,
|
|
385
|
+
fallbackModule: string,
|
|
386
|
+
): AppSpec {
|
|
387
|
+
if (!raw || typeof raw !== 'object') {
|
|
388
|
+
throw new Error(
|
|
389
|
+
`Design app spec for "${fallbackName}" is not an object.`,
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const obj = raw as Record<string, unknown>;
|
|
394
|
+
const appName =
|
|
395
|
+
typeof obj.appName === 'string' ? obj.appName : fallbackName;
|
|
396
|
+
const dirName = pascalToKebabCase(appName);
|
|
397
|
+
const moduleName =
|
|
398
|
+
typeof obj.moduleName === 'string' ? obj.moduleName : fallbackModule;
|
|
399
|
+
|
|
400
|
+
const entities: EntitySpec[] = Array.isArray(obj.entities)
|
|
401
|
+
? obj.entities
|
|
402
|
+
.map((e: unknown) => {
|
|
403
|
+
const eo = e as Record<string, unknown>;
|
|
404
|
+
const features: FeatureAnnotation[] = Array.isArray(eo.features)
|
|
405
|
+
? eo.features
|
|
406
|
+
.map((f: unknown) => {
|
|
407
|
+
const fo = f as Record<string, unknown>;
|
|
408
|
+
return {
|
|
409
|
+
feature: typeof fo.feature === 'string' ? fo.feature : '',
|
|
410
|
+
rationale:
|
|
411
|
+
typeof fo.rationale === 'string' ? fo.rationale : '',
|
|
412
|
+
};
|
|
413
|
+
})
|
|
414
|
+
.filter((f) => f.feature)
|
|
415
|
+
: [];
|
|
416
|
+
return {
|
|
417
|
+
name: typeof eo.name === 'string' ? eo.name : '',
|
|
418
|
+
description:
|
|
419
|
+
typeof eo.description === 'string' ? eo.description : '',
|
|
420
|
+
features,
|
|
421
|
+
};
|
|
422
|
+
})
|
|
423
|
+
.filter((e) => e.name)
|
|
424
|
+
: [];
|
|
425
|
+
|
|
426
|
+
const relationships: RelationshipSpec[] = Array.isArray(obj.relationships)
|
|
427
|
+
? obj.relationships
|
|
428
|
+
.map((r: unknown) => {
|
|
429
|
+
const ro = r as Record<string, unknown>;
|
|
430
|
+
const between: [string, string] =
|
|
431
|
+
Array.isArray(ro.between) && ro.between.length >= 2
|
|
432
|
+
? [String(ro.between[0]), String(ro.between[1])]
|
|
433
|
+
: ['', ''];
|
|
434
|
+
const type =
|
|
435
|
+
typeof ro.type === 'string' &&
|
|
436
|
+
['one_one', 'one_many', 'many_many'].includes(ro.type)
|
|
437
|
+
? (ro.type as RelationshipSpec['type'])
|
|
438
|
+
: 'one_many';
|
|
439
|
+
const kind =
|
|
440
|
+
typeof ro.kind === 'string' &&
|
|
441
|
+
['contains', 'between'].includes(ro.kind)
|
|
442
|
+
? (ro.kind as 'contains' | 'between')
|
|
443
|
+
: 'between';
|
|
444
|
+
const spec: RelationshipSpec = {
|
|
445
|
+
name: typeof ro.name === 'string' ? ro.name : '',
|
|
446
|
+
between,
|
|
447
|
+
type,
|
|
448
|
+
kind,
|
|
449
|
+
rationale: typeof ro.rationale === 'string' ? ro.rationale : '',
|
|
450
|
+
};
|
|
451
|
+
if (Array.isArray(ro.roleAliases) && ro.roleAliases.length >= 2) {
|
|
452
|
+
spec.roleAliases = [
|
|
453
|
+
String(ro.roleAliases[0]),
|
|
454
|
+
String(ro.roleAliases[1]),
|
|
455
|
+
];
|
|
456
|
+
}
|
|
457
|
+
if (ro.hasSchema === true) {
|
|
458
|
+
spec.hasSchema = true;
|
|
459
|
+
if (typeof ro.hasSchemaRationale === 'string') {
|
|
460
|
+
spec.hasSchemaRationale = ro.hasSchemaRationale;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return spec;
|
|
464
|
+
})
|
|
465
|
+
.filter((r) => r.name)
|
|
466
|
+
: [];
|
|
467
|
+
|
|
468
|
+
const events: EventSpec[] = Array.isArray(obj.events)
|
|
469
|
+
? obj.events
|
|
470
|
+
.map((e: unknown) => {
|
|
471
|
+
const eo = e as Record<string, unknown>;
|
|
472
|
+
return {
|
|
473
|
+
name: typeof eo.name === 'string' ? eo.name : '',
|
|
474
|
+
public: eo.public === true,
|
|
475
|
+
description:
|
|
476
|
+
typeof eo.description === 'string' ? eo.description : '',
|
|
477
|
+
};
|
|
478
|
+
})
|
|
479
|
+
.filter((e) => e.name)
|
|
480
|
+
: [];
|
|
481
|
+
|
|
482
|
+
const workflows: WorkflowSpec[] = Array.isArray(obj.workflows)
|
|
483
|
+
? obj.workflows
|
|
484
|
+
.map((w: unknown) => {
|
|
485
|
+
const wo = w as Record<string, unknown>;
|
|
486
|
+
const spec: WorkflowSpec = {
|
|
487
|
+
name: typeof wo.name === 'string' ? wo.name : '',
|
|
488
|
+
description:
|
|
489
|
+
typeof wo.description === 'string' ? wo.description : '',
|
|
490
|
+
dataTouched: Array.isArray(wo.dataTouched)
|
|
491
|
+
? wo.dataTouched.filter(
|
|
492
|
+
(d): d is string => typeof d === 'string',
|
|
493
|
+
)
|
|
494
|
+
: [],
|
|
495
|
+
};
|
|
496
|
+
if (wo.triggerOn && typeof wo.triggerOn === 'object') {
|
|
497
|
+
const t = wo.triggerOn as Record<string, unknown>;
|
|
498
|
+
const timing = String(t.timing ?? '');
|
|
499
|
+
const operation = String(t.operation ?? '');
|
|
500
|
+
const entity = String(t.entity ?? '');
|
|
501
|
+
if (
|
|
502
|
+
['before', 'after'].includes(timing) &&
|
|
503
|
+
['create', 'update', 'delete'].includes(operation) &&
|
|
504
|
+
entity
|
|
505
|
+
) {
|
|
506
|
+
spec.triggerOn = {
|
|
507
|
+
timing: timing as 'before' | 'after',
|
|
508
|
+
operation: operation as 'create' | 'update' | 'delete',
|
|
509
|
+
entity,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (typeof wo.withRole === 'string' && wo.withRole) {
|
|
514
|
+
spec.withRole = wo.withRole;
|
|
515
|
+
}
|
|
516
|
+
return spec;
|
|
517
|
+
})
|
|
518
|
+
.filter((w) => w.name)
|
|
519
|
+
: [];
|
|
520
|
+
|
|
521
|
+
const agents: AgentSpec[] = Array.isArray(obj.agents)
|
|
522
|
+
? obj.agents
|
|
523
|
+
.map((a: unknown) => {
|
|
524
|
+
const ao = a as Record<string, unknown>;
|
|
525
|
+
const capabilities: FeatureAnnotation[] = Array.isArray(
|
|
526
|
+
ao.capabilities,
|
|
527
|
+
)
|
|
528
|
+
? ao.capabilities
|
|
529
|
+
.map((c: unknown) => {
|
|
530
|
+
const co = c as Record<string, unknown>;
|
|
531
|
+
return {
|
|
532
|
+
feature:
|
|
533
|
+
typeof co.feature === 'string'
|
|
534
|
+
? co.feature
|
|
535
|
+
: typeof co.capability === 'string'
|
|
536
|
+
? co.capability
|
|
537
|
+
: '',
|
|
538
|
+
rationale:
|
|
539
|
+
typeof co.rationale === 'string' ? co.rationale : '',
|
|
540
|
+
};
|
|
541
|
+
})
|
|
542
|
+
.filter((c) => c.feature)
|
|
543
|
+
: [];
|
|
544
|
+
return {
|
|
545
|
+
name: typeof ao.name === 'string' ? ao.name : '',
|
|
546
|
+
description:
|
|
547
|
+
typeof ao.description === 'string' ? ao.description : '',
|
|
548
|
+
goal: typeof ao.goal === 'string' ? ao.goal : '',
|
|
549
|
+
tools: Array.isArray(ao.tools)
|
|
550
|
+
? ao.tools.filter((t): t is string => typeof t === 'string')
|
|
551
|
+
: [],
|
|
552
|
+
capabilities,
|
|
553
|
+
};
|
|
554
|
+
})
|
|
555
|
+
.filter((a) => a.name)
|
|
556
|
+
: [];
|
|
557
|
+
|
|
558
|
+
return {
|
|
559
|
+
appName,
|
|
560
|
+
dirName,
|
|
561
|
+
moduleName,
|
|
562
|
+
entities,
|
|
563
|
+
relationships,
|
|
564
|
+
events,
|
|
565
|
+
workflows,
|
|
566
|
+
agents,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export function designSpecToDescription(
|
|
572
|
+
spec: AppSpec,
|
|
573
|
+
baselineSpec?: AppSpec,
|
|
574
|
+
): string {
|
|
575
|
+
const parts: string[] = [];
|
|
576
|
+
|
|
577
|
+
parts.push(
|
|
578
|
+
`Generate code for the "${spec.appName}" app (module: ${spec.moduleName}).`,
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
if (spec.entities.length > 0) {
|
|
582
|
+
parts.push('', '## Entities', '');
|
|
583
|
+
for (const e of spec.entities) {
|
|
584
|
+
parts.push(`- **${e.name}**: ${e.description}`);
|
|
585
|
+
if (e.features.length > 0) {
|
|
586
|
+
for (const f of e.features) {
|
|
587
|
+
parts.push(` - ${f.feature}: ${f.rationale}`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (spec.relationships.length > 0) {
|
|
594
|
+
parts.push('', '## Relationships', '');
|
|
595
|
+
for (const r of spec.relationships) {
|
|
596
|
+
parts.push(
|
|
597
|
+
`- **${r.name}** (${r.kind}): ${r.between[0]} → ${r.between[1]} (@${r.type})`,
|
|
598
|
+
);
|
|
599
|
+
if (r.rationale) parts.push(` Rationale: ${r.rationale}`);
|
|
600
|
+
if (r.roleAliases)
|
|
601
|
+
parts.push(
|
|
602
|
+
` Role aliases: ${r.between[0]} @as ${r.roleAliases[0]}, ${r.between[1]} @as ${r.roleAliases[1]}`,
|
|
603
|
+
);
|
|
604
|
+
if (r.hasSchema)
|
|
605
|
+
parts.push(
|
|
606
|
+
` Has schema: yes${r.hasSchemaRationale ? ` — ${r.hasSchemaRationale}` : ''}`,
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (spec.events.length > 0) {
|
|
612
|
+
parts.push('', '## Events', '');
|
|
613
|
+
for (const e of spec.events) {
|
|
614
|
+
const pub = e.public ? ' (@public)' : '';
|
|
615
|
+
parts.push(`- **${e.name}**${pub}: ${e.description}`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (spec.workflows.length > 0) {
|
|
620
|
+
parts.push('', '## Workflows', '');
|
|
621
|
+
for (const w of spec.workflows) {
|
|
622
|
+
if (w.triggerOn) {
|
|
623
|
+
parts.push(
|
|
624
|
+
`- **${w.name}** (trigger: @${w.triggerOn.timing} ${w.triggerOn.operation} ${w.triggerOn.entity}): ${w.description}`,
|
|
625
|
+
);
|
|
626
|
+
} else {
|
|
627
|
+
parts.push(`- **${w.name}**: ${w.description}`);
|
|
628
|
+
}
|
|
629
|
+
if (w.withRole) parts.push(` Requires role: ${w.withRole}`);
|
|
630
|
+
if (w.dataTouched.length > 0)
|
|
631
|
+
parts.push(` Data touched: ${w.dataTouched.join(', ')}`);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (spec.agents.length > 0) {
|
|
636
|
+
parts.push('', '## Agents', '');
|
|
637
|
+
for (const a of spec.agents) {
|
|
638
|
+
parts.push(`- **${a.name}**: ${a.description}`);
|
|
639
|
+
if (a.goal) parts.push(` Goal: ${a.goal}`);
|
|
640
|
+
if (a.tools.length > 0) parts.push(` Tools: ${a.tools.join(', ')}`);
|
|
641
|
+
if (a.capabilities.length > 0) {
|
|
642
|
+
for (const c of a.capabilities) {
|
|
643
|
+
parts.push(` - ${c.feature}: ${c.rationale}`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (baselineSpec && baselineSpec.entities.length > 0) {
|
|
650
|
+
parts.push(
|
|
651
|
+
'',
|
|
652
|
+
'## Baseline Entities (DO NOT redefine — reference only)',
|
|
653
|
+
'',
|
|
654
|
+
);
|
|
655
|
+
parts.push(
|
|
656
|
+
`The baseline module \`${baselineSpec.moduleName}\` provides these shared entities:`,
|
|
657
|
+
);
|
|
658
|
+
for (const e of baselineSpec.entities) {
|
|
659
|
+
parts.push(`- ${e.name}: ${e.description}`);
|
|
660
|
+
}
|
|
661
|
+
parts.push(
|
|
662
|
+
'',
|
|
663
|
+
'Reference them using fully-qualified names, e.g. `' +
|
|
664
|
+
baselineSpec.moduleName.replace('.core', '') +
|
|
665
|
+
'.core/' +
|
|
666
|
+
baselineSpec.entities[0].name +
|
|
667
|
+
'`',
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return parts.join('\n');
|
|
672
|
+
}
|