@inkeep/agents-cli 0.22.8 → 0.22.11
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 +1 -60
- package/dist/index.js +215 -585
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -327,37 +327,6 @@ export const myAgent = agent({
|
|
|
327
327
|
// No agent.init() call - CLI handles initialization
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
### `inkeep chat [graph-id]`
|
|
331
|
-
|
|
332
|
-
Start an interactive chat session with a graph.
|
|
333
|
-
|
|
334
|
-
```bash
|
|
335
|
-
# Chat with specific graph
|
|
336
|
-
inkeep chat my-graph-id
|
|
337
|
-
|
|
338
|
-
# Interactive graph selection (with search)
|
|
339
|
-
inkeep chat
|
|
340
|
-
|
|
341
|
-
# With custom API URLs
|
|
342
|
-
inkeep chat --agents-manage-api-url http://manage.example.com --agents-run-api-url http://run.example.com
|
|
343
|
-
|
|
344
|
-
# With custom tenant ID
|
|
345
|
-
inkeep chat --tenant-id my-tenant-id
|
|
346
|
-
|
|
347
|
-
# Using config file
|
|
348
|
-
inkeep chat --config ./my-config.ts
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
**Interactive Features:**
|
|
352
|
-
|
|
353
|
-
- **Graph selection**: If no graph ID provided, shows searchable list
|
|
354
|
-
- **Chat commands**:
|
|
355
|
-
- `help` - Show available commands
|
|
356
|
-
- `clear` - Clear screen (preserves context)
|
|
357
|
-
- `history` - Show conversation history
|
|
358
|
-
- `reset` - Reset conversation context
|
|
359
|
-
- `exit` - End chat session
|
|
360
|
-
|
|
361
330
|
### `inkeep mcp start <graph-file>` ⚠️ NOT IMPLEMENTED
|
|
362
331
|
|
|
363
332
|
> **⚠️ WARNING: This command is not yet implemented in the current CLI.**
|
|
@@ -499,21 +468,7 @@ export const myAgent = agent({
|
|
|
499
468
|
export const servers = [randomNumberServer, weatherServer];
|
|
500
469
|
```
|
|
501
470
|
|
|
502
|
-
2. **
|
|
503
|
-
|
|
504
|
-
```bash
|
|
505
|
-
# Start MCP servers (works with TypeScript directly!)
|
|
506
|
-
inkeep mcp start my-agent.ts
|
|
507
|
-
|
|
508
|
-
# In another terminal, start chatting
|
|
509
|
-
inkeep chat my-assistant
|
|
510
|
-
|
|
511
|
-
# Try commands like:
|
|
512
|
-
# > "Generate a random number"
|
|
513
|
-
# > "What's the weather like?"
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
3. **Monitor and manage servers**
|
|
471
|
+
2. **Monitor and manage servers**
|
|
517
472
|
|
|
518
473
|
```bash
|
|
519
474
|
# Check server status
|
|
@@ -537,7 +492,6 @@ INKEEP_AGENTS_MANAGE_API_URL=http://localhost:3002 inkeep list-graphs
|
|
|
537
492
|
# Using .env file
|
|
538
493
|
echo "INKEEP_AGENTS_MANAGE_API_URL=http://localhost:3002" > .env
|
|
539
494
|
echo "INKEEP_AGENTS_RUN_API_URL=http://localhost:3003" >> .env
|
|
540
|
-
inkeep chat my-graph
|
|
541
495
|
```
|
|
542
496
|
|
|
543
497
|
### Staging
|
|
@@ -602,8 +556,6 @@ agents-cli/
|
|
|
602
556
|
│ ├── api.ts # API client for backend
|
|
603
557
|
│ ├── commands/ # Command implementations
|
|
604
558
|
│ │ ├── push.ts # Push graph configurations
|
|
605
|
-
│ │ ├── chat.ts # Basic chat interface
|
|
606
|
-
│ │ ├── chat-enhanced.ts # Enhanced chat with autocomplete
|
|
607
559
|
│ │ ├── tenant.ts # Tenant management
|
|
608
560
|
│ │ └── list-graphs.ts # List graphs
|
|
609
561
|
│ ├── types/ # TypeScript declarations
|
|
@@ -632,17 +584,6 @@ echo $INKEEP_AGENTS_RUN_API_URL
|
|
|
632
584
|
inkeep list-graphs --project my-project-id --agents-manage-api-url http://localhost:3002
|
|
633
585
|
```
|
|
634
586
|
|
|
635
|
-
**"Graph not found" when using chat**
|
|
636
|
-
|
|
637
|
-
```bash
|
|
638
|
-
# List available graphs first (requires project)
|
|
639
|
-
inkeep list-graphs --project my-project-id
|
|
640
|
-
|
|
641
|
-
# Use interactive selection
|
|
642
|
-
inkeep chat
|
|
643
|
-
# (Select from list)
|
|
644
|
-
```
|
|
645
|
-
|
|
646
587
|
**Command not found: inkeep**
|
|
647
588
|
|
|
648
589
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1803,6 +1803,7 @@ var init_schema = __esm({
|
|
|
1803
1803
|
...projectScoped,
|
|
1804
1804
|
...uiProperties,
|
|
1805
1805
|
props: blob("props", { mode: "json" }).$type(),
|
|
1806
|
+
preview: blob("preview", { mode: "json" }).$type(),
|
|
1806
1807
|
...timestamps
|
|
1807
1808
|
},
|
|
1808
1809
|
(table) => [
|
|
@@ -233393,6 +233394,14 @@ var init_conversations2 = __esm({
|
|
|
233393
233394
|
}
|
|
233394
233395
|
});
|
|
233395
233396
|
|
|
233397
|
+
// ../packages/agents-core/src/validation/preview-validation.ts
|
|
233398
|
+
var init_preview_validation = __esm({
|
|
233399
|
+
"../packages/agents-core/src/validation/preview-validation.ts"() {
|
|
233400
|
+
"use strict";
|
|
233401
|
+
init_esm_shims();
|
|
233402
|
+
}
|
|
233403
|
+
});
|
|
233404
|
+
|
|
233396
233405
|
// ../packages/agents-core/src/data-access/dataComponents.ts
|
|
233397
233406
|
import { and as and14, count as count12, desc as desc12, eq as eq14 } from "drizzle-orm";
|
|
233398
233407
|
var init_dataComponents = __esm({
|
|
@@ -233400,6 +233409,7 @@ var init_dataComponents = __esm({
|
|
|
233400
233409
|
"use strict";
|
|
233401
233410
|
init_esm_shims();
|
|
233402
233411
|
init_schema();
|
|
233412
|
+
init_preview_validation();
|
|
233403
233413
|
init_props_validation();
|
|
233404
233414
|
}
|
|
233405
233415
|
});
|
|
@@ -233955,9 +233965,10 @@ var init_validation2 = __esm({
|
|
|
233955
233965
|
"../packages/agents-core/src/validation/index.ts"() {
|
|
233956
233966
|
"use strict";
|
|
233957
233967
|
init_esm_shims();
|
|
233958
|
-
init_event_schemas();
|
|
233959
233968
|
init_agentFull();
|
|
233969
|
+
init_event_schemas();
|
|
233960
233970
|
init_id_validation();
|
|
233971
|
+
init_preview_validation();
|
|
233961
233972
|
init_props_validation();
|
|
233962
233973
|
init_schemas();
|
|
233963
233974
|
}
|
|
@@ -234195,250 +234206,6 @@ var init_config = __esm({
|
|
|
234195
234206
|
}
|
|
234196
234207
|
});
|
|
234197
234208
|
|
|
234198
|
-
// src/api.ts
|
|
234199
|
-
var BaseApiClient, ManagementApiClient, ExecutionApiClient;
|
|
234200
|
-
var init_api = __esm({
|
|
234201
|
-
"src/api.ts"() {
|
|
234202
|
-
"use strict";
|
|
234203
|
-
init_esm_shims();
|
|
234204
|
-
init_src();
|
|
234205
|
-
BaseApiClient = class {
|
|
234206
|
-
apiUrl;
|
|
234207
|
-
tenantId;
|
|
234208
|
-
projectId;
|
|
234209
|
-
apiKey;
|
|
234210
|
-
constructor(apiUrl, tenantId, projectId, apiKey) {
|
|
234211
|
-
this.apiUrl = apiUrl;
|
|
234212
|
-
this.tenantId = tenantId;
|
|
234213
|
-
this.projectId = projectId;
|
|
234214
|
-
this.apiKey = apiKey;
|
|
234215
|
-
}
|
|
234216
|
-
checkTenantId() {
|
|
234217
|
-
if (!this.tenantId) {
|
|
234218
|
-
throw new Error("No tenant ID configured. Please run: inkeep init");
|
|
234219
|
-
}
|
|
234220
|
-
return this.tenantId;
|
|
234221
|
-
}
|
|
234222
|
-
/**
|
|
234223
|
-
* Wrapper around fetch that automatically includes Authorization header if API key is present
|
|
234224
|
-
*/
|
|
234225
|
-
async authenticatedFetch(url, options = {}) {
|
|
234226
|
-
const headers2 = {
|
|
234227
|
-
...options.headers || {}
|
|
234228
|
-
};
|
|
234229
|
-
if (this.apiKey) {
|
|
234230
|
-
headers2.Authorization = `Bearer ${this.apiKey}`;
|
|
234231
|
-
}
|
|
234232
|
-
return apiFetch(url, {
|
|
234233
|
-
...options,
|
|
234234
|
-
headers: headers2
|
|
234235
|
-
});
|
|
234236
|
-
}
|
|
234237
|
-
getTenantId() {
|
|
234238
|
-
return this.tenantId;
|
|
234239
|
-
}
|
|
234240
|
-
getProjectId() {
|
|
234241
|
-
return this.projectId;
|
|
234242
|
-
}
|
|
234243
|
-
getApiUrl() {
|
|
234244
|
-
return this.apiUrl;
|
|
234245
|
-
}
|
|
234246
|
-
};
|
|
234247
|
-
ManagementApiClient = class _ManagementApiClient extends BaseApiClient {
|
|
234248
|
-
constructor(apiUrl, tenantId, projectId, apiKey) {
|
|
234249
|
-
super(apiUrl, tenantId, projectId, apiKey);
|
|
234250
|
-
}
|
|
234251
|
-
static async create(apiUrl, configPath, tenantIdOverride, projectIdOverride) {
|
|
234252
|
-
const { validateConfiguration: validateConfiguration2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
234253
|
-
const config = await validateConfiguration2(configPath);
|
|
234254
|
-
const resolvedApiUrl = apiUrl || config.agentsManageApiUrl;
|
|
234255
|
-
const tenantId = tenantIdOverride || config.tenantId;
|
|
234256
|
-
const projectId = projectIdOverride || "";
|
|
234257
|
-
return new _ManagementApiClient(resolvedApiUrl, tenantId, projectId, config.agentsManageApiKey);
|
|
234258
|
-
}
|
|
234259
|
-
async listAgents() {
|
|
234260
|
-
const tenantId = this.checkTenantId();
|
|
234261
|
-
const projectId = this.getProjectId();
|
|
234262
|
-
const response = await this.authenticatedFetch(
|
|
234263
|
-
`${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agents`,
|
|
234264
|
-
{
|
|
234265
|
-
method: "GET"
|
|
234266
|
-
}
|
|
234267
|
-
);
|
|
234268
|
-
if (!response.ok) {
|
|
234269
|
-
throw new Error(`Failed to list agents: ${response.statusText}`);
|
|
234270
|
-
}
|
|
234271
|
-
const data = await response.json();
|
|
234272
|
-
return data.data || [];
|
|
234273
|
-
}
|
|
234274
|
-
async getAgent(agentId) {
|
|
234275
|
-
const agents2 = await this.listAgents();
|
|
234276
|
-
const agent = agents2.find((g) => g.id === agentId);
|
|
234277
|
-
return agent || null;
|
|
234278
|
-
}
|
|
234279
|
-
async pushAgent(agentDefinition) {
|
|
234280
|
-
const tenantId = this.checkTenantId();
|
|
234281
|
-
const projectId = this.getProjectId();
|
|
234282
|
-
const agentId = agentDefinition.id;
|
|
234283
|
-
if (!agentId) {
|
|
234284
|
-
throw new Error("Agent must have an id property");
|
|
234285
|
-
}
|
|
234286
|
-
const response = await this.authenticatedFetch(
|
|
234287
|
-
`${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agents/${agentId}`,
|
|
234288
|
-
{
|
|
234289
|
-
method: "PUT",
|
|
234290
|
-
body: JSON.stringify({
|
|
234291
|
-
...agentDefinition,
|
|
234292
|
-
tenantId
|
|
234293
|
-
})
|
|
234294
|
-
}
|
|
234295
|
-
);
|
|
234296
|
-
if (!response.ok) {
|
|
234297
|
-
const errorText = await response.text();
|
|
234298
|
-
throw new Error(`Failed to push agent: ${response.statusText}
|
|
234299
|
-
${errorText}`);
|
|
234300
|
-
}
|
|
234301
|
-
const data = await response.json();
|
|
234302
|
-
return data.data;
|
|
234303
|
-
}
|
|
234304
|
-
async getFullProject(projectId) {
|
|
234305
|
-
const tenantId = this.checkTenantId();
|
|
234306
|
-
const response = await this.authenticatedFetch(
|
|
234307
|
-
`${this.apiUrl}/tenants/${tenantId}/project-full/${projectId}`,
|
|
234308
|
-
{
|
|
234309
|
-
method: "GET"
|
|
234310
|
-
}
|
|
234311
|
-
);
|
|
234312
|
-
if (!response.ok) {
|
|
234313
|
-
if (response.status === 404) {
|
|
234314
|
-
throw new Error(`Project "${projectId}" not found`);
|
|
234315
|
-
}
|
|
234316
|
-
if (response.status === 401 || response.status === 403) {
|
|
234317
|
-
const errorText2 = await response.text().catch(() => "");
|
|
234318
|
-
let errorMessage = "Authentication failed - check your API key configuration\n\n";
|
|
234319
|
-
errorMessage += "Common issues:\n";
|
|
234320
|
-
errorMessage += " \u2022 Missing or invalid API key in inkeep.config.ts\n";
|
|
234321
|
-
errorMessage += " \u2022 API key does not have access to this tenant/project\n";
|
|
234322
|
-
errorMessage += " \u2022 For local development, ensure INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET is set\n";
|
|
234323
|
-
if (errorText2) {
|
|
234324
|
-
errorMessage += `
|
|
234325
|
-
Server response: ${errorText2}`;
|
|
234326
|
-
}
|
|
234327
|
-
throw new Error(errorMessage);
|
|
234328
|
-
}
|
|
234329
|
-
const errorText = await response.text().catch(() => "");
|
|
234330
|
-
throw new Error(
|
|
234331
|
-
`Failed to fetch project: ${response.statusText}${errorText ? `
|
|
234332
|
-
${errorText}` : ""}`
|
|
234333
|
-
);
|
|
234334
|
-
}
|
|
234335
|
-
const responseData = await response.json();
|
|
234336
|
-
return responseData.data;
|
|
234337
|
-
}
|
|
234338
|
-
};
|
|
234339
|
-
ExecutionApiClient = class _ExecutionApiClient extends BaseApiClient {
|
|
234340
|
-
constructor(apiUrl, tenantId, projectId, apiKey) {
|
|
234341
|
-
super(apiUrl, tenantId, projectId, apiKey);
|
|
234342
|
-
}
|
|
234343
|
-
static async create(apiUrl, configPath, tenantIdOverride, projectIdOverride) {
|
|
234344
|
-
const { validateConfiguration: validateConfiguration2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
234345
|
-
const config = await validateConfiguration2(configPath);
|
|
234346
|
-
const resolvedApiUrl = apiUrl || config.agentsRunApiUrl;
|
|
234347
|
-
const tenantId = tenantIdOverride || config.tenantId;
|
|
234348
|
-
const projectId = projectIdOverride || "";
|
|
234349
|
-
return new _ExecutionApiClient(resolvedApiUrl, tenantId, projectId, config.agentsRunApiKey);
|
|
234350
|
-
}
|
|
234351
|
-
async chatCompletion(agentId, messages2, conversationId, emitOperations) {
|
|
234352
|
-
const response = await this.authenticatedFetch(`${this.apiUrl}/v1/chat/completions`, {
|
|
234353
|
-
method: "POST",
|
|
234354
|
-
headers: {
|
|
234355
|
-
Accept: "text/event-stream",
|
|
234356
|
-
"x-inkeep-tenant-id": this.tenantId || "test-tenant-id",
|
|
234357
|
-
"x-inkeep-project-id": this.projectId,
|
|
234358
|
-
"x-inkeep-agent-id": agentId,
|
|
234359
|
-
...emitOperations && { "x-emit-operations": "true" }
|
|
234360
|
-
},
|
|
234361
|
-
body: JSON.stringify({
|
|
234362
|
-
model: OPENAI_MODELS.GPT_4_1_MINI,
|
|
234363
|
-
// Required but will be overridden by graph config
|
|
234364
|
-
messages: messages2,
|
|
234365
|
-
conversationId,
|
|
234366
|
-
stream: true
|
|
234367
|
-
})
|
|
234368
|
-
});
|
|
234369
|
-
if (!response.ok) {
|
|
234370
|
-
const errorText = await response.text();
|
|
234371
|
-
throw new Error(`Chat request failed: ${response.statusText}
|
|
234372
|
-
${errorText}`);
|
|
234373
|
-
}
|
|
234374
|
-
const contentType = response.headers.get("content-type");
|
|
234375
|
-
if (contentType?.includes("text/event-stream")) {
|
|
234376
|
-
if (!response.body) {
|
|
234377
|
-
throw new Error("No response body for streaming request");
|
|
234378
|
-
}
|
|
234379
|
-
return response.body;
|
|
234380
|
-
} else {
|
|
234381
|
-
const data = await response.json();
|
|
234382
|
-
return data.choices?.[0]?.message?.content || data.result || "";
|
|
234383
|
-
}
|
|
234384
|
-
}
|
|
234385
|
-
};
|
|
234386
|
-
}
|
|
234387
|
-
});
|
|
234388
|
-
|
|
234389
|
-
// src/utils/cli-pipeline.ts
|
|
234390
|
-
import chalk5 from "chalk";
|
|
234391
|
-
import ora3 from "ora";
|
|
234392
|
-
async function initializeCommand(options = {}) {
|
|
234393
|
-
const {
|
|
234394
|
-
configPath,
|
|
234395
|
-
showSpinner = false,
|
|
234396
|
-
spinnerText = "Loading configuration...",
|
|
234397
|
-
logConfig = true
|
|
234398
|
-
} = options;
|
|
234399
|
-
const spinner = showSpinner ? ora3(spinnerText).start() : void 0;
|
|
234400
|
-
try {
|
|
234401
|
-
const config = await validateConfiguration(configPath);
|
|
234402
|
-
if (spinner) {
|
|
234403
|
-
spinner.succeed("Configuration loaded");
|
|
234404
|
-
}
|
|
234405
|
-
if (logConfig) {
|
|
234406
|
-
console.log(chalk5.gray("Configuration:"));
|
|
234407
|
-
console.log(chalk5.gray(` \u2022 Tenant ID: ${config.tenantId}`));
|
|
234408
|
-
console.log(chalk5.gray(` \u2022 Manage API URL: ${config.agentsManageApiUrl}`));
|
|
234409
|
-
console.log(chalk5.gray(` \u2022 Run API URL: ${config.agentsRunApiUrl}`));
|
|
234410
|
-
if (config.sources.configFile) {
|
|
234411
|
-
console.log(chalk5.gray(` \u2022 Config file: ${config.sources.configFile}`));
|
|
234412
|
-
}
|
|
234413
|
-
}
|
|
234414
|
-
return { config, spinner };
|
|
234415
|
-
} catch (error) {
|
|
234416
|
-
if (spinner) {
|
|
234417
|
-
spinner.fail("Configuration failed");
|
|
234418
|
-
}
|
|
234419
|
-
console.error(chalk5.red("Error:"), error.message);
|
|
234420
|
-
if (error.message.includes("No configuration found")) {
|
|
234421
|
-
console.log(chalk5.yellow("\nHint: Create a configuration file by running:"));
|
|
234422
|
-
console.log(chalk5.gray(" inkeep init"));
|
|
234423
|
-
} else if (error.message.includes("Config file not found")) {
|
|
234424
|
-
console.log(chalk5.yellow("\nHint: Check that your config file path is correct"));
|
|
234425
|
-
} else if (error.message.includes("tenantId") || error.message.includes("API URL")) {
|
|
234426
|
-
console.log(chalk5.yellow("\nHint: Ensure your inkeep.config.ts has all required fields:"));
|
|
234427
|
-
console.log(chalk5.gray(" - tenantId"));
|
|
234428
|
-
console.log(chalk5.gray(" - agentsManageApiUrl (or agentsManageApi.url)"));
|
|
234429
|
-
console.log(chalk5.gray(" - agentsRunApiUrl (or agentsRunApi.url)"));
|
|
234430
|
-
}
|
|
234431
|
-
process.exit(1);
|
|
234432
|
-
}
|
|
234433
|
-
}
|
|
234434
|
-
var init_cli_pipeline = __esm({
|
|
234435
|
-
"src/utils/cli-pipeline.ts"() {
|
|
234436
|
-
"use strict";
|
|
234437
|
-
init_esm_shims();
|
|
234438
|
-
init_config();
|
|
234439
|
-
}
|
|
234440
|
-
});
|
|
234441
|
-
|
|
234442
234209
|
// src/commands/pull.placeholder-system.ts
|
|
234443
234210
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
234444
234211
|
import { jsonSchemaToZod } from "json-schema-to-zod";
|
|
@@ -237950,36 +237717,36 @@ function comparePatterns(oldPatterns, newPatterns, diff) {
|
|
|
237950
237717
|
}
|
|
237951
237718
|
}
|
|
237952
237719
|
function displayPlanDiff(diff) {
|
|
237953
|
-
const
|
|
237720
|
+
const chalk12 = __require("chalk");
|
|
237954
237721
|
if (diff.filesAdded.length === 0 && diff.filesRemoved.length === 0 && diff.registryChanges.length === 0 && diff.patternChanges.length === 0) {
|
|
237955
|
-
console.log(
|
|
237722
|
+
console.log(chalk12.green("No changes detected"));
|
|
237956
237723
|
return;
|
|
237957
237724
|
}
|
|
237958
|
-
console.log(
|
|
237725
|
+
console.log(chalk12.cyan("\n\u{1F4DD} Changes since last pull:"));
|
|
237959
237726
|
if (diff.filesAdded.length > 0) {
|
|
237960
|
-
console.log(
|
|
237727
|
+
console.log(chalk12.green("\n Files added:"));
|
|
237961
237728
|
for (const file of diff.filesAdded) {
|
|
237962
|
-
console.log(
|
|
237729
|
+
console.log(chalk12.green(` + ${file}`));
|
|
237963
237730
|
}
|
|
237964
237731
|
}
|
|
237965
237732
|
if (diff.filesRemoved.length > 0) {
|
|
237966
|
-
console.log(
|
|
237733
|
+
console.log(chalk12.red("\n Files removed:"));
|
|
237967
237734
|
for (const file of diff.filesRemoved) {
|
|
237968
|
-
console.log(
|
|
237735
|
+
console.log(chalk12.red(` - ${file}`));
|
|
237969
237736
|
}
|
|
237970
237737
|
}
|
|
237971
237738
|
if (diff.registryChanges.length > 0) {
|
|
237972
|
-
console.log(
|
|
237739
|
+
console.log(chalk12.yellow("\n Variable name changes:"));
|
|
237973
237740
|
for (const change of diff.registryChanges) {
|
|
237974
|
-
console.log(
|
|
237975
|
-
console.log(
|
|
237741
|
+
console.log(chalk12.yellow(` \u2022 ${change.type}.${change.id}:`));
|
|
237742
|
+
console.log(chalk12.gray(` ${change.oldName} \u2192 ${change.newName}`));
|
|
237976
237743
|
}
|
|
237977
237744
|
}
|
|
237978
237745
|
if (diff.patternChanges.length > 0) {
|
|
237979
|
-
console.log(
|
|
237746
|
+
console.log(chalk12.yellow("\n Pattern changes:"));
|
|
237980
237747
|
for (const change of diff.patternChanges) {
|
|
237981
|
-
console.log(
|
|
237982
|
-
console.log(
|
|
237748
|
+
console.log(chalk12.yellow(` \u2022 ${change.field}:`));
|
|
237749
|
+
console.log(chalk12.gray(` ${change.oldValue} \u2192 ${change.newValue}`));
|
|
237983
237750
|
}
|
|
237984
237751
|
}
|
|
237985
237752
|
}
|
|
@@ -238002,322 +237769,6 @@ var init_plan_storage = __esm({
|
|
|
238002
237769
|
}
|
|
238003
237770
|
});
|
|
238004
237771
|
|
|
238005
|
-
// src/commands/chat-enhanced.ts
|
|
238006
|
-
var chat_enhanced_exports = {};
|
|
238007
|
-
__export(chat_enhanced_exports, {
|
|
238008
|
-
chatCommandEnhanced: () => chatCommandEnhanced
|
|
238009
|
-
});
|
|
238010
|
-
import * as readline from "readline";
|
|
238011
|
-
import chalk12 from "chalk";
|
|
238012
|
-
import inquirer2 from "inquirer";
|
|
238013
|
-
import ora8 from "ora";
|
|
238014
|
-
async function chatCommandEnhanced(agentIdInput, options) {
|
|
238015
|
-
console.log(chalk12.cyan("\u{1F916} Inkeep Chat Interface\n"));
|
|
238016
|
-
const configPath = options?.config || options?.configFilePath;
|
|
238017
|
-
const { config } = await initializeCommand({
|
|
238018
|
-
configPath,
|
|
238019
|
-
showSpinner: false,
|
|
238020
|
-
logConfig: true
|
|
238021
|
-
});
|
|
238022
|
-
console.log();
|
|
238023
|
-
const managementApi = await ManagementApiClient.create(
|
|
238024
|
-
config.agentsManageApiUrl,
|
|
238025
|
-
configPath,
|
|
238026
|
-
config.tenantId
|
|
238027
|
-
);
|
|
238028
|
-
const executionApi = await ExecutionApiClient.create(
|
|
238029
|
-
config.agentsRunApiUrl,
|
|
238030
|
-
configPath,
|
|
238031
|
-
config.tenantId
|
|
238032
|
-
);
|
|
238033
|
-
let agentId = agentIdInput;
|
|
238034
|
-
if (!agentId) {
|
|
238035
|
-
const spinner2 = ora8("Fetching available agent...").start();
|
|
238036
|
-
try {
|
|
238037
|
-
const agent = await managementApi.listAgents();
|
|
238038
|
-
spinner2.stop();
|
|
238039
|
-
if (agent.length === 0) {
|
|
238040
|
-
console.error(
|
|
238041
|
-
chalk12.red("No agent available. Define agent in your project and run: inkeep push")
|
|
238042
|
-
);
|
|
238043
|
-
process.exit(1);
|
|
238044
|
-
}
|
|
238045
|
-
const agentChoices = agent.map((g) => ({
|
|
238046
|
-
name: `${chalk12.cyan(g.id)} - ${g.name || "Unnamed Agent"}`,
|
|
238047
|
-
value: g.id,
|
|
238048
|
-
short: g.id,
|
|
238049
|
-
searchText: `${g.id} ${g.name || ""}`.toLowerCase()
|
|
238050
|
-
}));
|
|
238051
|
-
const answer = await inquirer2.prompt([
|
|
238052
|
-
{
|
|
238053
|
-
type: "list",
|
|
238054
|
-
name: "agentId",
|
|
238055
|
-
message: "Select an agent to chat with:",
|
|
238056
|
-
choices: agentChoices,
|
|
238057
|
-
pageSize: 10
|
|
238058
|
-
}
|
|
238059
|
-
]);
|
|
238060
|
-
agentId = answer.agentId;
|
|
238061
|
-
} catch (error) {
|
|
238062
|
-
spinner2.fail("Failed to fetch agent");
|
|
238063
|
-
console.error(chalk12.red("Error:"), error instanceof Error ? error.message : error);
|
|
238064
|
-
process.exit(1);
|
|
238065
|
-
}
|
|
238066
|
-
}
|
|
238067
|
-
const spinner = ora8("Connecting to agent...").start();
|
|
238068
|
-
try {
|
|
238069
|
-
if (!agentId) {
|
|
238070
|
-
throw new Error("No agent selected");
|
|
238071
|
-
}
|
|
238072
|
-
const agent = await managementApi.getAgent(agentId);
|
|
238073
|
-
if (!agent) {
|
|
238074
|
-
spinner.fail(`Agent "${agentId}" not found`);
|
|
238075
|
-
const agent2 = await managementApi.listAgents();
|
|
238076
|
-
if (agent2.length > 0) {
|
|
238077
|
-
console.log(chalk12.yellow("\nAvailable agent:"));
|
|
238078
|
-
agent2.forEach((g) => {
|
|
238079
|
-
console.log(chalk12.gray(` \u2022 ${g.id} - ${g.name || "Unnamed"}`));
|
|
238080
|
-
});
|
|
238081
|
-
console.log(chalk12.gray('\nRun "inkeep chat" without arguments for interactive selection'));
|
|
238082
|
-
} else {
|
|
238083
|
-
console.log(chalk12.yellow("\nNo agent found. Please define agent and push your project."));
|
|
238084
|
-
}
|
|
238085
|
-
process.exit(1);
|
|
238086
|
-
}
|
|
238087
|
-
spinner.succeed(`Connected to agent: ${chalk12.green(agent.name || agentId)}`);
|
|
238088
|
-
if (agent.description) {
|
|
238089
|
-
console.log(chalk12.gray(`Description: ${agent.description}`));
|
|
238090
|
-
}
|
|
238091
|
-
if (agent.defaultSubAgentId) {
|
|
238092
|
-
console.log(chalk12.gray(`Default Agent: ${agent.defaultSubAgentId}`));
|
|
238093
|
-
}
|
|
238094
|
-
} catch (error) {
|
|
238095
|
-
spinner.fail("Failed to connect to agent");
|
|
238096
|
-
console.error(chalk12.red("Error:"), error instanceof Error ? error.message : error);
|
|
238097
|
-
process.exit(1);
|
|
238098
|
-
}
|
|
238099
|
-
const rl = readline.createInterface({
|
|
238100
|
-
input: process.stdin,
|
|
238101
|
-
output: process.stdout,
|
|
238102
|
-
prompt: chalk12.cyan("You> ")
|
|
238103
|
-
});
|
|
238104
|
-
const conversationId = `cli-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
238105
|
-
const messages2 = [];
|
|
238106
|
-
let emitOperations = false;
|
|
238107
|
-
console.log(chalk12.gray('\n\u{1F4AC} Chat session started. Type "exit" or press Ctrl+C to quit.'));
|
|
238108
|
-
console.log(chalk12.gray("Commands: help, clear, history, reset, operations\n"));
|
|
238109
|
-
async function handleStreamingResponse(stream, showDebug = false) {
|
|
238110
|
-
const decoder = new TextDecoder();
|
|
238111
|
-
const reader = stream.getReader();
|
|
238112
|
-
let buffer = "";
|
|
238113
|
-
let responseContent = "";
|
|
238114
|
-
const debugOperations = [];
|
|
238115
|
-
let hasStartedResponse = false;
|
|
238116
|
-
try {
|
|
238117
|
-
while (true) {
|
|
238118
|
-
const { done, value } = await reader.read();
|
|
238119
|
-
if (done) break;
|
|
238120
|
-
buffer += decoder.decode(value, { stream: true });
|
|
238121
|
-
const lines = buffer.split("\n");
|
|
238122
|
-
buffer = lines.pop() || "";
|
|
238123
|
-
for (const line of lines) {
|
|
238124
|
-
if (line.startsWith("data: ")) {
|
|
238125
|
-
const data = line.slice(6);
|
|
238126
|
-
if (data === "[DONE]") continue;
|
|
238127
|
-
try {
|
|
238128
|
-
const parsed = JSON.parse(data);
|
|
238129
|
-
const content = parsed.choices?.[0]?.delta?.content;
|
|
238130
|
-
if (content) {
|
|
238131
|
-
let currentPos = 0;
|
|
238132
|
-
while (currentPos < content.length) {
|
|
238133
|
-
if (content.substring(currentPos).startsWith('{"type":"data-operation"')) {
|
|
238134
|
-
let braceCount = 0;
|
|
238135
|
-
let jsonEnd = currentPos;
|
|
238136
|
-
for (let i2 = currentPos; i2 < content.length; i2++) {
|
|
238137
|
-
if (content[i2] === "{") braceCount++;
|
|
238138
|
-
if (content[i2] === "}") {
|
|
238139
|
-
braceCount--;
|
|
238140
|
-
if (braceCount === 0) {
|
|
238141
|
-
jsonEnd = i2 + 1;
|
|
238142
|
-
break;
|
|
238143
|
-
}
|
|
238144
|
-
}
|
|
238145
|
-
}
|
|
238146
|
-
const jsonStr = content.substring(currentPos, jsonEnd);
|
|
238147
|
-
try {
|
|
238148
|
-
const dataOp = JSON.parse(jsonStr);
|
|
238149
|
-
debugOperations.push(dataOp);
|
|
238150
|
-
if (showDebug && dataOp.type === "data-operation") {
|
|
238151
|
-
const opType = dataOp.data?.type || "unknown";
|
|
238152
|
-
const label = dataOp.data?.label || "Unknown operation";
|
|
238153
|
-
const details = dataOp.data?.details || {};
|
|
238154
|
-
const subAgentId = details.subAgentId || "unknown-agent";
|
|
238155
|
-
let displayText = "";
|
|
238156
|
-
if (opType === "completion") {
|
|
238157
|
-
displayText = `${label} (sub-agent: ${agentId})`;
|
|
238158
|
-
} else if (opType === "tool_call") {
|
|
238159
|
-
const toolData = details.data || {};
|
|
238160
|
-
displayText = `${label} - ${toolData.toolName || "unknown tool"} (calling)`;
|
|
238161
|
-
} else if (opType === "tool_result") {
|
|
238162
|
-
const toolData = details.data || {};
|
|
238163
|
-
const status = toolData.error ? "failed" : "completed";
|
|
238164
|
-
displayText = `${label} - ${toolData.toolName || "unknown tool"} (${status})`;
|
|
238165
|
-
} else if (opType === "error") {
|
|
238166
|
-
displayText = `${label} - ${dataOp.data?.message || "Unknown error"}`;
|
|
238167
|
-
} else if (opType === "agent_generate" || opType === "agent_reasoning") {
|
|
238168
|
-
displayText = `${label}`;
|
|
238169
|
-
} else {
|
|
238170
|
-
displayText = `${label} (${subAgentId})`;
|
|
238171
|
-
}
|
|
238172
|
-
if (opType === "completion" && hasStartedResponse) {
|
|
238173
|
-
console.log("");
|
|
238174
|
-
}
|
|
238175
|
-
console.log(chalk12.gray(` [${opType}] ${displayText}`));
|
|
238176
|
-
}
|
|
238177
|
-
currentPos = jsonEnd;
|
|
238178
|
-
} catch {
|
|
238179
|
-
if (!hasStartedResponse) {
|
|
238180
|
-
process.stdout.write(chalk12.green("Assistant> "));
|
|
238181
|
-
hasStartedResponse = true;
|
|
238182
|
-
}
|
|
238183
|
-
process.stdout.write(content[currentPos]);
|
|
238184
|
-
responseContent += content[currentPos];
|
|
238185
|
-
currentPos++;
|
|
238186
|
-
}
|
|
238187
|
-
} else {
|
|
238188
|
-
if (!hasStartedResponse) {
|
|
238189
|
-
process.stdout.write(chalk12.green("Assistant> "));
|
|
238190
|
-
hasStartedResponse = true;
|
|
238191
|
-
}
|
|
238192
|
-
process.stdout.write(content[currentPos]);
|
|
238193
|
-
responseContent += content[currentPos];
|
|
238194
|
-
currentPos++;
|
|
238195
|
-
}
|
|
238196
|
-
}
|
|
238197
|
-
}
|
|
238198
|
-
} catch {
|
|
238199
|
-
}
|
|
238200
|
-
}
|
|
238201
|
-
}
|
|
238202
|
-
}
|
|
238203
|
-
} finally {
|
|
238204
|
-
reader.releaseLock();
|
|
238205
|
-
}
|
|
238206
|
-
if (hasStartedResponse) {
|
|
238207
|
-
console.log("\n");
|
|
238208
|
-
} else {
|
|
238209
|
-
console.log(`${chalk12.green("Assistant> ") + chalk12.gray("(no response)")}
|
|
238210
|
-
`);
|
|
238211
|
-
}
|
|
238212
|
-
return responseContent;
|
|
238213
|
-
}
|
|
238214
|
-
rl.on("line", async (input) => {
|
|
238215
|
-
const trimmedInput = input.trim();
|
|
238216
|
-
const command = trimmedInput.toLowerCase().replace(/^\//, "");
|
|
238217
|
-
if (command === "exit") {
|
|
238218
|
-
console.log(chalk12.gray("Goodbye! \u{1F44B}"));
|
|
238219
|
-
rl.close();
|
|
238220
|
-
process.exit(0);
|
|
238221
|
-
}
|
|
238222
|
-
if (command === "clear") {
|
|
238223
|
-
console.clear();
|
|
238224
|
-
console.log(chalk12.gray("Screen cleared. Conversation context preserved.\n"));
|
|
238225
|
-
rl.prompt();
|
|
238226
|
-
return;
|
|
238227
|
-
}
|
|
238228
|
-
if (command === "help") {
|
|
238229
|
-
console.log(chalk12.cyan("\n\u{1F4DA} Available commands:"));
|
|
238230
|
-
console.log(chalk12.gray(" \u2022 exit - End the chat session"));
|
|
238231
|
-
console.log(chalk12.gray(" \u2022 clear - Clear the screen (preserves context)"));
|
|
238232
|
-
console.log(chalk12.gray(" \u2022 history - Show conversation history"));
|
|
238233
|
-
console.log(chalk12.gray(" \u2022 reset - Reset conversation context"));
|
|
238234
|
-
console.log(
|
|
238235
|
-
chalk12.gray(" \u2022 operations - Toggle emit operations (show/hide data operations)")
|
|
238236
|
-
);
|
|
238237
|
-
console.log(chalk12.gray(" \u2022 help - Show this help message"));
|
|
238238
|
-
console.log(chalk12.gray("\n Commands can be prefixed with / (e.g., /help)\n"));
|
|
238239
|
-
rl.prompt();
|
|
238240
|
-
return;
|
|
238241
|
-
}
|
|
238242
|
-
if (command === "operations") {
|
|
238243
|
-
emitOperations = !emitOperations;
|
|
238244
|
-
console.log(chalk12.yellow(`
|
|
238245
|
-
\u{1F527} Data operations: ${emitOperations ? "ON" : "OFF"}`));
|
|
238246
|
-
if (emitOperations) {
|
|
238247
|
-
console.log(chalk12.gray("Data operations will be shown during responses.\n"));
|
|
238248
|
-
} else {
|
|
238249
|
-
console.log(chalk12.gray("Data operations are hidden.\n"));
|
|
238250
|
-
}
|
|
238251
|
-
rl.prompt();
|
|
238252
|
-
return;
|
|
238253
|
-
}
|
|
238254
|
-
if (command === "history") {
|
|
238255
|
-
console.log(chalk12.cyan("\n\u{1F4DC} Conversation History:"));
|
|
238256
|
-
if (messages2.length === 0) {
|
|
238257
|
-
console.log(chalk12.gray(" (No messages yet)\n"));
|
|
238258
|
-
} else {
|
|
238259
|
-
messages2.forEach((msg, idx) => {
|
|
238260
|
-
const role = msg.role === "user" ? chalk12.blue("You") : chalk12.green("Assistant");
|
|
238261
|
-
const preview = msg.content.substring(0, 100);
|
|
238262
|
-
const suffix = msg.content.length > 100 ? "..." : "";
|
|
238263
|
-
console.log(` ${idx + 1}. ${role}: ${preview}${suffix}`);
|
|
238264
|
-
});
|
|
238265
|
-
console.log();
|
|
238266
|
-
}
|
|
238267
|
-
rl.prompt();
|
|
238268
|
-
return;
|
|
238269
|
-
}
|
|
238270
|
-
if (command === "reset") {
|
|
238271
|
-
messages2.length = 0;
|
|
238272
|
-
console.log(chalk12.yellow("\u26A0\uFE0F Conversation context has been reset.\n"));
|
|
238273
|
-
rl.prompt();
|
|
238274
|
-
return;
|
|
238275
|
-
}
|
|
238276
|
-
if (!trimmedInput) {
|
|
238277
|
-
rl.prompt();
|
|
238278
|
-
return;
|
|
238279
|
-
}
|
|
238280
|
-
messages2.push({ role: "user", content: trimmedInput });
|
|
238281
|
-
try {
|
|
238282
|
-
if (!agentId) throw new Error("No agent selected");
|
|
238283
|
-
const response = await executionApi.chatCompletion(
|
|
238284
|
-
agentId,
|
|
238285
|
-
messages2,
|
|
238286
|
-
conversationId,
|
|
238287
|
-
emitOperations
|
|
238288
|
-
);
|
|
238289
|
-
let assistantResponse;
|
|
238290
|
-
if (typeof response === "string") {
|
|
238291
|
-
console.log(chalk12.green("Assistant>"), response);
|
|
238292
|
-
assistantResponse = response;
|
|
238293
|
-
} else {
|
|
238294
|
-
assistantResponse = await handleStreamingResponse(response, emitOperations);
|
|
238295
|
-
}
|
|
238296
|
-
messages2.push({ role: "assistant", content: assistantResponse });
|
|
238297
|
-
} catch (error) {
|
|
238298
|
-
console.error(chalk12.red("Error:"), error instanceof Error ? error.message : error);
|
|
238299
|
-
}
|
|
238300
|
-
rl.prompt();
|
|
238301
|
-
});
|
|
238302
|
-
rl.on("close", () => {
|
|
238303
|
-
console.log(chalk12.gray("\n\u{1F4CA} Session Summary:"));
|
|
238304
|
-
console.log(chalk12.gray(` \u2022 Agent: ${agentId}`));
|
|
238305
|
-
console.log(chalk12.gray(` \u2022 Messages: ${messages2.length}`));
|
|
238306
|
-
console.log(chalk12.gray(` \u2022 Duration: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
|
|
238307
|
-
console.log(chalk12.gray("\nChat session ended."));
|
|
238308
|
-
process.exit(0);
|
|
238309
|
-
});
|
|
238310
|
-
rl.prompt();
|
|
238311
|
-
}
|
|
238312
|
-
var init_chat_enhanced = __esm({
|
|
238313
|
-
"src/commands/chat-enhanced.ts"() {
|
|
238314
|
-
"use strict";
|
|
238315
|
-
init_esm_shims();
|
|
238316
|
-
init_api();
|
|
238317
|
-
init_cli_pipeline();
|
|
238318
|
-
}
|
|
238319
|
-
});
|
|
238320
|
-
|
|
238321
237772
|
// src/index.ts
|
|
238322
237773
|
init_esm_shims();
|
|
238323
237774
|
|
|
@@ -239134,11 +238585,199 @@ Note: Config file created in ${configDir}`));
|
|
|
239134
238585
|
|
|
239135
238586
|
// src/commands/list-agents.ts
|
|
239136
238587
|
init_esm_shims();
|
|
239137
|
-
init_api();
|
|
239138
|
-
init_cli_pipeline();
|
|
239139
238588
|
import chalk6 from "chalk";
|
|
239140
238589
|
import Table from "cli-table3";
|
|
239141
238590
|
import ora4 from "ora";
|
|
238591
|
+
|
|
238592
|
+
// src/api.ts
|
|
238593
|
+
init_esm_shims();
|
|
238594
|
+
init_src();
|
|
238595
|
+
var BaseApiClient = class {
|
|
238596
|
+
apiUrl;
|
|
238597
|
+
tenantId;
|
|
238598
|
+
projectId;
|
|
238599
|
+
apiKey;
|
|
238600
|
+
constructor(apiUrl, tenantId, projectId, apiKey) {
|
|
238601
|
+
this.apiUrl = apiUrl;
|
|
238602
|
+
this.tenantId = tenantId;
|
|
238603
|
+
this.projectId = projectId;
|
|
238604
|
+
this.apiKey = apiKey;
|
|
238605
|
+
}
|
|
238606
|
+
checkTenantId() {
|
|
238607
|
+
if (!this.tenantId) {
|
|
238608
|
+
throw new Error("No tenant ID configured. Please run: inkeep init");
|
|
238609
|
+
}
|
|
238610
|
+
return this.tenantId;
|
|
238611
|
+
}
|
|
238612
|
+
/**
|
|
238613
|
+
* Wrapper around fetch that automatically includes Authorization header if API key is present
|
|
238614
|
+
*/
|
|
238615
|
+
async authenticatedFetch(url, options = {}) {
|
|
238616
|
+
const headers2 = {
|
|
238617
|
+
...options.headers || {}
|
|
238618
|
+
};
|
|
238619
|
+
if (this.apiKey) {
|
|
238620
|
+
headers2.Authorization = `Bearer ${this.apiKey}`;
|
|
238621
|
+
}
|
|
238622
|
+
return apiFetch(url, {
|
|
238623
|
+
...options,
|
|
238624
|
+
headers: headers2
|
|
238625
|
+
});
|
|
238626
|
+
}
|
|
238627
|
+
getTenantId() {
|
|
238628
|
+
return this.tenantId;
|
|
238629
|
+
}
|
|
238630
|
+
getProjectId() {
|
|
238631
|
+
return this.projectId;
|
|
238632
|
+
}
|
|
238633
|
+
getApiUrl() {
|
|
238634
|
+
return this.apiUrl;
|
|
238635
|
+
}
|
|
238636
|
+
};
|
|
238637
|
+
var ManagementApiClient = class _ManagementApiClient extends BaseApiClient {
|
|
238638
|
+
constructor(apiUrl, tenantId, projectId, apiKey) {
|
|
238639
|
+
super(apiUrl, tenantId, projectId, apiKey);
|
|
238640
|
+
}
|
|
238641
|
+
static async create(apiUrl, configPath, tenantIdOverride, projectIdOverride) {
|
|
238642
|
+
const { validateConfiguration: validateConfiguration2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
238643
|
+
const config = await validateConfiguration2(configPath);
|
|
238644
|
+
const resolvedApiUrl = apiUrl || config.agentsManageApiUrl;
|
|
238645
|
+
const tenantId = tenantIdOverride || config.tenantId;
|
|
238646
|
+
const projectId = projectIdOverride || "";
|
|
238647
|
+
return new _ManagementApiClient(resolvedApiUrl, tenantId, projectId, config.agentsManageApiKey);
|
|
238648
|
+
}
|
|
238649
|
+
async listAgents() {
|
|
238650
|
+
const tenantId = this.checkTenantId();
|
|
238651
|
+
const projectId = this.getProjectId();
|
|
238652
|
+
const response = await this.authenticatedFetch(
|
|
238653
|
+
`${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agents`,
|
|
238654
|
+
{
|
|
238655
|
+
method: "GET"
|
|
238656
|
+
}
|
|
238657
|
+
);
|
|
238658
|
+
if (!response.ok) {
|
|
238659
|
+
throw new Error(
|
|
238660
|
+
`Failed to list agents: ${response.statusText}. ${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agents`
|
|
238661
|
+
);
|
|
238662
|
+
}
|
|
238663
|
+
const data = await response.json();
|
|
238664
|
+
return data.data || [];
|
|
238665
|
+
}
|
|
238666
|
+
async getAgent(agentId) {
|
|
238667
|
+
const agents2 = await this.listAgents();
|
|
238668
|
+
const agent = agents2.find((g) => g.id === agentId);
|
|
238669
|
+
return agent || null;
|
|
238670
|
+
}
|
|
238671
|
+
async pushAgent(agentDefinition) {
|
|
238672
|
+
const tenantId = this.checkTenantId();
|
|
238673
|
+
const projectId = this.getProjectId();
|
|
238674
|
+
const agentId = agentDefinition.id;
|
|
238675
|
+
if (!agentId) {
|
|
238676
|
+
throw new Error("Agent must have an id property");
|
|
238677
|
+
}
|
|
238678
|
+
const response = await this.authenticatedFetch(
|
|
238679
|
+
`${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agents/${agentId}`,
|
|
238680
|
+
{
|
|
238681
|
+
method: "PUT",
|
|
238682
|
+
body: JSON.stringify({
|
|
238683
|
+
...agentDefinition,
|
|
238684
|
+
tenantId
|
|
238685
|
+
})
|
|
238686
|
+
}
|
|
238687
|
+
);
|
|
238688
|
+
if (!response.ok) {
|
|
238689
|
+
const errorText = await response.text();
|
|
238690
|
+
throw new Error(`Failed to push agent: ${response.statusText}
|
|
238691
|
+
${errorText}`);
|
|
238692
|
+
}
|
|
238693
|
+
const data = await response.json();
|
|
238694
|
+
return data.data;
|
|
238695
|
+
}
|
|
238696
|
+
async getFullProject(projectId) {
|
|
238697
|
+
const tenantId = this.checkTenantId();
|
|
238698
|
+
const response = await this.authenticatedFetch(
|
|
238699
|
+
`${this.apiUrl}/tenants/${tenantId}/project-full/${projectId}`,
|
|
238700
|
+
{
|
|
238701
|
+
method: "GET"
|
|
238702
|
+
}
|
|
238703
|
+
);
|
|
238704
|
+
if (!response.ok) {
|
|
238705
|
+
if (response.status === 404) {
|
|
238706
|
+
throw new Error(`Project "${projectId}" not found`);
|
|
238707
|
+
}
|
|
238708
|
+
if (response.status === 401 || response.status === 403) {
|
|
238709
|
+
const errorText2 = await response.text().catch(() => "");
|
|
238710
|
+
let errorMessage = "Authentication failed - check your API key configuration\n\n";
|
|
238711
|
+
errorMessage += "Common issues:\n";
|
|
238712
|
+
errorMessage += " \u2022 Missing or invalid API key in inkeep.config.ts\n";
|
|
238713
|
+
errorMessage += " \u2022 API key does not have access to this tenant/project\n";
|
|
238714
|
+
errorMessage += " \u2022 For local development, ensure INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET is set\n";
|
|
238715
|
+
if (errorText2) {
|
|
238716
|
+
errorMessage += `
|
|
238717
|
+
Server response: ${errorText2}`;
|
|
238718
|
+
}
|
|
238719
|
+
throw new Error(errorMessage);
|
|
238720
|
+
}
|
|
238721
|
+
const errorText = await response.text().catch(() => "");
|
|
238722
|
+
throw new Error(
|
|
238723
|
+
`Failed to fetch project: ${response.statusText}${errorText ? `
|
|
238724
|
+
${errorText}` : ""}`
|
|
238725
|
+
);
|
|
238726
|
+
}
|
|
238727
|
+
const responseData = await response.json();
|
|
238728
|
+
return responseData.data;
|
|
238729
|
+
}
|
|
238730
|
+
};
|
|
238731
|
+
|
|
238732
|
+
// src/utils/cli-pipeline.ts
|
|
238733
|
+
init_esm_shims();
|
|
238734
|
+
init_config();
|
|
238735
|
+
import chalk5 from "chalk";
|
|
238736
|
+
import ora3 from "ora";
|
|
238737
|
+
async function initializeCommand(options = {}) {
|
|
238738
|
+
const {
|
|
238739
|
+
configPath,
|
|
238740
|
+
showSpinner = false,
|
|
238741
|
+
spinnerText = "Loading configuration...",
|
|
238742
|
+
logConfig = true
|
|
238743
|
+
} = options;
|
|
238744
|
+
const spinner = showSpinner ? ora3(spinnerText).start() : void 0;
|
|
238745
|
+
try {
|
|
238746
|
+
const config = await validateConfiguration(configPath);
|
|
238747
|
+
if (spinner) {
|
|
238748
|
+
spinner.succeed("Configuration loaded");
|
|
238749
|
+
}
|
|
238750
|
+
if (logConfig) {
|
|
238751
|
+
console.log(chalk5.gray("Configuration:"));
|
|
238752
|
+
console.log(chalk5.gray(` \u2022 Tenant ID: ${config.tenantId}`));
|
|
238753
|
+
console.log(chalk5.gray(` \u2022 Manage API URL: ${config.agentsManageApiUrl}`));
|
|
238754
|
+
console.log(chalk5.gray(` \u2022 Run API URL: ${config.agentsRunApiUrl}`));
|
|
238755
|
+
if (config.sources.configFile) {
|
|
238756
|
+
console.log(chalk5.gray(` \u2022 Config file: ${config.sources.configFile}`));
|
|
238757
|
+
}
|
|
238758
|
+
}
|
|
238759
|
+
return { config, spinner };
|
|
238760
|
+
} catch (error) {
|
|
238761
|
+
if (spinner) {
|
|
238762
|
+
spinner.fail("Configuration failed");
|
|
238763
|
+
}
|
|
238764
|
+
console.error(chalk5.red("Error:"), error.message);
|
|
238765
|
+
if (error.message.includes("No configuration found")) {
|
|
238766
|
+
console.log(chalk5.yellow("\nHint: Create a configuration file by running:"));
|
|
238767
|
+
console.log(chalk5.gray(" inkeep init"));
|
|
238768
|
+
} else if (error.message.includes("Config file not found")) {
|
|
238769
|
+
console.log(chalk5.yellow("\nHint: Check that your config file path is correct"));
|
|
238770
|
+
} else if (error.message.includes("tenantId") || error.message.includes("API URL")) {
|
|
238771
|
+
console.log(chalk5.yellow("\nHint: Ensure your inkeep.config.ts has all required fields:"));
|
|
238772
|
+
console.log(chalk5.gray(" - tenantId"));
|
|
238773
|
+
console.log(chalk5.gray(" - agentsManageApiUrl (or agentsManageApi.url)"));
|
|
238774
|
+
console.log(chalk5.gray(" - agentsRunApiUrl (or agentsRunApi.url)"));
|
|
238775
|
+
}
|
|
238776
|
+
process.exit(1);
|
|
238777
|
+
}
|
|
238778
|
+
}
|
|
238779
|
+
|
|
238780
|
+
// src/commands/list-agents.ts
|
|
239142
238781
|
async function listAgentsCommand(options) {
|
|
239143
238782
|
const configPath = options.config || options.configFilePath;
|
|
239144
238783
|
const { config } = await initializeCommand({
|
|
@@ -239199,7 +238838,6 @@ ${table.toString()}`);
|
|
|
239199
238838
|
// src/commands/pull.ts
|
|
239200
238839
|
init_esm_shims();
|
|
239201
238840
|
init_src();
|
|
239202
|
-
init_api();
|
|
239203
238841
|
import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
239204
238842
|
import { dirname as dirname5, join as join10, resolve as resolve4 } from "path";
|
|
239205
238843
|
import chalk9 from "chalk";
|
|
@@ -239965,7 +239603,6 @@ import { existsSync as existsSync11 } from "fs";
|
|
|
239965
239603
|
import { join as join12, resolve as resolve5 } from "path";
|
|
239966
239604
|
import chalk10 from "chalk";
|
|
239967
239605
|
import ora6 from "ora";
|
|
239968
|
-
init_cli_pipeline();
|
|
239969
239606
|
|
|
239970
239607
|
// src/utils/environment-loader.ts
|
|
239971
239608
|
init_esm_shims();
|
|
@@ -240373,13 +240010,6 @@ program.command("pull").description("Pull entire project configuration from back
|
|
|
240373
240010
|
).option("--json", "Generate project data JSON file instead of updating files").option("--debug", "Enable debug logging for LLM generation").action(async (options) => {
|
|
240374
240011
|
await pullProjectCommand(options);
|
|
240375
240012
|
});
|
|
240376
|
-
program.command("chat [agent-id]").description(
|
|
240377
|
-
"Start an interactive chat session with an agent (interactive selection if no ID provided)"
|
|
240378
|
-
).option("--tenant-id <tenant-id>", "Tenant ID").option("--agents-manage-api-url <url>", "Agents manage API URL").option("--agents-run-api-url <url>", "Agents run API URL").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (agentId, options) => {
|
|
240379
|
-
const { chatCommandEnhanced: chatCommandEnhanced2 } = await Promise.resolve().then(() => (init_chat_enhanced(), chat_enhanced_exports));
|
|
240380
|
-
const config = options.config || options.configFilePath;
|
|
240381
|
-
await chatCommandEnhanced2(agentId, { ...options, config });
|
|
240382
|
-
});
|
|
240383
240013
|
program.command("list-agent").description("List all available agents for a specific project").requiredOption("--project <project-id>", "Project ID to list agent for").option("--tenant-id <tenant-id>", "Tenant ID").option("--agents-manage-api-url <url>", "Agents manage API URL").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (options) => {
|
|
240384
240014
|
const config = options.config || options.configFilePath;
|
|
240385
240015
|
await listAgentsCommand({ ...options, config });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.11",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"recast": "^0.23.0",
|
|
47
47
|
"ts-morph": "^26.0.0",
|
|
48
48
|
"tsx": "^4.20.5",
|
|
49
|
-
"@inkeep/agents-core": "^0.22.
|
|
50
|
-
"@inkeep/agents-sdk": "^0.22.
|
|
49
|
+
"@inkeep/agents-core": "^0.22.11",
|
|
50
|
+
"@inkeep/agents-sdk": "^0.22.11"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/degit": "^2.8.6",
|