agent-orcha 0.0.1

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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +917 -0
  3. package/bin/cli.js +2 -0
  4. package/dist/lib/agents/agent-executor.d.ts +13 -0
  5. package/dist/lib/agents/agent-executor.d.ts.map +1 -0
  6. package/dist/lib/agents/agent-executor.js +158 -0
  7. package/dist/lib/agents/agent-executor.js.map +1 -0
  8. package/dist/lib/agents/agent-loader.d.ts +13 -0
  9. package/dist/lib/agents/agent-loader.d.ts.map +1 -0
  10. package/dist/lib/agents/agent-loader.js +39 -0
  11. package/dist/lib/agents/agent-loader.js.map +1 -0
  12. package/dist/lib/agents/index.d.ts +5 -0
  13. package/dist/lib/agents/index.d.ts.map +1 -0
  14. package/dist/lib/agents/index.js +4 -0
  15. package/dist/lib/agents/index.js.map +1 -0
  16. package/dist/lib/agents/types.d.ts +140 -0
  17. package/dist/lib/agents/types.d.ts.map +1 -0
  18. package/dist/lib/agents/types.js +28 -0
  19. package/dist/lib/agents/types.js.map +1 -0
  20. package/dist/lib/functions/function-loader.d.ts +30 -0
  21. package/dist/lib/functions/function-loader.d.ts.map +1 -0
  22. package/dist/lib/functions/function-loader.js +107 -0
  23. package/dist/lib/functions/function-loader.js.map +1 -0
  24. package/dist/lib/functions/index.d.ts +3 -0
  25. package/dist/lib/functions/index.d.ts.map +1 -0
  26. package/dist/lib/functions/index.js +2 -0
  27. package/dist/lib/functions/index.js.map +1 -0
  28. package/dist/lib/functions/simple-function-wrapper.d.ts +33 -0
  29. package/dist/lib/functions/simple-function-wrapper.d.ts.map +1 -0
  30. package/dist/lib/functions/simple-function-wrapper.js +66 -0
  31. package/dist/lib/functions/simple-function-wrapper.js.map +1 -0
  32. package/dist/lib/index.d.ts +16 -0
  33. package/dist/lib/index.d.ts.map +1 -0
  34. package/dist/lib/index.js +17 -0
  35. package/dist/lib/index.js.map +1 -0
  36. package/dist/lib/llm/index.d.ts +6 -0
  37. package/dist/lib/llm/index.d.ts.map +1 -0
  38. package/dist/lib/llm/index.js +4 -0
  39. package/dist/lib/llm/index.js.map +1 -0
  40. package/dist/lib/llm/llm-config.d.ts +138 -0
  41. package/dist/lib/llm/llm-config.d.ts.map +1 -0
  42. package/dist/lib/llm/llm-config.js +75 -0
  43. package/dist/lib/llm/llm-config.js.map +1 -0
  44. package/dist/lib/llm/llm-factory.d.ts +30 -0
  45. package/dist/lib/llm/llm-factory.d.ts.map +1 -0
  46. package/dist/lib/llm/llm-factory.js +103 -0
  47. package/dist/lib/llm/llm-factory.js.map +1 -0
  48. package/dist/lib/llm/provider-detector.d.ts +12 -0
  49. package/dist/lib/llm/provider-detector.d.ts.map +1 -0
  50. package/dist/lib/llm/provider-detector.js +46 -0
  51. package/dist/lib/llm/provider-detector.js.map +1 -0
  52. package/dist/lib/llm/types.d.ts +19 -0
  53. package/dist/lib/llm/types.d.ts.map +1 -0
  54. package/dist/lib/llm/types.js +18 -0
  55. package/dist/lib/llm/types.js.map +1 -0
  56. package/dist/lib/logger.d.ts +43 -0
  57. package/dist/lib/logger.d.ts.map +1 -0
  58. package/dist/lib/logger.js +113 -0
  59. package/dist/lib/logger.js.map +1 -0
  60. package/dist/lib/mcp/index.d.ts +4 -0
  61. package/dist/lib/mcp/index.d.ts.map +1 -0
  62. package/dist/lib/mcp/index.js +3 -0
  63. package/dist/lib/mcp/index.js.map +1 -0
  64. package/dist/lib/mcp/mcp-client.d.ts +17 -0
  65. package/dist/lib/mcp/mcp-client.d.ts.map +1 -0
  66. package/dist/lib/mcp/mcp-client.js +166 -0
  67. package/dist/lib/mcp/mcp-client.js.map +1 -0
  68. package/dist/lib/mcp/types.d.ts +146 -0
  69. package/dist/lib/mcp/types.d.ts.map +1 -0
  70. package/dist/lib/mcp/types.js +24 -0
  71. package/dist/lib/mcp/types.js.map +1 -0
  72. package/dist/lib/orchestrator.d.ts +64 -0
  73. package/dist/lib/orchestrator.d.ts.map +1 -0
  74. package/dist/lib/orchestrator.js +201 -0
  75. package/dist/lib/orchestrator.js.map +1 -0
  76. package/dist/lib/tools/built-in/index.d.ts +2 -0
  77. package/dist/lib/tools/built-in/index.d.ts.map +1 -0
  78. package/dist/lib/tools/built-in/index.js +2 -0
  79. package/dist/lib/tools/built-in/index.js.map +1 -0
  80. package/dist/lib/tools/built-in/vector-search.tool.d.ts +4 -0
  81. package/dist/lib/tools/built-in/vector-search.tool.d.ts.map +1 -0
  82. package/dist/lib/tools/built-in/vector-search.tool.js +26 -0
  83. package/dist/lib/tools/built-in/vector-search.tool.js.map +1 -0
  84. package/dist/lib/tools/index.d.ts +3 -0
  85. package/dist/lib/tools/index.d.ts.map +1 -0
  86. package/dist/lib/tools/index.js +3 -0
  87. package/dist/lib/tools/index.js.map +1 -0
  88. package/dist/lib/tools/tool-registry.d.ts +20 -0
  89. package/dist/lib/tools/tool-registry.d.ts.map +1 -0
  90. package/dist/lib/tools/tool-registry.js +76 -0
  91. package/dist/lib/tools/tool-registry.js.map +1 -0
  92. package/dist/lib/vectors/index.d.ts +5 -0
  93. package/dist/lib/vectors/index.d.ts.map +1 -0
  94. package/dist/lib/vectors/index.js +4 -0
  95. package/dist/lib/vectors/index.js.map +1 -0
  96. package/dist/lib/vectors/types.d.ts +212 -0
  97. package/dist/lib/vectors/types.d.ts.map +1 -0
  98. package/dist/lib/vectors/types.js +39 -0
  99. package/dist/lib/vectors/types.js.map +1 -0
  100. package/dist/lib/vectors/vector-store-factory.d.ts +14 -0
  101. package/dist/lib/vectors/vector-store-factory.d.ts.map +1 -0
  102. package/dist/lib/vectors/vector-store-factory.js +350 -0
  103. package/dist/lib/vectors/vector-store-factory.js.map +1 -0
  104. package/dist/lib/vectors/vector-store-manager.d.ts +18 -0
  105. package/dist/lib/vectors/vector-store-manager.d.ts.map +1 -0
  106. package/dist/lib/vectors/vector-store-manager.js +79 -0
  107. package/dist/lib/vectors/vector-store-manager.js.map +1 -0
  108. package/dist/lib/workflows/index.d.ts +5 -0
  109. package/dist/lib/workflows/index.d.ts.map +1 -0
  110. package/dist/lib/workflows/index.js +4 -0
  111. package/dist/lib/workflows/index.js.map +1 -0
  112. package/dist/lib/workflows/types.d.ts +630 -0
  113. package/dist/lib/workflows/types.d.ts.map +1 -0
  114. package/dist/lib/workflows/types.js +51 -0
  115. package/dist/lib/workflows/types.js.map +1 -0
  116. package/dist/lib/workflows/workflow-executor.d.ts +22 -0
  117. package/dist/lib/workflows/workflow-executor.d.ts.map +1 -0
  118. package/dist/lib/workflows/workflow-executor.js +276 -0
  119. package/dist/lib/workflows/workflow-executor.js.map +1 -0
  120. package/dist/lib/workflows/workflow-loader.d.ts +13 -0
  121. package/dist/lib/workflows/workflow-loader.d.ts.map +1 -0
  122. package/dist/lib/workflows/workflow-loader.js +39 -0
  123. package/dist/lib/workflows/workflow-loader.js.map +1 -0
  124. package/dist/public/index.html +762 -0
  125. package/dist/src/cli/commands/init.d.ts +2 -0
  126. package/dist/src/cli/commands/init.d.ts.map +1 -0
  127. package/dist/src/cli/commands/init.js +108 -0
  128. package/dist/src/cli/commands/init.js.map +1 -0
  129. package/dist/src/cli/commands/start.d.ts +3 -0
  130. package/dist/src/cli/commands/start.d.ts.map +1 -0
  131. package/dist/src/cli/commands/start.js +114 -0
  132. package/dist/src/cli/commands/start.js.map +1 -0
  133. package/dist/src/cli/index.d.ts +3 -0
  134. package/dist/src/cli/index.d.ts.map +1 -0
  135. package/dist/src/cli/index.js +59 -0
  136. package/dist/src/cli/index.js.map +1 -0
  137. package/dist/src/index.d.ts +2 -0
  138. package/dist/src/index.d.ts.map +1 -0
  139. package/dist/src/index.js +62 -0
  140. package/dist/src/index.js.map +1 -0
  141. package/dist/src/routes/agents.route.d.ts +3 -0
  142. package/dist/src/routes/agents.route.d.ts.map +1 -0
  143. package/dist/src/routes/agents.route.js +58 -0
  144. package/dist/src/routes/agents.route.js.map +1 -0
  145. package/dist/src/routes/llm.route.d.ts +3 -0
  146. package/dist/src/routes/llm.route.d.ts.map +1 -0
  147. package/dist/src/routes/llm.route.js +97 -0
  148. package/dist/src/routes/llm.route.js.map +1 -0
  149. package/dist/src/routes/vectors.route.d.ts +3 -0
  150. package/dist/src/routes/vectors.route.d.ts.map +1 -0
  151. package/dist/src/routes/vectors.route.js +74 -0
  152. package/dist/src/routes/vectors.route.js.map +1 -0
  153. package/dist/src/routes/workflows.route.d.ts +3 -0
  154. package/dist/src/routes/workflows.route.d.ts.map +1 -0
  155. package/dist/src/routes/workflows.route.js +58 -0
  156. package/dist/src/routes/workflows.route.js.map +1 -0
  157. package/dist/src/server.d.ts +9 -0
  158. package/dist/src/server.d.ts.map +1 -0
  159. package/dist/src/server.js +34 -0
  160. package/dist/src/server.js.map +1 -0
  161. package/dist/templates/.env.example +6 -0
  162. package/dist/templates/README.md +234 -0
  163. package/dist/templates/agents/example.agent.yaml +32 -0
  164. package/dist/templates/agents/knowledge.agent.yaml +36 -0
  165. package/dist/templates/agents/math.agent.yaml +38 -0
  166. package/dist/templates/agents/time.agent.yaml +42 -0
  167. package/dist/templates/functions/README.md +195 -0
  168. package/dist/templates/functions/fibonacci.function.js +55 -0
  169. package/dist/templates/llm.json +44 -0
  170. package/dist/templates/mcp.json +18 -0
  171. package/dist/templates/vectors/example-chroma.vector.yaml +43 -0
  172. package/dist/templates/vectors/example.vector.yaml +28 -0
  173. package/dist/templates/vectors/sample-data/example-document.txt +15 -0
  174. package/dist/templates/workflows/example.workflow.yaml +79 -0
  175. package/package.json +77 -0
package/README.md ADDED
@@ -0,0 +1,917 @@
1
+ # Agent Orcha
2
+
3
+ A TypeScript framework for building and orchestrating multi-agent AI systems with LangChain, Model Context Protocol (MCP), and vector store integration.
4
+
5
+ ## Overview
6
+
7
+ Agent Orcha enables you to:
8
+
9
+ - **Define agents** using YAML configuration files with customizable LLM providers, prompts, and tools
10
+ - **Create workflows** that coordinate multiple agents in sequential or parallel execution
11
+ - **Integrate vector stores** for RAG (Retrieval Augmented Generation) capabilities
12
+ - **Connect MCP servers** to extend agent capabilities with external tools
13
+ - **Create local Functions** give your agents the ability to call your own custom code
14
+
15
+ ## Usage
16
+ - **Use as is** check out and run
17
+ - **Use as a library** in your TypeScript/JavaScript projects
18
+ - **Use as a CLI** with npx for standalone agent orchestration (recommended)
19
+
20
+ **Requirements:** Node.js >= 20.0.0
21
+
22
+
23
+ ## Quick Start
24
+
25
+ ### CLI Usage
26
+
27
+ 1. **Initialize a project:**
28
+ ```bash
29
+ npx agent-orcha init my-project
30
+ cd my-project
31
+ ```
32
+
33
+ 2. **Configure LLM settings** in `llm.json`:
34
+ ```json
35
+ {
36
+ "version": "1.0",
37
+ "models": {
38
+ "default": {
39
+ "provider": "openai",
40
+ "baseUrl": "http://localhost:1234/v1",
41
+ "apiKey": "not-needed",
42
+ "model": "your-model-name",
43
+ "temperature": 0.7
44
+ }
45
+ },
46
+ "embeddings": {
47
+ "default": {
48
+ "provider": "openai",
49
+ "baseUrl": "http://localhost:1234/v1",
50
+ "apiKey": "not-needed",
51
+ "model": "text-embedding-model"
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ 3. **Start the server:**
58
+ ```bash
59
+ npx agent-orcha start
60
+ ```
61
+
62
+ 4. **Test your agent:**
63
+ ```bash
64
+ curl -X POST http://localhost:3000/api/agents/example/invoke \
65
+ -H "Content-Type: application/json" \
66
+ -d '{"input": {"query": "Hello, how are you?"}}'
67
+ ```
68
+
69
+ ### Library Usage
70
+
71
+ ```typescript
72
+ import { Orchestrator } from 'agent-orcha';
73
+
74
+ const orchestrator = new Orchestrator({
75
+ projectRoot: './my-agents-project'
76
+ });
77
+
78
+ await orchestrator.initialize();
79
+
80
+ // Invoke an agent
81
+ const result = await orchestrator.agents.invoke('researcher', {
82
+ topic: 'machine learning',
83
+ context: 'brief overview'
84
+ });
85
+
86
+ console.log(result.output);
87
+
88
+ // Run a workflow
89
+ const workflowResult = await orchestrator.workflows.run('research-paper', {
90
+ topic: 'artificial intelligence'
91
+ });
92
+
93
+ console.log(workflowResult.output);
94
+
95
+ // Clean up
96
+ await orchestrator.close();
97
+ ```
98
+
99
+ ## CLI Commands
100
+
101
+ | Command | Description |
102
+ |---------|-------------|
103
+ | `npx agent-orcha init [dir]` | Initialize a new project with example configs |
104
+ | `npx agent-orcha start` | Start the agent orchestrator server |
105
+ | `npx agent-orcha help` | Show help information |
106
+
107
+ ## Development Scripts
108
+
109
+ For development on the agent-orcha framework itself:
110
+
111
+ | Command | Description |
112
+ |---------|-------------|
113
+ | `npm run dev` | Start development server with auto-reload |
114
+ | `npm run build` | Build for production |
115
+ | `npm start` | Run production build |
116
+ | `npm run lint` | Run ESLint |
117
+ | `npm run typecheck` | Run TypeScript type checking |
118
+
119
+ ## Configuration
120
+
121
+ ### LLM Configuration (llm.json)
122
+
123
+ All LLM and embedding configurations are defined in `llm.json` at the project root. Agents and vector stores reference these configs by name.
124
+
125
+ ```json
126
+ {
127
+ "version": "1.0",
128
+ "models": {
129
+ "default": {
130
+ "baseUrl": "http://localhost:1234/v1",
131
+ "apiKey": "not-needed",
132
+ "model": "qwen/qwen3-4b-2507",
133
+ "temperature": 0.7
134
+ },
135
+ "openai": {
136
+ "apiKey": "sk-your-openai-key",
137
+ "model": "gpt-4o",
138
+ "temperature": 0.7
139
+ }
140
+ },
141
+ "embeddings": {
142
+ "default": {
143
+ "baseUrl": "http://localhost:1234/v1",
144
+ "apiKey": "not-needed",
145
+ "model": "text-embedding-nomic-embed-text-v1.5",
146
+ "eosToken": " "
147
+ },
148
+ "openai": {
149
+ "apiKey": "sk-your-openai-key",
150
+ "model": "text-embedding-3-small",
151
+ "dimensions": 1536
152
+ },
153
+ "gemini": {
154
+ "apiKey": "sk-your-gemini-key",
155
+ "model": "text-embedding-004"
156
+ }
157
+ }
158
+ }
159
+ ```
160
+
161
+ All providers are treated as OpenAI-compatible APIs. For local inference:
162
+ - **LM Studio**: Use `baseUrl: "http://localhost:1234/v1"`
163
+ - **Ollama**: Use `baseUrl: "http://localhost:11434/v1"`
164
+ - **OpenAI**: Omit `baseUrl` (uses default OpenAI endpoint)
165
+
166
+ #### Embedding Configuration Options
167
+
168
+ Embedding configurations support the following options:
169
+
170
+ - **model** (required): The embedding model name
171
+ - **apiKey** (required): API key for the embedding service
172
+ - **baseUrl** (optional): Custom API endpoint URL for local or alternative services
173
+ - **provider** (optional): Provider type (openai, gemini, local). Auto-detected if omitted
174
+ - **dimensions** (optional): Output embedding dimensions (e.g., 1536 for OpenAI text-embedding-3-small)
175
+ - **eosToken** (optional): Token to append to all text inputs (e.g., " " for Nomic models to avoid SEP warnings)
176
+
177
+
178
+ **Example configurations:**
179
+
180
+ ```json
181
+ {
182
+ "embeddings": {
183
+ "nomic-local": {
184
+ "baseUrl": "http://localhost:1234/v1",
185
+ "apiKey": "not-needed",
186
+ "model": "text-embedding-nomic-embed-text-v1.5",
187
+ "eosToken": " "
188
+ },
189
+ "openai-small": {
190
+ "apiKey": "sk-your-key",
191
+ "model": "text-embedding-3-small",
192
+ "dimensions": 1536
193
+ },
194
+ "openai-large": {
195
+ "apiKey": "sk-your-key",
196
+ "model": "text-embedding-3-large",
197
+ "dimensions": 3072
198
+ },
199
+ "gemini": {
200
+ "apiKey": "sk-your-key",
201
+ "model": "text-embedding-004"
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ ### Environment Variables (Optional)
208
+
209
+ ```bash
210
+ # Server configuration
211
+ PORT=3000
212
+ HOST=0.0.0.0
213
+ ```
214
+
215
+ ## Agents
216
+
217
+ Agents are AI-powered units that can use tools and respond to queries. Define agents in YAML files within the `agents/` directory.
218
+
219
+ ### Agent Schema
220
+
221
+ ```yaml
222
+ # agents/<name>.agent.yaml
223
+
224
+ name: string # Unique identifier (required)
225
+ description: string # Human-readable description (required)
226
+ version: string # Semantic version (default: "1.0.0")
227
+
228
+ llm: string | object # Reference to LLM config in llm.json
229
+ # Simple: llm: default
230
+ # With override: llm: { name: default, temperature: 0.3 }
231
+
232
+ prompt: # Prompt configuration (required)
233
+ system: string # System message/instructions
234
+ inputVariables: [string] # Variables to interpolate in the prompt
235
+
236
+ tools: # Tools available to agent (optional)
237
+ - mcp:<server-name> # MCP server tools
238
+ - vector:<store-name> # Vector store search
239
+ - builtin:<tool-name> # Built-in tools
240
+
241
+ output: # Output formatting (optional)
242
+ format: text | json | structured
243
+
244
+ metadata: # Custom metadata (optional)
245
+ category: string
246
+ tags: [string]
247
+ ```
248
+
249
+ ### Example Agent
250
+
251
+ ```yaml
252
+ # agents/researcher.agent.yaml
253
+
254
+ name: researcher
255
+ description: Researches topics using web fetch and vector search
256
+ version: "1.0.0"
257
+
258
+ llm:
259
+ name: default
260
+ temperature: 0.5 # Override default temperature
261
+
262
+ prompt:
263
+ system: |
264
+ You are a thorough researcher. Your task is to:
265
+ 1. Search through available knowledge bases
266
+ 2. Fetch additional information from the web
267
+ 3. Synthesize findings into a comprehensive report
268
+
269
+ Use the available tools to gather information before responding.
270
+ inputVariables:
271
+ - topic
272
+ - context
273
+
274
+ tools:
275
+ - mcp:fetch
276
+ - vector:transcripts
277
+
278
+ output:
279
+ format: text
280
+
281
+ metadata:
282
+ category: research
283
+ tags: [research, web, vectors]
284
+ ```
285
+
286
+ ## Workflows
287
+
288
+ Workflows orchestrate multiple agents in a defined sequence. Define workflows in YAML files within the `workflows/` directory.
289
+
290
+ ### Workflow Schema
291
+
292
+ ```yaml
293
+ # workflows/<name>.workflow.yaml
294
+
295
+ name: string # Unique identifier (required)
296
+ description: string # Human-readable description (required)
297
+ version: string # Semantic version (default: "1.0.0")
298
+
299
+ input: # Input schema (required)
300
+ schema:
301
+ <field_name>:
302
+ type: string | number | boolean | array | object
303
+ required: boolean # (default: false)
304
+ default: any # Default value
305
+ description: string # Field description
306
+
307
+ steps: # Workflow steps (required)
308
+ - id: string # Unique step identifier
309
+ agent: string # Agent name to execute
310
+ input: # Input mapping using templates
311
+ <key>: "{{input.field}}" # From workflow input
312
+ <key>: "{{steps.stepId.output}}" # From previous step
313
+ condition: string # Optional conditional execution
314
+ retry: # Optional retry configuration
315
+ maxAttempts: number
316
+ delay: number # Milliseconds
317
+ output:
318
+ key: string # Store output under this key
319
+
320
+ # Parallel execution
321
+ - parallel:
322
+ - id: step1
323
+ agent: agent1
324
+ input: {...}
325
+ - id: step2
326
+ agent: agent2
327
+ input: {...}
328
+
329
+ config: # Workflow configuration (optional)
330
+ timeout: number # Total timeout ms (default: 300000)
331
+ onError: stop | continue | retry
332
+
333
+ output: # Output mapping (required)
334
+ <key>: "{{steps.stepId.output}}"
335
+
336
+ metadata: # Custom metadata (optional)
337
+ category: string
338
+ tags: [string]
339
+ ```
340
+
341
+ ### Template Syntax
342
+
343
+ Access data within workflows using double curly braces:
344
+
345
+ | Template | Description |
346
+ |----------|-------------|
347
+ | `{{input.fieldName}}` | Access workflow input field |
348
+ | `{{steps.stepId.output}}` | Access step output |
349
+ | `{{steps.stepId.output.nested.path}}` | Access nested output |
350
+ | `{{steps.stepId.metadata.duration}}` | Access step metadata |
351
+
352
+ ### Example Workflow
353
+
354
+ ```yaml
355
+ # workflows/research-paper.workflow.yaml
356
+
357
+ name: research-paper
358
+ description: Research a topic and write a comprehensive paper
359
+ version: "1.0.0"
360
+
361
+ input:
362
+ schema:
363
+ topic:
364
+ type: string
365
+ required: true
366
+ description: The topic to research
367
+ style:
368
+ type: string
369
+ default: "professional"
370
+
371
+ steps:
372
+ - id: research
373
+ agent: researcher
374
+ input:
375
+ topic: "{{input.topic}}"
376
+ context: "Gather comprehensive information"
377
+ output:
378
+ key: researchFindings
379
+
380
+ - id: summarize
381
+ agent: summarizer
382
+ input:
383
+ content: "{{steps.research.output}}"
384
+ maxPoints: "10"
385
+ condition: "{{steps.research.metadata.success}}"
386
+ output:
387
+ key: summary
388
+
389
+ - id: write
390
+ agent: writer
391
+ input:
392
+ research: "{{steps.research.output}}"
393
+ outline: "{{steps.summarize.output}}"
394
+ style: "{{input.style}}"
395
+ output:
396
+ key: paper
397
+
398
+ config:
399
+ timeout: 600000
400
+ onError: stop
401
+
402
+ output:
403
+ paper: "{{steps.write.output}}"
404
+ summary: "{{steps.summarize.output}}"
405
+ researchFindings: "{{steps.research.output}}"
406
+ ```
407
+
408
+ ## Vector Stores
409
+
410
+ Vector stores enable semantic search and RAG capabilities. Define vector stores in YAML files within the `vectors/` directory.
411
+
412
+ ### Vector Store Schema
413
+
414
+ ```yaml
415
+ # vectors/<name>.vector.yaml
416
+
417
+ name: string # Unique identifier (required)
418
+ description: string # Human-readable description (required)
419
+
420
+ source: # Data source (required)
421
+ type: directory | file | url
422
+ path: string # Path relative to project root
423
+ pattern: string # Glob pattern for directories
424
+ recursive: boolean # Recursive search (default: true)
425
+
426
+ loader: # Document loader (required)
427
+ type: text | pdf | csv | json | markdown
428
+
429
+ splitter: # Text chunking (required)
430
+ type: character | recursive | token | markdown
431
+ chunkSize: number # Characters per chunk (default: 1000)
432
+ chunkOverlap: number # Overlap between chunks (default: 200)
433
+
434
+ embedding: string # Reference to embedding config in llm.json (default: "default")
435
+
436
+ store: # Vector store backend (required)
437
+ type: memory | chroma
438
+ options: # Store-specific options (optional)
439
+ path: string # Storage path (for chroma)
440
+ collectionName: string # Collection name (for chroma)
441
+ url: string # Server URL (for chroma, qdrant)
442
+
443
+ search: # Search configuration (optional)
444
+ defaultK: number # Results per search (default: 4)
445
+ scoreThreshold: number # Minimum similarity (0-1)
446
+ ```
447
+
448
+ ### Example Vector Store
449
+
450
+ ```yaml
451
+ # vectors/transcripts.vector.yaml
452
+
453
+ name: transcripts
454
+ description: Meeting transcripts for context retrieval
455
+
456
+ source:
457
+ type: directory
458
+ path: vectors/sample-data
459
+ pattern: "*.txt"
460
+
461
+ loader:
462
+ type: text
463
+
464
+ splitter:
465
+ type: character
466
+ chunkSize: 1000
467
+ chunkOverlap: 200
468
+
469
+ embedding: default # References embedding config in llm.json
470
+
471
+ store:
472
+ type: memory
473
+
474
+ search:
475
+ defaultK: 4
476
+ scoreThreshold: 0.2
477
+ ```
478
+
479
+ **Note:** Vector stores are initialized on startup, loading documents and creating embeddings immediately.
480
+
481
+ ### Vector Store Types
482
+
483
+ #### Memory (Development)
484
+ In-memory vector storage. Fast but not persistent - embeddings are recreated on every startup.
485
+
486
+ ```yaml
487
+ store:
488
+ type: memory
489
+ ```
490
+
491
+ **Use cases:** Development, testing, small datasets
492
+
493
+ #### Chroma (Production - Local)
494
+ Persistent local vector storage using Chroma. Embeddings are cached and reused across restarts.
495
+
496
+ ```yaml
497
+ store:
498
+ type: chroma
499
+ options:
500
+ path: .chroma # Storage directory (default: .chroma)
501
+ collectionName: my-collection # Collection name (default: vector store name)
502
+ url: http://localhost:8000 # Chroma server URL (default: http://localhost:8000)
503
+ ```
504
+
505
+ **Setup:**
506
+ ```bash
507
+ # Option 1: Run Chroma server with Docker
508
+ docker run -p 8000:8000 chromadb/chroma
509
+
510
+ # Option 2: Install and run Chroma locally
511
+ pip install chromadb
512
+ chroma run --path .chroma --port 8000
513
+ ```
514
+
515
+
516
+ ## Functions
517
+
518
+ Functions are custom JavaScript tools that extend agent capabilities with your own code. They're simple to create and require no dependencies.
519
+
520
+ ### Function Schema
521
+
522
+ Create a file in `functions/` ending with `.function.js`:
523
+
524
+ ```javascript
525
+ /**
526
+ * Function description
527
+ */
528
+ export default {
529
+ name: 'function-name', // Unique identifier (required)
530
+ description: 'What it does', // Clear description (required)
531
+
532
+ parameters: { // Input parameters (required)
533
+ param1: {
534
+ type: 'number', // string | number | boolean | array | object | enum
535
+ description: 'Parameter description',
536
+ required: true, // Optional, defaults to true
537
+ default: 0, // Optional default value
538
+ },
539
+ },
540
+
541
+ execute: async ({ param1 }) => { // Execution function (required)
542
+ // Your logic here
543
+ return `Result: ${param1}`;
544
+ },
545
+ };
546
+
547
+ // Optional metadata for documentation
548
+ export const metadata = {
549
+ name: 'function-name',
550
+ version: '1.0.0',
551
+ author: 'Your Name',
552
+ tags: ['category'],
553
+ };
554
+ ```
555
+
556
+ ### Example Function
557
+
558
+ ```javascript
559
+ // functions/fibonacci.function.js
560
+
561
+ export default {
562
+ name: 'fibonacci',
563
+ description: 'Returns the nth Fibonacci number (0-based indexing)',
564
+
565
+ parameters: {
566
+ n: {
567
+ type: 'number',
568
+ description: 'The index (0-based, max 100)',
569
+ },
570
+ },
571
+
572
+ execute: async ({ n }) => {
573
+ if (n < 0 || !Number.isInteger(n)) {
574
+ throw new Error('Index must be a non-negative integer');
575
+ }
576
+ if (n > 100) {
577
+ throw new Error('Index too large (max 100)');
578
+ }
579
+
580
+ if (n === 0) return 'Fibonacci(0) = 0';
581
+ if (n === 1) return 'Fibonacci(1) = 1';
582
+
583
+ let prev = 0, curr = 1;
584
+ for (let i = 2; i <= n; i++) {
585
+ [prev, curr] = [curr, prev + curr];
586
+ }
587
+
588
+ return `Fibonacci(${n}) = ${curr}`;
589
+ },
590
+ };
591
+ ```
592
+
593
+ ### Using Functions in Agents
594
+
595
+ Reference functions in your agent's tools list with the `function:` prefix:
596
+
597
+ ```yaml
598
+ name: math-assistant
599
+ description: Assistant that can calculate Fibonacci numbers
600
+
601
+ llm:
602
+ name: default
603
+ temperature: 0.3
604
+
605
+ prompt:
606
+ system: |
607
+ You are a math assistant. Use the fibonacci tool to calculate
608
+ Fibonacci numbers when asked.
609
+ inputVariables:
610
+ - query
611
+
612
+ tools:
613
+ - function:fibonacci # References fibonacci.function.js
614
+
615
+ output:
616
+ format: text
617
+ ```
618
+
619
+ ### Parameter Types
620
+
621
+ - **string**: Text value
622
+ - **number**: Numeric value
623
+ - **boolean**: true/false
624
+ - **array**: Array of values
625
+ - **object**: JSON object
626
+ - **enum**: One of a fixed set (requires `values` array)
627
+
628
+ Example enum parameter:
629
+ ```javascript
630
+ parameters: {
631
+ operation: {
632
+ type: 'enum',
633
+ values: ['add', 'subtract', 'multiply', 'divide'],
634
+ description: 'Math operation to perform',
635
+ },
636
+ }
637
+ ```
638
+
639
+ ## MCP Servers
640
+
641
+ Model Context Protocol (MCP) servers provide external tools to agents. Configure MCP servers in `mcp.json` at the project root.
642
+
643
+ ### MCP Configuration
644
+
645
+ ```json
646
+ {
647
+ "version": "1.0.0",
648
+ "servers": {
649
+ "<server-name>": {
650
+ "transport": "streamable-http | stdio | sse",
651
+ "url": "https://server-url/mcp",
652
+ "command": "node",
653
+ "args": ["./mcp-server.js"],
654
+ "timeout": 30000,
655
+ "enabled": true,
656
+ "description": "Server description"
657
+ }
658
+ },
659
+ "globalOptions": {
660
+ "throwOnLoadError": false,
661
+ "prefixToolNameWithServerName": true,
662
+ "defaultToolTimeout": 30000
663
+ }
664
+ }
665
+ ```
666
+
667
+ ### Example MCP Configuration
668
+
669
+ ```json
670
+ {
671
+ "version": "1.0.0",
672
+ "servers": {
673
+ "fetch": {
674
+ "transport": "streamable-http",
675
+ "url": "https://remote.mcpservers.org/fetch/mcp",
676
+ "description": "Web fetch capabilities",
677
+ "timeout": 30000,
678
+ "enabled": true
679
+ }
680
+ }
681
+ }
682
+ ```
683
+
684
+ Reference MCP tools in agents:
685
+ ```yaml
686
+ tools:
687
+ - mcp:fetch # All tools from "fetch" server
688
+ ```
689
+
690
+ ## API Reference
691
+
692
+ ### Health Check
693
+
694
+ ```
695
+ GET /health
696
+ Response: { "status": "ok", "timestamp": "..." }
697
+ ```
698
+
699
+ ### Agents
700
+
701
+ | Method | Endpoint | Description |
702
+ |--------|----------|-------------|
703
+ | GET | `/api/agents` | List all agents |
704
+ | GET | `/api/agents/:name` | Get agent details |
705
+ | POST | `/api/agents/:name/invoke` | Run agent |
706
+ | POST | `/api/agents/:name/stream` | Stream agent response (SSE) |
707
+
708
+ **Invoke Request:**
709
+ ```json
710
+ {
711
+ "input": {
712
+ "topic": "your topic",
713
+ "context": "additional context"
714
+ }
715
+ }
716
+ ```
717
+
718
+ **Response:**
719
+ ```json
720
+ {
721
+ "output": "Agent response text",
722
+ "metadata": {
723
+ "tokensUsed": 150,
724
+ "toolCalls": [],
725
+ "duration": 1234
726
+ }
727
+ }
728
+ ```
729
+
730
+ ### Workflows
731
+
732
+ | Method | Endpoint | Description |
733
+ |--------|----------|-------------|
734
+ | GET | `/api/workflows` | List all workflows |
735
+ | GET | `/api/workflows/:name` | Get workflow details |
736
+ | POST | `/api/workflows/:name/run` | Execute workflow |
737
+
738
+ **Run Request:**
739
+ ```json
740
+ {
741
+ "input": {
742
+ "topic": "research topic",
743
+ "style": "professional"
744
+ }
745
+ }
746
+ ```
747
+
748
+ **Response:**
749
+ ```json
750
+ {
751
+ "output": {
752
+ "paper": "Final content",
753
+ "summary": "Key points"
754
+ },
755
+ "metadata": {
756
+ "duration": 5000,
757
+ "stepsExecuted": 3,
758
+ "success": true
759
+ },
760
+ "stepResults": {
761
+ "research": { "output": "...", "metadata": {...} },
762
+ "summarize": { "output": "...", "metadata": {...} }
763
+ }
764
+ }
765
+ ```
766
+
767
+ ### Vector Stores
768
+
769
+ | Method | Endpoint | Description |
770
+ |--------|----------|-------------|
771
+ | GET | `/api/vectors` | List all vector stores |
772
+ | GET | `/api/vectors/:name` | Get vector store config |
773
+ | POST | `/api/vectors/:name/search` | Search vector store |
774
+ | POST | `/api/vectors/:name/refresh` | Reload documents |
775
+ | POST | `/api/vectors/:name/add` | Add documents |
776
+
777
+ **Search Request:**
778
+ ```json
779
+ {
780
+ "query": "search term",
781
+ "k": 4
782
+ }
783
+ ```
784
+
785
+ ## Directory Structure
786
+
787
+ ```
788
+ agent-orcha/
789
+ ├── src/ # Server/API code
790
+ │ ├── index.ts # Entry point
791
+ │ ├── server.ts # Fastify server setup
792
+ │ └── routes/ # API route handlers
793
+ │ ├── agents.route.ts
794
+ │ ├── workflows.route.ts
795
+ │ └── vectors.route.ts
796
+
797
+ ├── lib/ # Core library
798
+ │ ├── orchestrator.ts # Main orchestrator class
799
+ │ ├── agents/ # Agent system
800
+ │ │ ├── types.ts
801
+ │ │ ├── agent-loader.ts
802
+ │ │ └── agent-executor.ts
803
+ │ ├── workflows/ # Workflow system
804
+ │ │ ├── types.ts
805
+ │ │ ├── workflow-loader.ts
806
+ │ │ └── workflow-executor.ts
807
+ │ ├── vectors/ # Vector store system
808
+ │ │ ├── types.ts
809
+ │ │ └── vector-store-manager.ts
810
+ │ ├── llm/ # LLM factory
811
+ │ │ └── llm-factory.ts
812
+ │ ├── mcp/ # MCP client
813
+ │ │ └── mcp-client.ts
814
+ │ └── tools/ # Tool registry
815
+ │ └── tool-registry.ts
816
+
817
+ ├── agents/ # Agent definitions (YAML)
818
+ ├── workflows/ # Workflow definitions (YAML)
819
+ ├── vectors/ # Vector store configs and data
820
+ ├── functions/ # Custom function tools (JavaScript)
821
+ ├── public/ # Web UI
822
+
823
+ ├── package.json
824
+ ├── tsconfig.json
825
+ ├── llm.json # LLM and embedding configurations
826
+ ├── mcp.json # MCP server configuration
827
+ └── .env # Environment variables
828
+ ```
829
+
830
+ **Referencing in agents:**
831
+
832
+ ```yaml
833
+ # Simple reference
834
+ llm: default
835
+
836
+ # With temperature override
837
+ llm:
838
+ name: default
839
+ temperature: 0.3
840
+ ```
841
+
842
+ ## Tool Types
843
+
844
+ ### Function Tools
845
+ Custom JavaScript/TypeScript functions you create in the `functions/` directory:
846
+ ```yaml
847
+ tools:
848
+ - function:fibonacci # References fibonacci.function.js
849
+ - function:your-custom-function
850
+ ```
851
+
852
+ ### MCP Tools
853
+ External tools from MCP servers:
854
+ ```yaml
855
+ tools:
856
+ - mcp:fetch # All tools from "fetch" server
857
+ ```
858
+
859
+ ### Vector Tools
860
+ Semantic search on vector stores:
861
+ ```yaml
862
+ tools:
863
+ - vector:transcripts # Search "transcripts" store
864
+ ```
865
+
866
+ ### Built-in Tools
867
+ Framework-provided tools:
868
+ ```yaml
869
+ tools:
870
+ - builtin:tool_name
871
+ ```
872
+
873
+ ## Web UI
874
+
875
+ Access the web interface at `http://localhost:3000` after starting the server. The UI provides:
876
+
877
+ - **Agents Tab**: Select and run individual agents with custom input
878
+ - **Workflows Tab**: Select workflows, view flow diagrams, and execute with inputs
879
+
880
+ The workflow flow diagram visualizes:
881
+ - Step sequence with agent names
882
+ - Tool badges (MCP servers, vector databases)
883
+ - Input/output nodes
884
+
885
+ ## Publishing to npm
886
+
887
+ To publish this package to npm:
888
+
889
+ 1. **Build the package:**
890
+ ```bash
891
+ npm run build
892
+ ```
893
+
894
+ 2. **Update version in package.json:**
895
+ ```bash
896
+ npm version patch # or minor, or major
897
+ ```
898
+
899
+ 3. **Publish to npm:**
900
+ ```bash
901
+ npm publish
902
+ ```
903
+
904
+ The package includes:
905
+ - Compiled TypeScript code (`dist/`)
906
+ - CLI executable (`bin/cli.js`)
907
+ - Template files for `init` command (`templates/`)
908
+ - Web UI (`public/`)
909
+ - Type definitions
910
+
911
+ Users can then:
912
+ - Use as CLI: `npx agent-orcha init`
913
+ - Install as library: `npm install agent-orcha`
914
+
915
+ ## License
916
+
917
+ MIT