@dexto/agent-management 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -0
- package/dist/AgentOrchestrator.cjs +263 -0
- package/dist/AgentOrchestrator.d.ts +191 -0
- package/dist/AgentOrchestrator.d.ts.map +1 -0
- package/dist/AgentOrchestrator.js +239 -0
- package/dist/config/config-enrichment.cjs +117 -0
- package/dist/config/config-enrichment.d.ts +31 -0
- package/dist/config/config-enrichment.d.ts.map +1 -0
- package/dist/config/config-enrichment.js +82 -0
- package/dist/config/config-manager.cjs +57 -0
- package/dist/config/config-manager.d.ts +51 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +32 -0
- package/dist/config/error-codes.cjs +39 -0
- package/dist/config/error-codes.d.ts +16 -0
- package/dist/config/error-codes.d.ts.map +1 -0
- package/dist/config/error-codes.js +15 -0
- package/dist/config/errors.cjs +125 -0
- package/dist/config/errors.d.ts +34 -0
- package/dist/config/errors.d.ts.map +1 -0
- package/dist/config/errors.js +101 -0
- package/dist/config/index.cjs +44 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +14 -0
- package/dist/config/loader.cjs +118 -0
- package/dist/config/loader.d.ts +18 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +84 -0
- package/dist/index.cjs +132 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/preferences/constants.cjs +28 -0
- package/dist/preferences/constants.d.ts +2 -0
- package/dist/preferences/constants.d.ts.map +1 -0
- package/dist/preferences/constants.js +4 -0
- package/dist/preferences/error-codes.cjs +35 -0
- package/dist/preferences/error-codes.d.ts +8 -0
- package/dist/preferences/error-codes.d.ts.map +1 -0
- package/dist/preferences/error-codes.js +11 -0
- package/dist/preferences/errors.cjs +74 -0
- package/dist/preferences/errors.d.ts +18 -0
- package/dist/preferences/errors.d.ts.map +1 -0
- package/dist/preferences/errors.js +49 -0
- package/dist/preferences/index.cjs +55 -0
- package/dist/preferences/index.d.ts +6 -0
- package/dist/preferences/index.d.ts.map +1 -0
- package/dist/preferences/index.js +31 -0
- package/dist/preferences/loader.cjs +138 -0
- package/dist/preferences/loader.d.ts +50 -0
- package/dist/preferences/loader.d.ts.map +1 -0
- package/dist/preferences/loader.js +109 -0
- package/dist/preferences/schemas.cjs +75 -0
- package/dist/preferences/schemas.d.ts +110 -0
- package/dist/preferences/schemas.d.ts.map +1 -0
- package/dist/preferences/schemas.js +48 -0
- package/dist/registry/error-codes.cjs +44 -0
- package/dist/registry/error-codes.d.ts +21 -0
- package/dist/registry/error-codes.d.ts.map +1 -0
- package/dist/registry/error-codes.js +20 -0
- package/dist/registry/errors.cjs +187 -0
- package/dist/registry/errors.d.ts +63 -0
- package/dist/registry/errors.d.ts.map +1 -0
- package/dist/registry/errors.js +163 -0
- package/dist/registry/registry.cjs +479 -0
- package/dist/registry/registry.d.ts +130 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +452 -0
- package/dist/registry/types.cjs +74 -0
- package/dist/registry/types.d.ts +142 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +47 -0
- package/dist/registry/user-registry.cjs +140 -0
- package/dist/registry/user-registry.d.ts +34 -0
- package/dist/registry/user-registry.d.ts.map +1 -0
- package/dist/registry/user-registry.js +104 -0
- package/dist/resolver.cjs +182 -0
- package/dist/resolver.d.ts +14 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +151 -0
- package/dist/utils/api-key-resolver.cjs +62 -0
- package/dist/utils/api-key-resolver.d.ts +21 -0
- package/dist/utils/api-key-resolver.d.ts.map +1 -0
- package/dist/utils/api-key-resolver.js +36 -0
- package/dist/utils/api-key-store.cjs +56 -0
- package/dist/utils/api-key-store.d.ts +18 -0
- package/dist/utils/api-key-store.d.ts.map +1 -0
- package/dist/utils/api-key-store.js +30 -0
- package/dist/utils/env-file.cjs +118 -0
- package/dist/utils/env-file.d.ts +5 -0
- package/dist/utils/env-file.d.ts.map +1 -0
- package/dist/utils/env-file.js +84 -0
- package/dist/utils/execution-context.cjs +85 -0
- package/dist/utils/execution-context.d.ts +20 -0
- package/dist/utils/execution-context.d.ts.map +1 -0
- package/dist/utils/execution-context.js +49 -0
- package/dist/utils/fs-walk.cjs +52 -0
- package/dist/utils/fs-walk.d.ts +8 -0
- package/dist/utils/fs-walk.d.ts.map +1 -0
- package/dist/utils/fs-walk.js +18 -0
- package/dist/utils/path.cjs +205 -0
- package/dist/utils/path.d.ts +58 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +167 -0
- package/dist/writer.cjs +182 -0
- package/dist/writer.d.ts +34 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +146 -0
- package/package.json +41 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var ConfigErrorCode = /* @__PURE__ */ ((ConfigErrorCode2) => {
|
|
2
|
+
ConfigErrorCode2["FILE_NOT_FOUND"] = "config_file_not_found";
|
|
3
|
+
ConfigErrorCode2["FILE_READ_ERROR"] = "config_file_read_error";
|
|
4
|
+
ConfigErrorCode2["FILE_WRITE_ERROR"] = "config_file_write_error";
|
|
5
|
+
ConfigErrorCode2["PARSE_ERROR"] = "config_parse_error";
|
|
6
|
+
ConfigErrorCode2["NO_PROJECT_DEFAULT"] = "config_no_project_default";
|
|
7
|
+
ConfigErrorCode2["NO_GLOBAL_PREFERENCES"] = "config_no_global_preferences";
|
|
8
|
+
ConfigErrorCode2["SETUP_INCOMPLETE"] = "config_setup_incomplete";
|
|
9
|
+
ConfigErrorCode2["BUNDLED_NOT_FOUND"] = "config_bundled_not_found";
|
|
10
|
+
ConfigErrorCode2["UNKNOWN_CONTEXT"] = "config_unknown_context";
|
|
11
|
+
return ConfigErrorCode2;
|
|
12
|
+
})(ConfigErrorCode || {});
|
|
13
|
+
export {
|
|
14
|
+
ConfigErrorCode
|
|
15
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
ConfigError: () => ConfigError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
var import_core = require("@dexto/core");
|
|
25
|
+
var import_error_codes = require("./error-codes.js");
|
|
26
|
+
class ConfigError {
|
|
27
|
+
// File operation errors
|
|
28
|
+
static fileNotFound(configPath) {
|
|
29
|
+
return new import_core.DextoRuntimeError(
|
|
30
|
+
import_error_codes.ConfigErrorCode.FILE_NOT_FOUND,
|
|
31
|
+
import_core.ErrorScope.CONFIG,
|
|
32
|
+
import_core.ErrorType.USER,
|
|
33
|
+
`Configuration file not found: ${configPath}`,
|
|
34
|
+
{ configPath },
|
|
35
|
+
"Ensure the configuration file exists at the specified path"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
static fileReadError(configPath, cause) {
|
|
39
|
+
return new import_core.DextoRuntimeError(
|
|
40
|
+
import_error_codes.ConfigErrorCode.FILE_READ_ERROR,
|
|
41
|
+
import_core.ErrorScope.CONFIG,
|
|
42
|
+
import_core.ErrorType.SYSTEM,
|
|
43
|
+
`Failed to read configuration file: ${cause}`,
|
|
44
|
+
{ configPath, cause },
|
|
45
|
+
"Check file permissions and ensure the file is not corrupted"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
static fileWriteError(configPath, cause) {
|
|
49
|
+
return new import_core.DextoRuntimeError(
|
|
50
|
+
import_error_codes.ConfigErrorCode.FILE_WRITE_ERROR,
|
|
51
|
+
import_core.ErrorScope.CONFIG,
|
|
52
|
+
import_core.ErrorType.SYSTEM,
|
|
53
|
+
`Failed to write configuration file '${configPath}': ${cause}`,
|
|
54
|
+
{ configPath, cause },
|
|
55
|
+
"Check file permissions and available disk space"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
// Parsing errors
|
|
59
|
+
static parseError(configPath, cause) {
|
|
60
|
+
return new import_core.DextoRuntimeError(
|
|
61
|
+
import_error_codes.ConfigErrorCode.PARSE_ERROR,
|
|
62
|
+
import_core.ErrorScope.CONFIG,
|
|
63
|
+
import_core.ErrorType.USER,
|
|
64
|
+
`Failed to parse configuration file: ${cause}`,
|
|
65
|
+
{ configPath, cause },
|
|
66
|
+
"Ensure the configuration file contains valid YAML syntax"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
// Resolution errors
|
|
70
|
+
static noProjectDefault(projectPath) {
|
|
71
|
+
return new import_core.DextoRuntimeError(
|
|
72
|
+
import_error_codes.ConfigErrorCode.NO_PROJECT_DEFAULT,
|
|
73
|
+
import_core.ErrorScope.CONFIG,
|
|
74
|
+
import_core.ErrorType.USER,
|
|
75
|
+
`No project default-agent.yml found and no global preferences configured.
|
|
76
|
+
Either create default-agent.yml in your project root (${projectPath}) or run \`dexto setup\` to configure preferences.`,
|
|
77
|
+
{ projectPath },
|
|
78
|
+
"Run `dexto setup` or create a project-specific agent config"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
static noGlobalPreferences() {
|
|
82
|
+
return new import_core.DextoRuntimeError(
|
|
83
|
+
import_error_codes.ConfigErrorCode.NO_GLOBAL_PREFERENCES,
|
|
84
|
+
import_core.ErrorScope.CONFIG,
|
|
85
|
+
import_core.ErrorType.USER,
|
|
86
|
+
`No global preferences found. Run \`dexto setup\` to get started.`,
|
|
87
|
+
{},
|
|
88
|
+
"Run `dexto setup` to configure your AI preferences"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
static setupIncomplete() {
|
|
92
|
+
return new import_core.DextoRuntimeError(
|
|
93
|
+
import_error_codes.ConfigErrorCode.SETUP_INCOMPLETE,
|
|
94
|
+
import_core.ErrorScope.CONFIG,
|
|
95
|
+
import_core.ErrorType.USER,
|
|
96
|
+
`Global preferences setup is incomplete. Run \`dexto setup\` to complete.`,
|
|
97
|
+
{},
|
|
98
|
+
"Run `dexto setup` to complete your configuration"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
static bundledNotFound(bundledPath) {
|
|
102
|
+
return new import_core.DextoRuntimeError(
|
|
103
|
+
import_error_codes.ConfigErrorCode.BUNDLED_NOT_FOUND,
|
|
104
|
+
import_core.ErrorScope.CONFIG,
|
|
105
|
+
import_core.ErrorType.NOT_FOUND,
|
|
106
|
+
`Bundled default agent not found: ${bundledPath}. Run npm run build first.`,
|
|
107
|
+
{ path: bundledPath },
|
|
108
|
+
"Run `npm run build` to build the bundled agents"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
static unknownContext(context) {
|
|
112
|
+
return new import_core.DextoRuntimeError(
|
|
113
|
+
import_error_codes.ConfigErrorCode.UNKNOWN_CONTEXT,
|
|
114
|
+
import_core.ErrorScope.CONFIG,
|
|
115
|
+
import_core.ErrorType.SYSTEM,
|
|
116
|
+
`Unknown execution context: ${context}`,
|
|
117
|
+
{ context },
|
|
118
|
+
"This is an internal error - please report it"
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
ConfigError
|
|
125
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DextoRuntimeError } from '@dexto/core';
|
|
2
|
+
/**
|
|
3
|
+
* Config runtime error factory methods
|
|
4
|
+
* Creates properly typed errors for configuration operations
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConfigError {
|
|
7
|
+
static fileNotFound(configPath: string): DextoRuntimeError<{
|
|
8
|
+
configPath: string;
|
|
9
|
+
}>;
|
|
10
|
+
static fileReadError(configPath: string, cause: string): DextoRuntimeError<{
|
|
11
|
+
configPath: string;
|
|
12
|
+
cause: string;
|
|
13
|
+
}>;
|
|
14
|
+
static fileWriteError(configPath: string, cause: string): DextoRuntimeError<{
|
|
15
|
+
configPath: string;
|
|
16
|
+
cause: string;
|
|
17
|
+
}>;
|
|
18
|
+
static parseError(configPath: string, cause: string): DextoRuntimeError<{
|
|
19
|
+
configPath: string;
|
|
20
|
+
cause: string;
|
|
21
|
+
}>;
|
|
22
|
+
static noProjectDefault(projectPath: string): DextoRuntimeError<{
|
|
23
|
+
projectPath: string;
|
|
24
|
+
}>;
|
|
25
|
+
static noGlobalPreferences(): DextoRuntimeError<{}>;
|
|
26
|
+
static setupIncomplete(): DextoRuntimeError<{}>;
|
|
27
|
+
static bundledNotFound(bundledPath: string): DextoRuntimeError<{
|
|
28
|
+
path: string;
|
|
29
|
+
}>;
|
|
30
|
+
static unknownContext(context: string): DextoRuntimeError<{
|
|
31
|
+
context: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/config/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,aAAa,CAAC;AAGvE;;;GAGG;AACH,qBAAa,WAAW;IAEpB,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM;;;IAWtC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAWtD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAYvD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAYnD,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM;;;IAW3C,MAAM,CAAC,mBAAmB;IAW1B,MAAM,CAAC,eAAe;IAWtB,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM;;;IAW1C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM;;;CAUxC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DextoRuntimeError, ErrorScope, ErrorType } from "@dexto/core";
|
|
2
|
+
import { ConfigErrorCode } from "./error-codes.js";
|
|
3
|
+
class ConfigError {
|
|
4
|
+
// File operation errors
|
|
5
|
+
static fileNotFound(configPath) {
|
|
6
|
+
return new DextoRuntimeError(
|
|
7
|
+
ConfigErrorCode.FILE_NOT_FOUND,
|
|
8
|
+
ErrorScope.CONFIG,
|
|
9
|
+
ErrorType.USER,
|
|
10
|
+
`Configuration file not found: ${configPath}`,
|
|
11
|
+
{ configPath },
|
|
12
|
+
"Ensure the configuration file exists at the specified path"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
static fileReadError(configPath, cause) {
|
|
16
|
+
return new DextoRuntimeError(
|
|
17
|
+
ConfigErrorCode.FILE_READ_ERROR,
|
|
18
|
+
ErrorScope.CONFIG,
|
|
19
|
+
ErrorType.SYSTEM,
|
|
20
|
+
`Failed to read configuration file: ${cause}`,
|
|
21
|
+
{ configPath, cause },
|
|
22
|
+
"Check file permissions and ensure the file is not corrupted"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
static fileWriteError(configPath, cause) {
|
|
26
|
+
return new DextoRuntimeError(
|
|
27
|
+
ConfigErrorCode.FILE_WRITE_ERROR,
|
|
28
|
+
ErrorScope.CONFIG,
|
|
29
|
+
ErrorType.SYSTEM,
|
|
30
|
+
`Failed to write configuration file '${configPath}': ${cause}`,
|
|
31
|
+
{ configPath, cause },
|
|
32
|
+
"Check file permissions and available disk space"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
// Parsing errors
|
|
36
|
+
static parseError(configPath, cause) {
|
|
37
|
+
return new DextoRuntimeError(
|
|
38
|
+
ConfigErrorCode.PARSE_ERROR,
|
|
39
|
+
ErrorScope.CONFIG,
|
|
40
|
+
ErrorType.USER,
|
|
41
|
+
`Failed to parse configuration file: ${cause}`,
|
|
42
|
+
{ configPath, cause },
|
|
43
|
+
"Ensure the configuration file contains valid YAML syntax"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
// Resolution errors
|
|
47
|
+
static noProjectDefault(projectPath) {
|
|
48
|
+
return new DextoRuntimeError(
|
|
49
|
+
ConfigErrorCode.NO_PROJECT_DEFAULT,
|
|
50
|
+
ErrorScope.CONFIG,
|
|
51
|
+
ErrorType.USER,
|
|
52
|
+
`No project default-agent.yml found and no global preferences configured.
|
|
53
|
+
Either create default-agent.yml in your project root (${projectPath}) or run \`dexto setup\` to configure preferences.`,
|
|
54
|
+
{ projectPath },
|
|
55
|
+
"Run `dexto setup` or create a project-specific agent config"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
static noGlobalPreferences() {
|
|
59
|
+
return new DextoRuntimeError(
|
|
60
|
+
ConfigErrorCode.NO_GLOBAL_PREFERENCES,
|
|
61
|
+
ErrorScope.CONFIG,
|
|
62
|
+
ErrorType.USER,
|
|
63
|
+
`No global preferences found. Run \`dexto setup\` to get started.`,
|
|
64
|
+
{},
|
|
65
|
+
"Run `dexto setup` to configure your AI preferences"
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
static setupIncomplete() {
|
|
69
|
+
return new DextoRuntimeError(
|
|
70
|
+
ConfigErrorCode.SETUP_INCOMPLETE,
|
|
71
|
+
ErrorScope.CONFIG,
|
|
72
|
+
ErrorType.USER,
|
|
73
|
+
`Global preferences setup is incomplete. Run \`dexto setup\` to complete.`,
|
|
74
|
+
{},
|
|
75
|
+
"Run `dexto setup` to complete your configuration"
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
static bundledNotFound(bundledPath) {
|
|
79
|
+
return new DextoRuntimeError(
|
|
80
|
+
ConfigErrorCode.BUNDLED_NOT_FOUND,
|
|
81
|
+
ErrorScope.CONFIG,
|
|
82
|
+
ErrorType.NOT_FOUND,
|
|
83
|
+
`Bundled default agent not found: ${bundledPath}. Run npm run build first.`,
|
|
84
|
+
{ path: bundledPath },
|
|
85
|
+
"Run `npm run build` to build the bundled agents"
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
static unknownContext(context) {
|
|
89
|
+
return new DextoRuntimeError(
|
|
90
|
+
ConfigErrorCode.UNKNOWN_CONTEXT,
|
|
91
|
+
ErrorScope.CONFIG,
|
|
92
|
+
ErrorType.SYSTEM,
|
|
93
|
+
`Unknown execution context: ${context}`,
|
|
94
|
+
{ context },
|
|
95
|
+
"This is an internal error - please report it"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
ConfigError
|
|
101
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
ConfigError: () => import_errors.ConfigError,
|
|
22
|
+
ConfigErrorCode: () => import_error_codes.ConfigErrorCode,
|
|
23
|
+
deriveAgentId: () => import_config_enrichment.deriveAgentId,
|
|
24
|
+
enrichAgentConfig: () => import_config_enrichment.enrichAgentConfig,
|
|
25
|
+
loadAgentConfig: () => import_loader.loadAgentConfig,
|
|
26
|
+
reloadAgentConfigFromFile: () => import_config_manager.reloadAgentConfigFromFile,
|
|
27
|
+
updateAgentConfigFile: () => import_config_manager.updateAgentConfigFile
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(config_exports);
|
|
30
|
+
var import_config_manager = require("./config-manager.js");
|
|
31
|
+
var import_loader = require("./loader.js");
|
|
32
|
+
var import_config_enrichment = require("./config-enrichment.js");
|
|
33
|
+
var import_errors = require("./errors.js");
|
|
34
|
+
var import_error_codes = require("./error-codes.js");
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
ConfigError,
|
|
38
|
+
ConfigErrorCode,
|
|
39
|
+
deriveAgentId,
|
|
40
|
+
enrichAgentConfig,
|
|
41
|
+
loadAgentConfig,
|
|
42
|
+
reloadAgentConfigFromFile,
|
|
43
|
+
updateAgentConfigFile
|
|
44
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { updateAgentConfigFile, reloadAgentConfigFromFile } from './config-manager.js';
|
|
2
|
+
export { loadAgentConfig } from './loader.js';
|
|
3
|
+
export { enrichAgentConfig, deriveAgentId } from './config-enrichment.js';
|
|
4
|
+
export { ConfigError } from './errors.js';
|
|
5
|
+
export { ConfigErrorCode } from './error-codes.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { updateAgentConfigFile, reloadAgentConfigFromFile } from "./config-manager.js";
|
|
2
|
+
import { loadAgentConfig } from "./loader.js";
|
|
3
|
+
import { enrichAgentConfig, deriveAgentId } from "./config-enrichment.js";
|
|
4
|
+
import { ConfigError } from "./errors.js";
|
|
5
|
+
import { ConfigErrorCode } from "./error-codes.js";
|
|
6
|
+
export {
|
|
7
|
+
ConfigError,
|
|
8
|
+
ConfigErrorCode,
|
|
9
|
+
deriveAgentId,
|
|
10
|
+
enrichAgentConfig,
|
|
11
|
+
loadAgentConfig,
|
|
12
|
+
reloadAgentConfigFromFile,
|
|
13
|
+
updateAgentConfigFile
|
|
14
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var loader_exports = {};
|
|
30
|
+
__export(loader_exports, {
|
|
31
|
+
loadAgentConfig: () => loadAgentConfig
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(loader_exports);
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_path = __toESM(require("path"), 1);
|
|
36
|
+
var import_yaml = require("yaml");
|
|
37
|
+
var import_errors = require("./errors.js");
|
|
38
|
+
function expandTemplateVars(config, agentDir) {
|
|
39
|
+
const result = JSON.parse(JSON.stringify(config));
|
|
40
|
+
function walk(obj) {
|
|
41
|
+
if (typeof obj === "string") {
|
|
42
|
+
return expandString(obj, agentDir);
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(obj)) {
|
|
45
|
+
return obj.map(walk);
|
|
46
|
+
}
|
|
47
|
+
if (obj !== null && typeof obj === "object") {
|
|
48
|
+
const result2 = {};
|
|
49
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
50
|
+
result2[key] = walk(value);
|
|
51
|
+
}
|
|
52
|
+
return result2;
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
return walk(result);
|
|
57
|
+
}
|
|
58
|
+
function expandString(str, agentDir) {
|
|
59
|
+
const result = str.replace(/\${{\s*dexto\.agent_dir\s*}}/g, agentDir);
|
|
60
|
+
if (result !== str) {
|
|
61
|
+
validateExpandedPath(str, result, agentDir);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
function validateExpandedPath(original, expanded, agentDir) {
|
|
66
|
+
const resolved = import_path.default.resolve(expanded);
|
|
67
|
+
const agentRoot = import_path.default.resolve(agentDir);
|
|
68
|
+
const relative = import_path.default.relative(agentRoot, resolved);
|
|
69
|
+
if (relative.startsWith("..") || import_path.default.isAbsolute(relative)) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Security: Template expansion attempted to escape agent directory.
|
|
72
|
+
Original: ${original}
|
|
73
|
+
Expanded: ${expanded}
|
|
74
|
+
Agent root: ${agentRoot}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function loadAgentConfig(configPath, logger) {
|
|
79
|
+
const absolutePath = import_path.default.resolve(configPath);
|
|
80
|
+
try {
|
|
81
|
+
await import_fs.promises.access(absolutePath);
|
|
82
|
+
} catch (_error) {
|
|
83
|
+
throw import_errors.ConfigError.fileNotFound(absolutePath);
|
|
84
|
+
}
|
|
85
|
+
let fileContent;
|
|
86
|
+
try {
|
|
87
|
+
fileContent = await import_fs.promises.readFile(absolutePath, "utf-8");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw import_errors.ConfigError.fileReadError(
|
|
90
|
+
absolutePath,
|
|
91
|
+
error instanceof Error ? error.message : String(error)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
let config;
|
|
95
|
+
try {
|
|
96
|
+
config = (0, import_yaml.parse)(fileContent);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw import_errors.ConfigError.parseError(
|
|
99
|
+
absolutePath,
|
|
100
|
+
error instanceof Error ? error.message : String(error)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const agentDir = import_path.default.dirname(absolutePath);
|
|
105
|
+
config = expandTemplateVars(config, agentDir);
|
|
106
|
+
logger?.debug(`Expanded template variables for agent in: ${agentDir}`);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
throw import_errors.ConfigError.parseError(
|
|
109
|
+
absolutePath,
|
|
110
|
+
`Template expansion failed: ${error instanceof Error ? error.message : String(error)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
loadAgentConfig
|
|
118
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentConfig } from '@dexto/core';
|
|
2
|
+
import type { IDextoLogger } from '@dexto/core';
|
|
3
|
+
/**
|
|
4
|
+
* Asynchronously loads and processes an agent configuration file.
|
|
5
|
+
* This function handles file reading, YAML parsing, and template variable expansion.
|
|
6
|
+
* Environment variable expansion is handled by the Zod schema during validation.
|
|
7
|
+
*
|
|
8
|
+
* Note: Path resolution should be done before calling this function using resolveConfigPath().
|
|
9
|
+
*
|
|
10
|
+
* @param configPath - Path to the configuration file (absolute or relative)
|
|
11
|
+
* @param logger - logger instance for logging
|
|
12
|
+
* @returns A Promise that resolves to the parsed `AgentConfig` object with template variables expanded
|
|
13
|
+
* @throws {ConfigError} with FILE_NOT_FOUND if the configuration file does not exist
|
|
14
|
+
* @throws {ConfigError} with FILE_READ_ERROR if file read fails (e.g., permissions issues)
|
|
15
|
+
* @throws {ConfigError} with PARSE_ERROR if the content is not valid YAML or template expansion fails
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadAgentConfig(configPath: string, logger?: IDextoLogger): Promise<AgentConfig>;
|
|
18
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgEhD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,YAAY,GACtB,OAAO,CAAC,WAAW,CAAC,CAuDtB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { ConfigError } from "./errors.js";
|
|
5
|
+
function expandTemplateVars(config, agentDir) {
|
|
6
|
+
const result = JSON.parse(JSON.stringify(config));
|
|
7
|
+
function walk(obj) {
|
|
8
|
+
if (typeof obj === "string") {
|
|
9
|
+
return expandString(obj, agentDir);
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(obj)) {
|
|
12
|
+
return obj.map(walk);
|
|
13
|
+
}
|
|
14
|
+
if (obj !== null && typeof obj === "object") {
|
|
15
|
+
const result2 = {};
|
|
16
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
17
|
+
result2[key] = walk(value);
|
|
18
|
+
}
|
|
19
|
+
return result2;
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
return walk(result);
|
|
24
|
+
}
|
|
25
|
+
function expandString(str, agentDir) {
|
|
26
|
+
const result = str.replace(/\${{\s*dexto\.agent_dir\s*}}/g, agentDir);
|
|
27
|
+
if (result !== str) {
|
|
28
|
+
validateExpandedPath(str, result, agentDir);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function validateExpandedPath(original, expanded, agentDir) {
|
|
33
|
+
const resolved = path.resolve(expanded);
|
|
34
|
+
const agentRoot = path.resolve(agentDir);
|
|
35
|
+
const relative = path.relative(agentRoot, resolved);
|
|
36
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Security: Template expansion attempted to escape agent directory.
|
|
39
|
+
Original: ${original}
|
|
40
|
+
Expanded: ${expanded}
|
|
41
|
+
Agent root: ${agentRoot}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function loadAgentConfig(configPath, logger) {
|
|
46
|
+
const absolutePath = path.resolve(configPath);
|
|
47
|
+
try {
|
|
48
|
+
await fs.access(absolutePath);
|
|
49
|
+
} catch (_error) {
|
|
50
|
+
throw ConfigError.fileNotFound(absolutePath);
|
|
51
|
+
}
|
|
52
|
+
let fileContent;
|
|
53
|
+
try {
|
|
54
|
+
fileContent = await fs.readFile(absolutePath, "utf-8");
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw ConfigError.fileReadError(
|
|
57
|
+
absolutePath,
|
|
58
|
+
error instanceof Error ? error.message : String(error)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
let config;
|
|
62
|
+
try {
|
|
63
|
+
config = parseYaml(fileContent);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw ConfigError.parseError(
|
|
66
|
+
absolutePath,
|
|
67
|
+
error instanceof Error ? error.message : String(error)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const agentDir = path.dirname(absolutePath);
|
|
72
|
+
config = expandTemplateVars(config, agentDir);
|
|
73
|
+
logger?.debug(`Expanded template variables for agent in: ${agentDir}`);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw ConfigError.parseError(
|
|
76
|
+
absolutePath,
|
|
77
|
+
`Template expansion failed: ${error instanceof Error ? error.message : String(error)}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return config;
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
loadAgentConfig
|
|
84
|
+
};
|