@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.
Files changed (110) hide show
  1. package/LICENSE +44 -0
  2. package/dist/AgentOrchestrator.cjs +263 -0
  3. package/dist/AgentOrchestrator.d.ts +191 -0
  4. package/dist/AgentOrchestrator.d.ts.map +1 -0
  5. package/dist/AgentOrchestrator.js +239 -0
  6. package/dist/config/config-enrichment.cjs +117 -0
  7. package/dist/config/config-enrichment.d.ts +31 -0
  8. package/dist/config/config-enrichment.d.ts.map +1 -0
  9. package/dist/config/config-enrichment.js +82 -0
  10. package/dist/config/config-manager.cjs +57 -0
  11. package/dist/config/config-manager.d.ts +51 -0
  12. package/dist/config/config-manager.d.ts.map +1 -0
  13. package/dist/config/config-manager.js +32 -0
  14. package/dist/config/error-codes.cjs +39 -0
  15. package/dist/config/error-codes.d.ts +16 -0
  16. package/dist/config/error-codes.d.ts.map +1 -0
  17. package/dist/config/error-codes.js +15 -0
  18. package/dist/config/errors.cjs +125 -0
  19. package/dist/config/errors.d.ts +34 -0
  20. package/dist/config/errors.d.ts.map +1 -0
  21. package/dist/config/errors.js +101 -0
  22. package/dist/config/index.cjs +44 -0
  23. package/dist/config/index.d.ts +6 -0
  24. package/dist/config/index.d.ts.map +1 -0
  25. package/dist/config/index.js +14 -0
  26. package/dist/config/loader.cjs +118 -0
  27. package/dist/config/loader.d.ts +18 -0
  28. package/dist/config/loader.d.ts.map +1 -0
  29. package/dist/config/loader.js +84 -0
  30. package/dist/index.cjs +132 -0
  31. package/dist/index.d.ts +20 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +104 -0
  34. package/dist/preferences/constants.cjs +28 -0
  35. package/dist/preferences/constants.d.ts +2 -0
  36. package/dist/preferences/constants.d.ts.map +1 -0
  37. package/dist/preferences/constants.js +4 -0
  38. package/dist/preferences/error-codes.cjs +35 -0
  39. package/dist/preferences/error-codes.d.ts +8 -0
  40. package/dist/preferences/error-codes.d.ts.map +1 -0
  41. package/dist/preferences/error-codes.js +11 -0
  42. package/dist/preferences/errors.cjs +74 -0
  43. package/dist/preferences/errors.d.ts +18 -0
  44. package/dist/preferences/errors.d.ts.map +1 -0
  45. package/dist/preferences/errors.js +49 -0
  46. package/dist/preferences/index.cjs +55 -0
  47. package/dist/preferences/index.d.ts +6 -0
  48. package/dist/preferences/index.d.ts.map +1 -0
  49. package/dist/preferences/index.js +31 -0
  50. package/dist/preferences/loader.cjs +138 -0
  51. package/dist/preferences/loader.d.ts +50 -0
  52. package/dist/preferences/loader.d.ts.map +1 -0
  53. package/dist/preferences/loader.js +109 -0
  54. package/dist/preferences/schemas.cjs +75 -0
  55. package/dist/preferences/schemas.d.ts +110 -0
  56. package/dist/preferences/schemas.d.ts.map +1 -0
  57. package/dist/preferences/schemas.js +48 -0
  58. package/dist/registry/error-codes.cjs +44 -0
  59. package/dist/registry/error-codes.d.ts +21 -0
  60. package/dist/registry/error-codes.d.ts.map +1 -0
  61. package/dist/registry/error-codes.js +20 -0
  62. package/dist/registry/errors.cjs +187 -0
  63. package/dist/registry/errors.d.ts +63 -0
  64. package/dist/registry/errors.d.ts.map +1 -0
  65. package/dist/registry/errors.js +163 -0
  66. package/dist/registry/registry.cjs +479 -0
  67. package/dist/registry/registry.d.ts +130 -0
  68. package/dist/registry/registry.d.ts.map +1 -0
  69. package/dist/registry/registry.js +452 -0
  70. package/dist/registry/types.cjs +74 -0
  71. package/dist/registry/types.d.ts +142 -0
  72. package/dist/registry/types.d.ts.map +1 -0
  73. package/dist/registry/types.js +47 -0
  74. package/dist/registry/user-registry.cjs +140 -0
  75. package/dist/registry/user-registry.d.ts +34 -0
  76. package/dist/registry/user-registry.d.ts.map +1 -0
  77. package/dist/registry/user-registry.js +104 -0
  78. package/dist/resolver.cjs +182 -0
  79. package/dist/resolver.d.ts +14 -0
  80. package/dist/resolver.d.ts.map +1 -0
  81. package/dist/resolver.js +151 -0
  82. package/dist/utils/api-key-resolver.cjs +62 -0
  83. package/dist/utils/api-key-resolver.d.ts +21 -0
  84. package/dist/utils/api-key-resolver.d.ts.map +1 -0
  85. package/dist/utils/api-key-resolver.js +36 -0
  86. package/dist/utils/api-key-store.cjs +56 -0
  87. package/dist/utils/api-key-store.d.ts +18 -0
  88. package/dist/utils/api-key-store.d.ts.map +1 -0
  89. package/dist/utils/api-key-store.js +30 -0
  90. package/dist/utils/env-file.cjs +118 -0
  91. package/dist/utils/env-file.d.ts +5 -0
  92. package/dist/utils/env-file.d.ts.map +1 -0
  93. package/dist/utils/env-file.js +84 -0
  94. package/dist/utils/execution-context.cjs +85 -0
  95. package/dist/utils/execution-context.d.ts +20 -0
  96. package/dist/utils/execution-context.d.ts.map +1 -0
  97. package/dist/utils/execution-context.js +49 -0
  98. package/dist/utils/fs-walk.cjs +52 -0
  99. package/dist/utils/fs-walk.d.ts +8 -0
  100. package/dist/utils/fs-walk.d.ts.map +1 -0
  101. package/dist/utils/fs-walk.js +18 -0
  102. package/dist/utils/path.cjs +205 -0
  103. package/dist/utils/path.d.ts +58 -0
  104. package/dist/utils/path.d.ts.map +1 -0
  105. package/dist/utils/path.js +167 -0
  106. package/dist/writer.cjs +182 -0
  107. package/dist/writer.d.ts +34 -0
  108. package/dist/writer.d.ts.map +1 -0
  109. package/dist/writer.js +146 -0
  110. package/package.json +41 -0
@@ -0,0 +1,138 @@
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 loader_exports = {};
20
+ __export(loader_exports, {
21
+ createInitialPreferences: () => createInitialPreferences,
22
+ getGlobalPreferencesPath: () => getGlobalPreferencesPath,
23
+ globalPreferencesExist: () => globalPreferencesExist,
24
+ loadGlobalPreferences: () => loadGlobalPreferences,
25
+ saveGlobalPreferences: () => saveGlobalPreferences,
26
+ updateGlobalPreferences: () => updateGlobalPreferences
27
+ });
28
+ module.exports = __toCommonJS(loader_exports);
29
+ var import_fs = require("fs");
30
+ var import_fs2 = require("fs");
31
+ var import_yaml = require("yaml");
32
+ var import_path = require("../utils/path.js");
33
+ var import_core = require("@dexto/core");
34
+ var import_core2 = require("@dexto/core");
35
+ var import_schemas = require("./schemas.js");
36
+ var import_constants = require("./constants.js");
37
+ var import_errors = require("./errors.js");
38
+ async function loadGlobalPreferences() {
39
+ const preferencesPath = (0, import_path.getDextoGlobalPath)(import_constants.PREFERENCES_FILE);
40
+ if (!(0, import_fs.existsSync)(preferencesPath)) {
41
+ throw import_errors.PreferenceError.fileNotFound(preferencesPath);
42
+ }
43
+ try {
44
+ const fileContent = await import_fs2.promises.readFile(preferencesPath, "utf-8");
45
+ const rawPreferences = (0, import_yaml.parse)(fileContent);
46
+ const validation = import_schemas.GlobalPreferencesSchema.safeParse(rawPreferences);
47
+ if (!validation.success) {
48
+ throw import_errors.PreferenceError.validationFailed(validation.error);
49
+ }
50
+ import_core.logger.debug(`Loaded global preferences from: ${preferencesPath}`);
51
+ return validation.data;
52
+ } catch (error) {
53
+ if (error instanceof import_core2.DextoValidationError || error instanceof import_core2.DextoRuntimeError) {
54
+ throw error;
55
+ }
56
+ throw import_errors.PreferenceError.fileReadError(
57
+ preferencesPath,
58
+ error instanceof Error ? error.message : String(error)
59
+ );
60
+ }
61
+ }
62
+ async function saveGlobalPreferences(preferences) {
63
+ const preferencesPath = (0, import_path.getDextoGlobalPath)(import_constants.PREFERENCES_FILE);
64
+ const validation = import_schemas.GlobalPreferencesSchema.safeParse(preferences);
65
+ if (!validation.success) {
66
+ throw import_errors.PreferenceError.validationFailed(validation.error);
67
+ }
68
+ try {
69
+ import_core.logger.info(`Saving global preferences to: ${preferencesPath}`);
70
+ const dextoDir = (0, import_path.getDextoGlobalPath)("");
71
+ await import_fs2.promises.mkdir(dextoDir, { recursive: true });
72
+ const yamlContent = (0, import_yaml.stringify)(preferences, {
73
+ indent: 2,
74
+ lineWidth: 100,
75
+ minContentWidth: 20
76
+ });
77
+ await import_fs2.promises.writeFile(preferencesPath, yamlContent, "utf-8");
78
+ import_core.logger.info(
79
+ `\u2713 Saved global preferences ${JSON.stringify(preferences)} to: ${preferencesPath}`
80
+ );
81
+ } catch (error) {
82
+ throw import_errors.PreferenceError.fileWriteError(
83
+ preferencesPath,
84
+ error instanceof Error ? error.message : String(error)
85
+ );
86
+ }
87
+ }
88
+ function globalPreferencesExist() {
89
+ const preferencesPath = (0, import_path.getDextoGlobalPath)(import_constants.PREFERENCES_FILE);
90
+ return (0, import_fs.existsSync)(preferencesPath);
91
+ }
92
+ function getGlobalPreferencesPath() {
93
+ return (0, import_path.getDextoGlobalPath)(import_constants.PREFERENCES_FILE);
94
+ }
95
+ function createInitialPreferences(provider, model, apiKeyVar, defaultAgent = "default-agent") {
96
+ return {
97
+ llm: {
98
+ provider,
99
+ model,
100
+ apiKey: `$${apiKeyVar}`
101
+ },
102
+ defaults: {
103
+ defaultAgent,
104
+ defaultMode: "web"
105
+ // Default to web mode
106
+ },
107
+ setup: {
108
+ completed: true
109
+ }
110
+ };
111
+ }
112
+ async function updateGlobalPreferences(updates) {
113
+ const existing = await loadGlobalPreferences();
114
+ const merged = {
115
+ ...existing,
116
+ ...updates,
117
+ // LLM section requires complete replacement (high coherence - provider/model/apiKey must match)
118
+ llm: updates.llm || existing.llm,
119
+ // Defaults and setup sections allow partial updates (low coherence - independent fields)
120
+ defaults: updates.defaults ? { ...existing.defaults, ...updates.defaults } : existing.defaults,
121
+ setup: updates.setup ? { ...existing.setup, ...updates.setup } : existing.setup
122
+ };
123
+ const validation = import_schemas.GlobalPreferencesSchema.safeParse(merged);
124
+ if (!validation.success) {
125
+ throw import_errors.PreferenceError.validationFailed(validation.error);
126
+ }
127
+ await saveGlobalPreferences(validation.data);
128
+ return validation.data;
129
+ }
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ createInitialPreferences,
133
+ getGlobalPreferencesPath,
134
+ globalPreferencesExist,
135
+ loadGlobalPreferences,
136
+ saveGlobalPreferences,
137
+ updateGlobalPreferences
138
+ });
@@ -0,0 +1,50 @@
1
+ import type { LLMProvider } from '@dexto/core';
2
+ import { type GlobalPreferences } from './schemas.js';
3
+ /**
4
+ * Load global preferences from ~/.dexto/preferences.yml
5
+ * @returns Global preferences object
6
+ * @throws DextoRuntimeError if file not found or corrupted
7
+ * @throws DextoValidationError if preferences are invalid
8
+ */
9
+ export declare function loadGlobalPreferences(): Promise<GlobalPreferences>;
10
+ /**
11
+ * Save global preferences to ~/.dexto/preferences.yml
12
+ * @param preferences Validated preferences object
13
+ * @throws DextoRuntimeError if write fails
14
+ */
15
+ export declare function saveGlobalPreferences(preferences: GlobalPreferences): Promise<void>;
16
+ /**
17
+ * Check if global preferences exist (for first-time detection)
18
+ * @returns true if preferences.yml exists
19
+ */
20
+ export declare function globalPreferencesExist(): boolean;
21
+ /**
22
+ * Get global preferences file path
23
+ * @returns Absolute path to preferences.yml
24
+ */
25
+ export declare function getGlobalPreferencesPath(): string;
26
+ /**
27
+ * Create initial preferences from setup data
28
+ * @param provider Selected LLM provider
29
+ * @param model Selected model
30
+ * @param apiKeyVar Environment variable name for API key
31
+ * @param defaultAgent Optional default agent name
32
+ */
33
+ export declare function createInitialPreferences(provider: LLMProvider, model: string, apiKeyVar: string, defaultAgent?: string): GlobalPreferences;
34
+ /**
35
+ * Updates type that allows partial nested objects
36
+ */
37
+ export type GlobalPreferencesUpdates = {
38
+ llm?: GlobalPreferences['llm'];
39
+ defaults?: Partial<GlobalPreferences['defaults']>;
40
+ setup?: Partial<GlobalPreferences['setup']>;
41
+ };
42
+ /**
43
+ * Update specific preference sections
44
+ * @param updates Partial preference updates
45
+ * @returns Updated preferences object
46
+ * @throws DextoRuntimeError if load/save fails
47
+ * @throws DextoValidationError if merged preferences are invalid
48
+ */
49
+ export declare function updateGlobalPreferences(updates: GlobalPreferencesUpdates): Promise<GlobalPreferences>;
50
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/preferences/loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAI/E;;;;;GAKG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CA+BxE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCzF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,YAAY,GAAE,MAAwB,GACvC,iBAAiB,CAenB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,GAAG,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,iBAAiB,CAAC,CA2B5B"}
@@ -0,0 +1,109 @@
1
+ import { existsSync } from "fs";
2
+ import { promises as fs } from "fs";
3
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
4
+ import { getDextoGlobalPath } from "../utils/path.js";
5
+ import { logger } from "@dexto/core";
6
+ import { DextoValidationError, DextoRuntimeError } from "@dexto/core";
7
+ import { GlobalPreferencesSchema } from "./schemas.js";
8
+ import { PREFERENCES_FILE } from "./constants.js";
9
+ import { PreferenceError } from "./errors.js";
10
+ async function loadGlobalPreferences() {
11
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
12
+ if (!existsSync(preferencesPath)) {
13
+ throw PreferenceError.fileNotFound(preferencesPath);
14
+ }
15
+ try {
16
+ const fileContent = await fs.readFile(preferencesPath, "utf-8");
17
+ const rawPreferences = parseYaml(fileContent);
18
+ const validation = GlobalPreferencesSchema.safeParse(rawPreferences);
19
+ if (!validation.success) {
20
+ throw PreferenceError.validationFailed(validation.error);
21
+ }
22
+ logger.debug(`Loaded global preferences from: ${preferencesPath}`);
23
+ return validation.data;
24
+ } catch (error) {
25
+ if (error instanceof DextoValidationError || error instanceof DextoRuntimeError) {
26
+ throw error;
27
+ }
28
+ throw PreferenceError.fileReadError(
29
+ preferencesPath,
30
+ error instanceof Error ? error.message : String(error)
31
+ );
32
+ }
33
+ }
34
+ async function saveGlobalPreferences(preferences) {
35
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
36
+ const validation = GlobalPreferencesSchema.safeParse(preferences);
37
+ if (!validation.success) {
38
+ throw PreferenceError.validationFailed(validation.error);
39
+ }
40
+ try {
41
+ logger.info(`Saving global preferences to: ${preferencesPath}`);
42
+ const dextoDir = getDextoGlobalPath("");
43
+ await fs.mkdir(dextoDir, { recursive: true });
44
+ const yamlContent = stringifyYaml(preferences, {
45
+ indent: 2,
46
+ lineWidth: 100,
47
+ minContentWidth: 20
48
+ });
49
+ await fs.writeFile(preferencesPath, yamlContent, "utf-8");
50
+ logger.info(
51
+ `\u2713 Saved global preferences ${JSON.stringify(preferences)} to: ${preferencesPath}`
52
+ );
53
+ } catch (error) {
54
+ throw PreferenceError.fileWriteError(
55
+ preferencesPath,
56
+ error instanceof Error ? error.message : String(error)
57
+ );
58
+ }
59
+ }
60
+ function globalPreferencesExist() {
61
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
62
+ return existsSync(preferencesPath);
63
+ }
64
+ function getGlobalPreferencesPath() {
65
+ return getDextoGlobalPath(PREFERENCES_FILE);
66
+ }
67
+ function createInitialPreferences(provider, model, apiKeyVar, defaultAgent = "default-agent") {
68
+ return {
69
+ llm: {
70
+ provider,
71
+ model,
72
+ apiKey: `$${apiKeyVar}`
73
+ },
74
+ defaults: {
75
+ defaultAgent,
76
+ defaultMode: "web"
77
+ // Default to web mode
78
+ },
79
+ setup: {
80
+ completed: true
81
+ }
82
+ };
83
+ }
84
+ async function updateGlobalPreferences(updates) {
85
+ const existing = await loadGlobalPreferences();
86
+ const merged = {
87
+ ...existing,
88
+ ...updates,
89
+ // LLM section requires complete replacement (high coherence - provider/model/apiKey must match)
90
+ llm: updates.llm || existing.llm,
91
+ // Defaults and setup sections allow partial updates (low coherence - independent fields)
92
+ defaults: updates.defaults ? { ...existing.defaults, ...updates.defaults } : existing.defaults,
93
+ setup: updates.setup ? { ...existing.setup, ...updates.setup } : existing.setup
94
+ };
95
+ const validation = GlobalPreferencesSchema.safeParse(merged);
96
+ if (!validation.success) {
97
+ throw PreferenceError.validationFailed(validation.error);
98
+ }
99
+ await saveGlobalPreferences(validation.data);
100
+ return validation.data;
101
+ }
102
+ export {
103
+ createInitialPreferences,
104
+ getGlobalPreferencesPath,
105
+ globalPreferencesExist,
106
+ loadGlobalPreferences,
107
+ saveGlobalPreferences,
108
+ updateGlobalPreferences
109
+ };
@@ -0,0 +1,75 @@
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 schemas_exports = {};
20
+ __export(schemas_exports, {
21
+ GlobalPreferencesSchema: () => GlobalPreferencesSchema,
22
+ PreferenceDefaultsSchema: () => PreferenceDefaultsSchema,
23
+ PreferenceLLMSchema: () => PreferenceLLMSchema,
24
+ PreferenceSetupSchema: () => PreferenceSetupSchema
25
+ });
26
+ module.exports = __toCommonJS(schemas_exports);
27
+ var import_zod = require("zod");
28
+ var import_core = require("@dexto/core");
29
+ var import_core2 = require("@dexto/core");
30
+ var import_core3 = require("@dexto/core");
31
+ var import_error_codes = require("./error-codes.js");
32
+ var import_core4 = require("@dexto/core");
33
+ const PreferenceLLMSchema = import_zod.z.object({
34
+ provider: import_zod.z.enum(import_core2.LLM_PROVIDERS).describe("LLM provider (openai, anthropic, google, etc.)"),
35
+ model: import_core3.NonEmptyTrimmed.describe("Model name for the provider"),
36
+ apiKey: import_zod.z.string().regex(
37
+ /^\$[A-Z_][A-Z0-9_]*$/,
38
+ "Must be environment variable reference (e.g., $OPENAI_API_KEY)"
39
+ ).describe("Environment variable reference for API key")
40
+ }).strict().superRefine((data, ctx) => {
41
+ if (!(0, import_core.isValidProviderModel)(data.provider, data.model)) {
42
+ const supportedModels = (0, import_core.getSupportedModels)(data.provider);
43
+ ctx.addIssue({
44
+ code: import_zod.z.ZodIssueCode.custom,
45
+ path: ["model"],
46
+ message: `Model '${data.model}' is not supported by provider '${data.provider}'. Supported models: ${supportedModels.join(", ")}`,
47
+ params: {
48
+ code: import_error_codes.PreferenceErrorCode.MODEL_INCOMPATIBLE,
49
+ scope: "preference",
50
+ type: import_core4.ErrorType.USER
51
+ }
52
+ });
53
+ }
54
+ });
55
+ const PreferenceDefaultsSchema = import_zod.z.object({
56
+ defaultAgent: import_zod.z.string().min(1).describe("Default agent name for global CLI usage (required)"),
57
+ defaultMode: import_zod.z.enum(["cli", "web", "server", "discord", "telegram", "mcp"]).default("web").describe("Default run mode when --mode flag is not specified (default: web)")
58
+ }).strict();
59
+ const PreferenceSetupSchema = import_zod.z.object({
60
+ completed: import_zod.z.boolean().default(false).describe("Whether initial setup has been completed")
61
+ }).strict();
62
+ const GlobalPreferencesSchema = import_zod.z.object({
63
+ llm: PreferenceLLMSchema.describe("LLM configuration preferences"),
64
+ defaults: PreferenceDefaultsSchema.describe("Default behavior preferences (required)"),
65
+ setup: PreferenceSetupSchema.default({ completed: false }).describe(
66
+ "Setup completion tracking"
67
+ )
68
+ }).strict();
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ GlobalPreferencesSchema,
72
+ PreferenceDefaultsSchema,
73
+ PreferenceLLMSchema,
74
+ PreferenceSetupSchema
75
+ });
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod';
2
+ export declare const PreferenceLLMSchema: z.ZodEffects<z.ZodObject<{
3
+ provider: z.ZodEnum<["openai", "openai-compatible", "anthropic", "google", "groq", "xai", "cohere"]>;
4
+ model: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
5
+ apiKey: z.ZodString;
6
+ }, "strict", z.ZodTypeAny, {
7
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
8
+ model: string;
9
+ apiKey: string;
10
+ }, {
11
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
12
+ model: string;
13
+ apiKey: string;
14
+ }>, {
15
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
16
+ model: string;
17
+ apiKey: string;
18
+ }, {
19
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
20
+ model: string;
21
+ apiKey: string;
22
+ }>;
23
+ export declare const PreferenceDefaultsSchema: z.ZodObject<{
24
+ defaultAgent: z.ZodString;
25
+ defaultMode: z.ZodDefault<z.ZodEnum<["cli", "web", "server", "discord", "telegram", "mcp"]>>;
26
+ }, "strict", z.ZodTypeAny, {
27
+ defaultAgent: string;
28
+ defaultMode: "cli" | "web" | "server" | "discord" | "telegram" | "mcp";
29
+ }, {
30
+ defaultAgent: string;
31
+ defaultMode?: "cli" | "web" | "server" | "discord" | "telegram" | "mcp" | undefined;
32
+ }>;
33
+ export declare const PreferenceSetupSchema: z.ZodObject<{
34
+ completed: z.ZodDefault<z.ZodBoolean>;
35
+ }, "strict", z.ZodTypeAny, {
36
+ completed: boolean;
37
+ }, {
38
+ completed?: boolean | undefined;
39
+ }>;
40
+ export declare const GlobalPreferencesSchema: z.ZodObject<{
41
+ llm: z.ZodEffects<z.ZodObject<{
42
+ provider: z.ZodEnum<["openai", "openai-compatible", "anthropic", "google", "groq", "xai", "cohere"]>;
43
+ model: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
44
+ apiKey: z.ZodString;
45
+ }, "strict", z.ZodTypeAny, {
46
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
47
+ model: string;
48
+ apiKey: string;
49
+ }, {
50
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
51
+ model: string;
52
+ apiKey: string;
53
+ }>, {
54
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
55
+ model: string;
56
+ apiKey: string;
57
+ }, {
58
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
59
+ model: string;
60
+ apiKey: string;
61
+ }>;
62
+ defaults: z.ZodObject<{
63
+ defaultAgent: z.ZodString;
64
+ defaultMode: z.ZodDefault<z.ZodEnum<["cli", "web", "server", "discord", "telegram", "mcp"]>>;
65
+ }, "strict", z.ZodTypeAny, {
66
+ defaultAgent: string;
67
+ defaultMode: "cli" | "web" | "server" | "discord" | "telegram" | "mcp";
68
+ }, {
69
+ defaultAgent: string;
70
+ defaultMode?: "cli" | "web" | "server" | "discord" | "telegram" | "mcp" | undefined;
71
+ }>;
72
+ setup: z.ZodDefault<z.ZodObject<{
73
+ completed: z.ZodDefault<z.ZodBoolean>;
74
+ }, "strict", z.ZodTypeAny, {
75
+ completed: boolean;
76
+ }, {
77
+ completed?: boolean | undefined;
78
+ }>>;
79
+ }, "strict", z.ZodTypeAny, {
80
+ llm: {
81
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
82
+ model: string;
83
+ apiKey: string;
84
+ };
85
+ defaults: {
86
+ defaultAgent: string;
87
+ defaultMode: "cli" | "web" | "server" | "discord" | "telegram" | "mcp";
88
+ };
89
+ setup: {
90
+ completed: boolean;
91
+ };
92
+ }, {
93
+ llm: {
94
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
95
+ model: string;
96
+ apiKey: string;
97
+ };
98
+ defaults: {
99
+ defaultAgent: string;
100
+ defaultMode?: "cli" | "web" | "server" | "discord" | "telegram" | "mcp" | undefined;
101
+ };
102
+ setup?: {
103
+ completed?: boolean | undefined;
104
+ } | undefined;
105
+ }>;
106
+ export type PreferenceLLM = z.output<typeof PreferenceLLMSchema>;
107
+ export type PreferenceDefaults = z.output<typeof PreferenceDefaultsSchema>;
108
+ export type PreferenceSetup = z.output<typeof PreferenceSetupSchema>;
109
+ export type GlobalPreferences = z.output<typeof GlobalPreferencesSchema>;
110
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/preferences/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;EA6B1B,CAAC;AAEP,eAAO,MAAM,wBAAwB;;;;;;;;;EAYxB,CAAC;AAEd,eAAO,MAAM,qBAAqB;;;;;;EAIrB,CAAC;AAEd,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUvB,CAAC;AAGd,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC3E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { isValidProviderModel, getSupportedModels } from "@dexto/core";
3
+ import { LLM_PROVIDERS } from "@dexto/core";
4
+ import { NonEmptyTrimmed } from "@dexto/core";
5
+ import { PreferenceErrorCode } from "./error-codes.js";
6
+ import { ErrorType } from "@dexto/core";
7
+ const PreferenceLLMSchema = z.object({
8
+ provider: z.enum(LLM_PROVIDERS).describe("LLM provider (openai, anthropic, google, etc.)"),
9
+ model: NonEmptyTrimmed.describe("Model name for the provider"),
10
+ apiKey: z.string().regex(
11
+ /^\$[A-Z_][A-Z0-9_]*$/,
12
+ "Must be environment variable reference (e.g., $OPENAI_API_KEY)"
13
+ ).describe("Environment variable reference for API key")
14
+ }).strict().superRefine((data, ctx) => {
15
+ if (!isValidProviderModel(data.provider, data.model)) {
16
+ const supportedModels = getSupportedModels(data.provider);
17
+ ctx.addIssue({
18
+ code: z.ZodIssueCode.custom,
19
+ path: ["model"],
20
+ message: `Model '${data.model}' is not supported by provider '${data.provider}'. Supported models: ${supportedModels.join(", ")}`,
21
+ params: {
22
+ code: PreferenceErrorCode.MODEL_INCOMPATIBLE,
23
+ scope: "preference",
24
+ type: ErrorType.USER
25
+ }
26
+ });
27
+ }
28
+ });
29
+ const PreferenceDefaultsSchema = z.object({
30
+ defaultAgent: z.string().min(1).describe("Default agent name for global CLI usage (required)"),
31
+ defaultMode: z.enum(["cli", "web", "server", "discord", "telegram", "mcp"]).default("web").describe("Default run mode when --mode flag is not specified (default: web)")
32
+ }).strict();
33
+ const PreferenceSetupSchema = z.object({
34
+ completed: z.boolean().default(false).describe("Whether initial setup has been completed")
35
+ }).strict();
36
+ const GlobalPreferencesSchema = z.object({
37
+ llm: PreferenceLLMSchema.describe("LLM configuration preferences"),
38
+ defaults: PreferenceDefaultsSchema.describe("Default behavior preferences (required)"),
39
+ setup: PreferenceSetupSchema.default({ completed: false }).describe(
40
+ "Setup completion tracking"
41
+ )
42
+ }).strict();
43
+ export {
44
+ GlobalPreferencesSchema,
45
+ PreferenceDefaultsSchema,
46
+ PreferenceLLMSchema,
47
+ PreferenceSetupSchema
48
+ };
@@ -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 error_codes_exports = {};
20
+ __export(error_codes_exports, {
21
+ RegistryErrorCode: () => RegistryErrorCode
22
+ });
23
+ module.exports = __toCommonJS(error_codes_exports);
24
+ var RegistryErrorCode = /* @__PURE__ */ ((RegistryErrorCode2) => {
25
+ RegistryErrorCode2["AGENT_NOT_FOUND"] = "registry_agent_not_found";
26
+ RegistryErrorCode2["AGENT_INVALID_ENTRY"] = "registry_agent_invalid_entry";
27
+ RegistryErrorCode2["AGENT_ALREADY_EXISTS"] = "registry_agent_already_exists";
28
+ RegistryErrorCode2["INSTALLATION_FAILED"] = "registry_installation_failed";
29
+ RegistryErrorCode2["INSTALLATION_VALIDATION_FAILED"] = "registry_installation_validation_failed";
30
+ RegistryErrorCode2["REGISTRY_NOT_FOUND"] = "registry_file_not_found";
31
+ RegistryErrorCode2["REGISTRY_PARSE_ERROR"] = "registry_parse_error";
32
+ RegistryErrorCode2["REGISTRY_WRITE_ERROR"] = "registry_write_error";
33
+ RegistryErrorCode2["CONFIG_NOT_FOUND"] = "registry_config_not_found";
34
+ RegistryErrorCode2["MAIN_CONFIG_MISSING"] = "registry_main_config_missing";
35
+ RegistryErrorCode2["AGENT_NOT_INSTALLED"] = "registry_agent_not_installed";
36
+ RegistryErrorCode2["AGENT_PROTECTED"] = "registry_agent_protected";
37
+ RegistryErrorCode2["UNINSTALLATION_FAILED"] = "registry_uninstallation_failed";
38
+ RegistryErrorCode2["AGENT_NOT_INSTALLED_AUTO_INSTALL_DISABLED"] = "registry_agent_not_installed_auto_install_disabled";
39
+ return RegistryErrorCode2;
40
+ })(RegistryErrorCode || {});
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ RegistryErrorCode
44
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Registry-specific error codes
3
+ * Includes agent resolution, installation, and registry management errors
4
+ */
5
+ export declare enum RegistryErrorCode {
6
+ AGENT_NOT_FOUND = "registry_agent_not_found",
7
+ AGENT_INVALID_ENTRY = "registry_agent_invalid_entry",
8
+ AGENT_ALREADY_EXISTS = "registry_agent_already_exists",
9
+ INSTALLATION_FAILED = "registry_installation_failed",
10
+ INSTALLATION_VALIDATION_FAILED = "registry_installation_validation_failed",
11
+ REGISTRY_NOT_FOUND = "registry_file_not_found",
12
+ REGISTRY_PARSE_ERROR = "registry_parse_error",
13
+ REGISTRY_WRITE_ERROR = "registry_write_error",
14
+ CONFIG_NOT_FOUND = "registry_config_not_found",
15
+ MAIN_CONFIG_MISSING = "registry_main_config_missing",
16
+ AGENT_NOT_INSTALLED = "registry_agent_not_installed",
17
+ AGENT_PROTECTED = "registry_agent_protected",
18
+ UNINSTALLATION_FAILED = "registry_uninstallation_failed",
19
+ AGENT_NOT_INSTALLED_AUTO_INSTALL_DISABLED = "registry_agent_not_installed_auto_install_disabled"
20
+ }
21
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/registry/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,iBAAiB;IAEzB,eAAe,6BAA6B;IAC5C,mBAAmB,iCAAiC;IACpD,oBAAoB,kCAAkC;IAGtD,mBAAmB,iCAAiC;IACpD,8BAA8B,4CAA4C;IAG1E,kBAAkB,4BAA4B;IAC9C,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAG7C,gBAAgB,8BAA8B;IAC9C,mBAAmB,iCAAiC;IAGpD,mBAAmB,iCAAiC;IACpD,eAAe,6BAA6B;IAC5C,qBAAqB,mCAAmC;IAGxD,yCAAyC,uDAAuD;CACnG"}
@@ -0,0 +1,20 @@
1
+ var RegistryErrorCode = /* @__PURE__ */ ((RegistryErrorCode2) => {
2
+ RegistryErrorCode2["AGENT_NOT_FOUND"] = "registry_agent_not_found";
3
+ RegistryErrorCode2["AGENT_INVALID_ENTRY"] = "registry_agent_invalid_entry";
4
+ RegistryErrorCode2["AGENT_ALREADY_EXISTS"] = "registry_agent_already_exists";
5
+ RegistryErrorCode2["INSTALLATION_FAILED"] = "registry_installation_failed";
6
+ RegistryErrorCode2["INSTALLATION_VALIDATION_FAILED"] = "registry_installation_validation_failed";
7
+ RegistryErrorCode2["REGISTRY_NOT_FOUND"] = "registry_file_not_found";
8
+ RegistryErrorCode2["REGISTRY_PARSE_ERROR"] = "registry_parse_error";
9
+ RegistryErrorCode2["REGISTRY_WRITE_ERROR"] = "registry_write_error";
10
+ RegistryErrorCode2["CONFIG_NOT_FOUND"] = "registry_config_not_found";
11
+ RegistryErrorCode2["MAIN_CONFIG_MISSING"] = "registry_main_config_missing";
12
+ RegistryErrorCode2["AGENT_NOT_INSTALLED"] = "registry_agent_not_installed";
13
+ RegistryErrorCode2["AGENT_PROTECTED"] = "registry_agent_protected";
14
+ RegistryErrorCode2["UNINSTALLATION_FAILED"] = "registry_uninstallation_failed";
15
+ RegistryErrorCode2["AGENT_NOT_INSTALLED_AUTO_INSTALL_DISABLED"] = "registry_agent_not_installed_auto_install_disabled";
16
+ return RegistryErrorCode2;
17
+ })(RegistryErrorCode || {});
18
+ export {
19
+ RegistryErrorCode
20
+ };