@dexto/agent-config 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -0
- package/README.md +46 -0
- package/dist/image/types.cjs +16 -0
- package/dist/image/types.d.ts +123 -0
- package/dist/image/types.d.ts.map +1 -0
- package/dist/image/types.js +0 -0
- package/dist/index.cjs +63 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/resolver/apply-image-defaults.cjs +102 -0
- package/dist/resolver/apply-image-defaults.d.ts +13 -0
- package/dist/resolver/apply-image-defaults.d.ts.map +1 -0
- package/dist/resolver/apply-image-defaults.js +78 -0
- package/dist/resolver/load-image.cjs +139 -0
- package/dist/resolver/load-image.d.ts +13 -0
- package/dist/resolver/load-image.d.ts.map +1 -0
- package/dist/resolver/load-image.js +114 -0
- package/dist/resolver/resolve-services-from-config.cjs +146 -0
- package/dist/resolver/resolve-services-from-config.d.ts +5 -0
- package/dist/resolver/resolve-services-from-config.d.ts.map +1 -0
- package/dist/resolver/resolve-services-from-config.js +122 -0
- package/dist/resolver/to-dexto-agent-options.cjs +51 -0
- package/dist/resolver/to-dexto-agent-options.d.ts +10 -0
- package/dist/resolver/to-dexto-agent-options.d.ts.map +1 -0
- package/dist/resolver/to-dexto-agent-options.js +27 -0
- package/dist/resolver/types.cjs +16 -0
- package/dist/resolver/types.d.ts +19 -0
- package/dist/resolver/types.d.ts.map +1 -0
- package/dist/resolver/types.js +0 -0
- package/dist/resolver/utils.cjs +35 -0
- package/dist/resolver/utils.d.ts +4 -0
- package/dist/resolver/utils.d.ts.map +1 -0
- package/dist/resolver/utils.js +10 -0
- package/dist/schemas/agent-config.cjs +117 -0
- package/dist/schemas/agent-config.d.ts +4910 -0
- package/dist/schemas/agent-config.d.ts.map +1 -0
- package/dist/schemas/agent-config.js +104 -0
- package/dist/schemas/compaction.cjs +64 -0
- package/dist/schemas/compaction.d.ts +77 -0
- package/dist/schemas/compaction.d.ts.map +1 -0
- package/dist/schemas/compaction.js +37 -0
- package/dist/schemas/hooks.cjs +37 -0
- package/dist/schemas/hooks.d.ts +36 -0
- package/dist/schemas/hooks.d.ts.map +1 -0
- package/dist/schemas/hooks.js +12 -0
- package/dist/utils/clean-null-values.cjs +52 -0
- package/dist/utils/clean-null-values.d.ts +8 -0
- package/dist/utils/clean-null-values.d.ts.map +1 -0
- package/dist/utils/clean-null-values.js +28 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
**Acceptance**
|
|
4
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
5
|
+
|
|
6
|
+
**Copyright License**
|
|
7
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
8
|
+
|
|
9
|
+
**Limitations**
|
|
10
|
+
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
11
|
+
|
|
12
|
+
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
13
|
+
|
|
14
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
15
|
+
|
|
16
|
+
**Patents**
|
|
17
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
18
|
+
|
|
19
|
+
**Notices**
|
|
20
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
21
|
+
|
|
22
|
+
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
23
|
+
|
|
24
|
+
**No Other Rights**
|
|
25
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
26
|
+
|
|
27
|
+
**Termination**
|
|
28
|
+
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
29
|
+
|
|
30
|
+
**No Liability**
|
|
31
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
32
|
+
|
|
33
|
+
**Definitions**
|
|
34
|
+
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
35
|
+
|
|
36
|
+
_you_ refers to the individual or entity agreeing to these terms.
|
|
37
|
+
|
|
38
|
+
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
39
|
+
|
|
40
|
+
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
41
|
+
|
|
42
|
+
_use_ means anything you do with the software requiring one of your licenses.
|
|
43
|
+
|
|
44
|
+
_trademark_ means trademarks, service marks, and similar rights.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# `@dexto/agent-config`
|
|
2
|
+
|
|
3
|
+
Schema + resolver utilities for turning an agent YAML config into concrete DI surfaces using images.
|
|
4
|
+
|
|
5
|
+
This package is **product-layer glue**: core (`@dexto/core`) stays DI-friendly, and hosts (CLI/server/apps)
|
|
6
|
+
use `@dexto/agent-config` to:
|
|
7
|
+
|
|
8
|
+
- validate agent config (`AgentConfigSchema`)
|
|
9
|
+
- load an image module (`loadImage()`)
|
|
10
|
+
- merge image defaults into raw config (`applyImageDefaults()`)
|
|
11
|
+
- resolve factories from the image into concrete instances (`resolveServicesFromConfig()`)
|
|
12
|
+
- convert the result into `DextoAgentOptions` (`toDextoAgentOptions()`)
|
|
13
|
+
|
|
14
|
+
## Quick example (apps)
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { DextoAgent } from '@dexto/core';
|
|
18
|
+
import { loadAgentConfig } from '@dexto/agent-management';
|
|
19
|
+
import {
|
|
20
|
+
AgentConfigSchema,
|
|
21
|
+
applyImageDefaults,
|
|
22
|
+
loadImage,
|
|
23
|
+
resolveServicesFromConfig,
|
|
24
|
+
setImageImporter,
|
|
25
|
+
toDextoAgentOptions,
|
|
26
|
+
} from '@dexto/agent-config';
|
|
27
|
+
|
|
28
|
+
// Under pnpm (strict dependency boundaries), configure image importing at the host entrypoint.
|
|
29
|
+
setImageImporter((specifier) => import(specifier));
|
|
30
|
+
|
|
31
|
+
const raw = await loadAgentConfig('./agents/my-agent.yml');
|
|
32
|
+
const image = await loadImage(raw.image ?? '@dexto/image-local');
|
|
33
|
+
const merged = applyImageDefaults(raw, image.defaults);
|
|
34
|
+
|
|
35
|
+
const config = AgentConfigSchema.parse(merged);
|
|
36
|
+
const services = await resolveServicesFromConfig(config, image);
|
|
37
|
+
|
|
38
|
+
const agent = new DextoAgent(toDextoAgentOptions({ config, services }));
|
|
39
|
+
await agent.start();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Images (no registries)
|
|
43
|
+
|
|
44
|
+
Images are typed modules (`DextoImage`) that export plain `Record<string, Factory>` maps.
|
|
45
|
+
Resolver logic does property access by config `type` (e.g., `image.tools[entry.type]`) — there are no
|
|
46
|
+
global registries or side effects.
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { BlobStore, Cache, Database, Hook, Logger, CompactionStrategy as CompactionStrategy, Tool } from '@dexto/core';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { AgentConfig } from '../schemas/agent-config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Image defaults are a partial, *unvalidated* agent config that is merged into the raw YAML config
|
|
6
|
+
* before schema validation.
|
|
7
|
+
*
|
|
8
|
+
* Merge semantics are implemented by `applyImageDefaults()`:
|
|
9
|
+
* - shallow merge at the top-level (config wins)
|
|
10
|
+
* - object fields merge 1-level deep
|
|
11
|
+
* - arrays are atomic (fully replaced; no concatenation) except `prompts`, which are merged to
|
|
12
|
+
* avoid accidentally dropping image-provided prompts when an agent config defines its own prompts
|
|
13
|
+
*/
|
|
14
|
+
export type ImageDefaults = Partial<AgentConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Optional tool metadata for UIs and discovery.
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolFactoryMetadata {
|
|
19
|
+
displayName: string;
|
|
20
|
+
description: string;
|
|
21
|
+
category: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tool factories are keyed by `type` in the agent config (`tools: [{ type: "..." }]`).
|
|
25
|
+
*
|
|
26
|
+
* A single factory entry can produce multiple tools, which is useful for "tool packs" where a single
|
|
27
|
+
* config block enables a related set of tools (e.g., filesystem tools: read/write/edit/glob/grep).
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolFactory<TConfig = unknown> {
|
|
30
|
+
/** Zod schema for validating factory-specific configuration. */
|
|
31
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
32
|
+
/** Create one or more tool instances from validated config. */
|
|
33
|
+
create(config: TConfig): Tool[];
|
|
34
|
+
metadata?: ToolFactoryMetadata;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Storage factories are keyed by `type` in the agent config (`storage.blob.type`, etc.).
|
|
38
|
+
*
|
|
39
|
+
* Factories may return a Promise to support lazy optional dependencies (e.g., sqlite/pg/redis).
|
|
40
|
+
*/
|
|
41
|
+
export interface BlobStoreFactory<TConfig = unknown> {
|
|
42
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
43
|
+
create(config: TConfig, logger: Logger): BlobStore | Promise<BlobStore>;
|
|
44
|
+
metadata?: Record<string, unknown> | undefined;
|
|
45
|
+
}
|
|
46
|
+
export interface DatabaseFactory<TConfig = unknown> {
|
|
47
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
48
|
+
create(config: TConfig, logger: Logger): Database | Promise<Database>;
|
|
49
|
+
metadata?: Record<string, unknown> | undefined;
|
|
50
|
+
}
|
|
51
|
+
export interface CacheFactory<TConfig = unknown> {
|
|
52
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
53
|
+
create(config: TConfig, logger: Logger): Cache | Promise<Cache>;
|
|
54
|
+
metadata?: Record<string, unknown> | undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Hook factories are keyed by `type` in the agent config (`hooks: [{ type: "..." }]`).
|
|
58
|
+
*/
|
|
59
|
+
export interface HookFactory<TConfig = unknown> {
|
|
60
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
61
|
+
create(config: TConfig): Hook;
|
|
62
|
+
metadata?: Record<string, unknown> | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Compaction factories are keyed by `type` in the agent config (`compaction.type`).
|
|
66
|
+
*/
|
|
67
|
+
export interface CompactionFactory<TConfig = unknown> {
|
|
68
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
69
|
+
create(config: TConfig): CompactionStrategy | Promise<CompactionStrategy>;
|
|
70
|
+
metadata?: Record<string, unknown> | undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Logger factory used by the agent to create its logger instance.
|
|
74
|
+
*
|
|
75
|
+
* This remains a factory (vs a map) because an agent should have a single logger implementation.
|
|
76
|
+
*/
|
|
77
|
+
export interface LoggerFactory<TConfig = unknown> {
|
|
78
|
+
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
79
|
+
create(config: TConfig): Logger;
|
|
80
|
+
metadata?: Record<string, unknown> | undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* An image is a typed module that bundles defaults and a set of factories that a host (CLI/server/app)
|
|
84
|
+
* may use to resolve config → concrete instances.
|
|
85
|
+
*
|
|
86
|
+
* Key design constraints:
|
|
87
|
+
* - No global registries; the image object itself is the lookup table (Record access by `type`)
|
|
88
|
+
* - Factories are plain exports; resolution is explicit and testable
|
|
89
|
+
* - Hosts decide how to load images (static import, dynamic import via `loadImage()`, allowlists, etc.)
|
|
90
|
+
*/
|
|
91
|
+
export interface DextoImage {
|
|
92
|
+
/**
|
|
93
|
+
* Metadata about the image package.
|
|
94
|
+
*
|
|
95
|
+
* `target`/`constraints` are free-form strings. Hosts may interpret these for UX/allowlisting
|
|
96
|
+
* but they have no built-in semantics in core.
|
|
97
|
+
*/
|
|
98
|
+
metadata: {
|
|
99
|
+
name: string;
|
|
100
|
+
version: string;
|
|
101
|
+
description: string;
|
|
102
|
+
target?: string;
|
|
103
|
+
constraints?: string[];
|
|
104
|
+
};
|
|
105
|
+
defaults?: ImageDefaults;
|
|
106
|
+
/**
|
|
107
|
+
* Tool factories keyed by config `type`.
|
|
108
|
+
* Example: `{ "filesystem-tools": fileSystemToolsFactory }`.
|
|
109
|
+
*/
|
|
110
|
+
tools: Record<string, ToolFactory>;
|
|
111
|
+
/**
|
|
112
|
+
* Storage factories keyed by config `type`.
|
|
113
|
+
*/
|
|
114
|
+
storage: {
|
|
115
|
+
blob: Record<string, BlobStoreFactory>;
|
|
116
|
+
database: Record<string, DatabaseFactory>;
|
|
117
|
+
cache: Record<string, CacheFactory>;
|
|
118
|
+
};
|
|
119
|
+
hooks: Record<string, HookFactory>;
|
|
120
|
+
compaction: Record<string, CompactionFactory>;
|
|
121
|
+
logger: LoggerFactory;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/image/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,kBAAkB,IAAI,kBAAkB,EACxC,IAAI,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,W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AE,CAAC;KAC1B,CAAC;IACF,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE;QACL,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACvC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9C,MAAM,EAAE,aAAa,CAAC;CACzB"}
|
|
File without changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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 index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
AgentConfigSchema: () => import_agent_config.AgentConfigSchema,
|
|
22
|
+
CompactionConfigSchema: () => import_compaction.CompactionConfigSchema,
|
|
23
|
+
DEFAULT_COMPACTION_CONFIG: () => import_compaction.DEFAULT_COMPACTION_CONFIG,
|
|
24
|
+
HookFactoryEntrySchema: () => import_hooks.HookFactoryEntrySchema,
|
|
25
|
+
HooksConfigSchema: () => import_hooks.HooksConfigSchema,
|
|
26
|
+
NoOpCompactionConfigSchema: () => import_compaction.NoOpCompactionConfigSchema,
|
|
27
|
+
ReactiveOverflowCompactionConfigSchema: () => import_compaction.ReactiveOverflowCompactionConfigSchema,
|
|
28
|
+
ToolFactoryEntrySchema: () => import_agent_config.ToolFactoryEntrySchema,
|
|
29
|
+
applyImageDefaults: () => import_apply_image_defaults.applyImageDefaults,
|
|
30
|
+
cleanNullValues: () => import_clean_null_values.cleanNullValues,
|
|
31
|
+
createAgentConfigSchema: () => import_agent_config.createAgentConfigSchema,
|
|
32
|
+
loadImage: () => import_load_image.loadImage,
|
|
33
|
+
resolveServicesFromConfig: () => import_resolve_services_from_config.resolveServicesFromConfig,
|
|
34
|
+
setImageImporter: () => import_load_image.setImageImporter,
|
|
35
|
+
toDextoAgentOptions: () => import_to_dexto_agent_options.toDextoAgentOptions
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_agent_config = require("./schemas/agent-config.js");
|
|
39
|
+
var import_hooks = require("./schemas/hooks.js");
|
|
40
|
+
var import_compaction = require("./schemas/compaction.js");
|
|
41
|
+
var import_apply_image_defaults = require("./resolver/apply-image-defaults.js");
|
|
42
|
+
var import_load_image = require("./resolver/load-image.js");
|
|
43
|
+
var import_resolve_services_from_config = require("./resolver/resolve-services-from-config.js");
|
|
44
|
+
var import_to_dexto_agent_options = require("./resolver/to-dexto-agent-options.js");
|
|
45
|
+
var import_clean_null_values = require("./utils/clean-null-values.js");
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
AgentConfigSchema,
|
|
49
|
+
CompactionConfigSchema,
|
|
50
|
+
DEFAULT_COMPACTION_CONFIG,
|
|
51
|
+
HookFactoryEntrySchema,
|
|
52
|
+
HooksConfigSchema,
|
|
53
|
+
NoOpCompactionConfigSchema,
|
|
54
|
+
ReactiveOverflowCompactionConfigSchema,
|
|
55
|
+
ToolFactoryEntrySchema,
|
|
56
|
+
applyImageDefaults,
|
|
57
|
+
cleanNullValues,
|
|
58
|
+
createAgentConfigSchema,
|
|
59
|
+
loadImage,
|
|
60
|
+
resolveServicesFromConfig,
|
|
61
|
+
setImageImporter,
|
|
62
|
+
toDextoAgentOptions
|
|
63
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { BlobStoreFactory, CacheFactory, CompactionFactory, DatabaseFactory, DextoImage, ImageDefaults, LoggerFactory, HookFactory, ToolFactory, } from './image/types.js';
|
|
2
|
+
export { AgentConfigSchema, createAgentConfigSchema, ToolFactoryEntrySchema, } from './schemas/agent-config.js';
|
|
3
|
+
export type { AgentConfig, ValidatedAgentConfig, ToolFactoryEntry, } from './schemas/agent-config.js';
|
|
4
|
+
export type { HooksConfig, ValidatedHooksConfig, HookFactoryEntry } from './schemas/hooks.js';
|
|
5
|
+
export { HookFactoryEntrySchema, HooksConfigSchema } from './schemas/hooks.js';
|
|
6
|
+
export { CompactionConfigSchema, DEFAULT_COMPACTION_CONFIG, ReactiveOverflowCompactionConfigSchema, NoOpCompactionConfigSchema, } from './schemas/compaction.js';
|
|
7
|
+
export type { CompactionConfig, ValidatedCompactionConfig, ReactiveOverflowCompactionConfig, NoOpCompactionConfig, } from './schemas/compaction.js';
|
|
8
|
+
export { applyImageDefaults } from './resolver/apply-image-defaults.js';
|
|
9
|
+
export { loadImage, setImageImporter } from './resolver/load-image.js';
|
|
10
|
+
export type { ImageImporter } from './resolver/load-image.js';
|
|
11
|
+
export { resolveServicesFromConfig } from './resolver/resolve-services-from-config.js';
|
|
12
|
+
export { toDextoAgentOptions } from './resolver/to-dexto-agent-options.js';
|
|
13
|
+
export type { ResolvedServices } from './resolver/types.js';
|
|
14
|
+
export { cleanNullValues } from './utils/clean-null-values.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACR,WAAW,EACX,oBAAoB,EACpB,gBAAgB,GACnB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE9F,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EACH,sBAAsB,EACtB,yBAAyB,EACzB,sCAAsC,EACtC,0BAA0B,GAC7B,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACR,gBAAgB,EAChB,yBAAyB,EACzB,gCAAgC,EAChC,oBAAoB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentConfigSchema,
|
|
3
|
+
createAgentConfigSchema,
|
|
4
|
+
ToolFactoryEntrySchema
|
|
5
|
+
} from "./schemas/agent-config.js";
|
|
6
|
+
import { HookFactoryEntrySchema, HooksConfigSchema } from "./schemas/hooks.js";
|
|
7
|
+
import {
|
|
8
|
+
CompactionConfigSchema,
|
|
9
|
+
DEFAULT_COMPACTION_CONFIG,
|
|
10
|
+
ReactiveOverflowCompactionConfigSchema,
|
|
11
|
+
NoOpCompactionConfigSchema
|
|
12
|
+
} from "./schemas/compaction.js";
|
|
13
|
+
import { applyImageDefaults } from "./resolver/apply-image-defaults.js";
|
|
14
|
+
import { loadImage, setImageImporter } from "./resolver/load-image.js";
|
|
15
|
+
import { resolveServicesFromConfig } from "./resolver/resolve-services-from-config.js";
|
|
16
|
+
import { toDextoAgentOptions } from "./resolver/to-dexto-agent-options.js";
|
|
17
|
+
import { cleanNullValues } from "./utils/clean-null-values.js";
|
|
18
|
+
export {
|
|
19
|
+
AgentConfigSchema,
|
|
20
|
+
CompactionConfigSchema,
|
|
21
|
+
DEFAULT_COMPACTION_CONFIG,
|
|
22
|
+
HookFactoryEntrySchema,
|
|
23
|
+
HooksConfigSchema,
|
|
24
|
+
NoOpCompactionConfigSchema,
|
|
25
|
+
ReactiveOverflowCompactionConfigSchema,
|
|
26
|
+
ToolFactoryEntrySchema,
|
|
27
|
+
applyImageDefaults,
|
|
28
|
+
cleanNullValues,
|
|
29
|
+
createAgentConfigSchema,
|
|
30
|
+
loadImage,
|
|
31
|
+
resolveServicesFromConfig,
|
|
32
|
+
setImageImporter,
|
|
33
|
+
toDextoAgentOptions
|
|
34
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
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 apply_image_defaults_exports = {};
|
|
20
|
+
__export(apply_image_defaults_exports, {
|
|
21
|
+
applyImageDefaults: () => applyImageDefaults
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(apply_image_defaults_exports);
|
|
24
|
+
var import_utils = require("./utils.js");
|
|
25
|
+
function promptIdentityKey(prompt) {
|
|
26
|
+
if (!(0, import_utils.isPlainObject)(prompt)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const type = prompt.type;
|
|
30
|
+
if (type === "inline") {
|
|
31
|
+
const id = prompt.id;
|
|
32
|
+
return typeof id === "string" && id.length > 0 ? `inline:${id}` : null;
|
|
33
|
+
}
|
|
34
|
+
if (type === "file") {
|
|
35
|
+
const file = prompt.file;
|
|
36
|
+
if (typeof file !== "string" || file.length === 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const namespace = prompt.namespace;
|
|
40
|
+
const namespacePart = typeof namespace === "string" ? namespace : "";
|
|
41
|
+
return `file:${namespacePart}:${file}`;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function mergePrompts(configPrompts, defaultPrompts) {
|
|
46
|
+
if (configPrompts === void 0) {
|
|
47
|
+
return defaultPrompts;
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(configPrompts)) {
|
|
50
|
+
return configPrompts;
|
|
51
|
+
}
|
|
52
|
+
if (configPrompts.length === 0) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(defaultPrompts) || defaultPrompts.length === 0) {
|
|
56
|
+
return configPrompts;
|
|
57
|
+
}
|
|
58
|
+
const order = [];
|
|
59
|
+
const entries = /* @__PURE__ */ new Map();
|
|
60
|
+
for (const [idx, prompt] of defaultPrompts.entries()) {
|
|
61
|
+
const key = promptIdentityKey(prompt) ?? `default:${idx}`;
|
|
62
|
+
if (!entries.has(key)) {
|
|
63
|
+
order.push(key);
|
|
64
|
+
}
|
|
65
|
+
entries.set(key, prompt);
|
|
66
|
+
}
|
|
67
|
+
for (const [idx, prompt] of configPrompts.entries()) {
|
|
68
|
+
const key = promptIdentityKey(prompt) ?? `config:${idx}`;
|
|
69
|
+
if (!entries.has(key)) {
|
|
70
|
+
order.push(key);
|
|
71
|
+
}
|
|
72
|
+
entries.set(key, prompt);
|
|
73
|
+
}
|
|
74
|
+
return order.map((key) => entries.get(key));
|
|
75
|
+
}
|
|
76
|
+
function applyImageDefaults(config, defaults) {
|
|
77
|
+
if (!defaults) {
|
|
78
|
+
return config;
|
|
79
|
+
}
|
|
80
|
+
const merged = { ...defaults, ...config };
|
|
81
|
+
for (const [key, defaultValue] of Object.entries(defaults)) {
|
|
82
|
+
const configValue = config[key];
|
|
83
|
+
if (!(0, import_utils.isPlainObject)(defaultValue) || !(0, import_utils.isPlainObject)(configValue)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
merged[key] = {
|
|
87
|
+
...defaultValue,
|
|
88
|
+
...configValue
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if ("prompts" in defaults || "prompts" in config) {
|
|
92
|
+
merged.prompts = mergePrompts(
|
|
93
|
+
config.prompts,
|
|
94
|
+
defaults.prompts
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return merged;
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
applyImageDefaults
|
|
102
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentConfig } from '../schemas/agent-config.js';
|
|
2
|
+
import type { ImageDefaults } from '../image/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Apply image defaults to an *unvalidated* agent config.
|
|
5
|
+
*
|
|
6
|
+
* Merge strategy:
|
|
7
|
+
* - shallow top-level merge, config wins
|
|
8
|
+
* - object fields merge 1-level deep
|
|
9
|
+
* - arrays are atomic and fully replaced (no concatenation) EXCEPT:
|
|
10
|
+
* - prompts: when config provides prompts, image prompts are retained unless config sets prompts: []
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyImageDefaults(config: AgentConfig, defaults?: ImageDefaults): AgentConfig;
|
|
13
|
+
//# sourceMappingURL=apply-image-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-image-defaults.d.ts","sourceRoot":"","sources":["../../src/resolver/apply-image-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAoEvD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,WAAW,CA2B7F"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { isPlainObject } from "./utils.js";
|
|
2
|
+
function promptIdentityKey(prompt) {
|
|
3
|
+
if (!isPlainObject(prompt)) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const type = prompt.type;
|
|
7
|
+
if (type === "inline") {
|
|
8
|
+
const id = prompt.id;
|
|
9
|
+
return typeof id === "string" && id.length > 0 ? `inline:${id}` : null;
|
|
10
|
+
}
|
|
11
|
+
if (type === "file") {
|
|
12
|
+
const file = prompt.file;
|
|
13
|
+
if (typeof file !== "string" || file.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const namespace = prompt.namespace;
|
|
17
|
+
const namespacePart = typeof namespace === "string" ? namespace : "";
|
|
18
|
+
return `file:${namespacePart}:${file}`;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function mergePrompts(configPrompts, defaultPrompts) {
|
|
23
|
+
if (configPrompts === void 0) {
|
|
24
|
+
return defaultPrompts;
|
|
25
|
+
}
|
|
26
|
+
if (!Array.isArray(configPrompts)) {
|
|
27
|
+
return configPrompts;
|
|
28
|
+
}
|
|
29
|
+
if (configPrompts.length === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
if (!Array.isArray(defaultPrompts) || defaultPrompts.length === 0) {
|
|
33
|
+
return configPrompts;
|
|
34
|
+
}
|
|
35
|
+
const order = [];
|
|
36
|
+
const entries = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const [idx, prompt] of defaultPrompts.entries()) {
|
|
38
|
+
const key = promptIdentityKey(prompt) ?? `default:${idx}`;
|
|
39
|
+
if (!entries.has(key)) {
|
|
40
|
+
order.push(key);
|
|
41
|
+
}
|
|
42
|
+
entries.set(key, prompt);
|
|
43
|
+
}
|
|
44
|
+
for (const [idx, prompt] of configPrompts.entries()) {
|
|
45
|
+
const key = promptIdentityKey(prompt) ?? `config:${idx}`;
|
|
46
|
+
if (!entries.has(key)) {
|
|
47
|
+
order.push(key);
|
|
48
|
+
}
|
|
49
|
+
entries.set(key, prompt);
|
|
50
|
+
}
|
|
51
|
+
return order.map((key) => entries.get(key));
|
|
52
|
+
}
|
|
53
|
+
function applyImageDefaults(config, defaults) {
|
|
54
|
+
if (!defaults) {
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
const merged = { ...defaults, ...config };
|
|
58
|
+
for (const [key, defaultValue] of Object.entries(defaults)) {
|
|
59
|
+
const configValue = config[key];
|
|
60
|
+
if (!isPlainObject(defaultValue) || !isPlainObject(configValue)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
merged[key] = {
|
|
64
|
+
...defaultValue,
|
|
65
|
+
...configValue
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if ("prompts" in defaults || "prompts" in config) {
|
|
69
|
+
merged.prompts = mergePrompts(
|
|
70
|
+
config.prompts,
|
|
71
|
+
defaults.prompts
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return merged;
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
applyImageDefaults
|
|
78
|
+
};
|