File size: 1,308 Bytes
e706de2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
/**
* RunnableConfig
*
* Configuration object passed through runnable chains
*
* @module src/core/context.js
*/
export class RunnableConfig {
constructor(options = {}) {
// Callbacks for monitoring
this.callbacks = options.callbacks || [];
// Metadata (arbitrary data)
this.metadata = options.metadata || {};
// Tags for filtering/organization
this.tags = options.tags || [];
// Recursion limit (prevent infinite loops)
this.recursionLimit = options.recursionLimit ?? 25;
// Runtime overrides for generation parameters
this.configurable = options.configurable || {};
}
/**
* Merge with another config (child inherits from parent)
*/
merge(other) {
return new RunnableConfig({
callbacks: [...this.callbacks, ...(other.callbacks || [])],
metadata: { ...this.metadata, ...(other.metadata || {}) },
tags: [...this.tags, ...(other.tags || [])],
recursionLimit: other.recursionLimit ?? this.recursionLimit,
configurable: { ...this.configurable, ...(other.configurable || {}) }
});
}
/**
* Create a child config with additional settings
*/
child(options = {}) {
return this.merge(new RunnableConfig(options));
}
}
export default RunnableConfig;
|