@iqai/adk-cli 0.3.23 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/http/providers/agent-loader/build-utils.d.ts +7 -0
  3. package/dist/http/providers/agent-loader/build-utils.d.ts.map +1 -0
  4. package/dist/http/providers/agent-loader/build-utils.js +52 -0
  5. package/dist/http/providers/agent-loader/build-utils.js.map +1 -0
  6. package/dist/http/providers/agent-loader/env.d.ts +3 -0
  7. package/dist/http/providers/agent-loader/env.d.ts.map +1 -0
  8. package/dist/http/providers/agent-loader/env.js +44 -0
  9. package/dist/http/providers/agent-loader/env.js.map +1 -0
  10. package/dist/http/providers/agent-loader/path-plugin.d.ts +7 -0
  11. package/dist/http/providers/agent-loader/path-plugin.d.ts.map +1 -0
  12. package/dist/http/providers/agent-loader/path-plugin.js +72 -0
  13. package/dist/http/providers/agent-loader/path-plugin.js.map +1 -0
  14. package/dist/http/providers/agent-loader/resolver.d.ts +3 -0
  15. package/dist/http/providers/agent-loader/resolver.d.ts.map +1 -0
  16. package/dist/http/providers/agent-loader/resolver.js +148 -0
  17. package/dist/http/providers/agent-loader/resolver.js.map +1 -0
  18. package/dist/http/providers/agent-loader/tsconfig.d.ts +4 -0
  19. package/dist/http/providers/agent-loader/tsconfig.d.ts.map +1 -0
  20. package/dist/http/providers/agent-loader/tsconfig.js +32 -0
  21. package/dist/http/providers/agent-loader/tsconfig.js.map +1 -0
  22. package/dist/http/providers/agent-loader/utils.d.ts +2 -0
  23. package/dist/http/providers/agent-loader/utils.d.ts.map +1 -0
  24. package/dist/http/providers/agent-loader/utils.js +7 -0
  25. package/dist/http/providers/agent-loader/utils.js.map +1 -0
  26. package/dist/http/providers/agent-loader.service.d.ts +0 -52
  27. package/dist/http/providers/agent-loader.service.d.ts.map +1 -1
  28. package/dist/http/providers/agent-loader.service.js +14 -371
  29. package/dist/http/providers/agent-loader.service.js.map +1 -1
  30. package/dist/http/providers/agent-manager/sessions.d.ts +36 -0
  31. package/dist/http/providers/agent-manager/sessions.d.ts.map +1 -0
  32. package/dist/http/providers/agent-manager/sessions.js +114 -0
  33. package/dist/http/providers/agent-manager/sessions.js.map +1 -0
  34. package/dist/http/providers/agent-manager/state.d.ts +8 -0
  35. package/dist/http/providers/agent-manager/state.d.ts.map +1 -0
  36. package/dist/http/providers/agent-manager/state.js +72 -0
  37. package/dist/http/providers/agent-manager/state.js.map +1 -0
  38. package/dist/http/providers/agent-manager.service.d.ts +1 -55
  39. package/dist/http/providers/agent-manager.service.d.ts.map +1 -1
  40. package/dist/http/providers/agent-manager.service.js +12 -261
  41. package/dist/http/providers/agent-manager.service.js.map +1 -1
  42. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iqai/adk-cli
2
2
 
3
+ ## 0.3.24
4
+
5
+ ### Patch Changes
6
+
7
+ - 8143f4f: refactor: simplified agent loaders and managers
8
+
3
9
  ## 0.3.23
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ import type { ESBuildPlugin } from "../agent-loader.types";
2
+ export declare function createExternalizePlugin(alwaysExternal?: string[], scopes?: string[]): ESBuildPlugin;
3
+ export declare function isRebuildNeeded(outFile: string, sourceFile: string, tsconfigPath: string, logger?: {
4
+ debug: (m: string) => void;
5
+ warn: (...args: any[]) => void;
6
+ }, quiet?: boolean): boolean;
7
+ //# sourceMappingURL=build-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-utils.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/build-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,wBAAgB,uBAAuB,CACtC,cAAc,GAAE,MAAM,EAAkB,EACxC,MAAM,GAAE,MAAM,EAAe,GAC3B,aAAa,CA2Bf;AAED,wBAAgB,eAAe,CAC9B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAAE,EACvE,KAAK,UAAQ,GACX,OAAO,CA0BT"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExternalizePlugin = createExternalizePlugin;
4
+ exports.isRebuildNeeded = isRebuildNeeded;
5
+ function createExternalizePlugin(alwaysExternal = ["@iqai/adk"], scopes = ["@iqai/"]) {
6
+ const ALWAYS_EXTERNAL_SCOPES = scopes;
7
+ const explicitExternals = new Set(alwaysExternal);
8
+ return {
9
+ name: "externalize-bare-imports",
10
+ setup(build) {
11
+ build.onResolve({ filter: /.*/ }, (args) => {
12
+ const isWindowsAbsolutePath = /^[a-zA-Z]:/.test(args.path);
13
+ if (args.path.startsWith(".") ||
14
+ args.path.startsWith("/") ||
15
+ args.path.startsWith("..") ||
16
+ isWindowsAbsolutePath) {
17
+ return;
18
+ }
19
+ if (ALWAYS_EXTERNAL_SCOPES.some((s) => args.path.startsWith(s)) ||
20
+ explicitExternals.has(args.path)) {
21
+ return { path: args.path, external: true };
22
+ }
23
+ return { path: args.path, external: true };
24
+ });
25
+ },
26
+ };
27
+ }
28
+ function isRebuildNeeded(outFile, sourceFile, tsconfigPath, logger, quiet = false) {
29
+ const { existsSync, statSync } = require("node:fs");
30
+ if (!existsSync(outFile))
31
+ return true;
32
+ try {
33
+ const outStat = statSync(outFile);
34
+ const srcStat = statSync(sourceFile);
35
+ const tsconfigMtime = existsSync(tsconfigPath)
36
+ ? statSync(tsconfigPath).mtimeMs
37
+ : 0;
38
+ const needRebuild = !(outStat.mtimeMs >= srcStat.mtimeMs && outStat.mtimeMs >= tsconfigMtime);
39
+ if (!needRebuild && !quiet) {
40
+ logger?.debug?.(`Reusing cached build: ${outFile}`);
41
+ }
42
+ return needRebuild;
43
+ }
44
+ catch (error) {
45
+ if (!quiet) {
46
+ const msg = error instanceof Error ? error.message : String(error);
47
+ logger?.warn?.(`Failed to check cache freshness for ${outFile}: ${msg}. Forcing rebuild.`);
48
+ }
49
+ return true;
50
+ }
51
+ }
52
+ //# sourceMappingURL=build-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-utils.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/build-utils.ts"],"names":[],"mappings":";;AAEA,0DA8BC;AAED,0CAgCC;AAhED,SAAgB,uBAAuB,CACtC,iBAA2B,CAAC,WAAW,CAAC,EACxC,SAAmB,CAAC,QAAQ,CAAC;IAE7B,MAAM,sBAAsB,GAAG,MAAM,CAAC;IACtC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IAElD,OAAO;QACN,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,KAAK;YACV,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC1C,MAAM,qBAAqB,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC3D,IACC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;oBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;oBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;oBAC1B,qBAAqB,EACpB,CAAC;oBACF,OAAO;gBACR,CAAC;gBACD,IACC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;oBAC3D,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAC/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,CAAC,CAAC;YACnE,MAAM,EAAE,IAAI,EAAE,CACb,uCAAuC,OAAO,KAAK,GAAG,oBAAoB,CAC1E,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Logger } from "@nestjs/common";
2
+ export declare function loadEnvironmentVariables(agentFilePath: string, logger?: Logger): void;
3
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/env.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,wBAAgB,wBAAwB,CACvC,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,MAAM,GACb,IAAI,CAqCN"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadEnvironmentVariables = loadEnvironmentVariables;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const find_project_root_1 = require("../../../common/find-project-root");
7
+ function loadEnvironmentVariables(agentFilePath, logger) {
8
+ const normalizedAgentPath = (0, node_path_1.normalize)((0, node_path_1.resolve)(agentFilePath));
9
+ const projectRoot = (0, find_project_root_1.findProjectRoot)((0, node_path_1.dirname)(normalizedAgentPath));
10
+ const envFiles = [
11
+ ".env.local",
12
+ ".env.development.local",
13
+ ".env.production.local",
14
+ ".env.development",
15
+ ".env.production",
16
+ ".env",
17
+ ];
18
+ for (const envFile of envFiles) {
19
+ const envPath = (0, node_path_1.join)(projectRoot, envFile);
20
+ if ((0, node_fs_1.existsSync)(envPath)) {
21
+ try {
22
+ const envContent = (0, node_fs_1.readFileSync)(envPath, "utf8");
23
+ const envLines = envContent.split("\n");
24
+ for (const line of envLines) {
25
+ const trimmedLine = line.trim();
26
+ if (trimmedLine && !trimmedLine.startsWith("#")) {
27
+ const [key, ...valueParts] = trimmedLine.split("=");
28
+ if (key && valueParts.length > 0) {
29
+ const value = valueParts.join("=").replace(/^"(.*)"$/, "$1");
30
+ if (!process.env[key.trim()]) {
31
+ process.env[key.trim()] = value.trim();
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ catch (error) {
38
+ const msg = error instanceof Error ? error.message : String(error);
39
+ logger?.warn(`Warning: Could not load ${envFile} file: ${msg}`);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/env.ts"],"names":[],"mappings":";;AAKA,4DAwCC;AA7CD,qCAAmD;AACnD,yCAA8D;AAE9D,yEAAoE;AAEpE,SAAgB,wBAAwB,CACvC,aAAqB,EACrB,MAAe;IAEf,MAAM,mBAAmB,GAAG,IAAA,qBAAS,EAAC,IAAA,mBAAO,EAAC,aAAa,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,IAAA,mCAAe,EAAC,IAAA,mBAAO,EAAC,mBAAmB,CAAC,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG;QAChB,YAAY;QACZ,wBAAwB;QACxB,uBAAuB;QACvB,kBAAkB;QAClB,iBAAiB;QACjB,MAAM;KACN,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,IAAA,oBAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC;gBACJ,MAAM,UAAU,GAAG,IAAA,sBAAY,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACxC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;oBAChC,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;wBACjD,MAAM,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBACpD,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;4BAClC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;4BAC7D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;gCAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;4BACxC,CAAC;wBACF,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnE,MAAM,EAAE,IAAI,CAAC,2BAA2B,OAAO,UAAU,GAAG,EAAE,CAAC,CAAC;YACjE,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ESBuildPlugin } from "../agent-loader.types";
2
+ import type { Logger } from "@nestjs/common";
3
+ export declare function createPathMappingPlugin(projectRoot: string, opts?: {
4
+ logger?: Logger;
5
+ quiet?: boolean;
6
+ }): ESBuildPlugin;
7
+ //# sourceMappingURL=path-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-plugin.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/path-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,aAAa,EAEb,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7C,wBAAgB,uBAAuB,CACtC,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7C,aAAa,CA8Ef"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPathMappingPlugin = createPathMappingPlugin;
4
+ const tsconfig_1 = require("./tsconfig");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const utils_1 = require("./utils");
8
+ function createPathMappingPlugin(projectRoot, opts = {}) {
9
+ const { baseUrl, paths } = (0, tsconfig_1.parseTsConfigPaths)(projectRoot, opts.logger);
10
+ const resolvedBaseUrl = baseUrl ? (0, node_path_1.resolve)(projectRoot, baseUrl) : projectRoot;
11
+ const logger = opts.logger;
12
+ const quiet = !!opts.quiet;
13
+ return {
14
+ name: "typescript-path-mapping",
15
+ setup(build) {
16
+ build.onResolve({ filter: /.*/ }, (args) => {
17
+ if (!quiet) {
18
+ logger?.debug(`Resolving import: "${args.path}" from "${args.importer || "unknown"}"`);
19
+ }
20
+ if (paths && !args.path.startsWith(".") && !(0, node_path_1.isAbsolute)(args.path)) {
21
+ for (const [alias, mappings] of Object.entries(paths)) {
22
+ const aliasPattern = alias.replace("*", "(.*)");
23
+ const aliasRegex = new RegExp(`^${aliasPattern}$`);
24
+ const match = args.path.match(aliasRegex);
25
+ if (match) {
26
+ for (const mapping of mappings) {
27
+ let resolvedPath = mapping;
28
+ if (match[1] && mapping.includes("*")) {
29
+ resolvedPath = mapping.replace("*", match[1]);
30
+ }
31
+ const fullPath = (0, node_path_1.normalize)((0, node_path_1.resolve)(resolvedBaseUrl, resolvedPath));
32
+ const extensions = [".ts", ".js", ".tsx", ".jsx", ""];
33
+ for (const ext of extensions) {
34
+ const pathWithExt = ext ? fullPath + ext : fullPath;
35
+ if ((0, node_fs_1.existsSync)(pathWithExt)) {
36
+ logger?.debug(`Path mapping resolved: ${args.path} -> ${pathWithExt}`);
37
+ return { path: (0, utils_1.normalizePathForEsbuild)(pathWithExt) };
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ if (args.path === "env" && baseUrl) {
45
+ const envPath = (0, node_path_1.resolve)(resolvedBaseUrl, "env");
46
+ const extensions = [".ts", ".js"];
47
+ for (const ext of extensions) {
48
+ const pathWithExt = (0, node_path_1.normalize)(envPath + ext);
49
+ if ((0, node_fs_1.existsSync)(pathWithExt)) {
50
+ logger?.debug(`Direct env import resolved: ${args.path} -> ${pathWithExt}`);
51
+ return { path: (0, utils_1.normalizePathForEsbuild)(pathWithExt) };
52
+ }
53
+ }
54
+ }
55
+ if (baseUrl && args.path.startsWith("../")) {
56
+ const relativePath = args.path.replace("../", "");
57
+ const fullPath = (0, node_path_1.resolve)(resolvedBaseUrl, relativePath);
58
+ const extensions = [".ts", ".js", ".tsx", ".jsx", ""];
59
+ for (const ext of extensions) {
60
+ const pathWithExt = (0, node_path_1.normalize)(ext ? fullPath + ext : fullPath);
61
+ if ((0, node_fs_1.existsSync)(pathWithExt)) {
62
+ logger?.debug(`Relative import resolved via baseUrl: ${args.path} -> ${pathWithExt}`);
63
+ return { path: (0, utils_1.normalizePathForEsbuild)(pathWithExt) };
64
+ }
65
+ }
66
+ }
67
+ return;
68
+ });
69
+ },
70
+ };
71
+ }
72
+ //# sourceMappingURL=path-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-plugin.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/path-plugin.ts"],"names":[],"mappings":";;AAWA,0DAiFC;AAvFD,yCAAgD;AAChD,qCAAqC;AACrC,yCAA2D;AAE3D,mCAAkD;AAElD,SAAgB,uBAAuB,CACtC,WAA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IAAI,IAAA,oBAAU,EAAC,WAAW,CAAC,EAAE,CAAC;4BAC7B,MAAM,EAAE,KAAK,CACZ,+BAA+B,IAAI,CAAC,IAAI,OAAO,WAAW,EAAE,CAC5D,CAAC;4BACF,OAAO,EAAE,IAAI,EAAE,IAAA,+BAAuB,EAAC,WAAW,CAAC,EAAE,CAAC;wBACvD,CAAC;oBACF,CAAC;gBACF,CAAC;gBAED,IAAI,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAClD,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,eAAe,EAAE,YAAY,CAAC,CAAC;oBACxD,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;oBACtD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;wBAC9B,MAAM,WAAW,GAAG,IAAA,qBAAS,EAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;wBAC/D,IAAI,IAAA,oBAAU,EAAC,WAAW,CAAC,EAAE,CAAC;4BAC7B,MAAM,EAAE,KAAK,CACZ,yCAAyC,IAAI,CAAC,IAAI,OAAO,WAAW,EAAE,CACtE,CAAC;4BACF,OAAO,EAAE,IAAI,EAAE,IAAA,+BAAuB,EAAC,WAAW,CAAC,EAAE,CAAC;wBACvD,CAAC;oBACF,CAAC;gBACF,CAAC;gBACD,OAAO;YACR,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentExportResult, ModuleExport } from "../agent-loader.types";
2
+ export declare function resolveAgentExport(mod: ModuleExport): Promise<AgentExportResult>;
3
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,iBAAiB,EAEjB,YAAY,EACZ,MAAM,uBAAuB,CAAC;AAyK/B,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,YAAY,GACf,OAAO,CAAC,iBAAiB,CAAC,CAyB5B"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAgentExport = resolveAgentExport;
4
+ function isLikelyAgentInstance(obj) {
5
+ return (obj != null &&
6
+ typeof obj === "object" &&
7
+ typeof obj.name === "string" &&
8
+ typeof obj.runAsync === "function");
9
+ }
10
+ function isAgentBuilder(obj) {
11
+ return (obj != null &&
12
+ typeof obj === "object" &&
13
+ typeof obj.build === "function" &&
14
+ typeof obj.withModel === "function");
15
+ }
16
+ function isBuiltAgent(obj) {
17
+ return (obj != null &&
18
+ typeof obj === "object" &&
19
+ "agent" in obj &&
20
+ "runner" in obj &&
21
+ "session" in obj);
22
+ }
23
+ function isPrimitive(v) {
24
+ return v == null || ["string", "number", "boolean"].includes(typeof v);
25
+ }
26
+ async function invokeFunctionSafely(fn) {
27
+ let result = fn();
28
+ if (result && typeof result === "object" && "then" in result) {
29
+ try {
30
+ result = await result;
31
+ }
32
+ catch (e) {
33
+ throw new Error(`Failed to await function result: ${e instanceof Error ? e.message : String(e)}`);
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ async function extractBaseAgent(item) {
39
+ if (isLikelyAgentInstance(item))
40
+ return { agent: item };
41
+ if (isAgentBuilder(item)) {
42
+ const built = await item.build();
43
+ return { agent: built.agent, builtAgent: built };
44
+ }
45
+ if (isBuiltAgent(item)) {
46
+ const builtItem = item;
47
+ return { agent: builtItem.agent, builtAgent: builtItem };
48
+ }
49
+ return null;
50
+ }
51
+ async function scanModuleExports(mod) {
52
+ for (const [key, value] of Object.entries(mod)) {
53
+ if (key === "default")
54
+ continue;
55
+ const keyLower = key.toLowerCase();
56
+ if (isPrimitive(value))
57
+ continue;
58
+ const result = await extractBaseAgent(value);
59
+ if (result)
60
+ return result;
61
+ if (value && typeof value === "object" && "agent" in value) {
62
+ const container = value;
63
+ const containerResult = await extractBaseAgent(container.agent);
64
+ if (containerResult)
65
+ return containerResult;
66
+ }
67
+ if (typeof value === "function" &&
68
+ (() => {
69
+ if (/(agent|build|create)/i.test(keyLower))
70
+ return true;
71
+ const fnLike = value;
72
+ const fnName = fnLike?.name;
73
+ return !!(fnName && /(agent|build|create)/i.test(fnName.toLowerCase()));
74
+ })()) {
75
+ try {
76
+ const functionResult = await invokeFunctionSafely(value);
77
+ const r = await extractBaseAgent(functionResult);
78
+ if (r)
79
+ return r;
80
+ if (functionResult &&
81
+ typeof functionResult === "object" &&
82
+ "agent" in functionResult) {
83
+ const containerResult = await extractBaseAgent(functionResult.agent);
84
+ if (containerResult)
85
+ return containerResult;
86
+ }
87
+ }
88
+ catch {
89
+ // swallow
90
+ }
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ async function tryResolvingDirectCandidate(candidateToResolve, mod) {
96
+ if (isPrimitive(candidateToResolve) ||
97
+ (candidateToResolve && candidateToResolve === mod)) {
98
+ return null;
99
+ }
100
+ const result = await extractBaseAgent(candidateToResolve);
101
+ if (result)
102
+ return result;
103
+ if (candidateToResolve &&
104
+ typeof candidateToResolve === "object" &&
105
+ "agent" in candidateToResolve) {
106
+ const container = candidateToResolve;
107
+ return await extractBaseAgent(container.agent);
108
+ }
109
+ return null;
110
+ }
111
+ async function tryResolvingFunctionCandidate(functionCandidate) {
112
+ try {
113
+ const functionResult = await invokeFunctionSafely(functionCandidate);
114
+ const r = await extractBaseAgent(functionResult);
115
+ if (r)
116
+ return r;
117
+ if (functionResult &&
118
+ typeof functionResult === "object" &&
119
+ "agent" in functionResult) {
120
+ const containerResult = await extractBaseAgent(functionResult.agent);
121
+ if (containerResult)
122
+ return containerResult;
123
+ }
124
+ }
125
+ catch (e) {
126
+ throw new Error(`Failed executing exported agent function: ${e instanceof Error ? e.message : String(e)}`);
127
+ }
128
+ return null;
129
+ }
130
+ async function resolveAgentExport(mod) {
131
+ const moduleDefault = mod.default && typeof mod.default === "object"
132
+ ? mod.default
133
+ : undefined;
134
+ const candidateToResolve = mod.agent ?? moduleDefault?.agent ?? moduleDefault ?? mod;
135
+ const directResult = await tryResolvingDirectCandidate(candidateToResolve, mod);
136
+ if (directResult)
137
+ return directResult;
138
+ const exportResult = await scanModuleExports(mod);
139
+ if (exportResult)
140
+ return exportResult;
141
+ if (typeof candidateToResolve === "function") {
142
+ const functionResult = await tryResolvingFunctionCandidate(candidateToResolve);
143
+ if (functionResult)
144
+ return functionResult;
145
+ }
146
+ throw new Error("No agent export resolved (expected BaseAgent, AgentBuilder, or BuiltAgent)");
147
+ }
148
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/resolver.ts"],"names":[],"mappings":";;AA8KA,gDA2BC;AAlMD,SAAS,qBAAqB,CAAC,GAAY;IAC1C,OAAO,CACN,GAAG,IAAI,IAAI;QACX,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAQ,GAAiB,CAAC,IAAI,KAAK,QAAQ;QAC3C,OAAQ,GAAiB,CAAC,QAAQ,KAAK,UAAU,CACjD,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,GAAY;IACnC,OAAO,CACN,GAAG,IAAI,IAAI;QACX,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAQ,GAAoB,CAAC,KAAK,KAAK,UAAU;QACjD,OAAQ,GAAoB,CAAC,SAAS,KAAK,UAAU,CACrD,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAY;IACjC,OAAO,CACN,GAAG,IAAI,IAAI;QACX,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,I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M,gBAAgB,CAC5C,cAAqC,CAAC,KAAK,CAC5C,CAAC;YACF,IAAI,eAAe;gBAAE,OAAO,eAAe,CAAC;QAC7C,CAAC;IACF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACd,6CAA6C,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CACzF,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACvC,GAAiB;IAEjB,MAAM,aAAa,GAClB,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAC7C,CAAC,CAAE,GAAG,CAAC,OAAwB;QAC/B,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,kBAAkB,GACvB,GAAG,CAAC,KAAK,IAAI,aAAa,EAAE,KAAK,IAAI,aAAa,IAAI,GAAG,CAAC;IAE3D,MAAM,YAAY,GAAG,MAAM,2BAA2B,CACrD,kBAAkB,EAClB,GAAG,CACH,CAAC;IACF,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IAEtC,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IAEtC,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,cAAc,GACnB,MAAM,6BAA6B,CAAC,kBAAkB,CAAC,CAAC;QACzD,IAAI,cAAc;YAAE,OAAO,cAAc,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,KAAK,CACd,4EAA4E,CAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TsConfigPaths } from "../agent-loader.types";
2
+ import type { Logger } from "@nestjs/common";
3
+ export declare function parseTsConfigPaths(projectRoot: string, logger?: Logger): TsConfigPaths;
4
+ //# sourceMappingURL=tsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GACb,aAAa,CA0Bf"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTsConfigPaths = parseTsConfigPaths;
4
+ const agent_loader_types_1 = require("../agent-loader.types");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ function parseTsConfigPaths(projectRoot, logger) {
8
+ const tsconfigPath = (0, node_path_1.join)(projectRoot, "tsconfig.json");
9
+ if (!(0, node_fs_1.existsSync)(tsconfigPath)) {
10
+ return {};
11
+ }
12
+ try {
13
+ const tsconfigContent = (0, node_fs_1.readFileSync)(tsconfigPath, "utf-8");
14
+ const tsconfigJson = JSON.parse(tsconfigContent);
15
+ const parsed = agent_loader_types_1.TsConfigSchema.safeParse(tsconfigJson);
16
+ if (!parsed.success) {
17
+ logger?.warn(`Invalid tsconfig.json structure: ${parsed.error.message}`);
18
+ return {};
19
+ }
20
+ const compilerOptions = parsed.data.compilerOptions || {};
21
+ return {
22
+ baseUrl: compilerOptions.baseUrl,
23
+ paths: compilerOptions.paths,
24
+ };
25
+ }
26
+ catch (error) {
27
+ const msg = error instanceof Error ? error.message : String(error);
28
+ logger?.warn(`Failed to parse tsconfig.json: ${msg}`);
29
+ return {};
30
+ }
31
+ }
32
+ //# sourceMappingURL=tsconfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/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 -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizePathForEsbuild = normalizePathForEsbuild;
4
+ function normalizePathForEsbuild(path) {
5
+ return path.replace(/\\/g, "/");
6
+ }
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/http/providers/agent-loader/utils.ts"],"names":[],"mappings":";;AAAA,0DAEC;AAFD,SAAgB,uBAAuB,CAAC,IAAY;IACnD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
@@ -24,18 +24,6 @@ export declare class AgentLoader {
24
24
  * Normalize path to use forward slashes (cross-platform)
25
25
  */
26
26
  private normalizePath;
27
- /**
28
- * Parse TypeScript path mappings from tsconfig.json
29
- */
30
- private parseTsConfigPaths;
31
- /**
32
- * Create an esbuild plugin to handle TypeScript path mappings and relative imports
33
- */
34
- private createPathMappingPlugin;
35
- /**
36
- * Check if a rebuild is needed based on file modification times
37
- */
38
- private isRebuildNeeded;
39
27
  /**
40
28
  * Import a TypeScript file by compiling it on-demand
41
29
  * @param filePath - Path to the TypeScript file
@@ -44,46 +32,6 @@ export declare class AgentLoader {
44
32
  */
45
33
  importTypeScriptFile(filePath: string, providedProjectRoot?: string, forceInvalidateCache?: boolean): Promise<ModuleExport>;
46
34
  loadEnvironmentVariables(agentFilePath: string): void;
47
- /**
48
- * Type guard to check if object is likely a BaseAgent instance
49
- */
50
- private isLikelyAgentInstance;
51
- /**
52
- * Type guard to check if object is an AgentBuilder
53
- */
54
- private isAgentBuilder;
55
- /**
56
- * Type guard to check if object is a BuiltAgent
57
- */
58
- private isBuiltAgent;
59
- /**
60
- * Type guard to check if value is a primitive type
61
- */
62
- private isPrimitive;
63
- /**
64
- * Safely invoke a function, handling both sync and async results
65
- */
66
- private invokeFunctionSafely;
67
- /**
68
- * Extract BaseAgent from different possible types
69
- * Returns both the agent and the full built context (if available)
70
- *
71
- * Note: `unknown` here is legitimate - we're dynamically inspecting module exports
72
- * from dynamically loaded code where the actual types are determined at runtime.
73
- */
74
- private extractBaseAgent;
75
- /**
76
- * Search through module exports to find potential agent exports
77
- */
78
- private scanModuleExports;
79
35
  resolveAgentExport(mod: ModuleExport): Promise<AgentExportResult>;
80
- /**
81
- * Try to resolve a direct candidate (not from scanning exports)
82
- */
83
- private tryResolvingDirectCandidate;
84
- /**
85
- * Try to resolve a function candidate by invoking it
86
- */
87
- private tryResolvingFunctionCandidate;
88
36
  }
89
37
  //# sourceMappingURL=agent-loader.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-loader.service.d.ts","sourceRoot":"","sources":["../../../src/http/providers/agent-loader.service.ts"],"names":[],"mappings":"AAaA,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EACX,iBAAiB,EAKjB,YAAY,EAGZ,MAAM,sBAAsB,CAAC;AAK9B,qBACa,WAAW;IAMX,OAAO,CAAC,KAAK;IALzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAS;IAC9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAqB;IACpD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAqB;gBAE5B,KAAK,UAAQ;IAKjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI;IAoCjE;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA+B1B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAkF/B;;OAEG;IACH,OAAO,CAAC,eAAe;IAsCvB;;;;;OAKG;IACG,oBAAoB,CACzB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,oBAAoB,CAAC,EAAE,OAAO,GAC5B,OAAO,CAAC,YAAY,CAAC;IA6LxB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IA6CrD;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;YACW,oBAAoB;IAgBlC;;;;;;OAMG;YACW,gBAAgB;IAoB9B;;OAEG;YACW,iBAAiB;IA8DzB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkCvE;;OAEG;YACW,2BAA2B;IA4BzC;;OAEG;YACW,6BAA6B;CAmC3C"}
1
+ {"version":3,"file":"agent-loader.service.d.ts","sourceRoot":"","sources":["../../../src/http/providers/agent-loader.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAUpD,OAAO,KAAK,EACX,iBAAiB,EACjB,YAAY,EAEZ,MAAM,sBAAsB,CAAC;AAI9B,qBACa,WAAW;IAMX,OAAO,CAAC,KAAK;IALzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAS;IAC9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAqB;IACpD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAqB;gBAE5B,KAAK,UAAQ;IAKjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;;OAGG;IACH,MAAM,CAAC,oBA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