@inkeep/agents-cli 0.0.0-dev-20250910233151

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/LICENSE.md ADDED
@@ -0,0 +1,56 @@
1
+ <!--
2
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
3
+ Source: ./LICENSE.md
4
+ This file is automatically copied from the root LICENSE.md during build.
5
+ Any changes should be made to the root LICENSE.md file.
6
+ -->
7
+
8
+ # Inkeep SDK – Elastic License 2.0 with Supplemental Terms
9
+
10
+ NOTE: The Inkeep SDK is licensed under the Elastic License 2.0 (ELv2), subject to Supplemental Terms included in [SUPPLEMENTAL_TERMS.md](SUPPLEMENTAL_TERMS.md). In the event of conflict, the Supplemental Terms control.
11
+
12
+ # Elastic License 2.0
13
+
14
+ ## Acceptance
15
+ By using the software, you agree to all of the terms and conditions below.
16
+
17
+ ## Copyright License
18
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
19
+
20
+ ## Limitations
21
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
22
+
23
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
24
+
25
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
26
+
27
+ ## Patents
28
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
29
+
30
+ ## Notices
31
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
32
+
33
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
34
+
35
+ ## No Other Rights
36
+ These terms do not imply any licenses other than those expressly granted in these terms.
37
+
38
+ ## Termination
39
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
40
+
41
+ ## No Liability
42
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
43
+
44
+ ## Definitions
45
+ The **licensor** is the entity offering these terms, and the **software** is the software the licensor makes available under these terms, including any portion of it.
46
+
47
+ **you** refers to the individual or entity agreeing to these terms.
48
+
49
+ **your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
50
+
51
+ **your licenses** are all the licenses granted to you for the software under these terms.
52
+
53
+ **use** means anything you do with the software requiring one of your licenses.
54
+
55
+ **trademark** means trademarks, service marks, and similar rights.
56
+
package/README.md ADDED
@@ -0,0 +1,500 @@
1
+ # Inkeep CLI
2
+
3
+ A command-line interface for managing and interacting with Inkeep Agent Framework graphs.
4
+
5
+ ## Installation & Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js >= 20.x
10
+ - pnpm package manager
11
+ - Inkeep Agent Framework backend running (default: http://localhost:3002)
12
+
13
+ ### Quick Start
14
+
15
+ > **πŸ“– For detailed setup instructions, see [SETUP.md](./SETUP.md)**
16
+
17
+ 1. **Install and build**
18
+ ```bash
19
+ # Navigate to the CLI directory
20
+ cd /path/to/agent-framework/agents-cli
21
+
22
+ # Install dependencies
23
+ pnpm install
24
+
25
+ # Build the CLI
26
+ pnpm build
27
+ ```
28
+
29
+ 2. **Install globally** (recommended)
30
+
31
+ **Option A: Using npm link (for development)**
32
+ ```bash
33
+ # Create global symlink from the agents-cli directory
34
+ npm link
35
+
36
+ # Verify installation
37
+ which inkeep # Should show path to inkeep command
38
+ ```
39
+
40
+ **Option B: Using pnpm/npm global install (after publishing)**
41
+ ```bash
42
+ # Install the scoped package globally
43
+ pnpm add -g @inkeep/agents-cli
44
+ # or
45
+ npm install -g @inkeep/agents-cli
46
+
47
+ # Verify installation
48
+ inkeep --version
49
+ ```
50
+
51
+ **Note:**
52
+ - For local development, use `npm link` (more reliable than `pnpm link --global`)
53
+ - The command is still `inkeep` even though the package name is `@inkeep/agents-cli`
54
+ - If linking fails, try unlinking first: `npm unlink -g @inkeep/agents-cli`
55
+
56
+ 3. **Configure tenant**
57
+ ```bash
58
+ # Set your tenant ID (required for most commands)
59
+ inkeep tenant your-tenant-id
60
+
61
+ # Verify configuration
62
+ inkeep tenant
63
+ ```
64
+
65
+ ## Configuration
66
+
67
+ ### Configuration Sources (priority order)
68
+
69
+ 1. **Command-line flags** - Highest priority (e.g., `--tenant-id`, `--api-url`)
70
+ 2. **Environment variables** - `INKEEP_API_URL`
71
+ 3. **`.env` file** - In current directory
72
+ 4. **Config file** - `inkeep.config.ts` or `.inkeeprc.ts/js`
73
+ 5. **Defaults** - Lowest priority (api-url defaults to `http://localhost:3002`)
74
+
75
+ ### Environment Variables
76
+
77
+ Create a `.env` file in your project directory:
78
+
79
+ ```bash
80
+ INKEEP_API_URL=http://localhost:3002
81
+ ```
82
+
83
+ Or export them in your shell:
84
+
85
+ ```bash
86
+ export INKEEP_API_URL=http://localhost:3002
87
+ ```
88
+
89
+ ## Commands
90
+
91
+ ### `inkeep tenant [tenant-id]`
92
+
93
+ Manage tenant configuration.
94
+
95
+ ```bash
96
+ # Set tenant ID
97
+ inkeep tenant my-tenant
98
+
99
+ # View current tenant ID
100
+ inkeep tenant
101
+ ```
102
+
103
+ ### `inkeep list-graphs`
104
+
105
+ List all available graphs for the current tenant.
106
+
107
+ ```bash
108
+ inkeep list-graphs
109
+
110
+ # With custom API URL
111
+ inkeep list-graphs --url http://api.example.com:3002
112
+ ```
113
+
114
+ Output:
115
+ ```
116
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
117
+ β”‚ Graph ID β”‚ Name β”‚ Default Agent β”‚ Created β”‚
118
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
119
+ β”‚ customer-support-graph β”‚ Customer Support β”‚ router β”‚ 1/15/2025 β”‚
120
+ β”‚ qa-assistant β”‚ QA Assistant β”‚ qa-agent β”‚ 1/14/2025 β”‚
121
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
122
+ ```
123
+
124
+ ### `inkeep push <config-path>`
125
+
126
+ Push a graph configuration to the backend.
127
+
128
+ ```bash
129
+ # Push a graph configuration
130
+ inkeep push ./my-graph.js
131
+
132
+ # With custom API URL
133
+ inkeep push ./graph.ts --url http://api.example.com:3002
134
+ ```
135
+
136
+ **Features:**
137
+ - Automatically injects tenant ID and API URL from `inkeep.config.ts`
138
+ - Validates exactly one AgentGraph is exported
139
+ - Warns about dangling resources (unreferenced agents/tools)
140
+ - Shows graph summary after successful push
141
+ - Handles graph initialization automatically
142
+
143
+ **Graph naming convention:** Graph files should follow the `*.graph.ts` naming pattern (e.g., `customer-support.graph.ts`, `qa-assistant.graph.ts`)
144
+
145
+ **Example graph configuration:**
146
+
147
+ ```javascript
148
+ // customer-support.graph.ts
149
+ import { agent, agentGraph, tool } from '@inkeep/agents-manage-api/builder';
150
+
151
+ const assistantAgent = agent({
152
+ id: 'assistant',
153
+ name: 'Assistant',
154
+ instructions: 'Help users with their questions',
155
+ tools: {
156
+ search: searchTool
157
+ }
158
+ // No tenantId needed - injected by CLI
159
+ });
160
+
161
+ // Must export exactly one graph
162
+ export const graph = agentGraph({
163
+ id: 'my-assistant',
164
+ name: 'My Assistant Graph',
165
+ defaultAgent: assistantAgent,
166
+ agents: {
167
+ assistant: assistantAgent
168
+ }
169
+ // No tenantId or apiUrl needed - CLI injects from config
170
+ });
171
+ // No graph.init() call - CLI handles initialization
172
+ ```
173
+
174
+ ### `inkeep chat [graph-id]`
175
+
176
+ Start an interactive chat session with a graph.
177
+
178
+ ```bash
179
+ # Chat with specific graph
180
+ inkeep chat my-graph-id
181
+
182
+ # Interactive graph selection (with search)
183
+ inkeep chat
184
+
185
+ # With custom API URL
186
+ inkeep chat --url http://api.example.com:3002
187
+ ```
188
+
189
+ **Interactive Features:**
190
+ - **Graph selection**: If no graph ID provided, shows searchable list
191
+ - **Chat commands**:
192
+ - `help` - Show available commands
193
+ - `clear` - Clear screen (preserves context)
194
+ - `history` - Show conversation history
195
+ - `reset` - Reset conversation context
196
+ - `exit` - End chat session
197
+
198
+ ### `inkeep mcp start <graph-file>`
199
+
200
+ Start MCP (Model Context Protocol) servers defined in a graph file.
201
+
202
+ ```bash
203
+ # Start MCP servers from a TypeScript graph file
204
+ inkeep mcp start examples/agent-configurations/graph.graph.ts
205
+
206
+ # Start from compiled JavaScript
207
+ inkeep mcp start dist/examples/agent-configurations/graph.graph.js
208
+
209
+ # Run in detached mode
210
+ inkeep mcp start graph.graph.ts --detached
211
+
212
+ # Show verbose output
213
+ inkeep mcp start graph.graph.ts --verbose
214
+ ```
215
+
216
+ **Features:**
217
+ - Supports both TypeScript (`.ts`) and JavaScript (`.js`) files
218
+ - Automatically allocates ports for local servers (3100-3200)
219
+ - Shows server names, ports, and URLs
220
+ - Distinguishes between local (🏠) and remote (☁️) servers
221
+
222
+ ### `inkeep mcp stop`
223
+
224
+ Stop running MCP servers.
225
+
226
+ ```bash
227
+ # Stop all servers
228
+ inkeep mcp stop --all
229
+
230
+ # Stop servers for a specific graph
231
+ inkeep mcp stop --graph customer-support-graph
232
+ ```
233
+
234
+ ### `inkeep mcp status`
235
+
236
+ Show status of all MCP servers.
237
+
238
+ ```bash
239
+ inkeep mcp status
240
+ ```
241
+
242
+ Output shows:
243
+ - Process ID
244
+ - Graph ID
245
+ - Tool name
246
+ - Port/URL
247
+ - Running status
248
+ - Uptime
249
+
250
+ ### `inkeep mcp list`
251
+
252
+ List all MCP servers with detailed information.
253
+
254
+ ```bash
255
+ # Default tree view
256
+ inkeep mcp list
257
+
258
+ # Table format
259
+ inkeep mcp list --format table
260
+
261
+ # Verbose output (includes descriptions)
262
+ inkeep mcp list --verbose
263
+ ```
264
+
265
+
266
+
267
+ ## Complete Workflow Example
268
+
269
+ ### Basic Setup
270
+ ```bash
271
+ # Install and link CLI
272
+ cd agents-cli
273
+ pnpm install
274
+ pnpm build
275
+ npm link
276
+
277
+ # Configure tenant
278
+ inkeep tenant test-tenant
279
+ ```
280
+
281
+ ### Working with Graphs and MCP Servers
282
+
283
+ 1. **Create a graph with MCP tools** (`my-graph.graph.ts`)
284
+ ```typescript
285
+ import { agent, agentGraph, mcpServer } from '@inkeep/agents-manage-api/builder';
286
+
287
+ // Define MCP servers (tools)
288
+ const randomNumberServer = mcpServer({
289
+ name: 'random_number',
290
+ description: 'Generates a random number',
291
+ execute: async () => Math.random()
292
+ });
293
+
294
+ const weatherServer = mcpServer({
295
+ name: 'weather_api',
296
+ description: 'Get weather information',
297
+ serverUrl: 'https://api.weather.example.com/mcp'
298
+ });
299
+
300
+ // Define agents
301
+ const assistantAgent = agent({
302
+ id: 'assistant',
303
+ name: 'Assistant',
304
+ instructions: 'Help users with various tasks',
305
+ tools: {
306
+ random: randomNumberServer,
307
+ weather: weatherServer
308
+ }
309
+ });
310
+
311
+ // Export the graph
312
+ export const graph = agentGraph({
313
+ id: 'my-assistant',
314
+ name: 'My Assistant',
315
+ defaultAgent: assistantAgent,
316
+ agents: { assistant: assistantAgent }
317
+ });
318
+
319
+ // Export servers for MCP management
320
+ export const servers = [randomNumberServer, weatherServer];
321
+ ```
322
+
323
+ 2. **Start MCP servers and chat**
324
+ ```bash
325
+ # Start MCP servers (works with TypeScript directly!)
326
+ inkeep mcp start my-graph.graph.ts
327
+
328
+ # In another terminal, start chatting
329
+ inkeep chat my-assistant
330
+
331
+ # Try commands like:
332
+ # > "Generate a random number"
333
+ # > "What's the weather like?"
334
+ ```
335
+
336
+ 3. **Monitor and manage servers**
337
+ ```bash
338
+ # Check server status
339
+ inkeep mcp status
340
+
341
+ # List all servers with details
342
+ inkeep mcp list
343
+
344
+ # Stop servers when done
345
+ inkeep mcp stop --all
346
+ ```
347
+
348
+ ## Working with Different Environments
349
+
350
+ ### Development
351
+ ```bash
352
+ # Using environment variable
353
+ INKEEP_API_URL=http://localhost:3002 inkeep list-graphs
354
+
355
+ # Using .env file
356
+ echo "INKEEP_API_URL=http://localhost:3002" > .env
357
+ inkeep chat my-graph
358
+ ```
359
+
360
+ ### Staging
361
+ ```bash
362
+ # Using command flag
363
+ inkeep push graph.js --url https://staging-api.example.com
364
+
365
+ # Set in config file
366
+ # Edit your inkeep.config.ts to set apiUrl: 'https://staging-api.example.com'
367
+ ```
368
+
369
+ ### Production
370
+ ```bash
371
+ # Using environment variables
372
+ export INKEEP_API_URL=https://api.example.com
373
+ inkeep list-graphs
374
+ ```
375
+
376
+ ## Development
377
+
378
+ ### Running from Source
379
+
380
+ ```bash
381
+ # Without building (using tsx)
382
+ pnpm tsx src/index.ts <command>
383
+
384
+ # After building
385
+ node dist/index.js <command>
386
+
387
+ # Watch mode (auto-rebuild on changes)
388
+ pnpm dev
389
+ ```
390
+
391
+ ### Testing
392
+
393
+ ```bash
394
+ # Run tests
395
+ pnpm test
396
+
397
+ # Watch mode
398
+ pnpm test:watch
399
+
400
+ # Coverage report
401
+ pnpm test:coverage
402
+ ```
403
+
404
+ ### Type Checking
405
+
406
+ ```bash
407
+ pnpm typecheck
408
+ ```
409
+
410
+ ### Project Structure
411
+
412
+ ```
413
+ agents-cli/
414
+ β”œβ”€β”€ src/
415
+ β”‚ β”œβ”€β”€ index.ts # Main CLI entry point
416
+ β”‚ β”œβ”€β”€ config.ts # Configuration management
417
+ β”‚ β”œβ”€β”€ api.ts # API client for backend
418
+ β”‚ β”œβ”€β”€ commands/ # Command implementations
419
+ β”‚ β”‚ β”œβ”€β”€ push.ts # Push graph configurations
420
+ β”‚ β”‚ β”œβ”€β”€ chat.ts # Basic chat interface
421
+ β”‚ β”‚ β”œβ”€β”€ chat-enhanced.ts # Enhanced chat with autocomplete
422
+ β”‚ β”‚ β”œβ”€β”€ tenant.ts # Tenant management
423
+ β”‚ β”‚ └── list-graphs.ts # List graphs
424
+ β”‚ β”œβ”€β”€ types/ # TypeScript declarations
425
+ β”‚ └── __tests__/ # Test files
426
+ β”œβ”€β”€ dist/ # Compiled JavaScript
427
+ β”œβ”€β”€ package.json
428
+ β”œβ”€β”€ tsconfig.json
429
+ └── README.md
430
+ ```
431
+
432
+ ## Troubleshooting
433
+
434
+ ### Common Issues
435
+
436
+ **"Failed to fetch graphs" or connection errors**
437
+ ```bash
438
+ # Check if backend is running
439
+ curl http://localhost:3002/health
440
+
441
+ # Verify API URL
442
+ echo $INKEEP_API_URL
443
+
444
+ # Try with explicit URL
445
+ inkeep list-graphs --url http://localhost:3002
446
+ ```
447
+
448
+
449
+ **"Graph not found" when using chat**
450
+ ```bash
451
+ # List available graphs first
452
+ inkeep list-graphs
453
+
454
+ # Use interactive selection
455
+ inkeep chat
456
+ # (Select from list)
457
+ ```
458
+
459
+ **Command not found: inkeep**
460
+ ```bash
461
+ # Ensure CLI is linked globally
462
+ cd agents-cli
463
+ npm link
464
+
465
+ # Or if published, install globally
466
+ pnpm add -g @inkeep/agents-cli
467
+ # or
468
+ npm install -g @inkeep/agents-cli
469
+
470
+ # Or add to PATH manually (for development)
471
+ export PATH="$PATH:/path/to/agents-cli/dist"
472
+ ```
473
+
474
+ ## Dependencies
475
+
476
+ ### Runtime Dependencies
477
+ - **commander**: Command-line framework
478
+ - **chalk**: Terminal styling
479
+ - **dotenv**: Environment variable loading
480
+ - **ora**: Loading spinners
481
+ - **cli-table3**: Table formatting
482
+ - **inquirer**: Interactive prompts
483
+ - **inquirer-autocomplete-prompt**: Searchable selections
484
+
485
+ ### Development Dependencies
486
+ - **typescript**: TypeScript compiler
487
+ - **@types/node**: Node.js types
488
+ - **vitest**: Testing framework
489
+ - **@vitest/coverage-v8**: Coverage reporting
490
+
491
+ ## Requirements
492
+
493
+ - Node.js >= 20.x
494
+ - pnpm package manager
495
+ - TypeScript 5.x
496
+ - Inkeep Agent Framework backend
497
+
498
+ ## License
499
+
500
+ MIT
@@ -0,0 +1,12 @@
1
+ declare const createAgents: (args?: {
2
+ tenantId?: string;
3
+ projectId?: string;
4
+ dirName?: string;
5
+ openAiKey?: string;
6
+ anthropicKey?: string;
7
+ manageApiPort?: string;
8
+ runApiPort?: string;
9
+ }) => Promise<void>;
10
+ declare function createCommand(dirName?: string, options?: any): Promise<void>;
11
+
12
+ export { createAgents, createCommand };