beddel 0.2.2 → 0.3.0
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 +50 -0
- package/README.md +117 -14
- package/dist/agents/chat/chat.handler.d.ts +12 -0
- package/dist/agents/chat/chat.handler.d.ts.map +1 -0
- package/dist/agents/chat/chat.handler.js +145 -0
- package/dist/agents/chat/chat.handler.js.map +1 -0
- package/dist/agents/chat/chat.schema.d.ts +38 -0
- package/dist/agents/chat/chat.schema.d.ts.map +1 -0
- package/dist/agents/chat/chat.schema.js +31 -0
- package/dist/agents/chat/chat.schema.js.map +1 -0
- package/dist/agents/chat/chat.types.d.ts +42 -0
- package/dist/agents/chat/chat.types.d.ts.map +1 -0
- package/dist/agents/chat/chat.types.js +6 -0
- package/dist/agents/chat/chat.types.js.map +1 -0
- package/dist/agents/chat/chat.yaml +148 -0
- package/dist/agents/chat/index.d.ts +16 -0
- package/dist/agents/chat/index.d.ts.map +1 -0
- package/dist/agents/chat/index.js +21 -0
- package/dist/agents/chat/index.js.map +1 -0
- package/dist/agents/chromadb/chromadb.handler.d.ts +12 -0
- package/dist/agents/chromadb/chromadb.handler.d.ts.map +1 -0
- package/dist/agents/chromadb/chromadb.handler.js +139 -0
- package/dist/agents/chromadb/chromadb.handler.js.map +1 -0
- package/dist/agents/chromadb/chromadb.schema.d.ts +36 -0
- package/dist/agents/chromadb/chromadb.schema.d.ts.map +1 -0
- package/dist/agents/chromadb/chromadb.schema.js +33 -0
- package/dist/agents/chromadb/chromadb.schema.js.map +1 -0
- package/dist/agents/chromadb/chromadb.types.d.ts +49 -0
- package/dist/agents/chromadb/chromadb.types.d.ts.map +1 -0
- package/dist/agents/chromadb/chromadb.types.js +6 -0
- package/dist/agents/chromadb/chromadb.types.js.map +1 -0
- package/dist/agents/chromadb/chromadb.yaml +128 -0
- package/dist/agents/chromadb/index.d.ts +15 -0
- package/dist/agents/chromadb/index.d.ts.map +1 -0
- package/dist/agents/chromadb/index.js +20 -0
- package/dist/agents/chromadb/index.js.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.handler.d.ts +8 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.handler.d.ts.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.handler.js +61 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.handler.js.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.schema.d.ts +22 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.schema.d.ts.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.schema.js +20 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.schema.js.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.types.d.ts +32 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.types.d.ts.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.types.js +6 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.types.js.map +1 -0
- package/dist/agents/gemini-vectorize/gemini-vectorize.yaml +84 -0
- package/dist/agents/gemini-vectorize/index.d.ts +15 -0
- package/dist/agents/gemini-vectorize/index.d.ts.map +1 -0
- package/dist/agents/gemini-vectorize/index.js +20 -0
- package/dist/agents/gemini-vectorize/index.js.map +1 -0
- package/dist/agents/gitmcp/gitmcp.handler.d.ts +12 -0
- package/dist/agents/gitmcp/gitmcp.handler.d.ts.map +1 -0
- package/dist/agents/gitmcp/gitmcp.handler.js +95 -0
- package/dist/agents/gitmcp/gitmcp.handler.js.map +1 -0
- package/dist/agents/gitmcp/gitmcp.schema.d.ts +17 -0
- package/dist/agents/gitmcp/gitmcp.schema.d.ts.map +1 -0
- package/dist/agents/gitmcp/gitmcp.schema.js +18 -0
- package/dist/agents/gitmcp/gitmcp.schema.js.map +1 -0
- package/dist/agents/gitmcp/gitmcp.types.d.ts +31 -0
- package/dist/agents/gitmcp/gitmcp.types.d.ts.map +1 -0
- package/dist/agents/gitmcp/gitmcp.types.js +6 -0
- package/dist/agents/gitmcp/gitmcp.types.js.map +1 -0
- package/dist/agents/gitmcp/gitmcp.yaml +71 -0
- package/dist/agents/gitmcp/index.d.ts +16 -0
- package/dist/agents/gitmcp/index.d.ts.map +1 -0
- package/dist/agents/gitmcp/index.js +21 -0
- package/dist/agents/gitmcp/index.js.map +1 -0
- package/dist/agents/image/image.handler.d.ts +8 -0
- package/dist/agents/image/image.handler.d.ts.map +1 -0
- package/dist/agents/image/image.handler.js +69 -0
- package/dist/agents/image/image.handler.js.map +1 -0
- package/dist/agents/image/image.schema.d.ts +29 -0
- package/dist/agents/image/image.schema.d.ts.map +1 -0
- package/dist/agents/image/image.schema.js +26 -0
- package/dist/agents/image/image.schema.js.map +1 -0
- package/dist/agents/image/image.types.d.ts +43 -0
- package/dist/agents/image/image.types.d.ts.map +1 -0
- package/dist/agents/image/image.types.js +6 -0
- package/dist/agents/image/image.types.js.map +1 -0
- package/{src/agents/image-agent.yaml → dist/agents/image/image.yaml} +21 -21
- package/dist/agents/image/index.d.ts +14 -0
- package/dist/agents/image/index.d.ts.map +1 -0
- package/dist/agents/image/index.js +19 -0
- package/dist/agents/image/index.js.map +1 -0
- package/dist/agents/index.d.ts +104 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +82 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/joker/index.d.ts +14 -0
- package/dist/agents/joker/index.d.ts.map +1 -0
- package/dist/agents/joker/index.js +19 -0
- package/dist/agents/joker/index.js.map +1 -0
- package/dist/agents/joker/joker.handler.d.ts +8 -0
- package/dist/agents/joker/joker.handler.d.ts.map +1 -0
- package/dist/agents/joker/joker.handler.js +44 -0
- package/dist/agents/joker/joker.handler.js.map +1 -0
- package/dist/agents/joker/joker.schema.d.ts +12 -0
- package/dist/agents/joker/joker.schema.d.ts.map +1 -0
- package/dist/agents/joker/joker.schema.js +13 -0
- package/dist/agents/joker/joker.schema.js.map +1 -0
- package/dist/agents/joker/joker.types.d.ts +36 -0
- package/dist/agents/joker/joker.types.d.ts.map +1 -0
- package/dist/agents/joker/joker.types.js +6 -0
- package/dist/agents/joker/joker.types.js.map +1 -0
- package/{src/agents/joker-agent.yaml → dist/agents/joker/joker.yaml} +4 -4
- package/dist/agents/llm/index.d.ts +15 -0
- package/dist/agents/llm/index.d.ts.map +1 -0
- package/dist/agents/llm/index.js +20 -0
- package/dist/agents/llm/index.js.map +1 -0
- package/dist/agents/llm/llm.handler.d.ts +8 -0
- package/dist/agents/llm/llm.handler.d.ts.map +1 -0
- package/dist/agents/llm/llm.handler.js +64 -0
- package/dist/agents/llm/llm.handler.js.map +1 -0
- package/dist/agents/llm/llm.schema.d.ts +26 -0
- package/dist/agents/llm/llm.schema.d.ts.map +1 -0
- package/dist/agents/llm/llm.schema.js +23 -0
- package/dist/agents/llm/llm.schema.js.map +1 -0
- package/dist/agents/llm/llm.types.d.ts +34 -0
- package/dist/agents/llm/llm.types.d.ts.map +1 -0
- package/dist/agents/llm/llm.types.js +7 -0
- package/dist/agents/llm/llm.types.js.map +1 -0
- package/dist/agents/llm/llm.yaml +87 -0
- package/dist/agents/mcp-tool/index.d.ts +14 -0
- package/dist/agents/mcp-tool/index.d.ts.map +1 -0
- package/dist/agents/mcp-tool/index.js +19 -0
- package/dist/agents/mcp-tool/index.js.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.handler.d.ts +12 -0
- package/dist/agents/mcp-tool/mcp-tool.handler.d.ts.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.handler.js +116 -0
- package/dist/agents/mcp-tool/mcp-tool.handler.js.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.schema.d.ts +19 -0
- package/dist/agents/mcp-tool/mcp-tool.schema.d.ts.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.schema.js +20 -0
- package/dist/agents/mcp-tool/mcp-tool.schema.js.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.types.d.ts +31 -0
- package/dist/agents/mcp-tool/mcp-tool.types.d.ts.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.types.js +6 -0
- package/dist/agents/mcp-tool/mcp-tool.types.js.map +1 -0
- package/dist/agents/mcp-tool/mcp-tool.yaml +71 -0
- package/dist/agents/rag/index.d.ts +15 -0
- package/dist/agents/rag/index.d.ts.map +1 -0
- package/dist/agents/rag/index.js +20 -0
- package/dist/agents/rag/index.js.map +1 -0
- package/dist/agents/rag/rag.handler.d.ts +9 -0
- package/dist/agents/rag/rag.handler.d.ts.map +1 -0
- package/dist/agents/rag/rag.handler.js +78 -0
- package/dist/agents/rag/rag.handler.js.map +1 -0
- package/dist/agents/rag/rag.schema.d.ts +27 -0
- package/dist/agents/rag/rag.schema.d.ts.map +1 -0
- package/dist/agents/rag/rag.schema.js +24 -0
- package/dist/agents/rag/rag.schema.js.map +1 -0
- package/dist/agents/rag/rag.types.d.ts +42 -0
- package/dist/agents/rag/rag.types.d.ts.map +1 -0
- package/dist/agents/rag/rag.types.js +7 -0
- package/dist/agents/rag/rag.types.js.map +1 -0
- package/dist/agents/rag/rag.yaml +89 -0
- package/dist/agents/{agentRegistry.d.ts → registry/agentRegistry.d.ts} +30 -1
- package/dist/agents/registry/agentRegistry.d.ts.map +1 -0
- package/dist/agents/{agentRegistry.js → registry/agentRegistry.js} +187 -5
- package/dist/agents/registry/agentRegistry.js.map +1 -0
- package/dist/agents/registry/index.d.ts +6 -0
- package/dist/agents/registry/index.d.ts.map +1 -0
- package/dist/agents/registry/index.js +10 -0
- package/dist/agents/registry/index.js.map +1 -0
- package/dist/agents/translator/index.d.ts +14 -0
- package/dist/agents/translator/index.d.ts.map +1 -0
- package/dist/agents/translator/index.js +19 -0
- package/dist/agents/translator/index.js.map +1 -0
- package/dist/agents/translator/translator.handler.d.ts +8 -0
- package/dist/agents/translator/translator.handler.d.ts.map +1 -0
- package/dist/agents/translator/translator.handler.js +81 -0
- package/dist/agents/translator/translator.handler.js.map +1 -0
- package/dist/agents/translator/translator.schema.d.ts +27 -0
- package/dist/agents/translator/translator.schema.d.ts.map +1 -0
- package/dist/agents/translator/translator.schema.js +28 -0
- package/dist/agents/translator/translator.schema.js.map +1 -0
- package/dist/agents/translator/translator.types.d.ts +41 -0
- package/dist/agents/translator/translator.types.d.ts.map +1 -0
- package/dist/agents/translator/translator.types.js +6 -0
- package/dist/agents/translator/translator.types.js.map +1 -0
- package/{src/agents/translator-agent.yaml → dist/agents/translator/translator.yaml} +27 -27
- package/dist/client/index.d.ts +89 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +93 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +17 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +7 -0
- package/dist/client/types.js.map +1 -0
- package/dist/firebase/tenantManager.d.ts +34 -2
- package/dist/firebase/tenantManager.d.ts.map +1 -1
- package/dist/firebase/tenantManager.js +67 -1
- package/dist/firebase/tenantManager.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/dist/runtime/declarativeAgentRuntime.d.ts +17 -52
- package/dist/runtime/declarativeAgentRuntime.d.ts.map +1 -1
- package/dist/runtime/declarativeAgentRuntime.js +259 -361
- package/dist/runtime/declarativeAgentRuntime.js.map +1 -1
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +38 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/llmProviderFactory.d.ts +47 -0
- package/dist/runtime/llmProviderFactory.d.ts.map +1 -0
- package/dist/runtime/llmProviderFactory.js +119 -0
- package/dist/runtime/llmProviderFactory.js.map +1 -0
- package/dist/runtime/workflowExecutor.d.ts +31 -0
- package/dist/runtime/workflowExecutor.d.ts.map +1 -0
- package/dist/runtime/workflowExecutor.js +80 -0
- package/dist/runtime/workflowExecutor.js.map +1 -0
- package/dist/server/api/graphql.js +3 -3
- package/dist/server/api/graphql.js.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.d.ts +7 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +23 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types/agent.types.d.ts +63 -0
- package/dist/shared/types/agent.types.d.ts.map +1 -0
- package/dist/shared/types/agent.types.js +18 -0
- package/dist/shared/types/agent.types.js.map +1 -0
- package/dist/shared/types/execution.types.d.ts +42 -0
- package/dist/shared/types/execution.types.d.ts.map +1 -0
- package/dist/shared/types/execution.types.js +7 -0
- package/dist/shared/types/execution.types.js.map +1 -0
- package/dist/shared/types/index.d.ts +7 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/shared/types/index.js +23 -0
- package/dist/shared/types/index.js.map +1 -0
- package/dist/shared/types/schema.types.d.ts +52 -0
- package/dist/shared/types/schema.types.d.ts.map +1 -0
- package/dist/shared/types/schema.types.js +7 -0
- package/dist/shared/types/schema.types.js.map +1 -0
- package/dist/shared/utils/index.d.ts +5 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +21 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/validation.d.ts +42 -0
- package/dist/shared/utils/validation.d.ts.map +1 -0
- package/dist/shared/utils/validation.js +93 -0
- package/dist/shared/utils/validation.js.map +1 -0
- package/dist/tenant/TenantManager.d.ts +152 -0
- package/dist/tenant/TenantManager.d.ts.map +1 -0
- package/dist/tenant/TenantManager.js +392 -0
- package/dist/tenant/TenantManager.js.map +1 -0
- package/dist/tenant/index.d.ts +47 -0
- package/dist/tenant/index.d.ts.map +1 -0
- package/dist/tenant/index.js +74 -0
- package/dist/tenant/index.js.map +1 -0
- package/dist/tenant/interfaces.d.ts +170 -0
- package/dist/tenant/interfaces.d.ts.map +1 -0
- package/dist/tenant/interfaces.js +67 -0
- package/dist/tenant/interfaces.js.map +1 -0
- package/dist/tenant/providerFactory.d.ts +43 -0
- package/dist/tenant/providerFactory.d.ts.map +1 -0
- package/dist/tenant/providerFactory.js +70 -0
- package/dist/tenant/providerFactory.js.map +1 -0
- package/dist/tenant/providerRegistry.d.ts +47 -0
- package/dist/tenant/providerRegistry.d.ts.map +1 -0
- package/dist/tenant/providerRegistry.js +79 -0
- package/dist/tenant/providerRegistry.js.map +1 -0
- package/dist/tenant/providers/FirebaseTenantProvider.d.ts +41 -0
- package/dist/tenant/providers/FirebaseTenantProvider.d.ts.map +1 -0
- package/dist/tenant/providers/FirebaseTenantProvider.js +290 -0
- package/dist/tenant/providers/FirebaseTenantProvider.js.map +1 -0
- package/dist/tenant/providers/InMemoryTenantProvider.d.ts +18 -0
- package/dist/tenant/providers/InMemoryTenantProvider.d.ts.map +1 -0
- package/dist/tenant/providers/InMemoryTenantProvider.js +137 -0
- package/dist/tenant/providers/InMemoryTenantProvider.js.map +1 -0
- package/package.json +46 -10
- package/src/agents/chat/chat.handler.ts +211 -0
- package/src/agents/chat/chat.schema.ts +33 -0
- package/src/agents/chat/chat.types.ts +46 -0
- package/src/agents/chat/chat.yaml +148 -0
- package/src/agents/chat/index.ts +21 -0
- package/src/agents/chromadb/chromadb.handler.ts +130 -0
- package/src/agents/chromadb/chromadb.schema.ts +35 -0
- package/src/agents/chromadb/chromadb.types.ts +52 -0
- package/src/agents/chromadb/chromadb.yaml +128 -0
- package/src/agents/chromadb/index.ts +20 -0
- package/src/agents/gemini-vectorize/gemini-vectorize.handler.ts +75 -0
- package/src/agents/gemini-vectorize/gemini-vectorize.schema.ts +22 -0
- package/src/agents/gemini-vectorize/gemini-vectorize.types.ts +34 -0
- package/src/agents/gemini-vectorize/gemini-vectorize.yaml +84 -0
- package/src/agents/gemini-vectorize/index.ts +20 -0
- package/src/agents/gitmcp/gitmcp.handler.ts +122 -0
- package/src/agents/gitmcp/gitmcp.schema.ts +20 -0
- package/src/agents/gitmcp/gitmcp.types.ts +33 -0
- package/src/agents/gitmcp/gitmcp.yaml +71 -0
- package/src/agents/gitmcp/index.ts +21 -0
- package/src/agents/image/image.handler.ts +86 -0
- package/src/agents/image/image.schema.ts +28 -0
- package/src/agents/image/image.types.ts +46 -0
- package/src/agents/image/image.yaml +86 -0
- package/src/agents/image/index.ts +19 -0
- package/src/agents/index.ts +63 -0
- package/src/agents/joker/index.ts +19 -0
- package/src/agents/joker/joker.handler.ts +55 -0
- package/src/agents/joker/joker.schema.ts +15 -0
- package/src/agents/joker/joker.types.ts +38 -0
- package/src/agents/joker/joker.yaml +47 -0
- package/src/agents/llm/index.ts +20 -0
- package/src/agents/llm/llm.handler.ts +82 -0
- package/src/agents/llm/llm.schema.ts +25 -0
- package/src/agents/llm/llm.types.ts +37 -0
- package/src/agents/llm/llm.yaml +87 -0
- package/src/agents/mcp-tool/index.ts +19 -0
- package/src/agents/mcp-tool/mcp-tool.handler.ts +112 -0
- package/src/agents/mcp-tool/mcp-tool.schema.ts +22 -0
- package/src/agents/mcp-tool/mcp-tool.types.ts +33 -0
- package/src/agents/mcp-tool/mcp-tool.yaml +71 -0
- package/src/agents/rag/index.ts +20 -0
- package/src/agents/rag/rag.handler.ts +95 -0
- package/src/agents/rag/rag.schema.ts +26 -0
- package/src/agents/rag/rag.types.ts +45 -0
- package/src/agents/rag/rag.yaml +89 -0
- package/src/agents/{agentRegistry.ts → registry/agentRegistry.ts} +195 -6
- package/src/agents/registry/index.ts +6 -0
- package/src/agents/translator/index.ts +19 -0
- package/src/agents/translator/translator.handler.ts +97 -0
- package/src/agents/translator/translator.schema.ts +30 -0
- package/src/agents/translator/translator.types.ts +43 -0
- package/src/agents/translator/translator.yaml +80 -0
- package/src/client/index.ts +53 -0
- package/src/client/types.ts +38 -0
- package/src/index.ts +56 -5
- package/src/runtime/declarativeAgentRuntime.ts +378 -495
- package/src/runtime/index.ts +36 -0
- package/src/runtime/llmProviderFactory.ts +145 -0
- package/src/runtime/workflowExecutor.ts +107 -0
- package/src/server/api/graphql.ts +1 -1
- package/src/server/index.ts +2 -2
- package/src/shared/index.ts +7 -0
- package/src/shared/types/agent.types.ts +100 -0
- package/src/shared/types/execution.types.ts +45 -0
- package/src/shared/types/index.ts +7 -0
- package/src/shared/types/schema.types.ts +55 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/utils/validation.ts +100 -0
- package/src/tenant/TenantManager.ts +488 -0
- package/src/tenant/index.ts +101 -0
- package/src/tenant/interfaces.ts +231 -0
- package/src/tenant/providerFactory.ts +75 -0
- package/src/tenant/providerRegistry.ts +86 -0
- package/src/tenant/providers/InMemoryTenantProvider.ts +168 -0
- package/dist/agents/agentRegistry.d.ts.map +0 -1
- package/dist/agents/agentRegistry.js.map +0 -1
- package/src/firebase/tenantManager.ts +0 -443
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Image Agent Handler - Server-only execution logic
|
|
5
|
+
* Generates images using LLM providers (Google Gemini Imagen by default)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { experimental_generateImage } from 'ai';
|
|
9
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
10
|
+
import { extractProviderConfig } from '../../runtime/llmProviderFactory';
|
|
11
|
+
import type { ExecutionContext } from '../../types/executionContext';
|
|
12
|
+
import type { ImageHandlerParams, ImageHandlerResult } from './image.types';
|
|
13
|
+
|
|
14
|
+
const GEMINI_IMAGE_MODEL = 'imagen-4.0-fast-generate-001';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Execute image generation using configured provider
|
|
18
|
+
*/
|
|
19
|
+
export async function executeImageHandler(
|
|
20
|
+
params: ImageHandlerParams,
|
|
21
|
+
props: Record<string, string>,
|
|
22
|
+
context: ExecutionContext
|
|
23
|
+
): Promise<ImageHandlerResult> {
|
|
24
|
+
const providerConfig = extractProviderConfig(props, 'google');
|
|
25
|
+
|
|
26
|
+
// Currently only Google supports image generation via Vercel AI SDK
|
|
27
|
+
if (providerConfig.provider !== 'google') {
|
|
28
|
+
throw new Error(`Image generation is currently only supported with Google provider, got: ${providerConfig.provider}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const description = params.description?.trim();
|
|
32
|
+
const style = params.style?.trim();
|
|
33
|
+
const resolution = params.resolution?.trim();
|
|
34
|
+
|
|
35
|
+
if (!description) {
|
|
36
|
+
throw new Error('Missing required image input: description');
|
|
37
|
+
}
|
|
38
|
+
if (!style) {
|
|
39
|
+
throw new Error('Missing required image input: style');
|
|
40
|
+
}
|
|
41
|
+
if (!resolution || !/^\d+x\d+$/.test(resolution)) {
|
|
42
|
+
throw new Error('Missing required image input: resolution (format: WIDTHxHEIGHT)');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const promptTemplate = params.promptTemplate?.trim() ||
|
|
46
|
+
'Create a detailed image in {{style}} style focusing on: {{description}}';
|
|
47
|
+
|
|
48
|
+
const prompt = promptTemplate
|
|
49
|
+
.replace(/{{description}}/g, description)
|
|
50
|
+
.replace(/{{style}}/g, style)
|
|
51
|
+
.trim();
|
|
52
|
+
|
|
53
|
+
const google = createGoogleGenerativeAI({ apiKey: providerConfig.apiKey });
|
|
54
|
+
const model = google.image(GEMINI_IMAGE_MODEL);
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
|
|
57
|
+
context.log(`[Image] Generating image with style=${style}, resolution=${resolution}`);
|
|
58
|
+
|
|
59
|
+
const result = await experimental_generateImage({
|
|
60
|
+
model,
|
|
61
|
+
prompt,
|
|
62
|
+
size: resolution as `${number}x${number}`,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const image = result.image;
|
|
66
|
+
if (!image?.base64 || !image.mediaType) {
|
|
67
|
+
throw new Error('Gemini Flash image helper returned an invalid file');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const normalizedBase64 = image.base64.replace(/\s+/g, '');
|
|
71
|
+
const imageUrl = `data:${image.mediaType};base64,${normalizedBase64}`;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
image_url: imageUrl,
|
|
75
|
+
image_base64: normalizedBase64,
|
|
76
|
+
media_type: image.mediaType,
|
|
77
|
+
prompt_used: prompt,
|
|
78
|
+
metadata: {
|
|
79
|
+
model_used: GEMINI_IMAGE_MODEL,
|
|
80
|
+
provider: providerConfig.provider,
|
|
81
|
+
processing_time: Date.now() - startTime,
|
|
82
|
+
style,
|
|
83
|
+
resolution,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Agent Schema - Zod validation schemas
|
|
3
|
+
* Safe for both client and server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const ImageInputSchema = z.object({
|
|
9
|
+
description: z.string().min(5).max(500),
|
|
10
|
+
style: z.enum(['watercolor', 'neon', 'sketch']),
|
|
11
|
+
resolution: z.string().regex(/^[0-9]{3,4}x[0-9]{3,4}$/),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const ImageOutputSchema = z.object({
|
|
15
|
+
image_url: z.string(),
|
|
16
|
+
image_base64: z.string().optional(),
|
|
17
|
+
media_type: z.string().optional(),
|
|
18
|
+
prompt_used: z.string(),
|
|
19
|
+
metadata: z.object({
|
|
20
|
+
model_used: z.string(),
|
|
21
|
+
processing_time: z.number(),
|
|
22
|
+
style: z.string(),
|
|
23
|
+
resolution: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type ImageInput = z.infer<typeof ImageInputSchema>;
|
|
28
|
+
export type ImageOutput = z.infer<typeof ImageOutputSchema>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Agent Types - Shared between client and server
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Supported image styles
|
|
7
|
+
*/
|
|
8
|
+
export type ImageStyle = 'watercolor' | 'neon' | 'sketch' | string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parameters for image generation
|
|
12
|
+
*/
|
|
13
|
+
export interface ImageHandlerParams {
|
|
14
|
+
description: string;
|
|
15
|
+
style: ImageStyle;
|
|
16
|
+
resolution: string;
|
|
17
|
+
promptTemplate?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Result from image generation
|
|
22
|
+
*/
|
|
23
|
+
export interface ImageHandlerResult {
|
|
24
|
+
image_url: string;
|
|
25
|
+
image_base64: string;
|
|
26
|
+
media_type: string;
|
|
27
|
+
prompt_used: string;
|
|
28
|
+
metadata: {
|
|
29
|
+
model_used: string;
|
|
30
|
+
provider: string;
|
|
31
|
+
processing_time: number;
|
|
32
|
+
style: string;
|
|
33
|
+
resolution: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Image agent metadata
|
|
39
|
+
*/
|
|
40
|
+
export interface ImageMetadata {
|
|
41
|
+
id: 'image';
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
category: 'creative';
|
|
45
|
+
route: '/agents/image';
|
|
46
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Image Generator Agent - Declarative Genkit workflow
|
|
2
|
+
# Route: /agents/image
|
|
3
|
+
# Method: image.generate
|
|
4
|
+
|
|
5
|
+
agent:
|
|
6
|
+
id: image
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
protocol: beddel-declarative-protocol/v2.0
|
|
9
|
+
|
|
10
|
+
metadata:
|
|
11
|
+
name: "Image Generator Agent"
|
|
12
|
+
description: "Generates images using Gemini Flash with curated styles"
|
|
13
|
+
category: "creative"
|
|
14
|
+
route: "/agents/image"
|
|
15
|
+
|
|
16
|
+
schema:
|
|
17
|
+
input:
|
|
18
|
+
type: "object"
|
|
19
|
+
properties:
|
|
20
|
+
description:
|
|
21
|
+
type: "string"
|
|
22
|
+
minLength: 5
|
|
23
|
+
maxLength: 500
|
|
24
|
+
description: "Detailed textual description of the scene"
|
|
25
|
+
style:
|
|
26
|
+
type: "string"
|
|
27
|
+
enum: ["watercolor", "neon", "sketch"]
|
|
28
|
+
description: "Desired visual style"
|
|
29
|
+
resolution:
|
|
30
|
+
type: "string"
|
|
31
|
+
pattern: "^[0-9]{3,4}x[0-9]{3,4}$"
|
|
32
|
+
description: "Resolution in WIDTHxHEIGHT format (e.g., 1024x1024)"
|
|
33
|
+
required: ["description", "style", "resolution"]
|
|
34
|
+
|
|
35
|
+
output:
|
|
36
|
+
type: "object"
|
|
37
|
+
properties:
|
|
38
|
+
image_url:
|
|
39
|
+
type: "string"
|
|
40
|
+
image_base64:
|
|
41
|
+
type: "string"
|
|
42
|
+
media_type:
|
|
43
|
+
type: "string"
|
|
44
|
+
prompt_used:
|
|
45
|
+
type: "string"
|
|
46
|
+
metadata:
|
|
47
|
+
type: "object"
|
|
48
|
+
properties:
|
|
49
|
+
model_used:
|
|
50
|
+
type: "string"
|
|
51
|
+
processing_time:
|
|
52
|
+
type: "number"
|
|
53
|
+
style:
|
|
54
|
+
type: "string"
|
|
55
|
+
resolution:
|
|
56
|
+
type: "string"
|
|
57
|
+
required: ["model_used", "processing_time", "style", "resolution"]
|
|
58
|
+
required: ["image_url", "prompt_used", "metadata"]
|
|
59
|
+
|
|
60
|
+
logic:
|
|
61
|
+
workflow:
|
|
62
|
+
- name: "generate-image"
|
|
63
|
+
type: "genkit-image"
|
|
64
|
+
action:
|
|
65
|
+
type: "image"
|
|
66
|
+
result: "imageResult"
|
|
67
|
+
promptTemplate: "Create an image in {{style}} style focusing on: {{description}}"
|
|
68
|
+
|
|
69
|
+
- name: "deliver-image"
|
|
70
|
+
type: "output-generator"
|
|
71
|
+
action:
|
|
72
|
+
type: "generate"
|
|
73
|
+
output:
|
|
74
|
+
image_url: "$imageResult.image_url"
|
|
75
|
+
image_base64: "$imageResult.image_base64"
|
|
76
|
+
media_type: "$imageResult.media_type"
|
|
77
|
+
prompt_used: "$imageResult.prompt_used"
|
|
78
|
+
metadata: "$imageResult.metadata"
|
|
79
|
+
|
|
80
|
+
output:
|
|
81
|
+
schema:
|
|
82
|
+
image_url: "$imageResult.image_url"
|
|
83
|
+
image_base64: "$imageResult.image_base64"
|
|
84
|
+
media_type: "$imageResult.media_type"
|
|
85
|
+
prompt_used: "$imageResult.prompt_used"
|
|
86
|
+
metadata: "$imageResult.metadata"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Agent - Public exports (client-safe)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Schema exports (client-safe)
|
|
6
|
+
export { ImageInputSchema, ImageOutputSchema } from './image.schema';
|
|
7
|
+
export type { ImageInput, ImageOutput } from './image.schema';
|
|
8
|
+
|
|
9
|
+
// Type exports (client-safe)
|
|
10
|
+
export type { ImageStyle, ImageHandlerParams, ImageHandlerResult, ImageMetadata } from './image.types';
|
|
11
|
+
|
|
12
|
+
// Metadata (client-safe)
|
|
13
|
+
export const imageMetadata = {
|
|
14
|
+
id: 'image',
|
|
15
|
+
name: 'Image Generator Agent',
|
|
16
|
+
description: 'Generates images using Gemini Flash with curated styles',
|
|
17
|
+
category: 'creative',
|
|
18
|
+
route: '/agents/image',
|
|
19
|
+
} as const;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents Module - Public exports
|
|
3
|
+
*
|
|
4
|
+
* This module provides the agent registry and agent metadata.
|
|
5
|
+
* Handler implementations are server-only and should be imported directly
|
|
6
|
+
* from their respective agent folders when needed.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Registry exports
|
|
10
|
+
export { AgentRegistry, agentRegistry } from './registry';
|
|
11
|
+
export type { AgentRegistration } from './registry';
|
|
12
|
+
|
|
13
|
+
// Agent metadata exports (client-safe)
|
|
14
|
+
export { jokerMetadata } from './joker';
|
|
15
|
+
export { translatorMetadata } from './translator';
|
|
16
|
+
export { imageMetadata } from './image';
|
|
17
|
+
export { mcpToolMetadata } from './mcp-tool';
|
|
18
|
+
export { geminiVectorizeMetadata } from './gemini-vectorize';
|
|
19
|
+
export { chromadbMetadata } from './chromadb';
|
|
20
|
+
export { gitmcpMetadata } from './gitmcp';
|
|
21
|
+
export { ragMetadata } from './rag';
|
|
22
|
+
export { llmMetadata } from './llm';
|
|
23
|
+
export { chatMetadata } from './chat';
|
|
24
|
+
|
|
25
|
+
// Schema exports (client-safe)
|
|
26
|
+
export { JokerInputSchema, JokerOutputSchema } from './joker';
|
|
27
|
+
export { TranslatorInputSchema, TranslatorOutputSchema } from './translator';
|
|
28
|
+
export { ImageInputSchema, ImageOutputSchema } from './image';
|
|
29
|
+
export { McpToolInputSchema, McpToolOutputSchema } from './mcp-tool';
|
|
30
|
+
export { GeminiVectorizeInputSchema, GeminiVectorizeOutputSchema } from './gemini-vectorize';
|
|
31
|
+
export { ChromaDBInputSchema, ChromaDBOutputSchema } from './chromadb';
|
|
32
|
+
export { GitMcpInputSchema, GitMcpOutputSchema } from './gitmcp';
|
|
33
|
+
export { RagInputSchema, RagOutputSchema } from './rag';
|
|
34
|
+
export { LlmInputSchema, LlmOutputSchema } from './llm';
|
|
35
|
+
export { ChatInputSchema, ChatOutputSchema } from './chat';
|
|
36
|
+
|
|
37
|
+
// Type exports (client-safe)
|
|
38
|
+
export type { JokerInput, JokerOutput, JokeHandlerParams, JokeHandlerResult } from './joker';
|
|
39
|
+
export type { TranslatorInput, TranslatorOutput, TranslationHandlerParams, TranslationHandlerResult } from './translator';
|
|
40
|
+
export type { ImageInput, ImageOutput, ImageStyle, ImageHandlerParams, ImageHandlerResult } from './image';
|
|
41
|
+
export type { McpToolInput, McpToolOutput, McpToolHandlerParams, McpToolHandlerResult } from './mcp-tool';
|
|
42
|
+
export type { GeminiVectorizeInput, GeminiVectorizeOutput, VectorizeHandlerParams, VectorizeHandlerResult } from './gemini-vectorize';
|
|
43
|
+
export type { ChromaDBInput, ChromaDBOutput, ChromaDBHandlerParams, ChromaDBHandlerResult, ChromaDBSearchResult } from './chromadb';
|
|
44
|
+
export type { GitMcpInput, GitMcpOutput, GitMcpHandlerParams, GitMcpHandlerResult } from './gitmcp';
|
|
45
|
+
export type { RagInput, RagOutput, RagHandlerParams, RagHandlerResult, ConversationMessage } from './rag';
|
|
46
|
+
export type { LlmInput, LlmOutput, LlmHandlerParams, LlmHandlerResult } from './llm';
|
|
47
|
+
export type { ChatInput, ChatOutput, ChatHandlerParams, ChatHandlerResult } from './chat';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* All agent metadata for UI display
|
|
51
|
+
*/
|
|
52
|
+
export const allAgentMetadata = [
|
|
53
|
+
{ id: 'joker', name: 'Joker Agent', description: 'Tells jokes using Gemini Flash', category: 'utility', route: '/agents/joker' },
|
|
54
|
+
{ id: 'translator', name: 'Translator Agent', description: 'Translates text between languages using Gemini Flash via Genkit', category: 'translation', route: '/agents/translator' },
|
|
55
|
+
{ id: 'image', name: 'Image Generator Agent', description: 'Generates images using Gemini Flash with curated styles', category: 'creative', route: '/agents/image' },
|
|
56
|
+
{ id: 'mcp-tool', name: 'MCP Tool Agent', description: 'Generic agent for calling MCP server tools via SSE transport', category: 'integration', route: '/agents/mcp-tool' },
|
|
57
|
+
{ id: 'gemini-vectorize', name: 'Gemini Vectorize Agent', description: "Generates text embeddings using Google's Gemini text-embedding-004 model", category: 'ai-service', route: '/agents/gemini-vectorize' },
|
|
58
|
+
{ id: 'chromadb', name: 'ChromaDB Agent', description: 'Vector storage and retrieval using ChromaDB. Supports local and cloud deployments.', category: 'database', route: '/agents/chromadb' },
|
|
59
|
+
{ id: 'gitmcp', name: 'GitMCP Documentation Agent', description: 'Fetches and chunks GitHub repository documentation via gitmcp.io MCP servers', category: 'integration', route: '/agents/gitmcp' },
|
|
60
|
+
{ id: 'rag', name: 'RAG Intelligence Agent', description: 'Generates natural language answers based on provided document context using Gemini', category: 'intelligence', route: '/agents/rag' },
|
|
61
|
+
{ id: 'llm', name: 'LLM Chat Agent', description: 'Direct LLM interaction with conversation history support (non-RAG)', category: 'intelligence', route: '/agents/llm' },
|
|
62
|
+
{ id: 'chat', name: 'Q&A Context Chat Agent', description: 'Orchestrates RAG pipeline or direct LLM chat based on mode selection', category: 'chat', route: '/agents/chat' },
|
|
63
|
+
] as const;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joker Agent - Public exports (client-safe)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Schema exports (client-safe)
|
|
6
|
+
export { JokerInputSchema, JokerOutputSchema } from './joker.schema';
|
|
7
|
+
export type { JokerInput, JokerOutput } from './joker.schema';
|
|
8
|
+
|
|
9
|
+
// Type exports (client-safe)
|
|
10
|
+
export type { JokeHandlerParams, JokeHandlerResult, JokerMetadata } from './joker.types';
|
|
11
|
+
|
|
12
|
+
// Metadata (client-safe)
|
|
13
|
+
export const jokerMetadata = {
|
|
14
|
+
id: 'joker',
|
|
15
|
+
name: 'Joker Agent',
|
|
16
|
+
description: 'Tells jokes using Gemini Flash',
|
|
17
|
+
category: 'utility',
|
|
18
|
+
route: '/agents/joker',
|
|
19
|
+
} as const;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Joker Agent Handler - Server-only execution logic
|
|
5
|
+
* Generates jokes using LLM providers (Google Gemini by default)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { generateText } from 'ai';
|
|
9
|
+
import { LLMProviderFactory, extractProviderConfig } from '../../runtime/llmProviderFactory';
|
|
10
|
+
import type { ExecutionContext } from '../../types/executionContext';
|
|
11
|
+
import type { JokeHandlerParams, JokeHandlerResult } from './joker.types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Execute joke generation using configured LLM provider
|
|
15
|
+
*/
|
|
16
|
+
export async function executeJokeHandler(
|
|
17
|
+
params: JokeHandlerParams,
|
|
18
|
+
props: Record<string, string>,
|
|
19
|
+
context: ExecutionContext
|
|
20
|
+
): Promise<JokeHandlerResult> {
|
|
21
|
+
const providerConfig = extractProviderConfig(props, 'google');
|
|
22
|
+
const model = LLMProviderFactory.createLanguageModel(providerConfig);
|
|
23
|
+
|
|
24
|
+
const prompt = params.prompt?.trim() || 'Tell a short and original joke that works for any audience.';
|
|
25
|
+
const temperature = params.temperature ?? 0.8;
|
|
26
|
+
const maxTokens = params.maxTokens;
|
|
27
|
+
|
|
28
|
+
const startTime = Date.now();
|
|
29
|
+
|
|
30
|
+
context.log(`[Joker] Generating joke with temperature=${temperature}`);
|
|
31
|
+
|
|
32
|
+
const { text } = await generateText({
|
|
33
|
+
model,
|
|
34
|
+
prompt,
|
|
35
|
+
temperature,
|
|
36
|
+
...(maxTokens && { maxOutputTokens: maxTokens }),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const finalText = text?.trim() || '';
|
|
40
|
+
if (!finalText) {
|
|
41
|
+
throw new Error('Gemini returned empty response');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
text: finalText,
|
|
46
|
+
metadata: {
|
|
47
|
+
model_used: providerConfig.model || LLMProviderFactory.getDefaultModel(providerConfig.provider),
|
|
48
|
+
provider: providerConfig.provider,
|
|
49
|
+
processing_time: Date.now() - startTime,
|
|
50
|
+
temperature,
|
|
51
|
+
max_tokens: maxTokens ?? null,
|
|
52
|
+
prompt_used: prompt,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joker Agent Schema - Zod validation schemas
|
|
3
|
+
* Safe for both client and server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const JokerInputSchema = z.object({}).optional();
|
|
9
|
+
|
|
10
|
+
export const JokerOutputSchema = z.object({
|
|
11
|
+
response: z.string(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type JokerInput = z.infer<typeof JokerInputSchema>;
|
|
15
|
+
export type JokerOutput = z.infer<typeof JokerOutputSchema>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joker Agent Types - Shared between client and server
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for joke generation
|
|
7
|
+
*/
|
|
8
|
+
export interface JokeHandlerParams {
|
|
9
|
+
prompt?: string;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Result from joke generation
|
|
16
|
+
*/
|
|
17
|
+
export interface JokeHandlerResult {
|
|
18
|
+
text: string;
|
|
19
|
+
metadata: {
|
|
20
|
+
model_used: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
processing_time: number;
|
|
23
|
+
temperature: number;
|
|
24
|
+
max_tokens: number | null;
|
|
25
|
+
prompt_used: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Joker agent metadata
|
|
31
|
+
*/
|
|
32
|
+
export interface JokerMetadata {
|
|
33
|
+
id: 'joker';
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
category: 'utility';
|
|
37
|
+
route: '/agents/joker';
|
|
38
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Joker Agent - Simple Response Agent for Beddel Runtime
|
|
2
|
+
# Route: /agents/joker
|
|
3
|
+
# Method: joker.execute
|
|
4
|
+
|
|
5
|
+
agent:
|
|
6
|
+
id: joker
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
protocol: beddel-declarative-protocol/v2.0
|
|
9
|
+
|
|
10
|
+
metadata:
|
|
11
|
+
name: "Joker Agent"
|
|
12
|
+
description: "Tells jokes using Gemini Flash"
|
|
13
|
+
category: "utility"
|
|
14
|
+
route: "/agents/joker"
|
|
15
|
+
|
|
16
|
+
schema:
|
|
17
|
+
input:
|
|
18
|
+
type: "object"
|
|
19
|
+
properties: {}
|
|
20
|
+
required: []
|
|
21
|
+
|
|
22
|
+
output:
|
|
23
|
+
type: "object"
|
|
24
|
+
properties:
|
|
25
|
+
response:
|
|
26
|
+
type: "string"
|
|
27
|
+
required: ["response"]
|
|
28
|
+
|
|
29
|
+
logic:
|
|
30
|
+
workflow:
|
|
31
|
+
- name: "generate-joke"
|
|
32
|
+
type: "genkit-joke"
|
|
33
|
+
action:
|
|
34
|
+
type: "joke"
|
|
35
|
+
prompt: "Tell a short and original joke that works for any audience."
|
|
36
|
+
result: "jokerResult"
|
|
37
|
+
|
|
38
|
+
- name: "deliver-response"
|
|
39
|
+
type: "output-generator"
|
|
40
|
+
action:
|
|
41
|
+
type: "generate"
|
|
42
|
+
output:
|
|
43
|
+
response: "$jokerResult.text"
|
|
44
|
+
|
|
45
|
+
output:
|
|
46
|
+
schema:
|
|
47
|
+
response: "$jokerResult.text"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Agent - Public exports (client-safe)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Schema exports (client-safe)
|
|
6
|
+
export { LlmInputSchema, LlmOutputSchema } from './llm.schema';
|
|
7
|
+
export type { LlmInput, LlmOutput } from './llm.schema';
|
|
8
|
+
|
|
9
|
+
// Type exports (client-safe)
|
|
10
|
+
export type { LlmHandlerParams, LlmHandlerResult, LlmMetadata } from './llm.types';
|
|
11
|
+
|
|
12
|
+
// Metadata (client-safe)
|
|
13
|
+
export const llmMetadata = {
|
|
14
|
+
id: 'llm',
|
|
15
|
+
name: 'LLM Chat Agent',
|
|
16
|
+
description: 'Direct LLM interaction with conversation history support (non-RAG)',
|
|
17
|
+
category: 'intelligence',
|
|
18
|
+
route: '/agents/llm',
|
|
19
|
+
tags: ['llm', 'chat', 'gemini', 'conversation'],
|
|
20
|
+
} as const;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LLM Agent Handler - Server-only execution logic
|
|
5
|
+
* Direct LLM interaction with conversation history support (non-RAG)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { generateText } from 'ai';
|
|
9
|
+
import { LLMProviderFactory, extractProviderConfig } from '../../runtime/llmProviderFactory';
|
|
10
|
+
import type { ExecutionContext } from '../../types/executionContext';
|
|
11
|
+
import type { LlmHandlerParams, LlmHandlerResult } from './llm.types';
|
|
12
|
+
import type { ConversationMessage } from '../rag/rag.types';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Build prompt for direct LLM chat (no document context)
|
|
16
|
+
*/
|
|
17
|
+
function buildChatPrompt(
|
|
18
|
+
query: string,
|
|
19
|
+
history?: ConversationMessage[],
|
|
20
|
+
systemPrompt?: string
|
|
21
|
+
): string {
|
|
22
|
+
const system = systemPrompt || 'You are a helpful, friendly assistant.';
|
|
23
|
+
|
|
24
|
+
const conversationContext = history?.length
|
|
25
|
+
? `CONVERSATION HISTORY:\n${history.map((m) => `${m.role.toUpperCase()}: ${m.content}`).join('\n')}\n\n`
|
|
26
|
+
: '';
|
|
27
|
+
|
|
28
|
+
return `${system}
|
|
29
|
+
|
|
30
|
+
${conversationContext}USER MESSAGE:
|
|
31
|
+
${query}
|
|
32
|
+
|
|
33
|
+
INSTRUCTIONS:
|
|
34
|
+
1. Respond naturally to the user's message.
|
|
35
|
+
2. Consider the conversation history for context continuity if available.
|
|
36
|
+
3. Be concise but helpful.
|
|
37
|
+
|
|
38
|
+
RESPONSE:`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Execute direct LLM chat
|
|
43
|
+
*/
|
|
44
|
+
export async function executeLlmHandler(
|
|
45
|
+
params: LlmHandlerParams,
|
|
46
|
+
props: Record<string, string>,
|
|
47
|
+
context: ExecutionContext
|
|
48
|
+
): Promise<LlmHandlerResult> {
|
|
49
|
+
const providerConfig = extractProviderConfig(props, 'google');
|
|
50
|
+
const model = LLMProviderFactory.createLanguageModel(providerConfig);
|
|
51
|
+
|
|
52
|
+
const { query, history, temperature = 0.7, systemPrompt } = params;
|
|
53
|
+
|
|
54
|
+
if (!query) {
|
|
55
|
+
throw new Error('Missing required LLM input: query');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prompt = buildChatPrompt(query, history, systemPrompt);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
context.log(`[LLM] Generating response for: "${query.substring(0, 50)}..."`);
|
|
62
|
+
|
|
63
|
+
const { text } = await generateText({
|
|
64
|
+
model,
|
|
65
|
+
prompt,
|
|
66
|
+
temperature,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
response: text,
|
|
71
|
+
timestamp: new Date().toISOString(),
|
|
72
|
+
};
|
|
73
|
+
} catch (error: unknown) {
|
|
74
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
+
context.log(`[LLM] Error: ${message}`);
|
|
76
|
+
return {
|
|
77
|
+
response: '',
|
|
78
|
+
timestamp: new Date().toISOString(),
|
|
79
|
+
error: message,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Agent Schema - Zod validation schemas
|
|
3
|
+
* Safe for both client and server
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const LlmInputSchema = z.object({
|
|
9
|
+
query: z.string().min(1),
|
|
10
|
+
history: z.array(z.object({
|
|
11
|
+
role: z.enum(['user', 'assistant', 'system']),
|
|
12
|
+
content: z.string(),
|
|
13
|
+
})).optional(),
|
|
14
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
15
|
+
systemPrompt: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const LlmOutputSchema = z.object({
|
|
19
|
+
response: z.string(),
|
|
20
|
+
timestamp: z.string().optional(),
|
|
21
|
+
error: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type LlmInput = z.infer<typeof LlmInputSchema>;
|
|
25
|
+
export type LlmOutput = z.infer<typeof LlmOutputSchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Agent Types - Shared between client and server
|
|
3
|
+
* Direct LLM interaction without document context (non-RAG)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ConversationMessage } from '../rag/rag.types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for direct LLM chat
|
|
10
|
+
*/
|
|
11
|
+
export interface LlmHandlerParams {
|
|
12
|
+
query: string;
|
|
13
|
+
history?: ConversationMessage[];
|
|
14
|
+
temperature?: number;
|
|
15
|
+
systemPrompt?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Result from LLM chat
|
|
20
|
+
*/
|
|
21
|
+
export interface LlmHandlerResult {
|
|
22
|
+
response: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* LLM agent metadata
|
|
29
|
+
*/
|
|
30
|
+
export interface LlmMetadata {
|
|
31
|
+
id: 'llm';
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
category: 'intelligence';
|
|
35
|
+
route: '/agents/llm';
|
|
36
|
+
tags: string[];
|
|
37
|
+
}
|