@iqai/adk-cli 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/dist/index.js +96 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ adk new my-agent --template simple-agent
|
|
|
86
86
|
- `discord-bot` - Agent integrated with Discord bot framework
|
|
87
87
|
- `telegram-bot` - Agent integrated with Telegram bot API
|
|
88
88
|
- `hono-server` - Web server with RESTful agent endpoints
|
|
89
|
+
- `shade-agent` – Agent with Near Shade Agents
|
|
89
90
|
- `mcp-starter` - Model Context Protocol server integration
|
|
90
91
|
|
|
91
92
|
### `adk run`
|
package/dist/index.js
CHANGED
|
@@ -25,13 +25,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
));
|
|
26
26
|
|
|
27
27
|
// src/index.ts
|
|
28
|
-
var
|
|
28
|
+
var import_chalk6 = __toESM(require("chalk"));
|
|
29
29
|
var import_commander = require("commander");
|
|
30
30
|
|
|
31
31
|
// package.json
|
|
32
32
|
var package_default = {
|
|
33
33
|
name: "@iqai/adk-cli",
|
|
34
|
-
version: "0.2.
|
|
34
|
+
version: "0.2.9",
|
|
35
35
|
description: "CLI tool for creating, running, and testing ADK agents",
|
|
36
36
|
main: "dist/index.js",
|
|
37
37
|
types: "dist/index.d.ts",
|
|
@@ -311,20 +311,55 @@ async function createProject(projectName, options) {
|
|
|
311
311
|
// src/commands/run.ts
|
|
312
312
|
var p = __toESM(require("@clack/prompts"));
|
|
313
313
|
var import_prompts2 = require("@clack/prompts");
|
|
314
|
-
var
|
|
314
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
315
315
|
var import_marked = require("marked");
|
|
316
316
|
var import_marked_terminal = require("marked-terminal");
|
|
317
317
|
|
|
318
318
|
// src/commands/serve.ts
|
|
319
319
|
var import_node_fs3 = require("fs");
|
|
320
320
|
var import_node_path3 = require("path");
|
|
321
|
-
var
|
|
321
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
322
322
|
|
|
323
323
|
// src/server/index.ts
|
|
324
324
|
var import_node_server = require("@hono/node-server");
|
|
325
325
|
var import_adk2 = require("@iqai/adk");
|
|
326
326
|
var import_hono = require("hono");
|
|
327
327
|
|
|
328
|
+
// src/server/logger.ts
|
|
329
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
330
|
+
var Logger = class {
|
|
331
|
+
name;
|
|
332
|
+
quiet;
|
|
333
|
+
debugEnabled;
|
|
334
|
+
constructor({ name, quiet = false }) {
|
|
335
|
+
this.name = name;
|
|
336
|
+
this.quiet = quiet;
|
|
337
|
+
this.debugEnabled = process.env.NODE_ENV === "development" || process.env.ADK_DEBUG === "true";
|
|
338
|
+
}
|
|
339
|
+
time() {
|
|
340
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
341
|
+
}
|
|
342
|
+
prefix(icon, message) {
|
|
343
|
+
return `${this.time()} ${icon} [${this.name}] ${message}`;
|
|
344
|
+
}
|
|
345
|
+
debug(message, ...args) {
|
|
346
|
+
if (!this.debugEnabled || this.quiet) return;
|
|
347
|
+
console.debug(import_chalk2.default.blue(this.prefix("\u{1F41B}", message)), ...args);
|
|
348
|
+
}
|
|
349
|
+
info(message, ...args) {
|
|
350
|
+
if (this.quiet) return;
|
|
351
|
+
console.info(import_chalk2.default.cyan(this.prefix("\u2139\uFE0F", message)), ...args);
|
|
352
|
+
}
|
|
353
|
+
warn(message, ...args) {
|
|
354
|
+
if (this.quiet) return;
|
|
355
|
+
console.warn(import_chalk2.default.yellow(this.prefix("\u{1F6A7}", message)), ...args);
|
|
356
|
+
}
|
|
357
|
+
error(message, ...args) {
|
|
358
|
+
if (this.quiet) return;
|
|
359
|
+
console.error(import_chalk2.default.red(this.prefix("\u274C", message)), ...args);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
328
363
|
// src/server/routes.ts
|
|
329
364
|
var import_cors = require("hono/cors");
|
|
330
365
|
function setupRoutes(app, agentManager, sessionManager, agentsDir) {
|
|
@@ -384,6 +419,10 @@ var import_adk = require("@iqai/adk");
|
|
|
384
419
|
var AgentScanner = class {
|
|
385
420
|
constructor(quiet = false) {
|
|
386
421
|
this.quiet = quiet;
|
|
422
|
+
this.logger = new Logger({ name: "session-manager", quiet: this.quiet });
|
|
423
|
+
}
|
|
424
|
+
logger;
|
|
425
|
+
async getSessionMessages(loadedAgent) {
|
|
387
426
|
}
|
|
388
427
|
scanAgents(agentsDir, loadedAgents) {
|
|
389
428
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -403,7 +442,6 @@ var AgentScanner = class {
|
|
|
403
442
|
return skipDirs.includes(dirName);
|
|
404
443
|
};
|
|
405
444
|
const scanDirectory = (dir) => {
|
|
406
|
-
if (!(0, import_node_fs2.existsSync)(dir)) return;
|
|
407
445
|
const items = (0, import_node_fs2.readdirSync)(dir);
|
|
408
446
|
for (const item of items) {
|
|
409
447
|
const fullPath = (0, import_node_path2.join)(dir, item);
|
|
@@ -435,9 +473,7 @@ var AgentScanner = class {
|
|
|
435
473
|
}
|
|
436
474
|
};
|
|
437
475
|
scanDirectory(scanDir);
|
|
438
|
-
|
|
439
|
-
console.log(`\u2705 Agent scan complete. Found ${agents.size} agents.`);
|
|
440
|
-
}
|
|
476
|
+
this.logger.info(`Agent scan complete. Found ${agents.size} agents. \u2728`);
|
|
441
477
|
return agents;
|
|
442
478
|
}
|
|
443
479
|
extractAgentNameFromFile(filePath) {
|
|
@@ -456,7 +492,9 @@ var AgentScanner = class {
|
|
|
456
492
|
var AgentLoader = class {
|
|
457
493
|
constructor(quiet = false) {
|
|
458
494
|
this.quiet = quiet;
|
|
495
|
+
this.logger = new Logger({ name: "agent-loader", quiet: this.quiet });
|
|
459
496
|
}
|
|
497
|
+
logger;
|
|
460
498
|
/**
|
|
461
499
|
* Import a TypeScript file by compiling it on-demand
|
|
462
500
|
*/
|
|
@@ -517,15 +555,11 @@ var AgentLoader = class {
|
|
|
517
555
|
if (agentExport) {
|
|
518
556
|
const isPrimitive = (v) => v == null || ["string", "number", "boolean"].includes(typeof v);
|
|
519
557
|
if (isPrimitive(agentExport)) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
);
|
|
524
|
-
}
|
|
558
|
+
this.logger.info(
|
|
559
|
+
`Ignoring primitive 'agent' export in ${filePath}; scanning module for factory...`
|
|
560
|
+
);
|
|
525
561
|
} else {
|
|
526
|
-
|
|
527
|
-
console.log(`\u2705 TS agent imported via esbuild: ${filePath}`);
|
|
528
|
-
}
|
|
562
|
+
this.logger.info(`TS agent imported via esbuild: ${filePath} \u2705`);
|
|
529
563
|
return { agent: agentExport };
|
|
530
564
|
}
|
|
531
565
|
}
|
|
@@ -571,8 +605,8 @@ var AgentLoader = class {
|
|
|
571
605
|
}
|
|
572
606
|
}
|
|
573
607
|
} catch (error) {
|
|
574
|
-
|
|
575
|
-
|
|
608
|
+
this.logger.warn(
|
|
609
|
+
`Warning: Could not load ${envFile} file: ${error instanceof Error ? error.message : String(error)}`
|
|
576
610
|
);
|
|
577
611
|
}
|
|
578
612
|
}
|
|
@@ -653,11 +687,13 @@ var AgentManager = class {
|
|
|
653
687
|
this.quiet = quiet;
|
|
654
688
|
this.scanner = new AgentScanner(quiet);
|
|
655
689
|
this.loader = new AgentLoader(quiet);
|
|
690
|
+
this.logger = new Logger({ name: "agent-manager", quiet: this.quiet });
|
|
656
691
|
}
|
|
657
692
|
agents = /* @__PURE__ */ new Map();
|
|
658
693
|
loadedAgents = /* @__PURE__ */ new Map();
|
|
659
694
|
scanner;
|
|
660
695
|
loader;
|
|
696
|
+
logger;
|
|
661
697
|
getAgents() {
|
|
662
698
|
return this.agents;
|
|
663
699
|
}
|
|
@@ -711,7 +747,10 @@ var AgentManager = class {
|
|
|
711
747
|
agent.instance = exportedAgent;
|
|
712
748
|
agent.name = exportedAgent.name;
|
|
713
749
|
} catch (error) {
|
|
714
|
-
|
|
750
|
+
const agentName = agent?.name ?? agentPath;
|
|
751
|
+
this.logger.error(
|
|
752
|
+
`Failed to load agent "${agentName}": ${error instanceof Error ? error.message : String(error)}`
|
|
753
|
+
);
|
|
715
754
|
throw new Error(
|
|
716
755
|
`Failed to load agent: ${error instanceof Error ? error.message : String(error)}`
|
|
717
756
|
);
|
|
@@ -752,9 +791,8 @@ var AgentManager = class {
|
|
|
752
791
|
return response;
|
|
753
792
|
} catch (error) {
|
|
754
793
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
755
|
-
|
|
756
|
-
`Error sending message to agent ${agentPath}
|
|
757
|
-
errorMessage
|
|
794
|
+
this.logger.error(
|
|
795
|
+
`Error sending message to agent ${agentPath}: ${errorMessage}`
|
|
758
796
|
);
|
|
759
797
|
throw new Error(`Failed to send message to agent: ${errorMessage}`);
|
|
760
798
|
}
|
|
@@ -766,9 +804,12 @@ var AgentManager = class {
|
|
|
766
804
|
}
|
|
767
805
|
};
|
|
768
806
|
var SessionManager = class {
|
|
769
|
-
constructor(sessionService) {
|
|
807
|
+
constructor(sessionService, quiet = false) {
|
|
770
808
|
this.sessionService = sessionService;
|
|
809
|
+
this.quiet = quiet;
|
|
810
|
+
this.logger = new Logger({ name: "session-manager", quiet: this.quiet });
|
|
771
811
|
}
|
|
812
|
+
logger;
|
|
772
813
|
async getSessionMessages(loadedAgent) {
|
|
773
814
|
try {
|
|
774
815
|
const session = await this.sessionService.getSession(
|
|
@@ -789,7 +830,10 @@ var SessionManager = class {
|
|
|
789
830
|
}));
|
|
790
831
|
return messages;
|
|
791
832
|
} catch (error) {
|
|
792
|
-
|
|
833
|
+
this.logger.error(
|
|
834
|
+
"Error fetching messages:",
|
|
835
|
+
error instanceof Error ? error.message : String(error)
|
|
836
|
+
);
|
|
793
837
|
return [];
|
|
794
838
|
}
|
|
795
839
|
}
|
|
@@ -803,13 +847,16 @@ var ADKServer = class {
|
|
|
803
847
|
app;
|
|
804
848
|
server;
|
|
805
849
|
config;
|
|
850
|
+
logger;
|
|
806
851
|
constructor(agentsDir, port = 8042, host = "localhost", quiet = false) {
|
|
807
852
|
this.config = { agentsDir, port, host, quiet };
|
|
853
|
+
this.logger = new Logger({ name: "adk-server", quiet });
|
|
808
854
|
this.sessionService = new import_adk2.InMemorySessionService();
|
|
809
855
|
this.agentManager = new AgentManager(this.sessionService, quiet);
|
|
810
|
-
this.sessionManager = new SessionManager(this.sessionService);
|
|
856
|
+
this.sessionManager = new SessionManager(this.sessionService, quiet);
|
|
811
857
|
this.app = new import_hono.Hono();
|
|
812
858
|
setupRoutes(this.app, this.agentManager, this.sessionManager, agentsDir);
|
|
859
|
+
this.logger.info(`Starting agent scan in ${agentsDir} \u2728`);
|
|
813
860
|
this.agentManager.scanAgents(agentsDir);
|
|
814
861
|
}
|
|
815
862
|
async start() {
|
|
@@ -820,16 +867,21 @@ var ADKServer = class {
|
|
|
820
867
|
hostname: this.config.host
|
|
821
868
|
});
|
|
822
869
|
setTimeout(() => {
|
|
870
|
+
this.logger.info(
|
|
871
|
+
`Server listening on http://${this.config.host}:${this.config.port} \u{1F680}`
|
|
872
|
+
);
|
|
823
873
|
resolve2();
|
|
824
874
|
}, 100);
|
|
825
875
|
});
|
|
826
876
|
}
|
|
827
877
|
async stop() {
|
|
828
878
|
return new Promise((resolve2) => {
|
|
879
|
+
this.logger.info("Stopping server and all agents... \u{1F6D1}");
|
|
829
880
|
this.agentManager.stopAllAgents();
|
|
830
881
|
if (this.server) {
|
|
831
882
|
this.server.close();
|
|
832
883
|
}
|
|
884
|
+
this.logger.info("Server stopped");
|
|
833
885
|
resolve2();
|
|
834
886
|
});
|
|
835
887
|
}
|
|
@@ -844,21 +896,21 @@ async function serveCommand(options = {}) {
|
|
|
844
896
|
const host = options.host || "localhost";
|
|
845
897
|
const agentsDir = (0, import_node_path3.resolve)(options.dir || ".");
|
|
846
898
|
if (!(0, import_node_fs3.existsSync)(agentsDir)) {
|
|
847
|
-
console.error(
|
|
899
|
+
console.error(import_chalk3.default.red(`\u274C Directory not found: ${agentsDir}`));
|
|
848
900
|
process.exit(1);
|
|
849
901
|
}
|
|
850
902
|
if (!options.quiet) {
|
|
851
|
-
console.log(
|
|
903
|
+
console.log(import_chalk3.default.blue(`\u{1F680} ADK Server starting on http://${host}:${port}`));
|
|
852
904
|
}
|
|
853
905
|
const server = new ADKServer(agentsDir, port, host, options.quiet);
|
|
854
906
|
try {
|
|
855
907
|
await server.start();
|
|
856
908
|
if (!options.quiet) {
|
|
857
|
-
console.log(
|
|
909
|
+
console.log(import_chalk3.default.green("\u2705 Server ready"));
|
|
858
910
|
}
|
|
859
911
|
const cleanup = async () => {
|
|
860
912
|
if (!options.quiet) {
|
|
861
|
-
console.log(
|
|
913
|
+
console.log(import_chalk3.default.yellow("\n\u{1F6D1} Stopping server..."));
|
|
862
914
|
}
|
|
863
915
|
await server.stop();
|
|
864
916
|
process.exit(0);
|
|
@@ -867,7 +919,7 @@ async function serveCommand(options = {}) {
|
|
|
867
919
|
process.on("SIGTERM", cleanup);
|
|
868
920
|
return server;
|
|
869
921
|
} catch (error) {
|
|
870
|
-
console.error(
|
|
922
|
+
console.error(import_chalk3.default.red("\u274C Failed to start ADK server:"), error);
|
|
871
923
|
process.exit(1);
|
|
872
924
|
}
|
|
873
925
|
}
|
|
@@ -990,7 +1042,7 @@ var AgentChatClient = class {
|
|
|
990
1042
|
await this.sendMessage(message.trim());
|
|
991
1043
|
}
|
|
992
1044
|
} catch (error) {
|
|
993
|
-
console.error(
|
|
1045
|
+
console.error(import_chalk4.default.red("Error in chat:"), error);
|
|
994
1046
|
break;
|
|
995
1047
|
}
|
|
996
1048
|
}
|
|
@@ -1007,7 +1059,7 @@ async function runAgent(agentPath, options = {}) {
|
|
|
1007
1059
|
if (options.server) {
|
|
1008
1060
|
const apiPort = 8042;
|
|
1009
1061
|
const host = options.host || "localhost";
|
|
1010
|
-
console.log(
|
|
1062
|
+
console.log(import_chalk4.default.blue("\u{1F680} Starting ADK Server..."));
|
|
1011
1063
|
const serveOptions = {
|
|
1012
1064
|
port: apiPort,
|
|
1013
1065
|
dir: process.cwd(),
|
|
@@ -1016,16 +1068,16 @@ async function runAgent(agentPath, options = {}) {
|
|
|
1016
1068
|
};
|
|
1017
1069
|
try {
|
|
1018
1070
|
const server = await serveCommand(serveOptions);
|
|
1019
|
-
console.log(
|
|
1071
|
+
console.log(import_chalk4.default.cyan("Press Ctrl+C to stop the server"));
|
|
1020
1072
|
process.on("SIGINT", async () => {
|
|
1021
|
-
console.log(
|
|
1073
|
+
console.log(import_chalk4.default.yellow("\n\u{1F6D1} Stopping server..."));
|
|
1022
1074
|
await server.stop();
|
|
1023
1075
|
process.exit(0);
|
|
1024
1076
|
});
|
|
1025
1077
|
return new Promise(() => {
|
|
1026
1078
|
});
|
|
1027
1079
|
} catch (error) {
|
|
1028
|
-
console.error(
|
|
1080
|
+
console.error(import_chalk4.default.red("\u274C Failed to start server"));
|
|
1029
1081
|
process.exit(1);
|
|
1030
1082
|
}
|
|
1031
1083
|
}
|
|
@@ -1089,14 +1141,14 @@ async function runAgent(agentPath, options = {}) {
|
|
|
1089
1141
|
}
|
|
1090
1142
|
|
|
1091
1143
|
// src/commands/web.ts
|
|
1092
|
-
var
|
|
1144
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
1093
1145
|
async function webCommand(options = {}) {
|
|
1094
1146
|
const apiPort = options.port || 8042;
|
|
1095
1147
|
const webPort = options.webPort || 3e3;
|
|
1096
1148
|
const host = options.host || "localhost";
|
|
1097
1149
|
const useLocal = options.local || false;
|
|
1098
1150
|
const webUrl = options.webUrl || "https://adk-web.iqai.com";
|
|
1099
|
-
console.log(
|
|
1151
|
+
console.log(import_chalk5.default.blue("\u{1F310} Starting ADK Web Interface..."));
|
|
1100
1152
|
const serveOptions = {
|
|
1101
1153
|
port: apiPort,
|
|
1102
1154
|
dir: options.dir,
|
|
@@ -1118,9 +1170,9 @@ async function webCommand(options = {}) {
|
|
|
1118
1170
|
webAppUrl = `${webUrl}?port=${apiPort}`;
|
|
1119
1171
|
}
|
|
1120
1172
|
}
|
|
1121
|
-
console.log(
|
|
1122
|
-
console.log(
|
|
1123
|
-
console.log(
|
|
1173
|
+
console.log(import_chalk5.default.cyan(`\u{1F517} Open this URL in your browser: ${webAppUrl}`));
|
|
1174
|
+
console.log(import_chalk5.default.gray(` API Server: http://${host}:${apiPort}`));
|
|
1175
|
+
console.log(import_chalk5.default.cyan("Press Ctrl+C to stop the API server"));
|
|
1124
1176
|
}
|
|
1125
1177
|
|
|
1126
1178
|
// src/index.ts
|
|
@@ -1132,7 +1184,7 @@ import_commander.program.command("new").description("Create a new ADK project").
|
|
|
1132
1184
|
try {
|
|
1133
1185
|
await createProject(projectName, options);
|
|
1134
1186
|
} catch (error) {
|
|
1135
|
-
console.error(
|
|
1187
|
+
console.error(import_chalk6.default.red("Error creating project:"), error);
|
|
1136
1188
|
process.exit(1);
|
|
1137
1189
|
}
|
|
1138
1190
|
});
|
|
@@ -1147,7 +1199,7 @@ import_commander.program.command("run").description("Start an interactive chat w
|
|
|
1147
1199
|
try {
|
|
1148
1200
|
await runAgent(agentPath, options);
|
|
1149
1201
|
} catch (error) {
|
|
1150
|
-
console.error(
|
|
1202
|
+
console.error(import_chalk6.default.red("Error running agent:"), error);
|
|
1151
1203
|
process.exit(1);
|
|
1152
1204
|
}
|
|
1153
1205
|
});
|
|
@@ -1167,7 +1219,7 @@ import_commander.program.command("web").description("Start a web interface for t
|
|
|
1167
1219
|
try {
|
|
1168
1220
|
await webCommand(options);
|
|
1169
1221
|
} catch (error) {
|
|
1170
|
-
console.error(
|
|
1222
|
+
console.error(import_chalk6.default.red("Error starting web UI:"), error);
|
|
1171
1223
|
process.exit(1);
|
|
1172
1224
|
}
|
|
1173
1225
|
});
|
|
@@ -1179,7 +1231,7 @@ import_commander.program.command("serve").description("Start an API server for a
|
|
|
1179
1231
|
try {
|
|
1180
1232
|
await serveCommand(options);
|
|
1181
1233
|
} catch (error) {
|
|
1182
|
-
console.error(
|
|
1234
|
+
console.error(import_chalk6.default.red("Error starting server:"), error);
|
|
1183
1235
|
process.exit(1);
|
|
1184
1236
|
}
|
|
1185
1237
|
});
|