@iqai/adk-cli 0.2.8 → 0.3.0
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 +20 -0
- package/README.md +1 -0
- package/dist/app.module.d.ts +3 -0
- package/dist/app.module.d.ts.map +1 -0
- package/dist/app.module.js +24 -0
- package/dist/app.module.js.map +1 -0
- package/dist/cli/cli.module.d.ts +3 -0
- package/dist/cli/cli.module.d.ts.map +1 -0
- package/dist/cli/cli.module.js +25 -0
- package/dist/cli/cli.module.js.map +1 -0
- package/dist/cli/new.command.d.ts +10 -0
- package/dist/cli/new.command.d.ts.map +1 -0
- package/dist/cli/new.command.js +273 -0
- package/dist/cli/new.command.js.map +1 -0
- package/dist/cli/run.command.d.ts +20 -0
- package/dist/cli/run.command.d.ts.map +1 -0
- package/dist/cli/run.command.js +342 -0
- package/dist/cli/run.command.js.map +1 -0
- package/dist/cli/serve.command.d.ts +20 -0
- package/dist/cli/serve.command.d.ts.map +1 -0
- package/dist/cli/serve.command.js +137 -0
- package/dist/cli/serve.command.js.map +1 -0
- package/dist/cli/web.command.d.ts +20 -0
- package/dist/cli/web.command.d.ts.map +1 -0
- package/dist/cli/web.command.js +146 -0
- package/dist/cli/web.command.js.map +1 -0
- package/dist/common/tokens.d.ts +5 -0
- package/dist/common/tokens.d.ts.map +1 -0
- package/dist/common/tokens.js +8 -0
- package/dist/common/tokens.js.map +1 -0
- package/dist/common/types.d.ts +91 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -0
- package/dist/http/bootstrap.d.ts +17 -0
- package/dist/http/bootstrap.d.ts.map +1 -0
- package/dist/http/bootstrap.js +221 -0
- package/dist/http/bootstrap.js.map +1 -0
- package/dist/http/config/config.module.d.ts +6 -0
- package/dist/http/config/config.module.d.ts.map +1 -0
- package/dist/http/config/config.module.js +32 -0
- package/dist/http/config/config.module.js.map +1 -0
- package/dist/http/discovery/agents.controller.d.ts +13 -0
- package/dist/http/discovery/agents.controller.d.ts.map +1 -0
- package/dist/http/discovery/agents.controller.js +73 -0
- package/dist/http/discovery/agents.controller.js.map +1 -0
- package/dist/http/discovery/discovery.module.d.ts +3 -0
- package/dist/http/discovery/discovery.module.d.ts.map +1 -0
- package/dist/http/discovery/discovery.module.js +22 -0
- package/dist/http/discovery/discovery.module.js.map +1 -0
- package/dist/http/dto/api.dto.d.ts +70 -0
- package/dist/http/dto/api.dto.d.ts.map +1 -0
- package/dist/http/dto/api.dto.js +268 -0
- package/dist/http/dto/api.dto.js.map +1 -0
- package/dist/http/events/events.controller.d.ts +8 -0
- package/dist/http/events/events.controller.d.ts.map +1 -0
- package/dist/http/events/events.controller.js +55 -0
- package/dist/http/events/events.controller.js.map +1 -0
- package/dist/http/events/events.module.d.ts +3 -0
- package/dist/http/events/events.module.d.ts.map +1 -0
- package/dist/http/events/events.module.js +25 -0
- package/dist/http/events/events.module.js.map +1 -0
- package/dist/http/events/events.service.d.ts +8 -0
- package/dist/http/events/events.service.d.ts.map +1 -0
- package/dist/http/events/events.service.js +37 -0
- package/dist/http/events/events.service.js.map +1 -0
- package/dist/http/health/health.controller.d.ts +6 -0
- package/dist/http/health/health.controller.d.ts.map +1 -0
- package/dist/http/health/health.controller.js +37 -0
- package/dist/http/health/health.controller.js.map +1 -0
- package/dist/http/health/health.module.d.ts +3 -0
- package/dist/http/health/health.module.d.ts.map +1 -0
- package/dist/http/health/health.module.js +20 -0
- package/dist/http/health/health.module.js.map +1 -0
- package/dist/http/http.module.d.ts +6 -0
- package/dist/http/http.module.d.ts.map +1 -0
- package/dist/http/http.module.js +43 -0
- package/dist/http/http.module.js.map +1 -0
- package/dist/http/messaging/messaging.controller.d.ts +9 -0
- package/dist/http/messaging/messaging.controller.d.ts.map +1 -0
- package/dist/http/messaging/messaging.controller.js +83 -0
- package/dist/http/messaging/messaging.controller.js.map +1 -0
- package/dist/http/messaging/messaging.module.d.ts +3 -0
- package/dist/http/messaging/messaging.module.d.ts.map +1 -0
- package/dist/http/messaging/messaging.module.js +25 -0
- package/dist/http/messaging/messaging.module.js.map +1 -0
- package/dist/http/messaging/messaging.service.d.ts +11 -0
- package/dist/http/messaging/messaging.service.d.ts.map +1 -0
- package/dist/http/messaging/messaging.service.js +48 -0
- package/dist/http/messaging/messaging.service.js.map +1 -0
- package/dist/http/providers/agent-loader.service.d.ts +49 -0
- package/dist/http/providers/agent-loader.service.d.ts.map +1 -0
- package/dist/http/providers/agent-loader.service.js +416 -0
- package/dist/http/providers/agent-loader.service.js.map +1 -0
- package/dist/http/providers/agent-manager.service.d.ts +24 -0
- package/dist/http/providers/agent-manager.service.d.ts.map +1 -0
- package/dist/http/providers/agent-manager.service.js +222 -0
- package/dist/http/providers/agent-manager.service.js.map +1 -0
- package/dist/http/providers/agent-scanner.service.d.ts +9 -0
- package/dist/http/providers/agent-scanner.service.d.ts.map +1 -0
- package/dist/http/providers/agent-scanner.service.js +108 -0
- package/dist/http/providers/agent-scanner.service.js.map +1 -0
- package/dist/http/providers/providers.module.d.ts +3 -0
- package/dist/http/providers/providers.module.d.ts.map +1 -0
- package/dist/http/providers/providers.module.js +47 -0
- package/dist/http/providers/providers.module.js.map +1 -0
- package/dist/http/reload/hot-reload.service.d.ts +16 -0
- package/dist/http/reload/hot-reload.service.d.ts.map +1 -0
- package/dist/http/reload/hot-reload.service.js +79 -0
- package/dist/http/reload/hot-reload.service.js.map +1 -0
- package/dist/http/reload/reload.controller.d.ts +14 -0
- package/dist/http/reload/reload.controller.d.ts.map +1 -0
- package/dist/http/reload/reload.controller.js +50 -0
- package/dist/http/reload/reload.controller.js.map +1 -0
- package/dist/http/reload/reload.module.d.ts +3 -0
- package/dist/http/reload/reload.module.d.ts.map +1 -0
- package/dist/http/reload/reload.module.js +23 -0
- package/dist/http/reload/reload.module.js.map +1 -0
- package/dist/http/runtime-config.d.ts +22 -0
- package/dist/http/runtime-config.d.ts.map +1 -0
- package/dist/http/runtime-config.js +5 -0
- package/dist/http/runtime-config.js.map +1 -0
- package/dist/http/sessions/sessions.controller.d.ts +11 -0
- package/dist/http/sessions/sessions.controller.d.ts.map +1 -0
- package/dist/http/sessions/sessions.controller.js +116 -0
- package/dist/http/sessions/sessions.controller.js.map +1 -0
- package/dist/http/sessions/sessions.module.d.ts +3 -0
- package/dist/http/sessions/sessions.module.d.ts.map +1 -0
- package/dist/http/sessions/sessions.module.js +25 -0
- package/dist/http/sessions/sessions.module.js.map +1 -0
- package/dist/http/sessions/sessions.service.d.ts +54 -0
- package/dist/http/sessions/sessions.service.d.ts.map +1 -0
- package/dist/http/sessions/sessions.service.js +353 -0
- package/dist/http/sessions/sessions.service.js.map +1 -0
- package/dist/http/state/state.controller.d.ts +9 -0
- package/dist/http/state/state.controller.d.ts.map +1 -0
- package/dist/http/state/state.controller.js +76 -0
- package/dist/http/state/state.controller.js.map +1 -0
- package/dist/http/state/state.module.d.ts +3 -0
- package/dist/http/state/state.module.d.ts.map +1 -0
- package/dist/http/state/state.module.js +25 -0
- package/dist/http/state/state.module.js.map +1 -0
- package/dist/http/state/state.service.d.ts +9 -0
- package/dist/http/state/state.service.d.ts.map +1 -0
- package/dist/http/state/state.service.js +55 -0
- package/dist/http/state/state.service.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +25 -0
- package/dist/main.js.map +1 -0
- package/package.json +18 -12
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1187
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1171
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.AgentLoader = void 0;
|
|
46
|
+
const node_fs_1 = require("node:fs");
|
|
47
|
+
const node_module_1 = require("node:module");
|
|
48
|
+
const node_path_1 = require("node:path");
|
|
49
|
+
const node_url_1 = require("node:url");
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const ADK_CACHE_DIR = ".adk-cache";
|
|
52
|
+
let AgentLoader = class AgentLoader {
|
|
53
|
+
quiet;
|
|
54
|
+
logger;
|
|
55
|
+
constructor(quiet = false) {
|
|
56
|
+
this.quiet = quiet;
|
|
57
|
+
this.logger = new common_1.Logger("agent-loader");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Import a TypeScript file by compiling it on-demand
|
|
61
|
+
*/
|
|
62
|
+
async importTypeScriptFile(filePath) {
|
|
63
|
+
// Determine project root (for tsconfig and resolving deps)
|
|
64
|
+
const startDir = (0, node_path_1.dirname)(filePath);
|
|
65
|
+
let projectRoot = startDir;
|
|
66
|
+
while (projectRoot !== "/" && projectRoot !== (0, node_path_1.dirname)(projectRoot)) {
|
|
67
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(projectRoot, "package.json")) ||
|
|
68
|
+
(0, node_fs_1.existsSync)((0, node_path_1.join)(projectRoot, ".env"))) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
projectRoot = (0, node_path_1.dirname)(projectRoot);
|
|
72
|
+
}
|
|
73
|
+
// If we reached root without finding markers, use the original start directory
|
|
74
|
+
if (projectRoot === "/") {
|
|
75
|
+
projectRoot = startDir;
|
|
76
|
+
}
|
|
77
|
+
// Transpile with esbuild and import (bundles local files, preserves tools)
|
|
78
|
+
// ---------------- esbuild dynamic compilation ----------------
|
|
79
|
+
try {
|
|
80
|
+
const { build } = await Promise.resolve().then(() => __importStar(require("esbuild")));
|
|
81
|
+
const cacheDir = (0, node_path_1.join)(projectRoot, ADK_CACHE_DIR);
|
|
82
|
+
if (!(0, node_fs_1.existsSync)(cacheDir)) {
|
|
83
|
+
(0, node_fs_1.mkdirSync)(cacheDir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
// Use CJS so we can require() cleanly inside a CJS Nest runtime; keep unique filename for cache busting
|
|
86
|
+
const outFile = (0, node_path_1.join)(cacheDir, `agent-${Date.now()}.cjs`);
|
|
87
|
+
// Always externalize workspace-scoped packages so we don't inline their transitive deps.
|
|
88
|
+
// This avoids PNPM "strictness" issues where a transitive dep (e.g. @google/genai) of @iqai/adk
|
|
89
|
+
// would become a direct require() from the bundled cache file and thus not resolvable.
|
|
90
|
+
const ALWAYS_EXTERNAL_SCOPES = ["@iqai/"];
|
|
91
|
+
const alwaysExternal = ["@iqai/adk"]; // explicit critical packages
|
|
92
|
+
// Generic plugin to externalize bare imports (node_modules) while still bundling local relative files.
|
|
93
|
+
const plugin = {
|
|
94
|
+
name: "externalize-bare-imports",
|
|
95
|
+
setup(build) {
|
|
96
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
97
|
+
// Relative / absolute => bundle
|
|
98
|
+
if (args.path.startsWith(".") ||
|
|
99
|
+
args.path.startsWith("/") ||
|
|
100
|
+
args.path.startsWith("..")) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// Force external for workspace scoped packages & explicit list
|
|
104
|
+
if (ALWAYS_EXTERNAL_SCOPES.some((s) => args.path.startsWith(s)) ||
|
|
105
|
+
alwaysExternal.includes(args.path)) {
|
|
106
|
+
return { path: args.path, external: true };
|
|
107
|
+
}
|
|
108
|
+
// Default: externalize other bare imports too
|
|
109
|
+
return { path: args.path, external: true };
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const tsconfigPath = (0, node_path_1.join)(projectRoot, "tsconfig.json");
|
|
114
|
+
await build({
|
|
115
|
+
entryPoints: [filePath],
|
|
116
|
+
outfile: outFile,
|
|
117
|
+
bundle: true,
|
|
118
|
+
format: "cjs", // match Nest's default compilation output
|
|
119
|
+
platform: "node",
|
|
120
|
+
target: ["node22"],
|
|
121
|
+
sourcemap: false,
|
|
122
|
+
logLevel: "silent",
|
|
123
|
+
plugins: [plugin],
|
|
124
|
+
absWorkingDir: projectRoot,
|
|
125
|
+
external: [...alwaysExternal],
|
|
126
|
+
// Use tsconfig if present for path aliases
|
|
127
|
+
...((0, node_fs_1.existsSync)(tsconfigPath) ? { tsconfig: tsconfigPath } : {}),
|
|
128
|
+
});
|
|
129
|
+
// Use Node's CJS require to avoid ESM loader caching oddities with file:// & query params.
|
|
130
|
+
// Avoid using import.meta (keeps compatibility with CommonJS transpilation target)
|
|
131
|
+
const dynamicRequire = (0, node_module_1.createRequire)(outFile);
|
|
132
|
+
let mod;
|
|
133
|
+
try {
|
|
134
|
+
mod = dynamicRequire(outFile);
|
|
135
|
+
}
|
|
136
|
+
catch (loadErr) {
|
|
137
|
+
this.logger.warn(`Primary require failed for built agent '${outFile}': ${loadErr instanceof Error ? loadErr.message : String(loadErr)}. Falling back to dynamic import...`);
|
|
138
|
+
try {
|
|
139
|
+
mod = (await Promise.resolve(`${(0, node_url_1.pathToFileURL)(outFile).href}`).then(s => __importStar(require(s))));
|
|
140
|
+
}
|
|
141
|
+
catch (fallbackErr) {
|
|
142
|
+
throw new Error(`Both require() and import() failed for built agent file '${outFile}': ${fallbackErr instanceof Error ? fallbackErr.message : String(fallbackErr)}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
let agentExport = mod?.agent;
|
|
146
|
+
if (!agentExport && mod?.default) {
|
|
147
|
+
const defaultExport = mod.default;
|
|
148
|
+
agentExport = defaultExport?.agent ?? defaultExport;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
(0, node_fs_1.unlinkSync)(outFile); // cleanup after successful load
|
|
152
|
+
}
|
|
153
|
+
catch { }
|
|
154
|
+
if (agentExport) {
|
|
155
|
+
const isPrimitive = (v) => v == null || ["string", "number", "boolean"].includes(typeof v);
|
|
156
|
+
if (isPrimitive(agentExport)) {
|
|
157
|
+
// Primitive named 'agent' export (e.g., a string) isn't a real agent; fall through to full-module scan
|
|
158
|
+
this.logger.log(`Ignoring primitive 'agent' export in ${filePath}; scanning module for factory...`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.logger.log(`TS agent imported via esbuild: ${filePath} ✅`);
|
|
162
|
+
return { agent: agentExport };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Fallback: return full module so downstream resolver can inspect named exports (e.g., getFooAgent)
|
|
166
|
+
return mod;
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
170
|
+
// Provide clearer guidance when a dependency is missing due to externalization.
|
|
171
|
+
if (/Cannot find module/.test(msg)) {
|
|
172
|
+
this.logger.error(`Module resolution failed while loading agent file '${filePath}'.\n> ${msg}\nThis usually means the dependency is declared in a parent workspace package (e.g. @iqai/adk) and got externalized,\nbut is not installed in the agent project's own node_modules (common with PNPM isolated hoisting).\nFix: add it to the agent project's package.json or run: pnpm add <missing-pkg> -F <agent-workspace>.`);
|
|
173
|
+
}
|
|
174
|
+
throw new Error(`Failed to import TS agent via esbuild: ${msg}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
loadEnvironmentVariables(agentFilePath) {
|
|
178
|
+
// Load environment variables from the project directory before importing
|
|
179
|
+
let projectRoot = (0, node_path_1.dirname)(agentFilePath);
|
|
180
|
+
while (projectRoot !== "/" && projectRoot !== (0, node_path_1.dirname)(projectRoot)) {
|
|
181
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(projectRoot, "package.json")) ||
|
|
182
|
+
(0, node_fs_1.existsSync)((0, node_path_1.join)(projectRoot, ".env"))) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
projectRoot = (0, node_path_1.dirname)(projectRoot);
|
|
186
|
+
}
|
|
187
|
+
// Check for multiple env files in priority order
|
|
188
|
+
const envFiles = [
|
|
189
|
+
".env.local",
|
|
190
|
+
".env.development.local",
|
|
191
|
+
".env.production.local",
|
|
192
|
+
".env.development",
|
|
193
|
+
".env.production",
|
|
194
|
+
".env",
|
|
195
|
+
];
|
|
196
|
+
for (const envFile of envFiles) {
|
|
197
|
+
const envPath = (0, node_path_1.join)(projectRoot, envFile);
|
|
198
|
+
if ((0, node_fs_1.existsSync)(envPath)) {
|
|
199
|
+
try {
|
|
200
|
+
const envContent = (0, node_fs_1.readFileSync)(envPath, "utf8");
|
|
201
|
+
const envLines = envContent.split("\n");
|
|
202
|
+
for (const line of envLines) {
|
|
203
|
+
const trimmedLine = line.trim();
|
|
204
|
+
if (trimmedLine && !trimmedLine.startsWith("#")) {
|
|
205
|
+
const [key, ...valueParts] = trimmedLine.split("=");
|
|
206
|
+
if (key && valueParts.length > 0) {
|
|
207
|
+
const value = valueParts.join("=").replace(/^"(.*)"$/, "$1");
|
|
208
|
+
// Set environment variables in current process (only if not already set)
|
|
209
|
+
if (!process.env[key.trim()]) {
|
|
210
|
+
process.env[key.trim()] = value.trim();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
this.logger.warn(`Warning: Could not load ${envFile} file: ${error instanceof Error ? error.message : String(error)}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Type guard to check if object is likely a BaseAgent instance
|
|
224
|
+
*/
|
|
225
|
+
isLikelyAgentInstance(obj) {
|
|
226
|
+
return (obj != null &&
|
|
227
|
+
typeof obj === "object" &&
|
|
228
|
+
typeof obj.name === "string" &&
|
|
229
|
+
typeof obj.runAsync === "function");
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Type guard to check if object is an AgentBuilder
|
|
233
|
+
*/
|
|
234
|
+
isAgentBuilder(obj) {
|
|
235
|
+
return (obj != null &&
|
|
236
|
+
typeof obj === "object" &&
|
|
237
|
+
typeof obj.build === "function" &&
|
|
238
|
+
typeof obj.withModel === "function");
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Type guard to check if object is a BuiltAgent
|
|
242
|
+
*/
|
|
243
|
+
isBuiltAgent(obj) {
|
|
244
|
+
return (obj != null &&
|
|
245
|
+
typeof obj === "object" &&
|
|
246
|
+
"agent" in obj &&
|
|
247
|
+
"runner" in obj &&
|
|
248
|
+
"session" in obj);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Type guard to check if value is a primitive type
|
|
252
|
+
*/
|
|
253
|
+
isPrimitive(v) {
|
|
254
|
+
return v == null || ["string", "number", "boolean"].includes(typeof v);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Safely invoke a function, handling both sync and async results
|
|
258
|
+
*/
|
|
259
|
+
async invokeFunctionSafely(fn) {
|
|
260
|
+
let result = fn();
|
|
261
|
+
if (result && typeof result === "object" && "then" in result) {
|
|
262
|
+
result = await result;
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Extract BaseAgent from different possible types
|
|
268
|
+
*/
|
|
269
|
+
async extractBaseAgent(item) {
|
|
270
|
+
if (this.isLikelyAgentInstance(item)) {
|
|
271
|
+
return item; // Already a BaseAgent
|
|
272
|
+
}
|
|
273
|
+
if (this.isAgentBuilder(item)) {
|
|
274
|
+
// Build the AgentBuilder to get BuiltAgent, then extract agent
|
|
275
|
+
const built = await item.build();
|
|
276
|
+
return built.agent;
|
|
277
|
+
}
|
|
278
|
+
if (this.isBuiltAgent(item)) {
|
|
279
|
+
// Extract agent from BuiltAgent
|
|
280
|
+
return item.agent;
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Search through module exports to find potential agent exports
|
|
286
|
+
*/
|
|
287
|
+
async scanModuleExports(mod) {
|
|
288
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
289
|
+
if (key === "default")
|
|
290
|
+
continue;
|
|
291
|
+
const keyLower = key.toLowerCase();
|
|
292
|
+
if (this.isPrimitive(value))
|
|
293
|
+
continue;
|
|
294
|
+
const baseAgent = await this.extractBaseAgent(value);
|
|
295
|
+
if (baseAgent) {
|
|
296
|
+
return baseAgent;
|
|
297
|
+
}
|
|
298
|
+
// Handle static container object: export const container = { agent: <BaseAgent> }
|
|
299
|
+
if (value && typeof value === "object" && "agent" in value) {
|
|
300
|
+
const container = value;
|
|
301
|
+
const containerAgent = await this.extractBaseAgent(container.agent);
|
|
302
|
+
if (containerAgent) {
|
|
303
|
+
return containerAgent;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// Handle function exports that might return agents
|
|
307
|
+
if (typeof value === "function" &&
|
|
308
|
+
(() => {
|
|
309
|
+
if (/(agent|build|create)/i.test(keyLower))
|
|
310
|
+
return true;
|
|
311
|
+
const fnName = value?.name;
|
|
312
|
+
return !!(fnName && /(agent|build|create)/i.test(fnName.toLowerCase()));
|
|
313
|
+
})()) {
|
|
314
|
+
try {
|
|
315
|
+
const functionResult = await this.invokeFunctionSafely(value);
|
|
316
|
+
const baseAgent = await this.extractBaseAgent(functionResult);
|
|
317
|
+
if (baseAgent) {
|
|
318
|
+
return baseAgent;
|
|
319
|
+
}
|
|
320
|
+
if (functionResult &&
|
|
321
|
+
typeof functionResult === "object" &&
|
|
322
|
+
"agent" in functionResult) {
|
|
323
|
+
const container = functionResult;
|
|
324
|
+
const containerAgent = await this.extractBaseAgent(container.agent);
|
|
325
|
+
if (containerAgent) {
|
|
326
|
+
return containerAgent;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch (e) {
|
|
331
|
+
// Swallow and continue searching
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
// Enhanced resolution logic for agent exports: always returns BaseAgent
|
|
338
|
+
async resolveAgentExport(mod) {
|
|
339
|
+
const moduleDefault = mod?.default;
|
|
340
|
+
const candidateToResolve = mod?.agent ??
|
|
341
|
+
moduleDefault?.agent ??
|
|
342
|
+
moduleDefault ??
|
|
343
|
+
mod;
|
|
344
|
+
// Try to extract from the initial candidate
|
|
345
|
+
const directResult = await this.tryResolvingDirectCandidate(candidateToResolve, mod);
|
|
346
|
+
if (directResult) {
|
|
347
|
+
return directResult;
|
|
348
|
+
}
|
|
349
|
+
// Search through module exports if no direct candidate found
|
|
350
|
+
const exportResult = await this.scanModuleExports(mod);
|
|
351
|
+
if (exportResult) {
|
|
352
|
+
return exportResult;
|
|
353
|
+
}
|
|
354
|
+
// Final attempt: handle function candidate
|
|
355
|
+
if (typeof candidateToResolve === "function") {
|
|
356
|
+
const functionResult = await this.tryResolvingFunctionCandidate(candidateToResolve);
|
|
357
|
+
if (functionResult) {
|
|
358
|
+
return functionResult;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
throw new Error("No agent export resolved (expected BaseAgent, AgentBuilder, or BuiltAgent)");
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Try to resolve a direct candidate (not from scanning exports)
|
|
365
|
+
*/
|
|
366
|
+
async tryResolvingDirectCandidate(candidateToResolve, mod) {
|
|
367
|
+
// Skip if candidate is primitive or represents the whole module
|
|
368
|
+
if (this.isPrimitive(candidateToResolve) ||
|
|
369
|
+
(candidateToResolve && candidateToResolve === mod)) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
// Try direct extraction
|
|
373
|
+
const directAgent = await this.extractBaseAgent(candidateToResolve);
|
|
374
|
+
if (directAgent) {
|
|
375
|
+
return directAgent;
|
|
376
|
+
}
|
|
377
|
+
// Check if it's a container object
|
|
378
|
+
if (candidateToResolve &&
|
|
379
|
+
typeof candidateToResolve === "object" &&
|
|
380
|
+
"agent" in candidateToResolve) {
|
|
381
|
+
const container = candidateToResolve;
|
|
382
|
+
return await this.extractBaseAgent(container.agent);
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Try to resolve a function candidate by invoking it
|
|
388
|
+
*/
|
|
389
|
+
async tryResolvingFunctionCandidate(functionCandidate) {
|
|
390
|
+
try {
|
|
391
|
+
const functionResult = await this.invokeFunctionSafely(functionCandidate);
|
|
392
|
+
// Try direct extraction from function result
|
|
393
|
+
const directAgent = await this.extractBaseAgent(functionResult);
|
|
394
|
+
if (directAgent) {
|
|
395
|
+
return directAgent;
|
|
396
|
+
}
|
|
397
|
+
// Check if function result is a container
|
|
398
|
+
if (functionResult &&
|
|
399
|
+
typeof functionResult === "object" &&
|
|
400
|
+
"agent" in functionResult) {
|
|
401
|
+
const container = functionResult;
|
|
402
|
+
return await this.extractBaseAgent(container.agent);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
throw new Error(`Failed executing exported agent function: ${e instanceof Error ? e.message : String(e)}`);
|
|
407
|
+
}
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
exports.AgentLoader = AgentLoader;
|
|
412
|
+
exports.AgentLoader = AgentLoader = __decorate([
|
|
413
|
+
(0, common_1.Injectable)(),
|
|
414
|
+
__metadata("design:paramtypes", [Object])
|
|
415
|
+
], AgentLoader);
|
|
416
|
+
//# sourceMappingURL=agent-loader.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-loader.service.js","sourceRoot":"","sources":["../../../src/http/providers/agent-loader.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA0E;AAC1E,6CAA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AC,CAAC;YAC9D,CAAC;QACF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACd,6CACC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAC1C,EAAE,CACF,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAA;AA/cY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;;GACA,WAAW,CA+cvB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InMemorySessionService } from "@iqai/adk";
|
|
2
|
+
import type { Agent, LoadedAgent } from "../../common/types";
|
|
3
|
+
export declare class AgentManager {
|
|
4
|
+
private sessionService;
|
|
5
|
+
private agents;
|
|
6
|
+
private loadedAgents;
|
|
7
|
+
private scanner;
|
|
8
|
+
private loader;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(sessionService: InMemorySessionService, quiet?: boolean);
|
|
11
|
+
getAgents(): Map<string, Agent>;
|
|
12
|
+
getLoadedAgents(): Map<string, LoadedAgent>;
|
|
13
|
+
skanAgents?(agentsDir: string): void;
|
|
14
|
+
scanAgents(agentsDir: string): void;
|
|
15
|
+
startAgent(agentPath: string): Promise<void>;
|
|
16
|
+
stopAgent(agentPath: string): Promise<void>;
|
|
17
|
+
sendMessageToAgent(agentPath: string, message: string, attachments?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
mimeType: string;
|
|
20
|
+
data: string;
|
|
21
|
+
}>): Promise<string>;
|
|
22
|
+
stopAllAgents(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=agent-manager.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-manager.service.d.ts","sourceRoot":"","sources":["../../../src/http/providers/agent-manager.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAGrE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAO7D,qBACa,YAAY;IAQvB,OAAO,CAAC,cAAc;IAPvB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAS;gBAGd,cAAc,EAAE,sBAAsB,EAC9C,KAAK,UAAQ;IAOd,SAAS,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC;IAI/B,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAI3C,UAAU,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAEpC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM7B,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoH5C,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3C,kBAAkB,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GACnE,OAAO,CAAC,MAAM,CAAC;IAiDlB,aAAa,IAAI,IAAI;CAKrB"}
|