@bluefly/openstandardagents 0.4.0 → 0.4.2
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/CHANGELOG.md +137 -0
- package/DEMO.md +212 -0
- package/README.md +77 -17
- package/dist/adapters/drupal/generator.d.ts +149 -0
- package/dist/adapters/drupal/generator.d.ts.map +1 -0
- package/dist/adapters/drupal/generator.js +1760 -0
- package/dist/adapters/drupal/generator.js.map +1 -0
- package/dist/adapters/drupal/index.d.ts +2 -0
- package/dist/adapters/drupal/index.d.ts.map +1 -1
- package/dist/adapters/drupal/index.js +3 -0
- package/dist/adapters/drupal/index.js.map +1 -1
- package/dist/adapters/npm/adapter.js +2 -2
- package/dist/adapters/npm/converter.js +3 -3
- package/dist/cli/banner.d.ts +21 -0
- package/dist/cli/banner.d.ts.map +1 -0
- package/dist/cli/banner.js +128 -0
- package/dist/cli/banner.js.map +1 -0
- package/dist/cli/commands/dev.command.d.ts +20 -0
- package/dist/cli/commands/dev.command.d.ts.map +1 -0
- package/dist/cli/commands/dev.command.js +78 -0
- package/dist/cli/commands/dev.command.js.map +1 -0
- package/dist/cli/commands/estimate.command.d.ts +12 -0
- package/dist/cli/commands/estimate.command.d.ts.map +1 -0
- package/dist/cli/commands/estimate.command.js +226 -0
- package/dist/cli/commands/estimate.command.js.map +1 -0
- package/dist/cli/commands/export-enhanced.command.d.ts +7 -0
- package/dist/cli/commands/export-enhanced.command.d.ts.map +1 -0
- package/dist/cli/commands/{export-v2.command.js → export-enhanced.command.js} +3 -3
- package/dist/cli/commands/export-enhanced.command.js.map +1 -0
- package/dist/cli/commands/export.command.d.ts.map +1 -1
- package/dist/cli/commands/export.command.js +82 -4
- package/dist/cli/commands/export.command.js.map +1 -1
- package/dist/cli/commands/init.command.d.ts.map +1 -1
- package/dist/cli/commands/init.command.js +2 -0
- package/dist/cli/commands/init.command.js.map +1 -1
- package/dist/cli/commands/test.command.d.ts +1 -0
- package/dist/cli/commands/test.command.d.ts.map +1 -1
- package/dist/cli/commands/test.command.js +172 -105
- package/dist/cli/commands/test.command.js.map +1 -1
- package/dist/cli/commands/types/wizard-config.types.d.ts +59 -0
- package/dist/cli/commands/types/wizard-config.types.d.ts.map +1 -0
- package/dist/cli/commands/types/wizard-config.types.js +34 -0
- package/dist/cli/commands/types/wizard-config.types.js.map +1 -0
- package/dist/cli/commands/upgrade.command.d.ts +9 -0
- package/dist/cli/commands/upgrade.command.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.command.js +167 -0
- package/dist/cli/commands/upgrade.command.js.map +1 -0
- package/dist/cli/commands/wizard-api-first.command.d.ts +18 -0
- package/dist/cli/commands/wizard-api-first.command.d.ts.map +1 -0
- package/dist/cli/commands/wizard-api-first.command.js +854 -0
- package/dist/cli/commands/wizard-api-first.command.js.map +1 -0
- package/dist/cli/commands/wizard-interactive.command.d.ts +25 -0
- package/dist/cli/commands/wizard-interactive.command.d.ts.map +1 -0
- package/dist/cli/commands/wizard-interactive.command.js +1875 -0
- package/dist/cli/commands/wizard-interactive.command.js.map +1 -0
- package/dist/cli/commands/workspace.command.js +1 -1
- package/dist/cli/commands/workspace.command.js.map +1 -1
- package/dist/cli/index.js +9 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/schema-driven/index.d.ts +27 -0
- package/dist/cli/schema-driven/index.d.ts.map +1 -0
- package/dist/cli/schema-driven/index.js +34 -0
- package/dist/cli/schema-driven/index.js.map +1 -0
- package/dist/cli/schema-driven/schema-loader.d.ts +115 -0
- package/dist/cli/schema-driven/schema-loader.d.ts.map +1 -0
- package/dist/cli/schema-driven/schema-loader.js +270 -0
- package/dist/cli/schema-driven/schema-loader.js.map +1 -0
- package/dist/cli/schema-driven/ui-generator.d.ts +88 -0
- package/dist/cli/schema-driven/ui-generator.d.ts.map +1 -0
- package/dist/cli/schema-driven/ui-generator.js +326 -0
- package/dist/cli/schema-driven/ui-generator.js.map +1 -0
- package/dist/cli/wizard/interactive-wizard.d.ts +26 -0
- package/dist/cli/wizard/interactive-wizard.d.ts.map +1 -0
- package/dist/cli/wizard/interactive-wizard.js +296 -0
- package/dist/cli/wizard/interactive-wizard.js.map +1 -0
- package/dist/cli/wizard/template-catalog.d.ts +32 -0
- package/dist/cli/wizard/template-catalog.d.ts.map +1 -0
- package/dist/cli/wizard/template-catalog.js +99 -0
- package/dist/cli/wizard/template-catalog.js.map +1 -0
- package/dist/cli/wizard/use-cases.d.ts +37 -0
- package/dist/cli/wizard/use-cases.d.ts.map +1 -0
- package/dist/cli/wizard/use-cases.js +157 -0
- package/dist/cli/wizard/use-cases.js.map +1 -0
- package/dist/di-container.d.ts.map +1 -1
- package/dist/di-container.js +2 -0
- package/dist/di-container.js.map +1 -1
- package/dist/package.json +33 -11
- package/dist/runtime/agent-runner.d.ts +46 -0
- package/dist/runtime/agent-runner.d.ts.map +1 -0
- package/dist/runtime/agent-runner.js +346 -0
- package/dist/runtime/agent-runner.js.map +1 -0
- package/dist/sdks/kagent/crd-generator.d.ts +4 -0
- package/dist/sdks/kagent/crd-generator.d.ts.map +1 -1
- package/dist/sdks/kagent/crd-generator.js +83 -2
- package/dist/sdks/kagent/crd-generator.js.map +1 -1
- package/dist/sdks/kagent/k8s-resources-generator.d.ts +73 -0
- package/dist/sdks/kagent/k8s-resources-generator.d.ts.map +1 -0
- package/dist/sdks/kagent/k8s-resources-generator.js +286 -0
- package/dist/sdks/kagent/k8s-resources-generator.js.map +1 -0
- package/dist/sdks/kagent/types.d.ts +79 -0
- package/dist/sdks/kagent/types.d.ts.map +1 -1
- package/dist/sdks/shared/validation.d.ts +2 -2
- package/dist/services/cost-estimation/optimization-patterns.d.ts +23 -0
- package/dist/services/cost-estimation/optimization-patterns.d.ts.map +1 -0
- package/dist/services/cost-estimation/optimization-patterns.js +147 -0
- package/dist/services/cost-estimation/optimization-patterns.js.map +1 -0
- package/dist/services/cost-estimation/pricing.d.ts +29 -0
- package/dist/services/cost-estimation/pricing.d.ts.map +1 -0
- package/dist/services/cost-estimation/pricing.js +225 -0
- package/dist/services/cost-estimation/pricing.js.map +1 -0
- package/dist/services/cost-estimation/scenario-estimator.d.ts +59 -0
- package/dist/services/cost-estimation/scenario-estimator.d.ts.map +1 -0
- package/dist/services/cost-estimation/scenario-estimator.js +145 -0
- package/dist/services/cost-estimation/scenario-estimator.js.map +1 -0
- package/dist/services/cost-estimation/token-counter.service.d.ts +51 -0
- package/dist/services/cost-estimation/token-counter.service.d.ts.map +1 -0
- package/dist/services/cost-estimation/token-counter.service.js +125 -0
- package/dist/services/cost-estimation/token-counter.service.js.map +1 -0
- package/dist/services/dev-server/dev-server.service.d.ts +121 -0
- package/dist/services/dev-server/dev-server.service.d.ts.map +1 -0
- package/dist/services/dev-server/dev-server.service.js +290 -0
- package/dist/services/dev-server/dev-server.service.js.map +1 -0
- package/dist/services/dev-server/file-watcher.d.ts +101 -0
- package/dist/services/dev-server/file-watcher.d.ts.map +1 -0
- package/dist/services/dev-server/file-watcher.js +190 -0
- package/dist/services/dev-server/file-watcher.js.map +1 -0
- package/dist/services/dev-server/live-validator.d.ts +157 -0
- package/dist/services/dev-server/live-validator.d.ts.map +1 -0
- package/dist/services/dev-server/live-validator.js +301 -0
- package/dist/services/dev-server/live-validator.js.map +1 -0
- package/dist/services/dev-server/websocket-server.d.ts +137 -0
- package/dist/services/dev-server/websocket-server.d.ts.map +1 -0
- package/dist/services/dev-server/websocket-server.js +229 -0
- package/dist/services/dev-server/websocket-server.js.map +1 -0
- package/dist/services/export/anthropic/anthropic-exporter.d.ts +70 -0
- package/dist/services/export/anthropic/anthropic-exporter.d.ts.map +1 -0
- package/dist/services/export/anthropic/anthropic-exporter.js +576 -0
- package/dist/services/export/anthropic/anthropic-exporter.js.map +1 -0
- package/dist/services/export/anthropic/api-generator.d.ts +39 -0
- package/dist/services/export/anthropic/api-generator.d.ts.map +1 -0
- package/dist/services/export/anthropic/api-generator.js +395 -0
- package/dist/services/export/anthropic/api-generator.js.map +1 -0
- package/dist/services/export/anthropic/index.d.ts +18 -0
- package/dist/services/export/anthropic/index.d.ts.map +1 -0
- package/dist/services/export/anthropic/index.js +16 -0
- package/dist/services/export/anthropic/index.js.map +1 -0
- package/dist/services/export/anthropic/tools-generator.d.ts +35 -0
- package/dist/services/export/anthropic/tools-generator.d.ts.map +1 -0
- package/dist/services/export/anthropic/tools-generator.js +260 -0
- package/dist/services/export/anthropic/tools-generator.js.map +1 -0
- package/dist/services/export/langchain/api-generator.d.ts +17 -0
- package/dist/services/export/langchain/api-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/api-generator.js +375 -0
- package/dist/services/export/langchain/api-generator.js.map +1 -0
- package/dist/services/export/langchain/callbacks-generator.d.ts +63 -0
- package/dist/services/export/langchain/callbacks-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/callbacks-generator.js +408 -0
- package/dist/services/export/langchain/callbacks-generator.js.map +1 -0
- package/dist/services/export/langchain/error-handling-generator.d.ts +76 -0
- package/dist/services/export/langchain/error-handling-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/error-handling-generator.js +522 -0
- package/dist/services/export/langchain/error-handling-generator.js.map +1 -0
- package/dist/services/export/langchain/index.d.ts +17 -0
- package/dist/services/export/langchain/index.d.ts.map +1 -0
- package/dist/services/export/langchain/index.js +13 -0
- package/dist/services/export/langchain/index.js.map +1 -0
- package/dist/services/export/langchain/langchain-exporter.d.ts +174 -0
- package/dist/services/export/langchain/langchain-exporter.d.ts.map +1 -0
- package/dist/services/export/langchain/langchain-exporter.js +953 -0
- package/dist/services/export/langchain/langchain-exporter.js.map +1 -0
- package/dist/services/export/langchain/langgraph-generator.d.ts +86 -0
- package/dist/services/export/langchain/langgraph-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/langgraph-generator.js +473 -0
- package/dist/services/export/langchain/langgraph-generator.js.map +1 -0
- package/dist/services/export/langchain/langserve-generator.d.ts +95 -0
- package/dist/services/export/langchain/langserve-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/langserve-generator.js +807 -0
- package/dist/services/export/langchain/langserve-generator.js.map +1 -0
- package/dist/services/export/langchain/memory-generator.d.ts +71 -0
- package/dist/services/export/langchain/memory-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/memory-generator.js +1182 -0
- package/dist/services/export/langchain/memory-generator.js.map +1 -0
- package/dist/services/export/langchain/openapi-generator.d.ts +20 -0
- package/dist/services/export/langchain/openapi-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/openapi-generator.js +364 -0
- package/dist/services/export/langchain/openapi-generator.js.map +1 -0
- package/dist/services/export/langchain/plan-execute-generator.d.ts +60 -0
- package/dist/services/export/langchain/plan-execute-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/plan-execute-generator.js +679 -0
- package/dist/services/export/langchain/plan-execute-generator.js.map +1 -0
- package/dist/services/export/langchain/streaming-generator.d.ts +66 -0
- package/dist/services/export/langchain/streaming-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/streaming-generator.js +749 -0
- package/dist/services/export/langchain/streaming-generator.js.map +1 -0
- package/dist/services/export/langchain/tools-generator.d.ts +67 -0
- package/dist/services/export/langchain/tools-generator.d.ts.map +1 -0
- package/dist/services/export/langchain/tools-generator.js +543 -0
- package/dist/services/export/langchain/tools-generator.js.map +1 -0
- package/dist/services/export/npm/express-generator.d.ts +23 -0
- package/dist/services/export/npm/express-generator.d.ts.map +1 -0
- package/dist/services/export/npm/express-generator.js +296 -0
- package/dist/services/export/npm/express-generator.js.map +1 -0
- package/dist/services/export/npm/index.d.ts +13 -0
- package/dist/services/export/npm/index.d.ts.map +1 -0
- package/dist/services/export/npm/index.js +11 -0
- package/dist/services/export/npm/index.js.map +1 -0
- package/dist/services/export/npm/npm-exporter.d.ts +142 -0
- package/dist/services/export/npm/npm-exporter.d.ts.map +1 -0
- package/dist/services/export/npm/npm-exporter.js +480 -0
- package/dist/services/export/npm/npm-exporter.js.map +1 -0
- package/dist/services/export/npm/openapi-generator.d.ts +19 -0
- package/dist/services/export/npm/openapi-generator.d.ts.map +1 -0
- package/dist/services/export/npm/openapi-generator.js +428 -0
- package/dist/services/export/npm/openapi-generator.js.map +1 -0
- package/dist/services/export/npm/package-json-generator.d.ts +31 -0
- package/dist/services/export/npm/package-json-generator.d.ts.map +1 -0
- package/dist/services/export/npm/package-json-generator.js +153 -0
- package/dist/services/export/npm/package-json-generator.js.map +1 -0
- package/dist/services/export/npm/typescript-generator.d.ts +69 -0
- package/dist/services/export/npm/typescript-generator.d.ts.map +1 -0
- package/dist/services/export/npm/typescript-generator.js +437 -0
- package/dist/services/export/npm/typescript-generator.js.map +1 -0
- package/dist/services/export/testing/index.d.ts +8 -0
- package/dist/services/export/testing/index.d.ts.map +1 -0
- package/dist/services/export/testing/index.js +7 -0
- package/dist/services/export/testing/index.js.map +1 -0
- package/dist/services/export/testing/test-generator.d.ts +178 -0
- package/dist/services/export/testing/test-generator.d.ts.map +1 -0
- package/dist/services/export/testing/test-generator.js +2542 -0
- package/dist/services/export/testing/test-generator.js.map +1 -0
- package/dist/services/test-runner/mock-llm.service.d.ts +77 -0
- package/dist/services/test-runner/mock-llm.service.d.ts.map +1 -0
- package/dist/services/test-runner/mock-llm.service.js +173 -0
- package/dist/services/test-runner/mock-llm.service.js.map +1 -0
- package/dist/services/test-runner/scenarios.d.ts +36 -0
- package/dist/services/test-runner/scenarios.d.ts.map +1 -0
- package/dist/services/test-runner/scenarios.js +196 -0
- package/dist/services/test-runner/scenarios.js.map +1 -0
- package/dist/services/test-runner/test-runner.service.d.ts +19 -1
- package/dist/services/test-runner/test-runner.service.d.ts.map +1 -1
- package/dist/services/test-runner/test-runner.service.js +72 -6
- package/dist/services/test-runner/test-runner.service.js.map +1 -1
- package/dist/services/validation/best-practices-validator.d.ts +84 -0
- package/dist/services/validation/best-practices-validator.d.ts.map +1 -0
- package/dist/services/validation/best-practices-validator.js +499 -0
- package/dist/services/validation/best-practices-validator.js.map +1 -0
- package/dist/services/validation/cost-estimator.d.ts +69 -0
- package/dist/services/validation/cost-estimator.d.ts.map +1 -0
- package/dist/services/validation/cost-estimator.js +221 -0
- package/dist/services/validation/cost-estimator.js.map +1 -0
- package/dist/services/validation/enhanced-validator.d.ts +78 -0
- package/dist/services/validation/enhanced-validator.d.ts.map +1 -0
- package/dist/services/validation/enhanced-validator.js +212 -0
- package/dist/services/validation/enhanced-validator.js.map +1 -0
- package/dist/services/validation/index.d.ts +13 -0
- package/dist/services/validation/index.d.ts.map +1 -0
- package/dist/services/validation/index.js +9 -0
- package/dist/services/validation/index.js.map +1 -0
- package/dist/services/validation/security-validator.d.ts +81 -0
- package/dist/services/validation/security-validator.d.ts.map +1 -0
- package/dist/services/validation/security-validator.js +328 -0
- package/dist/services/validation/security-validator.js.map +1 -0
- package/dist/services/wizard/prompts.d.ts +71 -0
- package/dist/services/wizard/prompts.d.ts.map +1 -0
- package/dist/services/wizard/prompts.js +322 -0
- package/dist/services/wizard/prompts.js.map +1 -0
- package/dist/services/wizard/wizard.service.d.ts +60 -0
- package/dist/services/wizard/wizard.service.d.ts.map +1 -0
- package/dist/services/wizard/wizard.service.js +261 -0
- package/dist/services/wizard/wizard.service.js.map +1 -0
- package/dist/types/personality.zod.d.ts +23 -23
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/version-management/core/version-manager.test.js.map +1 -1
- package/dist/version.d.ts +62 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +73 -0
- package/dist/version.js.map +1 -0
- package/examples/a2a/agent-handoff.ossa.yaml +1 -1
- package/examples/a2a/service-discovery.ossa.yaml +1 -1
- package/examples/adapters/drupal-eca-mapping.yaml +1 -1
- package/examples/adapters/drupal-eca-task.yaml +1 -1
- package/examples/adapters/drupal-flowdrop-mapping.yaml +1 -1
- package/examples/adapters/drupal-maestro-mapping.yaml +1 -1
- package/examples/adapters/mistral-agent.yaml +1 -1
- package/examples/adapters/symfony-messenger-task.yaml +1 -1
- package/examples/adapters/symfony-messenger-workflow.yaml +1 -1
- package/examples/adk-integration/code-review-workflow.yml +1 -1
- package/examples/adk-integration/customer-support.yml +1 -1
- package/examples/adk-integration/data-pipeline.yml +1 -1
- package/examples/advanced/reasoning-agent.yaml +1 -1
- package/examples/advanced/workflows/hybrid-model-strategy.yaml +1 -1
- package/examples/agent-manifests/critics/critic-agent.yaml +1 -1
- package/examples/agent-manifests/governors/governor-agent.yaml +1 -1
- package/examples/agent-manifests/integrators/integrator-agent.yaml +1 -1
- package/examples/agent-manifests/judges/judge-agent.yaml +1 -1
- package/examples/agent-manifests/monitors/monitor-agent.yaml +1 -1
- package/examples/agent-manifests/orchestrators/orchestrator-agent.yaml +1 -1
- package/examples/agent-manifests/sample-compliant-agent.yaml +1 -1
- package/examples/agent-manifests/workers/worker-agent.yaml +1 -1
- package/examples/agents/01-customer-support-bot/.env.example +32 -0
- package/examples/agents/01-customer-support-bot/Dockerfile +30 -0
- package/examples/agents/01-customer-support-bot/README.md +295 -0
- package/examples/agents/01-customer-support-bot/agent.ossa.yaml +172 -0
- package/examples/agents/01-customer-support-bot/docker-compose.yml +55 -0
- package/examples/agents/01-customer-support-bot/openapi.yaml +238 -0
- package/examples/agents/01-customer-support-bot/package.json +48 -0
- package/examples/agents/02-code-review-agent/README.md +72 -0
- package/examples/agents/02-code-review-agent/agent.ossa.yaml +239 -0
- package/examples/agents/02-code-review-agent/docker-compose.yml +22 -0
- package/examples/agents/02-code-review-agent/openapi.yaml +150 -0
- package/examples/agents/03-data-analysis-agent/README.md +51 -0
- package/examples/agents/03-data-analysis-agent/agent.ossa.yaml +97 -0
- package/examples/agents/03-data-analysis-agent/openapi.yaml +74 -0
- package/examples/agents/04-content-moderator/README.md +55 -0
- package/examples/agents/04-content-moderator/agent.ossa.yaml +131 -0
- package/examples/agents/04-content-moderator/openapi.yaml +50 -0
- package/examples/agents/05-sales-assistant/README.md +37 -0
- package/examples/agents/05-sales-assistant/agent.ossa.yaml +146 -0
- package/examples/agents/05-sales-assistant/openapi.yaml +59 -0
- package/examples/agents/06-devops-agent/README.md +39 -0
- package/examples/agents/06-devops-agent/agent.ossa.yaml +141 -0
- package/examples/agents/06-devops-agent/openapi.yaml +51 -0
- package/examples/agents/07-research-assistant/README.md +31 -0
- package/examples/agents/07-research-assistant/agent.ossa.yaml +119 -0
- package/examples/agents/07-research-assistant/openapi.yaml +56 -0
- package/examples/agents/08-email-triage-agent/README.md +33 -0
- package/examples/agents/08-email-triage-agent/agent.ossa.yaml +133 -0
- package/examples/agents/08-email-triage-agent/openapi.yaml +41 -0
- package/examples/agents/09-security-scanner/README.md +49 -0
- package/examples/agents/09-security-scanner/agent.ossa.yaml +174 -0
- package/examples/agents/09-security-scanner/openapi.yaml +46 -0
- package/examples/agents/10-meeting-assistant/README.md +53 -0
- package/examples/agents/10-meeting-assistant/agent.ossa.yaml +211 -0
- package/examples/agents/10-meeting-assistant/docker-compose.yml +27 -0
- package/examples/agents/10-meeting-assistant/openapi.yaml +131 -0
- package/examples/agents/COMPLETION_REPORT.txt +272 -0
- package/examples/agents/INDEX.md +296 -0
- package/examples/agents/README.md +452 -0
- package/examples/agents/SUMMARY.md +362 -0
- package/examples/agents/TEST_RESULTS.md +458 -0
- package/examples/agents/architecture-healer-enterprise.yaml +1 -1
- package/examples/agents/dependency-healer-npm.yaml +1 -1
- package/examples/agents/spec-healer-openapi.yaml +1 -1
- package/examples/agents/wiki-healer-production.yaml +1 -1
- package/examples/agents-md/code-agent.ossa.json +1 -1
- package/examples/agents-md/monorepo-agent.ossa.yaml +1 -1
- package/examples/anthropic/claude-assistant.ossa.json +1 -1
- package/examples/autogen/multi-agent.ossa.json +1 -1
- package/examples/autonomous-evolution/self-evolving-agent.ossa.yaml +1 -1
- package/examples/build-once-use-everywhere/agent.ossa.yaml +1 -1
- package/examples/claude-code/code-reviewer.ossa.yaml +1 -1
- package/examples/claude-code/ossa-validator.ossa.yaml +1 -1
- package/examples/common_npm/agent-router.ossa.yaml +2 -2
- package/examples/contracts/data-consumer.ossa.yaml +1 -1
- package/examples/contracts/data-producer-v2.ossa.yaml +1 -1
- package/examples/contracts/data-producer.ossa.yaml +1 -1
- package/examples/crewai/research-team.ossa.json +1 -1
- package/examples/cursor/code-review-agent.ossa.json +1 -1
- package/examples/drupal/QUICKSTART.md +439 -0
- package/examples/drupal/ai_agents_ossa-module/.agents/example-agent/agent.ossa.yaml +1 -1
- package/examples/drupal/content-moderator.ossa.yaml +107 -0
- package/examples/drupal/gitlab-ml-recommender.ossa.yaml +2 -2
- package/examples/economics/marketplace-agent.ossa.json +1 -1
- package/examples/export/langchain/production-agent-with-memory/README.md +373 -0
- package/examples/export/langchain/production-agent-with-memory/agent.ossa.yaml +97 -0
- package/examples/export/langchain/production-agent-with-streaming/README.md +617 -0
- package/examples/export/langchain/production-agent-with-streaming/agent.ossa.yaml +100 -0
- package/examples/export/langchain/production-agent-with-streaming/client-example.py +263 -0
- package/examples/export/langchain/production-agent-with-tools/README.md +296 -0
- package/examples/export/langchain/production-agent-with-tools/agent.ossa.yaml +216 -0
- package/examples/export/langchain-export-example.ts +246 -0
- package/examples/export/langserve-export-example.ts +246 -0
- package/examples/export/test-generation-example.ts +457 -0
- package/examples/extensions/agents-md-advanced.yml +1 -1
- package/examples/extensions/agents-md-basic.yml +1 -1
- package/examples/extensions/agents-md-sync.yml +1 -1
- package/examples/extensions/agents-md-v1.yml +1 -1
- package/examples/extensions/drupal-v1.yml +1 -1
- package/examples/extensions/encryption-multi-provider.yaml +4 -4
- package/examples/extensions/kagent-v1.yml +1 -1
- package/examples/extensions/knowledge-sources.yaml +1 -1
- package/examples/extensions/mcp-full-featured.yaml +1 -1
- package/examples/genetics/breeding-agent.ossa.json +1 -1
- package/examples/getting-started/01-minimal-agent.ossa.yaml +1 -1
- package/examples/getting-started/02-agent-with-tools.ossa.yaml +1 -1
- package/examples/getting-started/03-agent-with-safety.ossa.yaml +1 -1
- package/examples/getting-started/04-agent-with-messaging.ossa.yaml +1 -1
- package/examples/getting-started/05-workflow-composition.ossa.yaml +1 -1
- package/examples/getting-started/hello-world-complete.ossa.yaml +1 -1
- package/examples/integration-patterns/agent-to-agent-orchestration.ossa.yaml +1 -1
- package/examples/kagent/compliance-validator.ossa.yaml +1 -1
- package/examples/kagent/cost-optimizer.ossa.yaml +1 -1
- package/examples/kagent/documentation-agent.ossa.yaml +1 -1
- package/examples/kagent/k8s-troubleshooter-v1.ossa.yaml +2 -2
- package/examples/kagent/k8s-troubleshooter.ossa.yaml +1 -1
- package/examples/kagent/security-scanner.ossa.yaml +1 -1
- package/examples/langchain/chain-agent.ossa.json +1 -1
- package/examples/langflow/workflow-agent.ossa.json +1 -1
- package/examples/langgraph/state-machine-agent.ossa.json +1 -1
- package/examples/lifecycle/mentoring-agent.ossa.json +1 -1
- package/examples/llamaindex/rag-agent.ossa.json +1 -1
- package/examples/mcp/database-mcp.ossa.yaml +1 -1
- package/examples/mcp/filesystem-mcp.ossa.yaml +1 -1
- package/examples/messaging/dependency-healer.ossa.yaml +1 -1
- package/examples/messaging/incident-responder.ossa.yaml +1 -1
- package/examples/messaging/routing-rules.ossa.yaml +1 -1
- package/examples/messaging/security-scanner.ossa.yaml +1 -1
- package/examples/migration-guides/from-langchain-to-ossa.yaml +4 -4
- package/examples/migrations/langchain/01-python-react-agent-after.ossa.yaml +1 -1
- package/examples/migrations/langchain/02-typescript-conversational-after.ossa.yaml +1 -1
- package/examples/migrations/langchain/03-sequential-chain-after.ossa.yaml +1 -1
- package/examples/migrations/langchain/04-config-based-after.ossa.yaml +1 -1
- package/examples/migrations/swarm-to-ossa/after-handoffs.ossa.yaml +6 -6
- package/examples/migrations/swarm-to-ossa/after-triage-agent.ossa.yaml +3 -3
- package/examples/multi-agent/conditional-router.ossa.yaml +1 -1
- package/examples/multi-agent/parallel-execution.ossa.yaml +1 -1
- package/examples/multi-agent/sequential-pipeline.ossa.yaml +1 -1
- package/examples/multi-agent-research-workflow.ossa.yaml +133 -0
- package/examples/multi-platform/single-manifest/agent.ossa.yaml +1 -1
- package/examples/npm-export-example.ts +150 -0
- package/examples/observability/activity-stream-full.yaml +1 -1
- package/examples/openai/basic-agent.ossa.yaml +1 -1
- package/examples/openai/multi-tool-agent.ossa.json +1 -1
- package/examples/openai/swarm-agent.ossa.json +1 -1
- package/examples/ossa-templates/01-code-assistant.ossa.yaml +1 -1
- package/examples/ossa-templates/02-security-scanner.ossa.yaml +1 -1
- package/examples/ossa-templates/03-ci-pipeline.ossa.yaml +1 -1
- package/examples/ossa-templates/04-code-reviewer.ossa.yaml +1 -1
- package/examples/ossa-templates/05-doc-generator.ossa.yaml +1 -1
- package/examples/ossa-templates/06-compliance-validator.ossa.yaml +1 -1
- package/examples/ossa-templates/07-workflow-orchestrator.ossa.yaml +1 -1
- package/examples/ossa-templates/08-content-writer.ossa.yaml +1 -1
- package/examples/ossa-templates/09-test-generator.ossa.yaml +1 -1
- package/examples/ossa-templates/10-data-transformer.ossa.yaml +1 -1
- package/examples/ossa-templates/11-react-performance-expert.ossa.yaml +1 -1
- package/examples/ossa-templates/12-typescript-type-safety-expert.ossa.yaml +1 -1
- package/examples/ossa-templates/13-accessibility-champion.ossa.yaml +1 -1
- package/examples/ossa-templates/14-security-hardening-agent.ossa.yaml +1 -1
- package/examples/production/document-analyzer-openai.yml +1 -1
- package/examples/production-ready/01-customer-support-bot/.env.example +32 -0
- package/examples/production-ready/01-customer-support-bot/Dockerfile +30 -0
- package/examples/production-ready/01-customer-support-bot/README.md +295 -0
- package/examples/production-ready/01-customer-support-bot/agent.ossa.yaml +172 -0
- package/examples/production-ready/01-customer-support-bot/docker-compose.yml +55 -0
- package/examples/production-ready/01-customer-support-bot/openapi.yaml +238 -0
- package/examples/production-ready/01-customer-support-bot/package.json +48 -0
- package/examples/production-ready/02-code-review-agent/README.md +72 -0
- package/examples/production-ready/02-code-review-agent/agent.ossa.yaml +239 -0
- package/examples/production-ready/02-code-review-agent/docker-compose.yml +22 -0
- package/examples/production-ready/02-code-review-agent/openapi.yaml +150 -0
- package/examples/production-ready/03-data-analysis-agent/README.md +51 -0
- package/examples/production-ready/03-data-analysis-agent/agent.ossa.yaml +97 -0
- package/examples/production-ready/03-data-analysis-agent/openapi.yaml +74 -0
- package/examples/production-ready/04-content-moderator/README.md +55 -0
- package/examples/production-ready/04-content-moderator/agent.ossa.yaml +131 -0
- package/examples/production-ready/04-content-moderator/openapi.yaml +50 -0
- package/examples/production-ready/05-sales-assistant/README.md +37 -0
- package/examples/production-ready/05-sales-assistant/agent.ossa.yaml +146 -0
- package/examples/production-ready/05-sales-assistant/openapi.yaml +59 -0
- package/examples/production-ready/06-devops-agent/README.md +39 -0
- package/examples/production-ready/06-devops-agent/agent.ossa.yaml +141 -0
- package/examples/production-ready/06-devops-agent/openapi.yaml +51 -0
- package/examples/production-ready/07-research-assistant/README.md +31 -0
- package/examples/production-ready/07-research-assistant/agent.ossa.yaml +119 -0
- package/examples/production-ready/07-research-assistant/openapi.yaml +56 -0
- package/examples/production-ready/08-email-triage-agent/README.md +33 -0
- package/examples/production-ready/08-email-triage-agent/agent.ossa.yaml +133 -0
- package/examples/production-ready/08-email-triage-agent/openapi.yaml +41 -0
- package/examples/production-ready/09-security-scanner/README.md +49 -0
- package/examples/production-ready/09-security-scanner/agent.ossa.yaml +174 -0
- package/examples/production-ready/09-security-scanner/openapi.yaml +46 -0
- package/examples/production-ready/10-meeting-assistant/README.md +53 -0
- package/examples/production-ready/10-meeting-assistant/agent.ossa.yaml +211 -0
- package/examples/production-ready/10-meeting-assistant/docker-compose.yml +27 -0
- package/examples/production-ready/10-meeting-assistant/openapi.yaml +131 -0
- package/examples/production-ready/COMPLETION_REPORT.txt +272 -0
- package/examples/production-ready/INDEX.md +296 -0
- package/examples/production-ready/README.md +452 -0
- package/examples/production-ready/SUMMARY.md +362 -0
- package/examples/production-ready/TEST_RESULTS.md +458 -0
- package/examples/quickstart/support-agent.ossa.yaml +1 -1
- package/examples/real-world/gitlab-cicd-optimizer.ossa.yaml +1 -1
- package/examples/real-world/rag-documentation-assistant.ossa.yaml +1 -1
- package/examples/registry/agents/code-reviewer/agent.yaml +1 -1
- package/examples/registry/agents/security-scanner/agent.yaml +1 -1
- package/examples/runtime-adapters/bedrock-claude-example.ossa.yaml +1 -1
- package/examples/schema/reusable-components.yaml +1 -1
- package/examples/showcase/ci-pipeline.ossa.yaml +1 -1
- package/examples/showcase/code-assistant.ossa.yaml +1 -1
- package/examples/showcase/code-reviewer.ossa.yaml +1 -1
- package/examples/showcase/compliance-validator.ossa.yaml +1 -1
- package/examples/showcase/content-writer.ossa.yaml +1 -1
- package/examples/showcase/data-transformer.ossa.yaml +1 -1
- package/examples/showcase/doc-generator.ossa.yaml +1 -1
- package/examples/showcase/security-scanner.ossa.yaml +1 -1
- package/examples/showcase/test-generator.ossa.yaml +1 -1
- package/examples/showcase/workflow-orchestrator.ossa.yaml +1 -1
- package/examples/skills-example.ossa.yaml +140 -0
- package/examples/swarm/pso-optimizer.ossa.json +1 -1
- package/examples/tasks/batch-email-sender.yaml +1 -1
- package/examples/tasks/data-transform.yaml +1 -1
- package/examples/tasks/publish-content.yaml +1 -1
- package/examples/templates/ossa-compliance.yaml +1 -1
- package/examples/unified/security-scanner.ossa.yaml +1 -1
- package/examples/v0.3.6-features/genetics-breeding-advanced.ossa.yaml +1 -1
- package/examples/v0.3.6-features/genetics-breeding-simple.ossa.yaml +1 -1
- package/examples/v0.3.6-features/genetics-fitness-scoring.ossa.yaml +1 -1
- package/examples/vercel/edge-agent.ossa.json +1 -1
- package/examples/workflows/batch-email-campaign.yaml +1 -1
- package/examples/workflows/content-review-publish.yaml +1 -1
- package/examples/workflows/simple-etl.yaml +1 -1
- package/openapi/cli/openapi.yaml +221 -5
- package/package.json +31 -9
- package/dist/cli/commands/export-v2.command.d.ts +0 -7
- package/dist/cli/commands/export-v2.command.d.ts.map +0 -1
- package/dist/cli/commands/export-v2.command.js.map +0 -1
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain Exporter Service
|
|
3
|
+
*
|
|
4
|
+
* Exports OSSA manifests to production-ready LangChain agents with:
|
|
5
|
+
* - Python agent code with @tool decorators
|
|
6
|
+
* - FastAPI REST API server
|
|
7
|
+
* - OpenAPI 3.1 specification
|
|
8
|
+
* - Docker containerization
|
|
9
|
+
* - Memory configuration
|
|
10
|
+
*
|
|
11
|
+
* SOLID: Single Responsibility - LangChain export orchestration
|
|
12
|
+
* DRY: Reuses generators for each component
|
|
13
|
+
* API-First: Generates OpenAPI spec from OSSA manifest
|
|
14
|
+
*/
|
|
15
|
+
import { ToolsGenerator } from './tools-generator.js';
|
|
16
|
+
import { MemoryGenerator } from './memory-generator.js';
|
|
17
|
+
import { ApiGenerator } from './api-generator.js';
|
|
18
|
+
import { OpenApiGenerator } from './openapi-generator.js';
|
|
19
|
+
import { StreamingGenerator } from './streaming-generator.js';
|
|
20
|
+
import { CallbacksGenerator } from './callbacks-generator.js';
|
|
21
|
+
import { ErrorHandlingGenerator } from './error-handling-generator.js';
|
|
22
|
+
import { TestGenerator } from '../testing/index.js';
|
|
23
|
+
import { LangGraphGenerator } from './langgraph-generator.js';
|
|
24
|
+
import { LangServeGenerator } from './langserve-generator.js';
|
|
25
|
+
import { PlanExecuteGenerator } from './plan-execute-generator.js';
|
|
26
|
+
/**
|
|
27
|
+
* LangChain Exporter
|
|
28
|
+
*/
|
|
29
|
+
export class LangChainExporter {
|
|
30
|
+
toolsGenerator;
|
|
31
|
+
memoryGenerator;
|
|
32
|
+
apiGenerator;
|
|
33
|
+
openApiGenerator;
|
|
34
|
+
streamingGenerator;
|
|
35
|
+
callbacksGenerator;
|
|
36
|
+
errorHandlingGenerator;
|
|
37
|
+
langGraphGenerator;
|
|
38
|
+
langserveGenerator;
|
|
39
|
+
planExecuteGenerator;
|
|
40
|
+
testGenerator;
|
|
41
|
+
constructor() {
|
|
42
|
+
this.toolsGenerator = new ToolsGenerator();
|
|
43
|
+
this.memoryGenerator = new MemoryGenerator();
|
|
44
|
+
this.apiGenerator = new ApiGenerator();
|
|
45
|
+
this.openApiGenerator = new OpenApiGenerator();
|
|
46
|
+
this.streamingGenerator = new StreamingGenerator();
|
|
47
|
+
this.callbacksGenerator = new CallbacksGenerator();
|
|
48
|
+
this.errorHandlingGenerator = new ErrorHandlingGenerator();
|
|
49
|
+
this.langGraphGenerator = new LangGraphGenerator();
|
|
50
|
+
this.langserveGenerator = new LangServeGenerator();
|
|
51
|
+
this.planExecuteGenerator = new PlanExecuteGenerator();
|
|
52
|
+
this.testGenerator = new TestGenerator();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Export OSSA manifest to LangChain
|
|
56
|
+
*/
|
|
57
|
+
async export(manifest, options = {}) {
|
|
58
|
+
const startTime = Date.now();
|
|
59
|
+
try {
|
|
60
|
+
const files = [];
|
|
61
|
+
const pythonVersion = options.pythonVersion || '3.11';
|
|
62
|
+
const includeApi = options.includeApi !== false;
|
|
63
|
+
const includeOpenApi = options.includeOpenApi !== false;
|
|
64
|
+
const includeDocker = options.includeDocker !== false;
|
|
65
|
+
const memoryBackend = options.memoryBackend || 'buffer';
|
|
66
|
+
// Validate manifest
|
|
67
|
+
this.validateManifest(manifest);
|
|
68
|
+
// Determine agent architecture
|
|
69
|
+
const architecture = options.agentArchitecture || 'react';
|
|
70
|
+
const isMultiAgentWorkflow = this.langGraphGenerator.shouldUseLangGraph(manifest);
|
|
71
|
+
// Generate agent code based on architecture
|
|
72
|
+
if (architecture === 'plan-execute') {
|
|
73
|
+
// Generate Plan-and-Execute agents
|
|
74
|
+
const planExecuteConfig = options.planExecute || {};
|
|
75
|
+
const plannerCode = this.planExecuteGenerator.generatePlanner(manifest, planExecuteConfig);
|
|
76
|
+
files.push({
|
|
77
|
+
path: 'planner_agent.py',
|
|
78
|
+
content: plannerCode,
|
|
79
|
+
type: 'code',
|
|
80
|
+
language: 'python',
|
|
81
|
+
});
|
|
82
|
+
const executorCode = this.planExecuteGenerator.generateExecutor(manifest, planExecuteConfig);
|
|
83
|
+
files.push({
|
|
84
|
+
path: 'executor_agent.py',
|
|
85
|
+
content: executorCode,
|
|
86
|
+
type: 'code',
|
|
87
|
+
language: 'python',
|
|
88
|
+
});
|
|
89
|
+
const planExecuteCode = this.planExecuteGenerator.generatePlanExecute(manifest, planExecuteConfig);
|
|
90
|
+
files.push({
|
|
91
|
+
path: 'plan_execute.py',
|
|
92
|
+
content: planExecuteCode,
|
|
93
|
+
type: 'code',
|
|
94
|
+
language: 'python',
|
|
95
|
+
});
|
|
96
|
+
// Also generate main agent.py that imports plan_execute
|
|
97
|
+
const mainAgentCode = this.generatePlanExecuteMainAgent(manifest);
|
|
98
|
+
files.push({
|
|
99
|
+
path: 'agent.py',
|
|
100
|
+
content: mainAgentCode,
|
|
101
|
+
type: 'code',
|
|
102
|
+
language: 'python',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Generate ReAct agent (default)
|
|
107
|
+
const agentCode = this.generateAgentCode(manifest, options);
|
|
108
|
+
files.push({
|
|
109
|
+
path: 'agent.py',
|
|
110
|
+
content: agentCode,
|
|
111
|
+
type: 'code',
|
|
112
|
+
language: 'python',
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Generate LangGraph workflow if multi-agent
|
|
116
|
+
if (isMultiAgentWorkflow) {
|
|
117
|
+
const langGraphCode = this.langGraphGenerator.generate(manifest);
|
|
118
|
+
files.push({
|
|
119
|
+
path: 'langgraph.py',
|
|
120
|
+
content: langGraphCode,
|
|
121
|
+
type: 'code',
|
|
122
|
+
language: 'python',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Generate tools
|
|
126
|
+
const toolsCode = this.toolsGenerator.generate(manifest);
|
|
127
|
+
files.push({
|
|
128
|
+
path: 'tools.py',
|
|
129
|
+
content: toolsCode,
|
|
130
|
+
type: 'code',
|
|
131
|
+
language: 'python',
|
|
132
|
+
});
|
|
133
|
+
// Generate memory configuration
|
|
134
|
+
const memoryCode = this.memoryGenerator.generate(manifest, memoryBackend);
|
|
135
|
+
files.push({
|
|
136
|
+
path: 'memory.py',
|
|
137
|
+
content: memoryCode,
|
|
138
|
+
type: 'code',
|
|
139
|
+
language: 'python',
|
|
140
|
+
});
|
|
141
|
+
// Generate streaming support
|
|
142
|
+
const streamingCode = this.streamingGenerator.generate(manifest, options.streaming || {});
|
|
143
|
+
files.push({
|
|
144
|
+
path: 'streaming.py',
|
|
145
|
+
content: streamingCode,
|
|
146
|
+
type: 'code',
|
|
147
|
+
language: 'python',
|
|
148
|
+
});
|
|
149
|
+
// Generate callbacks and observability
|
|
150
|
+
const callbacksCode = this.callbacksGenerator.generate(manifest, options.callbacks || {});
|
|
151
|
+
files.push({
|
|
152
|
+
path: 'callbacks.py',
|
|
153
|
+
content: callbacksCode,
|
|
154
|
+
type: 'code',
|
|
155
|
+
language: 'python',
|
|
156
|
+
});
|
|
157
|
+
// Generate error handling
|
|
158
|
+
const errorHandlingCode = this.errorHandlingGenerator.generate(manifest, options.errorHandling || {});
|
|
159
|
+
files.push({
|
|
160
|
+
path: 'error_handling.py',
|
|
161
|
+
content: errorHandlingCode,
|
|
162
|
+
type: 'code',
|
|
163
|
+
language: 'python',
|
|
164
|
+
});
|
|
165
|
+
// Generate FastAPI server
|
|
166
|
+
if (includeApi) {
|
|
167
|
+
const apiCode = this.apiGenerator.generate(manifest, options.apiPort);
|
|
168
|
+
files.push({
|
|
169
|
+
path: 'server.py',
|
|
170
|
+
content: apiCode,
|
|
171
|
+
type: 'code',
|
|
172
|
+
language: 'python',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// Generate OpenAPI spec
|
|
176
|
+
if (includeOpenApi) {
|
|
177
|
+
const openApiSpec = this.openApiGenerator.generate(manifest);
|
|
178
|
+
files.push({
|
|
179
|
+
path: 'openapi.yaml',
|
|
180
|
+
content: openApiSpec,
|
|
181
|
+
type: 'config',
|
|
182
|
+
language: 'yaml',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
// Generate LangServe deployment (if requested)
|
|
186
|
+
if (options.includeLangServe) {
|
|
187
|
+
const langserveConfig = options.langserve || {};
|
|
188
|
+
// Generate LangServe app
|
|
189
|
+
const langserveApp = this.langserveGenerator.generateApp(manifest, langserveConfig);
|
|
190
|
+
files.push({
|
|
191
|
+
path: 'langserve_app.py',
|
|
192
|
+
content: langserveApp,
|
|
193
|
+
type: 'code',
|
|
194
|
+
language: 'python',
|
|
195
|
+
});
|
|
196
|
+
// Generate deployment configs
|
|
197
|
+
if (langserveConfig.includeDeployment !== false) {
|
|
198
|
+
const platforms = langserveConfig.deploymentPlatforms || ['docker', 'kubernetes', 'railway', 'render', 'fly'];
|
|
199
|
+
// Docker configs
|
|
200
|
+
if (platforms.includes('docker')) {
|
|
201
|
+
const langserveDockerfile = this.langserveGenerator.generateDockerfile(pythonVersion);
|
|
202
|
+
files.push({
|
|
203
|
+
path: 'Dockerfile.langserve',
|
|
204
|
+
content: langserveDockerfile,
|
|
205
|
+
type: 'config',
|
|
206
|
+
});
|
|
207
|
+
const langserveCompose = this.langserveGenerator.generateDockerCompose(manifest, langserveConfig);
|
|
208
|
+
files.push({
|
|
209
|
+
path: 'docker-compose.langserve.yaml',
|
|
210
|
+
content: langserveCompose,
|
|
211
|
+
type: 'config',
|
|
212
|
+
language: 'yaml',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// Kubernetes manifests
|
|
216
|
+
if (platforms.includes('kubernetes')) {
|
|
217
|
+
const k8sManifests = this.langserveGenerator.generateKubernetesManifests(manifest, langserveConfig);
|
|
218
|
+
files.push({
|
|
219
|
+
path: 'k8s/deployment.yaml',
|
|
220
|
+
content: k8sManifests.deployment,
|
|
221
|
+
type: 'config',
|
|
222
|
+
language: 'yaml',
|
|
223
|
+
});
|
|
224
|
+
files.push({
|
|
225
|
+
path: 'k8s/service.yaml',
|
|
226
|
+
content: k8sManifests.service,
|
|
227
|
+
type: 'config',
|
|
228
|
+
language: 'yaml',
|
|
229
|
+
});
|
|
230
|
+
files.push({
|
|
231
|
+
path: 'k8s/ingress.yaml',
|
|
232
|
+
content: k8sManifests.ingress,
|
|
233
|
+
type: 'config',
|
|
234
|
+
language: 'yaml',
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// Railway config
|
|
238
|
+
if (platforms.includes('railway')) {
|
|
239
|
+
const railwayConfig = this.langserveGenerator.generateRailwayConfig(manifest, langserveConfig);
|
|
240
|
+
files.push({
|
|
241
|
+
path: 'railway.json',
|
|
242
|
+
content: railwayConfig,
|
|
243
|
+
type: 'config',
|
|
244
|
+
language: 'json',
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
// Render config
|
|
248
|
+
if (platforms.includes('render')) {
|
|
249
|
+
const renderConfig = this.langserveGenerator.generateRenderConfig(manifest, langserveConfig);
|
|
250
|
+
files.push({
|
|
251
|
+
path: 'render.yaml',
|
|
252
|
+
content: renderConfig,
|
|
253
|
+
type: 'config',
|
|
254
|
+
language: 'yaml',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
// Fly.io config
|
|
258
|
+
if (platforms.includes('fly')) {
|
|
259
|
+
const flyConfig = this.langserveGenerator.generateFlyConfig(manifest, langserveConfig);
|
|
260
|
+
files.push({
|
|
261
|
+
path: 'fly.toml',
|
|
262
|
+
content: flyConfig,
|
|
263
|
+
type: 'config',
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// Deployment README
|
|
267
|
+
const deploymentReadme = this.langserveGenerator.generateDeploymentReadme(manifest, langserveConfig);
|
|
268
|
+
files.push({
|
|
269
|
+
path: 'DEPLOYMENT.md',
|
|
270
|
+
content: deploymentReadme,
|
|
271
|
+
type: 'documentation',
|
|
272
|
+
language: 'markdown',
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Generate requirements.txt
|
|
277
|
+
const requirements = this.generateRequirements(manifest, options);
|
|
278
|
+
files.push({
|
|
279
|
+
path: 'requirements.txt',
|
|
280
|
+
content: requirements,
|
|
281
|
+
type: 'config',
|
|
282
|
+
});
|
|
283
|
+
// Generate Dockerfile
|
|
284
|
+
if (includeDocker) {
|
|
285
|
+
const dockerfile = this.generateDockerfile(pythonVersion);
|
|
286
|
+
files.push({
|
|
287
|
+
path: 'Dockerfile',
|
|
288
|
+
content: dockerfile,
|
|
289
|
+
type: 'config',
|
|
290
|
+
});
|
|
291
|
+
const dockerCompose = this.generateDockerCompose(manifest, options);
|
|
292
|
+
files.push({
|
|
293
|
+
path: 'docker-compose.yaml',
|
|
294
|
+
content: dockerCompose,
|
|
295
|
+
type: 'config',
|
|
296
|
+
language: 'yaml',
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
// Generate .env.example
|
|
300
|
+
const envExample = this.generateEnvExample(manifest);
|
|
301
|
+
files.push({
|
|
302
|
+
path: '.env.example',
|
|
303
|
+
content: envExample,
|
|
304
|
+
type: 'config',
|
|
305
|
+
});
|
|
306
|
+
// Generate README
|
|
307
|
+
const readme = this.generateReadme(manifest, options);
|
|
308
|
+
files.push({
|
|
309
|
+
path: 'README.md',
|
|
310
|
+
content: readme,
|
|
311
|
+
type: 'documentation',
|
|
312
|
+
language: 'markdown',
|
|
313
|
+
});
|
|
314
|
+
// Generate tests (if requested) - Use comprehensive test generator
|
|
315
|
+
if (options.includeTests) {
|
|
316
|
+
const testSuite = this.testGenerator.generateLangChainTests(manifest, options.testOptions || {
|
|
317
|
+
includeUnit: true,
|
|
318
|
+
includeIntegration: true,
|
|
319
|
+
includeLoad: true,
|
|
320
|
+
includeSecurity: true,
|
|
321
|
+
includeCost: true,
|
|
322
|
+
});
|
|
323
|
+
// Add all test files
|
|
324
|
+
files.push(...testSuite.files);
|
|
325
|
+
files.push(...testSuite.configs);
|
|
326
|
+
files.push(...testSuite.fixtures);
|
|
327
|
+
}
|
|
328
|
+
const duration = Date.now() - startTime;
|
|
329
|
+
const toolsCount = manifest.spec?.tools?.length || 0;
|
|
330
|
+
return {
|
|
331
|
+
success: true,
|
|
332
|
+
files,
|
|
333
|
+
metadata: {
|
|
334
|
+
pythonVersion,
|
|
335
|
+
langchainVersion: '0.1.0',
|
|
336
|
+
toolsCount,
|
|
337
|
+
memoryType: memoryBackend,
|
|
338
|
+
hasApi: includeApi,
|
|
339
|
+
hasOpenApi: includeOpenApi,
|
|
340
|
+
duration,
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
return {
|
|
346
|
+
success: false,
|
|
347
|
+
files: [],
|
|
348
|
+
error: error instanceof Error ? error.message : String(error),
|
|
349
|
+
metadata: {
|
|
350
|
+
pythonVersion: options.pythonVersion || '3.11',
|
|
351
|
+
langchainVersion: '0.1.0',
|
|
352
|
+
toolsCount: 0,
|
|
353
|
+
memoryType: options.memoryBackend || 'buffer',
|
|
354
|
+
hasApi: false,
|
|
355
|
+
hasOpenApi: false,
|
|
356
|
+
duration: Date.now() - startTime,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Validate OSSA manifest for LangChain export
|
|
363
|
+
*/
|
|
364
|
+
validateManifest(manifest) {
|
|
365
|
+
if (!manifest.metadata?.name) {
|
|
366
|
+
throw new Error('Manifest must have metadata.name');
|
|
367
|
+
}
|
|
368
|
+
if (!manifest.spec?.role) {
|
|
369
|
+
throw new Error('Manifest must have spec.role (system prompt)');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Generate main agent code
|
|
374
|
+
*/
|
|
375
|
+
generateAgentCode(manifest, options) {
|
|
376
|
+
const agentName = manifest.metadata?.name || 'agent';
|
|
377
|
+
const systemPrompt = manifest.spec?.role || '';
|
|
378
|
+
const llm = manifest.spec?.llm;
|
|
379
|
+
const provider = llm?.provider || 'openai';
|
|
380
|
+
const model = llm?.model || 'gpt-4';
|
|
381
|
+
const temperature = llm?.temperature ?? 0.7;
|
|
382
|
+
const maxTokens = llm?.maxTokens ?? 2000;
|
|
383
|
+
return `"""
|
|
384
|
+
${agentName} - LangChain Agent
|
|
385
|
+
Generated from OSSA manifest
|
|
386
|
+
|
|
387
|
+
Description: ${manifest.metadata?.description || 'AI Agent'}
|
|
388
|
+
Version: ${manifest.metadata?.version || '1.0.0'}
|
|
389
|
+
"""
|
|
390
|
+
|
|
391
|
+
from typing import Any, Dict, List, Optional
|
|
392
|
+
from langchain.agents import AgentExecutor, create_openai_tools_agent
|
|
393
|
+
from langchain_openai import ChatOpenAI
|
|
394
|
+
from langchain_anthropic import ChatAnthropic
|
|
395
|
+
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
396
|
+
from tools import get_tools
|
|
397
|
+
from memory import get_memory
|
|
398
|
+
from callbacks import get_callbacks, get_cost_tracker, print_cost_summary
|
|
399
|
+
from error_handling import safe_agent_invoke, get_error_stats
|
|
400
|
+
import os
|
|
401
|
+
|
|
402
|
+
# LLM Configuration
|
|
403
|
+
LLM_PROVIDER = "${provider}"
|
|
404
|
+
LLM_MODEL = "${model}"
|
|
405
|
+
LLM_TEMPERATURE = ${temperature}
|
|
406
|
+
LLM_MAX_TOKENS = ${maxTokens}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def create_llm():
|
|
410
|
+
"""Initialize LLM based on provider configuration"""
|
|
411
|
+
if LLM_PROVIDER == "anthropic":
|
|
412
|
+
return ChatAnthropic(
|
|
413
|
+
model=LLM_MODEL,
|
|
414
|
+
temperature=LLM_TEMPERATURE,
|
|
415
|
+
max_tokens=LLM_MAX_TOKENS,
|
|
416
|
+
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
|
417
|
+
)
|
|
418
|
+
elif LLM_PROVIDER == "openai":
|
|
419
|
+
return ChatOpenAI(
|
|
420
|
+
model=LLM_MODEL,
|
|
421
|
+
temperature=LLM_TEMPERATURE,
|
|
422
|
+
max_tokens=LLM_MAX_TOKENS,
|
|
423
|
+
api_key=os.getenv("OPENAI_API_KEY"),
|
|
424
|
+
)
|
|
425
|
+
else:
|
|
426
|
+
raise ValueError(f"Unsupported LLM provider: {LLM_PROVIDER}")
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def create_agent() -> AgentExecutor:
|
|
430
|
+
"""Create and configure the LangChain agent"""
|
|
431
|
+
|
|
432
|
+
# Initialize LLM
|
|
433
|
+
llm = create_llm()
|
|
434
|
+
|
|
435
|
+
# Get tools
|
|
436
|
+
tools = get_tools()
|
|
437
|
+
|
|
438
|
+
# Create prompt template
|
|
439
|
+
prompt = ChatPromptTemplate.from_messages([
|
|
440
|
+
("system", """${systemPrompt.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"""),
|
|
441
|
+
MessagesPlaceholder(variable_name="chat_history"),
|
|
442
|
+
("human", "{input}"),
|
|
443
|
+
MessagesPlaceholder(variable_name="agent_scratchpad"),
|
|
444
|
+
])
|
|
445
|
+
|
|
446
|
+
# Create agent
|
|
447
|
+
agent = create_openai_tools_agent(llm, tools, prompt)
|
|
448
|
+
|
|
449
|
+
# Get memory
|
|
450
|
+
memory = get_memory()
|
|
451
|
+
|
|
452
|
+
# Get callbacks (observability + cost tracking)
|
|
453
|
+
callbacks = get_callbacks()
|
|
454
|
+
|
|
455
|
+
# Create executor
|
|
456
|
+
agent_executor = AgentExecutor(
|
|
457
|
+
agent=agent,
|
|
458
|
+
tools=tools,
|
|
459
|
+
memory=memory,
|
|
460
|
+
callbacks=callbacks.handlers,
|
|
461
|
+
verbose=True,
|
|
462
|
+
handle_parsing_errors=True,
|
|
463
|
+
max_iterations=10,
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
return agent_executor
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
# Create global agent instance
|
|
470
|
+
agent = create_agent()
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def run(input_text: str, chat_history: Optional[List[Dict[str, str]]] = None) -> Dict[str, Any]:
|
|
474
|
+
"""
|
|
475
|
+
Run the agent with input text (production-grade error handling)
|
|
476
|
+
|
|
477
|
+
Args:
|
|
478
|
+
input_text: User input message
|
|
479
|
+
chat_history: Optional chat history for context
|
|
480
|
+
|
|
481
|
+
Returns:
|
|
482
|
+
Agent response with output, cost tracking, and error handling
|
|
483
|
+
"""
|
|
484
|
+
# Use safe invoke with retry, circuit breaker, and fallback
|
|
485
|
+
result = safe_agent_invoke(
|
|
486
|
+
agent,
|
|
487
|
+
input_text,
|
|
488
|
+
chat_history=chat_history or [],
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
# Add cost tracking to response
|
|
492
|
+
cost_tracker = get_cost_tracker()
|
|
493
|
+
result["cost"] = cost_tracker.get_summary()
|
|
494
|
+
|
|
495
|
+
return result
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
if __name__ == "__main__":
|
|
499
|
+
# Example usage
|
|
500
|
+
print(f"Starting {agentName}...")
|
|
501
|
+
|
|
502
|
+
response = run("Hello! What can you help me with?")
|
|
503
|
+
print(f"Agent: {response['output']}")
|
|
504
|
+
`;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Generate requirements.txt
|
|
508
|
+
*/
|
|
509
|
+
generateRequirements(manifest, options) {
|
|
510
|
+
const isMultiAgentWorkflow = this.langGraphGenerator.shouldUseLangGraph(manifest);
|
|
511
|
+
const requirements = [
|
|
512
|
+
'# LangChain Core',
|
|
513
|
+
'langchain>=0.1.0',
|
|
514
|
+
'langchain-openai>=0.0.5',
|
|
515
|
+
'langchain-core>=0.1.0',
|
|
516
|
+
'',
|
|
517
|
+
];
|
|
518
|
+
// Add LangGraph for multi-agent workflows
|
|
519
|
+
if (isMultiAgentWorkflow) {
|
|
520
|
+
requirements.push('# LangGraph (Multi-Agent Workflows)', 'langgraph>=0.0.30', '');
|
|
521
|
+
}
|
|
522
|
+
requirements.push('# LLM Providers');
|
|
523
|
+
const llm = manifest.spec?.llm;
|
|
524
|
+
const provider = llm?.provider || 'openai';
|
|
525
|
+
if (provider === 'anthropic') {
|
|
526
|
+
requirements.push('langchain-anthropic>=0.1.0');
|
|
527
|
+
}
|
|
528
|
+
else if (provider === 'openai') {
|
|
529
|
+
requirements.push('openai>=1.0.0');
|
|
530
|
+
}
|
|
531
|
+
requirements.push('', '# Memory & Storage', 'redis>=5.0.0 # For Redis memory backend', 'psycopg2-binary>=2.9.0 # For Postgres memory backend', '');
|
|
532
|
+
if (options.includeApi !== false) {
|
|
533
|
+
requirements.push('# FastAPI Server', 'fastapi>=0.109.0', 'uvicorn[standard]>=0.27.0', 'pydantic>=2.0.0', '');
|
|
534
|
+
}
|
|
535
|
+
// Streaming dependencies (always included with API for SSE + WebSocket support)
|
|
536
|
+
if (options.includeApi !== false) {
|
|
537
|
+
requirements.push('# Streaming Support (SSE + WebSocket)', 'sse-starlette>=1.8.0 # Server-Sent Events', 'websockets>=12.0 # WebSocket streaming', '');
|
|
538
|
+
}
|
|
539
|
+
// Callbacks and observability dependencies
|
|
540
|
+
const callbacksConfig = options.callbacks;
|
|
541
|
+
if (callbacksConfig) {
|
|
542
|
+
requirements.push('# Observability & Callbacks');
|
|
543
|
+
if (callbacksConfig.langsmith !== false) {
|
|
544
|
+
requirements.push('langsmith>=0.1.0 # LangSmith tracing');
|
|
545
|
+
}
|
|
546
|
+
if (callbacksConfig.langfuse) {
|
|
547
|
+
requirements.push('langfuse>=2.0.0 # LangFuse observability');
|
|
548
|
+
}
|
|
549
|
+
if (callbacksConfig.opentelemetry) {
|
|
550
|
+
requirements.push('opentelemetry-api>=1.20.0 # OpenTelemetry', 'opentelemetry-sdk>=1.20.0', 'opentelemetry-exporter-otlp>=1.20.0');
|
|
551
|
+
}
|
|
552
|
+
requirements.push('');
|
|
553
|
+
}
|
|
554
|
+
// Error handling dependencies
|
|
555
|
+
const errorHandlingConfig = options.errorHandling;
|
|
556
|
+
if (errorHandlingConfig?.fallback?.useCachedResponses) {
|
|
557
|
+
requirements.push('# Error Handling', 'cachetools>=5.0.0 # Response caching', '');
|
|
558
|
+
}
|
|
559
|
+
// LangServe deployment dependencies
|
|
560
|
+
if (options.includeLangServe) {
|
|
561
|
+
requirements.push('# LangServe Deployment', 'langserve[all]>=0.0.30 # LangServe REST API deployment', 'sse-starlette>=1.8.0 # Server-Sent Events for streaming', '');
|
|
562
|
+
}
|
|
563
|
+
requirements.push('# Utilities', 'python-dotenv>=1.0.0', 'pyyaml>=6.0.0', 'httpx>=0.26.0', '');
|
|
564
|
+
return requirements.join('\n');
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Generate Dockerfile
|
|
568
|
+
*/
|
|
569
|
+
generateDockerfile(pythonVersion) {
|
|
570
|
+
return `FROM python:${pythonVersion}-slim
|
|
571
|
+
|
|
572
|
+
WORKDIR /app
|
|
573
|
+
|
|
574
|
+
# Install system dependencies
|
|
575
|
+
RUN apt-get update && apt-get install -y \\
|
|
576
|
+
gcc \\
|
|
577
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
578
|
+
|
|
579
|
+
# Copy requirements
|
|
580
|
+
COPY requirements.txt .
|
|
581
|
+
|
|
582
|
+
# Install Python dependencies
|
|
583
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
584
|
+
|
|
585
|
+
# Copy application code
|
|
586
|
+
COPY . .
|
|
587
|
+
|
|
588
|
+
# Expose API port
|
|
589
|
+
EXPOSE 8000
|
|
590
|
+
|
|
591
|
+
# Run FastAPI server
|
|
592
|
+
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
593
|
+
`;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Generate docker-compose.yaml
|
|
597
|
+
*/
|
|
598
|
+
generateDockerCompose(manifest, options) {
|
|
599
|
+
const agentName = manifest.metadata?.name || 'agent';
|
|
600
|
+
const port = options.apiPort || 8000;
|
|
601
|
+
const memoryBackend = options.memoryBackend || 'buffer';
|
|
602
|
+
let compose = `version: '3.8'
|
|
603
|
+
|
|
604
|
+
services:
|
|
605
|
+
${agentName}:
|
|
606
|
+
build: .
|
|
607
|
+
ports:
|
|
608
|
+
- "${port}:8000"
|
|
609
|
+
environment:
|
|
610
|
+
- OPENAI_API_KEY=\${OPENAI_API_KEY}
|
|
611
|
+
- ANTHROPIC_API_KEY=\${ANTHROPIC_API_KEY}
|
|
612
|
+
`;
|
|
613
|
+
if (memoryBackend === 'redis') {
|
|
614
|
+
compose += ` - REDIS_URL=redis://redis:6379
|
|
615
|
+
depends_on:
|
|
616
|
+
- redis
|
|
617
|
+
|
|
618
|
+
redis:
|
|
619
|
+
image: redis:7-alpine
|
|
620
|
+
ports:
|
|
621
|
+
- "6379:6379"
|
|
622
|
+
`;
|
|
623
|
+
}
|
|
624
|
+
else if (memoryBackend === 'postgres') {
|
|
625
|
+
compose += ` - POSTGRES_URL=postgresql://postgres:postgres@postgres:5432/agent_memory
|
|
626
|
+
depends_on:
|
|
627
|
+
- postgres
|
|
628
|
+
|
|
629
|
+
postgres:
|
|
630
|
+
image: postgres:15-alpine
|
|
631
|
+
environment:
|
|
632
|
+
- POSTGRES_PASSWORD=postgres
|
|
633
|
+
- POSTGRES_DB=agent_memory
|
|
634
|
+
ports:
|
|
635
|
+
- "5432:5432"
|
|
636
|
+
volumes:
|
|
637
|
+
- postgres_data:/var/lib/postgresql/data
|
|
638
|
+
|
|
639
|
+
volumes:
|
|
640
|
+
postgres_data:
|
|
641
|
+
`;
|
|
642
|
+
}
|
|
643
|
+
return compose;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Generate .env.example
|
|
647
|
+
*/
|
|
648
|
+
generateEnvExample(manifest) {
|
|
649
|
+
const llm = manifest.spec?.llm;
|
|
650
|
+
const provider = llm?.provider || 'openai';
|
|
651
|
+
const vars = [
|
|
652
|
+
'# LLM API Keys',
|
|
653
|
+
'OPENAI_API_KEY=your-openai-api-key-here',
|
|
654
|
+
'ANTHROPIC_API_KEY=your-anthropic-api-key-here',
|
|
655
|
+
'',
|
|
656
|
+
'# Memory Backend',
|
|
657
|
+
'REDIS_URL=redis://localhost:6379',
|
|
658
|
+
'POSTGRES_URL=postgresql://postgres:postgres@localhost:5432/agent_memory',
|
|
659
|
+
'',
|
|
660
|
+
'# API Configuration',
|
|
661
|
+
'API_PORT=8000',
|
|
662
|
+
'API_HOST=0.0.0.0',
|
|
663
|
+
'',
|
|
664
|
+
'# Callbacks & Observability',
|
|
665
|
+
'CALLBACK_LOG_LEVEL=info # debug, info, warn, error',
|
|
666
|
+
'',
|
|
667
|
+
'# LangSmith (Observability)',
|
|
668
|
+
'LANGSMITH_ENABLED=true',
|
|
669
|
+
'LANGCHAIN_API_KEY=your-langsmith-api-key',
|
|
670
|
+
'LANGCHAIN_PROJECT=default',
|
|
671
|
+
'LANGCHAIN_ENDPOINT=https://api.smith.langchain.com',
|
|
672
|
+
'',
|
|
673
|
+
'# LangFuse (Optional)',
|
|
674
|
+
'LANGFUSE_ENABLED=false',
|
|
675
|
+
'LANGFUSE_PUBLIC_KEY=your-public-key',
|
|
676
|
+
'LANGFUSE_SECRET_KEY=your-secret-key',
|
|
677
|
+
'LANGFUSE_HOST=https://cloud.langfuse.com',
|
|
678
|
+
'',
|
|
679
|
+
'# OpenTelemetry (Optional)',
|
|
680
|
+
'OTEL_ENABLED=false',
|
|
681
|
+
'OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317',
|
|
682
|
+
'OTEL_SERVICE_NAME=langchain-agent',
|
|
683
|
+
'',
|
|
684
|
+
];
|
|
685
|
+
return vars.join('\n');
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Generate README.md
|
|
689
|
+
*/
|
|
690
|
+
generateReadme(manifest, options) {
|
|
691
|
+
const agentName = manifest.metadata?.name || 'agent';
|
|
692
|
+
const description = manifest.metadata?.description || 'AI Agent';
|
|
693
|
+
const llm = manifest.spec?.llm;
|
|
694
|
+
const provider = llm?.provider || 'openai';
|
|
695
|
+
const model = llm?.model || 'gpt-4';
|
|
696
|
+
const toolsCount = manifest.spec?.tools?.length || 0;
|
|
697
|
+
const isMultiAgentWorkflow = this.langGraphGenerator.shouldUseLangGraph(manifest);
|
|
698
|
+
let workflowInfo = '';
|
|
699
|
+
if (isMultiAgentWorkflow) {
|
|
700
|
+
const structure = this.langGraphGenerator.analyzeWorkflow(manifest);
|
|
701
|
+
workflowInfo = `
|
|
702
|
+
- **Workflow Type**: Multi-Agent (LangGraph)
|
|
703
|
+
- **Pattern**: ${structure.pattern}
|
|
704
|
+
- **Agents**: ${structure.agents.length}
|
|
705
|
+
- **Conditional Logic**: ${structure.hasConditionalLogic ? 'Yes' : 'No'}
|
|
706
|
+
- **Human Approval**: ${structure.hasHumanApproval ? 'Yes' : 'No'}`;
|
|
707
|
+
}
|
|
708
|
+
return `# ${agentName}
|
|
709
|
+
|
|
710
|
+
${description}
|
|
711
|
+
|
|
712
|
+
## Overview
|
|
713
|
+
|
|
714
|
+
This is a production-ready LangChain agent exported from an OSSA manifest.${isMultiAgentWorkflow ? ' This agent uses **LangGraph** for multi-agent workflow orchestration.' : ''}
|
|
715
|
+
|
|
716
|
+
**Configuration:**
|
|
717
|
+
- LLM: ${provider} (${model})
|
|
718
|
+
- Tools: ${toolsCount} available
|
|
719
|
+
- Memory: ${options.memoryBackend || 'buffer'}
|
|
720
|
+
- API: ${options.includeApi !== false ? 'FastAPI REST server' : 'No API'}${workflowInfo}
|
|
721
|
+
|
|
722
|
+
## Setup
|
|
723
|
+
|
|
724
|
+
### 1. Install Dependencies
|
|
725
|
+
|
|
726
|
+
\`\`\`bash
|
|
727
|
+
pip install -r requirements.txt
|
|
728
|
+
\`\`\`
|
|
729
|
+
|
|
730
|
+
### 2. Configure Environment
|
|
731
|
+
|
|
732
|
+
Copy \`.env.example\` to \`.env\` and add your API keys:
|
|
733
|
+
|
|
734
|
+
\`\`\`bash
|
|
735
|
+
cp .env.example .env
|
|
736
|
+
# Edit .env with your API keys
|
|
737
|
+
\`\`\`
|
|
738
|
+
|
|
739
|
+
### 3. Run Agent
|
|
740
|
+
|
|
741
|
+
**Python CLI:**
|
|
742
|
+
\`\`\`bash
|
|
743
|
+
python agent.py
|
|
744
|
+
\`\`\`
|
|
745
|
+
${isMultiAgentWorkflow ? `
|
|
746
|
+
**LangGraph Workflow:**
|
|
747
|
+
\`\`\`bash
|
|
748
|
+
python langgraph.py
|
|
749
|
+
\`\`\`
|
|
750
|
+
` : ''}
|
|
751
|
+
**FastAPI Server:**
|
|
752
|
+
\`\`\`bash
|
|
753
|
+
uvicorn server:app --reload
|
|
754
|
+
\`\`\`
|
|
755
|
+
|
|
756
|
+
**Docker:**
|
|
757
|
+
\`\`\`bash
|
|
758
|
+
docker-compose up
|
|
759
|
+
\`\`\`
|
|
760
|
+
|
|
761
|
+
## API Usage
|
|
762
|
+
|
|
763
|
+
### POST /chat
|
|
764
|
+
|
|
765
|
+
Send a message to the agent:
|
|
766
|
+
|
|
767
|
+
\`\`\`bash
|
|
768
|
+
curl -X POST http://localhost:8000/chat \\
|
|
769
|
+
-H "Content-Type: application/json" \\
|
|
770
|
+
-d '{"message": "Hello, agent!"}'
|
|
771
|
+
\`\`\`
|
|
772
|
+
|
|
773
|
+
### GET /health
|
|
774
|
+
|
|
775
|
+
Check server health:
|
|
776
|
+
|
|
777
|
+
\`\`\`bash
|
|
778
|
+
curl http://localhost:8000/health
|
|
779
|
+
\`\`\`
|
|
780
|
+
|
|
781
|
+
### GET /openapi.json
|
|
782
|
+
|
|
783
|
+
Get OpenAPI specification:
|
|
784
|
+
|
|
785
|
+
\`\`\`bash
|
|
786
|
+
curl http://localhost:8000/openapi.json
|
|
787
|
+
\`\`\`
|
|
788
|
+
|
|
789
|
+
## Development
|
|
790
|
+
|
|
791
|
+
### Run Tests
|
|
792
|
+
|
|
793
|
+
\`\`\`bash
|
|
794
|
+
pytest test_agent.py -v
|
|
795
|
+
\`\`\`
|
|
796
|
+
|
|
797
|
+
### Code Quality
|
|
798
|
+
|
|
799
|
+
\`\`\`bash
|
|
800
|
+
black .
|
|
801
|
+
ruff check .
|
|
802
|
+
mypy .
|
|
803
|
+
\`\`\`
|
|
804
|
+
|
|
805
|
+
## Tools
|
|
806
|
+
|
|
807
|
+
${manifest.spec?.tools?.map((tool) => `- **${tool.name}**: ${tool.description || 'No description'}`).join('\n') || 'No tools configured'}
|
|
808
|
+
|
|
809
|
+
## Generated from OSSA
|
|
810
|
+
|
|
811
|
+
- Manifest: \`agent.ossa.yaml\`
|
|
812
|
+
- OSSA Version: ${manifest.apiVersion?.split('/')[1] || 'v0.3.6'}
|
|
813
|
+
- Export Date: ${new Date().toISOString().split('T')[0]}
|
|
814
|
+
|
|
815
|
+
## License
|
|
816
|
+
|
|
817
|
+
${manifest.metadata?.license || 'MIT'}
|
|
818
|
+
`;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Generate tests
|
|
822
|
+
*/
|
|
823
|
+
generateTests(manifest) {
|
|
824
|
+
const agentName = manifest.metadata?.name || 'agent';
|
|
825
|
+
return `"""
|
|
826
|
+
Tests for ${agentName}
|
|
827
|
+
"""
|
|
828
|
+
|
|
829
|
+
import pytest
|
|
830
|
+
from agent import create_agent, run
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
def test_agent_creation():
|
|
834
|
+
"""Test agent can be created"""
|
|
835
|
+
agent = create_agent()
|
|
836
|
+
assert agent is not None
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
def test_agent_run():
|
|
840
|
+
"""Test agent can process input"""
|
|
841
|
+
response = run("Hello!")
|
|
842
|
+
assert response is not None
|
|
843
|
+
assert "success" in response
|
|
844
|
+
assert response["success"] is True
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
def test_agent_error_handling():
|
|
848
|
+
"""Test agent handles errors gracefully"""
|
|
849
|
+
# This should not crash
|
|
850
|
+
response = run("")
|
|
851
|
+
assert response is not None
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
@pytest.mark.parametrize("input_text", [
|
|
855
|
+
"What can you help me with?",
|
|
856
|
+
"Tell me about yourself",
|
|
857
|
+
"What tools do you have?",
|
|
858
|
+
])
|
|
859
|
+
def test_agent_various_inputs(input_text):
|
|
860
|
+
"""Test agent with various inputs"""
|
|
861
|
+
response = run(input_text)
|
|
862
|
+
assert response["success"] is True
|
|
863
|
+
assert len(response.get("output", "")) > 0
|
|
864
|
+
`;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Generate main agent.py wrapper for Plan-and-Execute architecture
|
|
868
|
+
*/
|
|
869
|
+
generatePlanExecuteMainAgent(manifest) {
|
|
870
|
+
const agentName = manifest.metadata?.name || 'agent';
|
|
871
|
+
const description = manifest.metadata?.description || 'AI Agent';
|
|
872
|
+
const version = manifest.metadata?.version || '1.0.0';
|
|
873
|
+
return `"""
|
|
874
|
+
${agentName} - Plan-and-Execute Agent
|
|
875
|
+
Generated from OSSA manifest
|
|
876
|
+
|
|
877
|
+
Description: ${description}
|
|
878
|
+
Version: ${version}
|
|
879
|
+
Architecture: Plan-and-Execute (Planner + Executor)
|
|
880
|
+
"""
|
|
881
|
+
|
|
882
|
+
from typing import Any, Dict, Optional
|
|
883
|
+
from plan_execute import run as plan_execute_run
|
|
884
|
+
from memory import get_memory
|
|
885
|
+
from callbacks import get_callbacks, get_cost_tracker, print_cost_summary
|
|
886
|
+
import logging
|
|
887
|
+
|
|
888
|
+
logging.basicConfig(level=logging.INFO)
|
|
889
|
+
logger = logging.getLogger(__name__)
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
def create_agent():
|
|
893
|
+
"""
|
|
894
|
+
Create Plan-and-Execute agent
|
|
895
|
+
|
|
896
|
+
Note: The actual agent is created in plan_execute.py
|
|
897
|
+
This is a wrapper for compatibility with standard agent interface
|
|
898
|
+
"""
|
|
899
|
+
logger.info("Plan-and-Execute agent initialized")
|
|
900
|
+
return {
|
|
901
|
+
"type": "plan-execute",
|
|
902
|
+
"components": ["planner", "executor"],
|
|
903
|
+
"memory": get_memory(),
|
|
904
|
+
"callbacks": get_callbacks(),
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
def run(goal: str, context: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
909
|
+
"""
|
|
910
|
+
Run the Plan-and-Execute agent
|
|
911
|
+
|
|
912
|
+
Args:
|
|
913
|
+
goal: The objective to achieve
|
|
914
|
+
context: Optional context information
|
|
915
|
+
|
|
916
|
+
Returns:
|
|
917
|
+
Execution results with plan and step outputs
|
|
918
|
+
"""
|
|
919
|
+
logger.info(f"Running Plan-and-Execute agent for goal: {goal}")
|
|
920
|
+
|
|
921
|
+
# Delegate to plan_execute module
|
|
922
|
+
result = plan_execute_run(goal, context)
|
|
923
|
+
|
|
924
|
+
# Log cost summary
|
|
925
|
+
if "cost" in result:
|
|
926
|
+
logger.info(f"Total cost: {result['cost']}")
|
|
927
|
+
|
|
928
|
+
return result
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
if __name__ == "__main__":
|
|
932
|
+
# Example usage
|
|
933
|
+
print(f"Starting {agentName} (Plan-and-Execute Architecture)...")
|
|
934
|
+
print("=" * 60)
|
|
935
|
+
|
|
936
|
+
response = run("Research and write a blog post about AI trends in 2024")
|
|
937
|
+
|
|
938
|
+
print("\\n" + "=" * 60)
|
|
939
|
+
print(f"Success: {response['success']}")
|
|
940
|
+
print(f"\\nFinal Output:")
|
|
941
|
+
print(response['output'])
|
|
942
|
+
|
|
943
|
+
if 'plan' in response:
|
|
944
|
+
print(f"\\nExecution Plan:")
|
|
945
|
+
for step in response['plan']['steps']:
|
|
946
|
+
print(f" {step['id']}. {step['description']}")
|
|
947
|
+
|
|
948
|
+
if 'cost' in response:
|
|
949
|
+
print(f"\\nCost Summary: {response['cost']}")
|
|
950
|
+
`;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
//# sourceMappingURL=langchain-exporter.js.map
|