agent-orcha 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +792 -125
- package/dist/lib/agents/agent-executor.d.ts +6 -1
- package/dist/lib/agents/agent-executor.d.ts.map +1 -1
- package/dist/lib/agents/agent-executor.js +241 -45
- package/dist/lib/agents/agent-executor.js.map +1 -1
- package/dist/lib/agents/agent-loader.d.ts.map +1 -1
- package/dist/lib/agents/agent-loader.js +3 -1
- package/dist/lib/agents/agent-loader.js.map +1 -1
- package/dist/lib/agents/index.d.ts +2 -1
- package/dist/lib/agents/index.d.ts.map +1 -1
- package/dist/lib/agents/index.js +1 -0
- package/dist/lib/agents/index.js.map +1 -1
- package/dist/lib/agents/structured-output-wrapper.d.ts +19 -0
- package/dist/lib/agents/structured-output-wrapper.d.ts.map +1 -0
- package/dist/lib/agents/structured-output-wrapper.js +104 -0
- package/dist/lib/agents/structured-output-wrapper.js.map +1 -0
- package/dist/lib/agents/types.d.ts +17 -10
- package/dist/lib/agents/types.d.ts.map +1 -1
- package/dist/lib/agents/types.js +1 -1
- package/dist/lib/agents/types.js.map +1 -1
- package/dist/lib/index.d.ts +9 -7
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +7 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/knowledge/graph-rag/community-detector.d.ts +16 -0
- package/dist/lib/knowledge/graph-rag/community-detector.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/community-detector.js +81 -0
- package/dist/lib/knowledge/graph-rag/community-detector.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/community-summarizer.d.ts +17 -0
- package/dist/lib/knowledge/graph-rag/community-summarizer.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/community-summarizer.js +87 -0
- package/dist/lib/knowledge/graph-rag/community-summarizer.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/entity-extractor.d.ts +36 -0
- package/dist/lib/knowledge/graph-rag/entity-extractor.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/entity-extractor.js +192 -0
- package/dist/lib/knowledge/graph-rag/entity-extractor.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/extraction-cache.d.ts +30 -0
- package/dist/lib/knowledge/graph-rag/extraction-cache.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/extraction-cache.js +88 -0
- package/dist/lib/knowledge/graph-rag/extraction-cache.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/global-search.d.ts +19 -0
- package/dist/lib/knowledge/graph-rag/global-search.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/global-search.js +96 -0
- package/dist/lib/knowledge/graph-rag/global-search.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.d.ts +24 -0
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.js +239 -0
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/index.d.ts +14 -0
- package/dist/lib/knowledge/graph-rag/index.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/index.js +12 -0
- package/dist/lib/knowledge/graph-rag/index.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/local-search.d.ts +20 -0
- package/dist/lib/knowledge/graph-rag/local-search.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/local-search.js +110 -0
- package/dist/lib/knowledge/graph-rag/local-search.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/memory-graph-store.d.ts +31 -0
- package/dist/lib/knowledge/graph-rag/memory-graph-store.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/memory-graph-store.js +165 -0
- package/dist/lib/knowledge/graph-rag/memory-graph-store.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.d.ts +38 -0
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.js +190 -0
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/search-mode-detector.d.ts +11 -0
- package/dist/lib/knowledge/graph-rag/search-mode-detector.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/search-mode-detector.js +50 -0
- package/dist/lib/knowledge/graph-rag/search-mode-detector.js.map +1 -0
- package/dist/lib/knowledge/graph-rag/types.d.ts +368 -0
- package/dist/lib/knowledge/graph-rag/types.d.ts.map +1 -0
- package/dist/lib/knowledge/graph-rag/types.js +48 -0
- package/dist/lib/knowledge/graph-rag/types.js.map +1 -0
- package/dist/lib/knowledge/index.d.ts +9 -0
- package/dist/lib/knowledge/index.d.ts.map +1 -0
- package/dist/lib/knowledge/index.js +8 -0
- package/dist/lib/knowledge/index.js.map +1 -0
- package/dist/lib/knowledge/knowledge-store-factory.d.ts +16 -0
- package/dist/lib/knowledge/knowledge-store-factory.d.ts.map +1 -0
- package/dist/lib/{vectors/vector-store-factory.js → knowledge/knowledge-store-factory.js} +36 -10
- package/dist/lib/knowledge/knowledge-store-factory.js.map +1 -0
- package/dist/lib/knowledge/knowledge-store-manager.d.ts +18 -0
- package/dist/lib/knowledge/knowledge-store-manager.d.ts.map +1 -0
- package/dist/lib/knowledge/knowledge-store-manager.js +98 -0
- package/dist/lib/knowledge/knowledge-store-manager.js.map +1 -0
- package/dist/lib/knowledge/loaders/database-loader.d.ts +18 -0
- package/dist/lib/knowledge/loaders/database-loader.d.ts.map +1 -0
- package/dist/lib/knowledge/loaders/database-loader.js +115 -0
- package/dist/lib/knowledge/loaders/database-loader.js.map +1 -0
- package/dist/lib/knowledge/loaders/index.d.ts +4 -0
- package/dist/lib/knowledge/loaders/index.d.ts.map +1 -0
- package/dist/lib/knowledge/loaders/index.js +4 -0
- package/dist/lib/knowledge/loaders/index.js.map +1 -0
- package/dist/lib/knowledge/loaders/s3-loader.d.ts +17 -0
- package/dist/lib/knowledge/loaders/s3-loader.d.ts.map +1 -0
- package/dist/lib/knowledge/loaders/s3-loader.js +185 -0
- package/dist/lib/knowledge/loaders/s3-loader.js.map +1 -0
- package/dist/lib/knowledge/loaders/web-loader.d.ts +12 -0
- package/dist/lib/knowledge/loaders/web-loader.d.ts.map +1 -0
- package/dist/lib/knowledge/loaders/web-loader.js +56 -0
- package/dist/lib/knowledge/loaders/web-loader.js.map +1 -0
- package/dist/lib/knowledge/types.d.ts +1839 -0
- package/dist/lib/knowledge/types.d.ts.map +1 -0
- package/dist/lib/knowledge/types.js +111 -0
- package/dist/lib/knowledge/types.js.map +1 -0
- package/dist/lib/knowledge/utils/connection-pool.d.ts +18 -0
- package/dist/lib/knowledge/utils/connection-pool.d.ts.map +1 -0
- package/dist/lib/knowledge/utils/connection-pool.js +77 -0
- package/dist/lib/knowledge/utils/connection-pool.js.map +1 -0
- package/dist/lib/knowledge/utils/file-type-detector.d.ts +10 -0
- package/dist/lib/knowledge/utils/file-type-detector.d.ts.map +1 -0
- package/dist/lib/knowledge/utils/file-type-detector.js +32 -0
- package/dist/lib/knowledge/utils/file-type-detector.js.map +1 -0
- package/dist/lib/knowledge/utils/index.d.ts +3 -0
- package/dist/lib/knowledge/utils/index.d.ts.map +1 -0
- package/dist/lib/knowledge/utils/index.js +3 -0
- package/dist/lib/knowledge/utils/index.js.map +1 -0
- package/dist/lib/mcp/mcp-client.d.ts +9 -1
- package/dist/lib/mcp/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp/mcp-client.js +33 -0
- package/dist/lib/mcp/mcp-client.js.map +1 -1
- package/dist/lib/memory/conversation-store.d.ts +43 -0
- package/dist/lib/memory/conversation-store.d.ts.map +1 -0
- package/dist/lib/memory/conversation-store.js +109 -0
- package/dist/lib/memory/conversation-store.js.map +1 -0
- package/dist/lib/memory/index.d.ts +3 -0
- package/dist/lib/memory/index.d.ts.map +1 -0
- package/dist/lib/memory/index.js +3 -0
- package/dist/lib/memory/index.js.map +1 -0
- package/dist/lib/memory/types.d.ts +19 -0
- package/dist/lib/memory/types.d.ts.map +1 -0
- package/dist/lib/memory/types.js +6 -0
- package/dist/lib/memory/types.js.map +1 -0
- package/dist/lib/orchestrator.d.ts +56 -14
- package/dist/lib/orchestrator.d.ts.map +1 -1
- package/dist/lib/orchestrator.js +182 -25
- package/dist/lib/orchestrator.js.map +1 -1
- package/dist/lib/tools/agent-tool-wrapper.d.ts +22 -0
- package/dist/lib/tools/agent-tool-wrapper.d.ts.map +1 -0
- package/dist/lib/tools/agent-tool-wrapper.js +56 -0
- package/dist/lib/tools/agent-tool-wrapper.js.map +1 -0
- package/dist/lib/tools/built-in/ask-user.tool.d.ts +7 -0
- package/dist/lib/tools/built-in/ask-user.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/ask-user.tool.js +23 -0
- package/dist/lib/tools/built-in/ask-user.tool.js.map +1 -0
- package/dist/lib/tools/built-in/index.d.ts +2 -1
- package/dist/lib/tools/built-in/index.d.ts.map +1 -1
- package/dist/lib/tools/built-in/index.js +2 -1
- package/dist/lib/tools/built-in/index.js.map +1 -1
- package/dist/lib/tools/built-in/knowledge-search.tool.d.ts +4 -0
- package/dist/lib/tools/built-in/knowledge-search.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/{vector-search.tool.js → knowledge-search.tool.js} +4 -4
- package/dist/lib/tools/built-in/knowledge-search.tool.js.map +1 -0
- package/dist/lib/tools/index.d.ts +3 -1
- package/dist/lib/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/index.js +3 -1
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/tool-discovery.d.ts +50 -0
- package/dist/lib/tools/tool-discovery.d.ts.map +1 -0
- package/dist/lib/tools/tool-discovery.js +178 -0
- package/dist/lib/tools/tool-discovery.js.map +1 -0
- package/dist/lib/tools/tool-registry.d.ts +19 -3
- package/dist/lib/tools/tool-registry.d.ts.map +1 -1
- package/dist/lib/tools/tool-registry.js +63 -10
- package/dist/lib/tools/tool-registry.js.map +1 -1
- package/dist/lib/workflows/index.d.ts +4 -2
- package/dist/lib/workflows/index.d.ts.map +1 -1
- package/dist/lib/workflows/index.js +3 -1
- package/dist/lib/workflows/index.js.map +1 -1
- package/dist/lib/workflows/interrupt-manager.d.ts +42 -0
- package/dist/lib/workflows/interrupt-manager.d.ts.map +1 -0
- package/dist/lib/workflows/interrupt-manager.js +102 -0
- package/dist/lib/workflows/interrupt-manager.js.map +1 -0
- package/dist/lib/workflows/langgraph-executor.d.ts +51 -0
- package/dist/lib/workflows/langgraph-executor.d.ts.map +1 -0
- package/dist/lib/workflows/langgraph-executor.js +297 -0
- package/dist/lib/workflows/langgraph-executor.js.map +1 -0
- package/dist/lib/workflows/types.d.ts +911 -34
- package/dist/lib/workflows/types.d.ts.map +1 -1
- package/dist/lib/workflows/types.js +51 -2
- package/dist/lib/workflows/types.js.map +1 -1
- package/dist/lib/workflows/workflow-executor.d.ts.map +1 -1
- package/dist/lib/workflows/workflow-executor.js +4 -0
- package/dist/lib/workflows/workflow-executor.js.map +1 -1
- package/dist/lib/workflows/workflow-loader.d.ts.map +1 -1
- package/dist/lib/workflows/workflow-loader.js +3 -1
- package/dist/lib/workflows/workflow-loader.js.map +1 -1
- package/dist/public/index.html +133 -700
- package/dist/public/src/components/AgentsView.js +763 -0
- package/dist/public/src/components/AppRoot.js +76 -0
- package/dist/public/src/components/IdeView.js +330 -0
- package/dist/public/src/components/KnowledgeView.js +133 -0
- package/dist/public/src/components/LlmView.js +127 -0
- package/dist/public/src/components/McpView.js +387 -0
- package/dist/public/src/components/NavBar.js +71 -0
- package/dist/public/src/components/WorkflowsView.js +243 -0
- package/dist/public/src/main.js +9 -0
- package/dist/public/src/services/ApiService.js +142 -0
- package/dist/public/src/store.js +41 -0
- package/dist/public/src/utils/Component.js +23 -0
- package/dist/public/src/utils/markdown.js +82 -0
- package/dist/src/cli/commands/start.d.ts.map +1 -1
- package/dist/src/cli/commands/start.js +3 -2
- package/dist/src/cli/commands/start.js.map +1 -1
- package/dist/src/index.js +46 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/routes/agents.route.d.ts.map +1 -1
- package/dist/src/routes/agents.route.js +38 -5
- package/dist/src/routes/agents.route.js.map +1 -1
- package/dist/src/routes/files.route.d.ts +3 -0
- package/dist/src/routes/files.route.d.ts.map +1 -0
- package/dist/src/routes/files.route.js +160 -0
- package/dist/src/routes/files.route.js.map +1 -0
- package/dist/src/routes/functions.route.d.ts +3 -0
- package/dist/src/routes/functions.route.d.ts.map +1 -0
- package/dist/src/routes/functions.route.js +83 -0
- package/dist/src/routes/functions.route.js.map +1 -0
- package/dist/src/routes/knowledge.route.d.ts +3 -0
- package/dist/src/routes/knowledge.route.d.ts.map +1 -0
- package/dist/src/routes/knowledge.route.js +153 -0
- package/dist/src/routes/knowledge.route.js.map +1 -0
- package/dist/src/routes/mcp.route.d.ts +3 -0
- package/dist/src/routes/mcp.route.d.ts.map +1 -0
- package/dist/src/routes/mcp.route.js +79 -0
- package/dist/src/routes/mcp.route.js.map +1 -0
- package/dist/src/routes/workflows.route.d.ts.map +1 -1
- package/dist/src/routes/workflows.route.js +2 -1
- package/dist/src/routes/workflows.route.js.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +8 -2
- package/dist/src/server.js.map +1 -1
- package/dist/templates/.env.example +21 -0
- package/dist/templates/README.md +43 -152
- package/dist/templates/agents/call-center-analyst-simple.agent.yaml +36 -0
- package/dist/templates/agents/math.agent.yaml +4 -14
- package/dist/templates/agents/sentiment-structured.agent.yaml +42 -0
- package/dist/templates/functions/calculator.function.js +69 -0
- package/dist/templates/functions/text-formatter.function.js +66 -0
- package/dist/templates/{vectors/example.vector.yaml → knowledge/example.knowledge.yaml} +1 -1
- package/dist/templates/knowledge/transcripts/call-001.txt +40 -0
- package/dist/templates/knowledge/transcripts/call-002.txt +36 -0
- package/dist/templates/knowledge/transcripts/call-003.txt +42 -0
- package/dist/templates/llm.md +1195 -0
- package/dist/templates/workflows/example.workflow.yaml +8 -19
- package/dist/templates/workflows/langgraph-example.workflow.yaml +84 -0
- package/package.json +19 -10
- package/dist/lib/tools/built-in/vector-search.tool.d.ts +0 -4
- package/dist/lib/tools/built-in/vector-search.tool.d.ts.map +0 -1
- package/dist/lib/tools/built-in/vector-search.tool.js.map +0 -1
- package/dist/lib/vectors/index.d.ts +0 -5
- package/dist/lib/vectors/index.d.ts.map +0 -1
- package/dist/lib/vectors/index.js +0 -4
- package/dist/lib/vectors/index.js.map +0 -1
- package/dist/lib/vectors/types.d.ts +0 -212
- package/dist/lib/vectors/types.d.ts.map +0 -1
- package/dist/lib/vectors/types.js +0 -39
- package/dist/lib/vectors/types.js.map +0 -1
- package/dist/lib/vectors/vector-store-factory.d.ts +0 -14
- package/dist/lib/vectors/vector-store-factory.d.ts.map +0 -1
- package/dist/lib/vectors/vector-store-factory.js.map +0 -1
- package/dist/lib/vectors/vector-store-manager.d.ts +0 -18
- package/dist/lib/vectors/vector-store-manager.d.ts.map +0 -1
- package/dist/lib/vectors/vector-store-manager.js +0 -79
- package/dist/lib/vectors/vector-store-manager.js.map +0 -1
- package/dist/src/routes/vectors.route.d.ts +0 -3
- package/dist/src/routes/vectors.route.d.ts.map +0 -1
- package/dist/src/routes/vectors.route.js +0 -74
- package/dist/src/routes/vectors.route.js.map +0 -1
- package/dist/templates/agents/example.agent.yaml +0 -32
- package/dist/templates/agents/knowledge.agent.yaml +0 -36
- package/dist/templates/agents/time.agent.yaml +0 -42
- package/dist/templates/functions/README.md +0 -195
- package/dist/templates/functions/fibonacci.function.js +0 -55
- package/dist/templates/vectors/example-chroma.vector.yaml +0 -43
- package/dist/templates/vectors/sample-data/example-document.txt +0 -15
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
|
|
2
|
+
import { Component } from '../utils/Component.js';
|
|
3
|
+
import { api } from '../services/ApiService.js';
|
|
4
|
+
|
|
5
|
+
export class McpView extends Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.source = 'mcp'; // 'mcp' | 'functions'
|
|
9
|
+
this.selectedItem = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async connectedCallback() {
|
|
13
|
+
super.connectedCallback();
|
|
14
|
+
this.loadContent();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async loadContent() {
|
|
18
|
+
const container = this.querySelector('#listContainer');
|
|
19
|
+
container.innerHTML = '<div class="text-gray-500 text-center py-8">Loading...</div>';
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
if (this.source === 'mcp') {
|
|
23
|
+
const servers = await api.getMCPServers();
|
|
24
|
+
this.renderServers(servers);
|
|
25
|
+
} else {
|
|
26
|
+
const functions = await api.getFunctions();
|
|
27
|
+
this.renderFunctions(functions);
|
|
28
|
+
}
|
|
29
|
+
} catch (e) {
|
|
30
|
+
container.innerHTML = `<div class="text-red-400 text-center">Error: ${e.message}</div>`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async renderServers(servers) {
|
|
35
|
+
const container = this.querySelector('#listContainer');
|
|
36
|
+
if (!servers.length) {
|
|
37
|
+
container.innerHTML = '<div class="text-gray-500 text-center py-8">No servers configured</div>';
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
container.innerHTML = '';
|
|
42
|
+
|
|
43
|
+
for (const server of servers) {
|
|
44
|
+
const section = document.createElement('div');
|
|
45
|
+
section.className = 'bg-dark-surface/30 border border-dark-border rounded-lg overflow-hidden mb-4';
|
|
46
|
+
|
|
47
|
+
// Initial render without tools
|
|
48
|
+
section.innerHTML = `
|
|
49
|
+
<div class="p-4 cursor-pointer hover:bg-dark-surface/50 transition-colors flex items-center justify-between" onclick="this.parentElement.querySelector('.tools-grid').classList.toggle('hidden'); this.querySelector('svg').classList.toggle('rotate-180')">
|
|
50
|
+
<div class="flex-1">
|
|
51
|
+
<div class="font-medium text-gray-200">${server.name}</div>
|
|
52
|
+
<div class="text-xs text-gray-500 mt-0.5">${server.transport}</div>
|
|
53
|
+
</div>
|
|
54
|
+
<svg class="w-5 h-5 text-gray-400 transform transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="tools-grid hidden p-4 pt-0 border-t border-dark-border/50">
|
|
57
|
+
<div class="text-gray-500 text-sm py-2">Loading tools...</div>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
// Lazy load tools
|
|
62
|
+
api.getMCPTools(server.name).then(tools => {
|
|
63
|
+
const grid = section.querySelector('.tools-grid');
|
|
64
|
+
if (!tools.length) {
|
|
65
|
+
grid.innerHTML = '<div class="text-gray-500 text-sm py-2">No tools available</div>';
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
grid.innerHTML = `<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2 mt-4">
|
|
70
|
+
${tools.map(tool => `
|
|
71
|
+
<div class="tool-card bg-dark-bg border border-dark-border hover:border-cyan-500 rounded p-3 cursor-pointer transition-colors" data-server="${server.name}" data-tool='${JSON.stringify(tool).replace(/'/g, "'")}'>
|
|
72
|
+
<div class="font-medium text-cyan-400 text-sm mb-1">${tool.name}</div>
|
|
73
|
+
<div class="text-xs text-gray-500 line-clamp-2">${tool.description || ''}</div>
|
|
74
|
+
</div>
|
|
75
|
+
`).join('')}
|
|
76
|
+
</div>`;
|
|
77
|
+
|
|
78
|
+
grid.querySelectorAll('.tool-card').forEach(card => {
|
|
79
|
+
card.addEventListener('click', (e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
const tool = JSON.parse(card.dataset.tool);
|
|
82
|
+
this.selectItem('tool', tool, card.dataset.server);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
container.appendChild(section);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
renderFunctions(functions) {
|
|
92
|
+
const container = this.querySelector('#listContainer');
|
|
93
|
+
if (!functions.length) {
|
|
94
|
+
container.innerHTML = '<div class="text-gray-500 text-center py-8">No functions available</div>';
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
container.innerHTML = `<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
|
|
99
|
+
${functions.map(func => `
|
|
100
|
+
<div class="func-card bg-dark-surface border border-dark-border hover:border-cyan-500 rounded-lg p-4 cursor-pointer transition-colors" data-func='${JSON.stringify(func).replace(/'/g, "'")}'>
|
|
101
|
+
<div class="font-medium text-cyan-400 mb-1">${func.name}</div>
|
|
102
|
+
<div class="text-xs text-gray-500 line-clamp-2">${func.description || ''}</div>
|
|
103
|
+
</div>
|
|
104
|
+
`).join('')}
|
|
105
|
+
</div>`;
|
|
106
|
+
|
|
107
|
+
container.querySelectorAll('.func-card').forEach(card => {
|
|
108
|
+
card.addEventListener('click', () => {
|
|
109
|
+
const func = JSON.parse(card.dataset.func);
|
|
110
|
+
this.selectItem('function', func);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async selectItem(type, item, serverName) {
|
|
116
|
+
this.selectedItem = { type, item, serverName };
|
|
117
|
+
const execArea = this.querySelector('#executionArea');
|
|
118
|
+
execArea.classList.remove('hidden');
|
|
119
|
+
|
|
120
|
+
this.querySelector('#selectedName').textContent = item.name;
|
|
121
|
+
this.querySelector('#selectedDesc').textContent = item.description || '';
|
|
122
|
+
|
|
123
|
+
// For functions, fetch full details including schema
|
|
124
|
+
let schema = item.inputSchema || item.schema || {};
|
|
125
|
+
if (type === 'function' && !item.schema) {
|
|
126
|
+
try {
|
|
127
|
+
const fullFunc = await api.getFunction(item.name);
|
|
128
|
+
schema = fullFunc.schema || {};
|
|
129
|
+
this.selectedItem.item = fullFunc; // Update with full details
|
|
130
|
+
} catch (e) {
|
|
131
|
+
console.error('Failed to fetch function schema:', e);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Generate placeholder JSON
|
|
136
|
+
const placeholder = this.generateJsonFromSchema(schema);
|
|
137
|
+
this.querySelector('#argsInput').value = JSON.stringify(placeholder, null, 2);
|
|
138
|
+
|
|
139
|
+
// Highlight
|
|
140
|
+
this.querySelectorAll('.tool-card, .func-card').forEach(el => {
|
|
141
|
+
el.classList.remove('border-cyan-500', 'bg-cyan-500/10');
|
|
142
|
+
el.classList.add('border-dark-border');
|
|
143
|
+
});
|
|
144
|
+
// (Visual highlight logic omitted for brevity as it requires complex matching)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
generateJsonFromSchema(schema) {
|
|
148
|
+
if (!schema) return {};
|
|
149
|
+
|
|
150
|
+
// Handle $ref - resolve the reference
|
|
151
|
+
if (schema.$ref && schema.definitions) {
|
|
152
|
+
const refName = schema.$ref.split('/').pop();
|
|
153
|
+
if (refName && schema.definitions[refName]) {
|
|
154
|
+
schema = schema.definitions[refName];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Handle JSON Schema structure (standard format)
|
|
159
|
+
if (schema.type === 'object' && schema.properties) {
|
|
160
|
+
return this.generateFromJsonSchema(schema);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Handle MCP tools inputSchema
|
|
164
|
+
if (schema.properties) {
|
|
165
|
+
return this.generateFromJsonSchema(schema);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Handle legacy Zod schema structure (shouldn't happen anymore)
|
|
169
|
+
if (schema.shape) {
|
|
170
|
+
return this.generateFromZodShape(schema.shape);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
generateFromZodShape(shape) {
|
|
177
|
+
const result = {};
|
|
178
|
+
|
|
179
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
180
|
+
result[key] = this.getPlaceholderValue(fieldSchema);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
generateFromJsonSchema(schema) {
|
|
187
|
+
const result = {};
|
|
188
|
+
const properties = schema.properties || {};
|
|
189
|
+
|
|
190
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
191
|
+
result[key] = this.getJsonSchemaPlaceholder(prop);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
getPlaceholderValue(fieldSchema) {
|
|
198
|
+
if (!fieldSchema) return '';
|
|
199
|
+
|
|
200
|
+
// Handle Zod schema with _def
|
|
201
|
+
const def = fieldSchema._def;
|
|
202
|
+
if (!def) return '';
|
|
203
|
+
|
|
204
|
+
const typeName = def.typeName;
|
|
205
|
+
|
|
206
|
+
// Handle optional/default values
|
|
207
|
+
if (typeName === 'ZodOptional' || typeName === 'ZodDefault') {
|
|
208
|
+
const innerDef = def.innerType?._def || def;
|
|
209
|
+
if (def.defaultValue !== undefined) {
|
|
210
|
+
return def.defaultValue();
|
|
211
|
+
}
|
|
212
|
+
return this.getPlaceholderValue({ _def: innerDef });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Generate placeholder based on type
|
|
216
|
+
switch (typeName) {
|
|
217
|
+
case 'ZodString':
|
|
218
|
+
return def.description || '';
|
|
219
|
+
case 'ZodNumber':
|
|
220
|
+
return 0;
|
|
221
|
+
case 'ZodBoolean':
|
|
222
|
+
return false;
|
|
223
|
+
case 'ZodArray':
|
|
224
|
+
return [];
|
|
225
|
+
case 'ZodObject':
|
|
226
|
+
if (def.shape) {
|
|
227
|
+
return this.generateFromZodShape(def.shape());
|
|
228
|
+
}
|
|
229
|
+
return {};
|
|
230
|
+
case 'ZodEnum':
|
|
231
|
+
const values = def.values;
|
|
232
|
+
return values && values.length > 0 ? values[0] : '';
|
|
233
|
+
default:
|
|
234
|
+
return '';
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
getJsonSchemaPlaceholder(prop) {
|
|
239
|
+
// Handle default values first
|
|
240
|
+
if (prop.default !== undefined) {
|
|
241
|
+
return prop.default;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const type = prop.type;
|
|
245
|
+
|
|
246
|
+
switch (type) {
|
|
247
|
+
case 'string':
|
|
248
|
+
if (prop.enum && prop.enum.length > 0) {
|
|
249
|
+
return prop.enum[0];
|
|
250
|
+
}
|
|
251
|
+
// Use description as hint if available
|
|
252
|
+
if (prop.description) {
|
|
253
|
+
return `<${prop.description}>`;
|
|
254
|
+
}
|
|
255
|
+
return '';
|
|
256
|
+
case 'number':
|
|
257
|
+
case 'integer':
|
|
258
|
+
return 0;
|
|
259
|
+
case 'boolean':
|
|
260
|
+
return false;
|
|
261
|
+
case 'array':
|
|
262
|
+
// If array has items schema, create one example item
|
|
263
|
+
if (prop.items) {
|
|
264
|
+
const exampleItem = this.getJsonSchemaPlaceholder(prop.items);
|
|
265
|
+
return [exampleItem];
|
|
266
|
+
}
|
|
267
|
+
return [];
|
|
268
|
+
case 'object':
|
|
269
|
+
if (prop.properties) {
|
|
270
|
+
return this.generateFromJsonSchema(prop);
|
|
271
|
+
}
|
|
272
|
+
return {};
|
|
273
|
+
default:
|
|
274
|
+
return '';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
postRender() {
|
|
279
|
+
const mcpBtn = this.querySelector('#mcpBtn');
|
|
280
|
+
const funcBtn = this.querySelector('#funcBtn');
|
|
281
|
+
|
|
282
|
+
mcpBtn.addEventListener('click', () => {
|
|
283
|
+
this.source = 'mcp';
|
|
284
|
+
mcpBtn.classList.replace('bg-dark-surface', 'bg-cyan-600');
|
|
285
|
+
mcpBtn.classList.replace('text-gray-400', 'text-white');
|
|
286
|
+
funcBtn.classList.replace('bg-cyan-600', 'bg-dark-surface');
|
|
287
|
+
funcBtn.classList.replace('text-white', 'text-gray-400');
|
|
288
|
+
this.querySelector('#executionArea').classList.add('hidden');
|
|
289
|
+
this.loadContent();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
funcBtn.addEventListener('click', () => {
|
|
293
|
+
this.source = 'functions';
|
|
294
|
+
funcBtn.classList.replace('bg-dark-surface', 'bg-cyan-600');
|
|
295
|
+
funcBtn.classList.replace('text-gray-400', 'text-white');
|
|
296
|
+
mcpBtn.classList.replace('bg-cyan-600', 'bg-dark-surface');
|
|
297
|
+
mcpBtn.classList.replace('text-white', 'text-gray-400');
|
|
298
|
+
this.querySelector('#executionArea').classList.add('hidden');
|
|
299
|
+
this.loadContent();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
this.querySelector('#executeBtn').addEventListener('click', () => this.execute());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async execute() {
|
|
306
|
+
const btn = this.querySelector('#executeBtn');
|
|
307
|
+
const outputArea = this.querySelector('#outputArea');
|
|
308
|
+
const outputEl = this.querySelector('#mcpOutput');
|
|
309
|
+
const argsInput = this.querySelector('#argsInput');
|
|
310
|
+
|
|
311
|
+
if (!this.selectedItem) return;
|
|
312
|
+
|
|
313
|
+
let args = {};
|
|
314
|
+
try {
|
|
315
|
+
args = JSON.parse(argsInput.value || '{}');
|
|
316
|
+
} catch (e) {
|
|
317
|
+
outputArea.classList.remove('hidden');
|
|
318
|
+
outputEl.textContent = 'Error: Invalid JSON arguments';
|
|
319
|
+
outputEl.classList.add('text-red-400');
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
btn.disabled = true;
|
|
324
|
+
btn.textContent = 'Executing...';
|
|
325
|
+
outputArea.classList.remove('hidden');
|
|
326
|
+
outputEl.textContent = 'Running...';
|
|
327
|
+
outputEl.classList.remove('text-red-400');
|
|
328
|
+
|
|
329
|
+
try {
|
|
330
|
+
let result;
|
|
331
|
+
if (this.selectedItem.type === 'tool') {
|
|
332
|
+
result = await api.executeMcpTool(this.selectedItem.serverName, this.selectedItem.item.name, args);
|
|
333
|
+
} else {
|
|
334
|
+
result = await api.executeFunction(this.selectedItem.item.name, args);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (result.error) {
|
|
338
|
+
throw new Error(result.error);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const content = typeof result.content === 'string' ? result.content : JSON.stringify(result, null, 2);
|
|
342
|
+
outputEl.textContent = content;
|
|
343
|
+
} catch (e) {
|
|
344
|
+
outputEl.textContent = 'Error: ' + e.message;
|
|
345
|
+
outputEl.classList.add('text-red-400');
|
|
346
|
+
} finally {
|
|
347
|
+
btn.disabled = false;
|
|
348
|
+
btn.textContent = 'Execute';
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
template() {
|
|
353
|
+
return `
|
|
354
|
+
<div class="space-y-6 h-full overflow-y-auto pb-8 custom-scrollbar">
|
|
355
|
+
<div class="flex gap-2 border-b border-dark-border pb-4">
|
|
356
|
+
<button id="mcpBtn" class="px-4 py-2 rounded-lg font-medium bg-cyan-600 text-white transition-colors">MCP Servers</button>
|
|
357
|
+
<button id="funcBtn" class="px-4 py-2 rounded-lg font-medium bg-dark-surface text-gray-400 hover:bg-dark-hover transition-colors">Internal Functions</button>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<div id="listContainer"></div>
|
|
361
|
+
|
|
362
|
+
<div id="executionArea" class="hidden border-t border-dark-border pt-6">
|
|
363
|
+
<div class="bg-dark-surface/50 border border-dark-border rounded-lg p-4 mb-4">
|
|
364
|
+
<div class="font-medium text-cyan-400" id="selectedName"></div>
|
|
365
|
+
<div class="text-xs text-gray-500 mt-1" id="selectedDesc"></div>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
<div class="mb-4">
|
|
369
|
+
<label class="block text-sm font-medium text-gray-300 mb-2">Arguments (JSON)</label>
|
|
370
|
+
<textarea id="argsInput" rows="6" class="w-full bg-dark-surface border border-dark-border rounded-lg px-4 py-3 text-gray-100 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-cyan-500"></textarea>
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
<button id="executeBtn" class="bg-cyan-600 hover:bg-cyan-700 text-white font-medium px-6 py-2.5 rounded-lg transition-colors">
|
|
374
|
+
Execute
|
|
375
|
+
</button>
|
|
376
|
+
|
|
377
|
+
<div id="outputArea" class="mt-4 hidden">
|
|
378
|
+
<label class="block text-sm font-medium text-gray-300 mb-2">Output</label>
|
|
379
|
+
<div id="mcpOutput" class="bg-dark-surface border border-dark-border rounded-lg p-4 min-h-[100px] font-mono text-sm text-gray-300 whitespace-pre-wrap overflow-x-auto"></div>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
</div>
|
|
383
|
+
`;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
customElements.define('mcp-view', McpView);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
import { Component } from '../utils/Component.js';
|
|
3
|
+
import { store } from '../store.js';
|
|
4
|
+
|
|
5
|
+
export class NavBar extends Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.tabs = [
|
|
9
|
+
{ id: 'agents', label: 'Agents', icon: 'fa-robot', color: 'blue' },
|
|
10
|
+
{ id: 'workflows', label: 'Workflows', icon: 'fa-project-diagram', color: 'purple' },
|
|
11
|
+
{ id: 'knowledge', label: 'Knowledge', icon: 'fa-brain', color: 'orange' },
|
|
12
|
+
{ id: 'mcp', label: 'MCP', icon: 'fa-server', color: 'cyan' },
|
|
13
|
+
{ id: 'ide', label: 'IDE', icon: 'fa-code', color: 'green' }
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
postRender() {
|
|
18
|
+
this.querySelectorAll('.tab-btn').forEach(btn => {
|
|
19
|
+
btn.addEventListener('click', (e) => {
|
|
20
|
+
const tabId = e.currentTarget.dataset.tab;
|
|
21
|
+
window.location.hash = tabId;
|
|
22
|
+
store.set('activeTab', tabId);
|
|
23
|
+
this.updateActiveState(tabId);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Sync visual state when tab changes externally (browser back/forward)
|
|
28
|
+
store.addEventListener('state-change', (e) => {
|
|
29
|
+
if (e.detail.key === 'activeTab') {
|
|
30
|
+
this.updateActiveState(e.detail.value);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Initialize state
|
|
35
|
+
this.updateActiveState(store.get('activeTab'));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
updateActiveState(activeId) {
|
|
39
|
+
this.querySelectorAll('.tab-btn').forEach(btn => {
|
|
40
|
+
const tabId = btn.dataset.tab;
|
|
41
|
+
const color = btn.dataset.color;
|
|
42
|
+
const isActive = tabId === activeId;
|
|
43
|
+
|
|
44
|
+
if (isActive) {
|
|
45
|
+
btn.classList.add(`border-${color}-500`, `text-${color}-400`);
|
|
46
|
+
btn.classList.remove('border-transparent', 'text-gray-400', 'hover:text-gray-300');
|
|
47
|
+
} else {
|
|
48
|
+
btn.classList.remove(`border-${color}-500`, `text-${color}-400`);
|
|
49
|
+
btn.classList.add('border-transparent', 'text-gray-400', 'hover:text-gray-300');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
template() {
|
|
55
|
+
return `
|
|
56
|
+
<div class="border-b border-dark-border mb-6">
|
|
57
|
+
<nav class="flex space-x-8 overflow-x-auto">
|
|
58
|
+
${this.tabs.map(tab => `
|
|
59
|
+
<button class="tab-btn group flex items-center gap-2 border-b-2 border-transparent text-gray-400 hover:text-gray-300 pb-3 px-1 font-medium transition-colors"
|
|
60
|
+
data-tab="${tab.id}" data-color="${tab.color}">
|
|
61
|
+
<i class="fas ${tab.icon} text-sm group-hover:scale-110 transition-transform"></i>
|
|
62
|
+
<span>${tab.label}</span>
|
|
63
|
+
</button>
|
|
64
|
+
`).join('')}
|
|
65
|
+
</nav>
|
|
66
|
+
</div>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
customElements.define('nav-bar', NavBar);
|