@iworkforces/tracelattice 2.0.8 → 2.1.2
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/README.md +89 -64
- package/dist/ServerConfig.d.ts +1 -1
- package/dist/ServerConfig.js.map +1 -1
- package/dist/cli.js +18 -73
- package/dist/cli.js.map +1 -1
- package/dist/config/ConfigLoader.d.ts +29 -26
- package/dist/config/ConfigLoader.d.ts.map +1 -1
- package/dist/config/ConfigLoader.js +40 -36
- package/dist/config/ConfigLoader.js.map +1 -1
- package/dist/contracts/PersistenceBackend.d.ts +7 -108
- package/dist/contracts/PersistenceBackend.d.ts.map +1 -1
- package/dist/contracts/PersistenceBackend.js +1 -6
- package/dist/contracts/calibrator.d.ts +6 -6
- package/dist/contracts/calibrator.d.ts.map +1 -1
- package/dist/contracts/ids.d.ts +1 -8
- package/dist/contracts/ids.d.ts.map +1 -1
- package/dist/contracts/ids.js +2 -3
- package/dist/contracts/ids.js.map +1 -1
- package/dist/contracts/interfaces.d.ts +4 -6
- package/dist/contracts/interfaces.d.ts.map +1 -1
- package/dist/contracts/persistence-work.d.ts +2 -3
- package/dist/contracts/persistence-work.d.ts.map +1 -1
- package/dist/core/HistoryManager.d.ts +12 -16
- package/dist/core/HistoryManager.d.ts.map +1 -1
- package/dist/core/HistoryManager.js +19 -40
- package/dist/core/HistoryManager.js.map +1 -1
- package/dist/core/IHistoryManager.d.ts +22 -30
- package/dist/core/IHistoryManager.d.ts.map +1 -1
- package/dist/core/InputNormalizer.d.ts +7 -24
- package/dist/core/InputNormalizer.d.ts.map +1 -1
- package/dist/core/InputNormalizer.js +3 -9
- package/dist/core/InputNormalizer.js.map +1 -1
- package/dist/core/PersistenceBuffer.d.ts +3 -20
- package/dist/core/PersistenceBuffer.d.ts.map +1 -1
- package/dist/core/PersistenceBuffer.js +1 -4
- package/dist/core/PersistenceBuffer.js.map +1 -1
- package/dist/core/PersistenceRestore.d.ts.map +1 -1
- package/dist/core/PersistenceRestore.js +4 -10
- package/dist/core/PersistenceRestore.js.map +1 -1
- package/dist/core/PersistenceWriter.d.ts.map +1 -1
- package/dist/core/PersistenceWriter.js +3 -12
- package/dist/core/PersistenceWriter.js.map +1 -1
- package/dist/core/SessionErrors.d.ts +0 -11
- package/dist/core/SessionErrors.d.ts.map +1 -1
- package/dist/core/SessionErrors.js +1 -14
- package/dist/core/SessionErrors.js.map +1 -1
- package/dist/core/SessionLock.d.ts +4 -5
- package/dist/core/SessionLock.d.ts.map +1 -1
- package/dist/core/SessionLock.js +5 -10
- package/dist/core/SessionLock.js.map +1 -1
- package/dist/core/SessionManager.d.ts +0 -2
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +3 -5
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/core/SessionResetCoordinator.d.ts +10 -7
- package/dist/core/SessionResetCoordinator.d.ts.map +1 -1
- package/dist/core/SessionResetCoordinator.js +10 -28
- package/dist/core/SessionResetCoordinator.js.map +1 -1
- package/dist/core/ThoughtEvaluator.d.ts +5 -5
- package/dist/core/ThoughtEvaluator.d.ts.map +1 -1
- package/dist/core/ThoughtEvaluator.js +4 -40
- package/dist/core/ThoughtEvaluator.js.map +1 -1
- package/dist/core/ThoughtProcessor.d.ts +10 -3
- package/dist/core/ThoughtProcessor.d.ts.map +1 -1
- package/dist/core/ThoughtProcessor.js +34 -38
- package/dist/core/ThoughtProcessor.js.map +1 -1
- package/dist/core/VerificationOutcomeAdmission.d.ts.map +1 -1
- package/dist/core/VerificationOutcomeAdmission.js +5 -7
- package/dist/core/VerificationOutcomeAdmission.js.map +1 -1
- package/dist/core/evaluator/Calibrator.d.ts +1 -1
- package/dist/core/evaluator/Calibrator.d.ts.map +1 -1
- package/dist/core/evaluator/Calibrator.js +2 -5
- package/dist/core/evaluator/Calibrator.js.map +1 -1
- package/dist/core/evaluator/internals.d.ts +0 -4
- package/dist/core/evaluator/internals.d.ts.map +1 -1
- package/dist/core/evaluator/internals.js +1 -3
- package/dist/core/evaluator/internals.js.map +1 -1
- package/dist/core/graph/Edge.d.ts +1 -1
- package/dist/core/graph/EdgeEmitter.d.ts +2 -4
- package/dist/core/graph/EdgeEmitter.d.ts.map +1 -1
- package/dist/core/graph/EdgeEmitter.js +2 -4
- package/dist/core/graph/EdgeEmitter.js.map +1 -1
- package/dist/core/reasoning/OutcomeRecorder.d.ts +0 -1
- package/dist/core/reasoning/OutcomeRecorder.d.ts.map +1 -1
- package/dist/core/reasoning/OutcomeRecorder.js.map +1 -1
- package/dist/core/reasoning/strategies/SequentialStrategy.d.ts +3 -3
- package/dist/core/reasoning/strategies/SequentialStrategy.js.map +1 -1
- package/dist/core/thought.d.ts +2 -1
- package/dist/core/thought.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -28
- package/dist/errors.js.map +1 -1
- package/dist/lib.d.ts +13 -20
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +4 -7
- package/dist/lib.js.map +1 -1
- package/dist/logger/NullLogger.d.ts +9 -11
- package/dist/logger/NullLogger.d.ts.map +1 -1
- package/dist/logger/NullLogger.js.map +1 -1
- package/dist/persistence/FilePersistence.d.ts +3 -12
- package/dist/persistence/FilePersistence.d.ts.map +1 -1
- package/dist/persistence/FilePersistence.js +9 -61
- package/dist/persistence/FilePersistence.js.map +1 -1
- package/dist/persistence/FileSnapshotV2.d.ts +2 -2
- package/dist/persistence/FileSnapshotV2.js +2 -2
- package/dist/persistence/FileSnapshotV2.js.map +1 -1
- package/dist/persistence/FileWriter.d.ts +1 -0
- package/dist/persistence/FileWriter.d.ts.map +1 -1
- package/dist/persistence/FileWriter.js +3 -3
- package/dist/persistence/FileWriter.js.map +1 -1
- package/dist/persistence/MemoryPersistence.d.ts +5 -15
- package/dist/persistence/MemoryPersistence.d.ts.map +1 -1
- package/dist/persistence/MemoryPersistence.js +6 -40
- package/dist/persistence/MemoryPersistence.js.map +1 -1
- package/dist/persistence/PersistenceCodec.js +1 -3
- package/dist/persistence/PersistenceCodec.js.map +1 -1
- package/dist/persistence/PersistenceErrors.d.ts +0 -6
- package/dist/persistence/PersistenceErrors.d.ts.map +1 -1
- package/dist/persistence/PersistenceErrors.js +1 -9
- package/dist/persistence/PersistenceErrors.js.map +1 -1
- package/dist/persistence/PersistenceScope.d.ts.map +1 -1
- package/dist/persistence/PersistenceScope.js +2 -2
- package/dist/persistence/PersistenceScope.js.map +1 -1
- package/dist/persistence/SqlitePersistence.d.ts +3 -10
- package/dist/persistence/SqlitePersistence.d.ts.map +1 -1
- package/dist/persistence/SqlitePersistence.js +2 -26
- package/dist/persistence/SqlitePersistence.js.map +1 -1
- package/dist/persistence/SqliteSchemaV2.d.ts.map +1 -1
- package/dist/persistence/SqliteSchemaV2.js +3 -12
- package/dist/persistence/SqliteSchemaV2.js.map +1 -1
- package/dist/pool/ConnectionPool.d.ts +3 -12
- package/dist/pool/ConnectionPool.d.ts.map +1 -1
- package/dist/pool/ConnectionPool.js +5 -8
- package/dist/pool/ConnectionPool.js.map +1 -1
- package/dist/pool/IConnectionPool.d.ts +3 -9
- package/dist/pool/IConnectionPool.d.ts.map +1 -1
- package/dist/registry/BaseRegistry.d.ts +10 -2
- package/dist/registry/BaseRegistry.d.ts.map +1 -1
- package/dist/registry/BaseRegistry.js +128 -81
- package/dist/registry/BaseRegistry.js.map +1 -1
- package/dist/registry/SkillRegistry.d.ts +1 -7
- package/dist/registry/SkillRegistry.d.ts.map +1 -1
- package/dist/registry/SkillRegistry.js +0 -15
- package/dist/registry/SkillRegistry.js.map +1 -1
- package/dist/registry/ToolRegistry.d.ts +1 -9
- package/dist/registry/ToolRegistry.d.ts.map +1 -1
- package/dist/registry/ToolRegistry.js +0 -21
- package/dist/registry/ToolRegistry.js.map +1 -1
- package/dist/schema.d.ts +2 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +3 -3
- package/dist/schema.js.map +1 -1
- package/dist/transport/BaseTransport.d.ts +0 -9
- package/dist/transport/BaseTransport.d.ts.map +1 -1
- package/dist/transport/BaseTransport.js +0 -11
- package/dist/transport/BaseTransport.js.map +1 -1
- package/dist/watchers/SkillWatcher.d.ts.map +1 -1
- package/dist/watchers/SkillWatcher.js +1 -1
- package/dist/watchers/SkillWatcher.js.map +1 -1
- package/package.json +1 -1
- package/dist/contracts/PersistenceBackend.js.map +0 -1
- package/dist/persistence/FileLegacyImport.d.ts +0 -2
- package/dist/persistence/FileLegacyImport.d.ts.map +0 -1
- package/dist/persistence/FileLegacyImport.js +0 -183
- package/dist/persistence/FileLegacyImport.js.map +0 -1
- package/dist/persistence/SessionScopedPersistence.d.ts +0 -4
- package/dist/persistence/SessionScopedPersistence.d.ts.map +0 -1
- package/dist/persistence/SessionScopedPersistence.js +0 -9
- package/dist/persistence/SessionScopedPersistence.js.map +0 -1
- package/dist/persistence/SqliteLegacyImport.d.ts +0 -14
- package/dist/persistence/SqliteLegacyImport.d.ts.map +0 -1
- package/dist/persistence/SqliteLegacyImport.js +0 -136
- package/dist/persistence/SqliteLegacyImport.js.map +0 -1
- package/dist/persistence/SqliteLegacySchema.d.ts +0 -15
- package/dist/persistence/SqliteLegacySchema.d.ts.map +0 -1
- package/dist/persistence/SqliteLegacySchema.js +0 -72
- package/dist/persistence/SqliteLegacySchema.js.map +0 -1
|
@@ -41,47 +41,48 @@ import type { ServerConfigOptions } from '../ServerConfig.js';
|
|
|
41
41
|
export interface ConfigFileOptions {
|
|
42
42
|
/**
|
|
43
43
|
* Maximum number of thoughts to keep in history.
|
|
44
|
-
* Can be overridden by `
|
|
44
|
+
* Can be overridden by `TRACELATTICE_MAX_HISTORY_SIZE` environment variable.
|
|
45
45
|
*/
|
|
46
46
|
readonly maxHistorySize?: number;
|
|
47
47
|
/**
|
|
48
48
|
* Maximum number of branches to maintain.
|
|
49
|
-
* Can be overridden by `
|
|
49
|
+
* Can be overridden by `TRACELATTICE_MAX_BRANCHES` environment variable.
|
|
50
50
|
*/
|
|
51
51
|
readonly maxBranches?: number;
|
|
52
52
|
/**
|
|
53
53
|
* Maximum size of each branch.
|
|
54
|
-
* Can be overridden by `
|
|
54
|
+
* Can be overridden by `TRACELATTICE_MAX_BRANCH_SIZE` environment variable.
|
|
55
55
|
*/
|
|
56
56
|
readonly maxBranchSize?: number;
|
|
57
57
|
/**
|
|
58
58
|
* Logging level for the application.
|
|
59
|
-
* Can be overridden by `
|
|
59
|
+
* Can be overridden by `TRACELATTICE_LOG_LEVEL` environment variable.
|
|
60
60
|
*/
|
|
61
61
|
readonly logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
62
62
|
/**
|
|
63
63
|
* Whether to enable pretty (formatted) logging output.
|
|
64
|
-
* Can be overridden by `
|
|
64
|
+
* Can be overridden by `TRACELATTICE_PRETTY_LOG` environment variable (set to "false" to disable).
|
|
65
65
|
*/
|
|
66
66
|
readonly prettyLog?: boolean;
|
|
67
67
|
/**
|
|
68
68
|
* Directory paths to search for skills.
|
|
69
|
-
* Can be overridden by `
|
|
69
|
+
* Can be overridden by `TRACELATTICE_SKILL_DIRS` environment variable (colon-separated).
|
|
70
70
|
*/
|
|
71
71
|
readonly skillDirs?: string[];
|
|
72
72
|
/**
|
|
73
73
|
* Directory paths to search for tools.
|
|
74
|
-
* Can be overridden by `
|
|
74
|
+
* Can be overridden by `TRACELATTICE_TOOL_DIRS` environment variable (colon-separated).
|
|
75
75
|
*/
|
|
76
76
|
readonly toolDirs?: string[];
|
|
77
77
|
/**
|
|
78
78
|
* Discovery cache configuration.
|
|
79
|
-
* Can be overridden by `
|
|
79
|
+
* Can be overridden by `TRACELATTICE_DISCOVERY_CACHE_TTL` and
|
|
80
|
+
* `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` environment variables.
|
|
80
81
|
*/
|
|
81
82
|
readonly discoveryCache?: {
|
|
82
83
|
/**
|
|
83
84
|
* Time-to-live for cache entries in milliseconds.
|
|
84
|
-
* Environment variable `
|
|
85
|
+
* Environment variable `TRACELATTICE_DISCOVERY_CACHE_TTL` accepts seconds.
|
|
85
86
|
*/
|
|
86
87
|
readonly ttl?: number;
|
|
87
88
|
/**
|
|
@@ -114,7 +115,7 @@ export interface ConfigFileOptions {
|
|
|
114
115
|
/**
|
|
115
116
|
* Maximum sessions per owner. Per-owner LRU bucket prevents one user from
|
|
116
117
|
* consuming all session slots.
|
|
117
|
-
* Can be overridden by `
|
|
118
|
+
* Can be overridden by `TRACELATTICE_SESSION_MAX_PER_OWNER` environment variable.
|
|
118
119
|
*/
|
|
119
120
|
readonly maxSessionsPerOwner?: number;
|
|
120
121
|
}
|
|
@@ -138,15 +139,15 @@ export interface ConfigFileOptions {
|
|
|
138
139
|
* **Environment Variable Overrides:**
|
|
139
140
|
* | Variable | Type | Description |
|
|
140
141
|
* |----------|------|-------------|
|
|
141
|
-
* | `
|
|
142
|
-
* | `
|
|
143
|
-
* | `
|
|
144
|
-
* | `
|
|
145
|
-
* | `
|
|
146
|
-
* | `
|
|
147
|
-
* | `
|
|
148
|
-
* | `
|
|
149
|
-
* | `
|
|
142
|
+
* | `TRACELATTICE_MAX_HISTORY_SIZE` | number | Max thoughts in history |
|
|
143
|
+
* | `TRACELATTICE_MAX_BRANCHES` | number | Max number of branches |
|
|
144
|
+
* | `TRACELATTICE_MAX_BRANCH_SIZE` | number | Max size of each branch |
|
|
145
|
+
* | `TRACELATTICE_LOG_LEVEL` | string | Logging level (debug/info/warn/error) |
|
|
146
|
+
* | `TRACELATTICE_PRETTY_LOG` | string | "false" to disable pretty logging |
|
|
147
|
+
* | `TRACELATTICE_SKILL_DIRS` | string | Colon-separated directory paths |
|
|
148
|
+
* | `TRACELATTICE_TOOL_DIRS` | string | Colon-separated directory paths |
|
|
149
|
+
* | `TRACELATTICE_DISCOVERY_CACHE_TTL` | number | TTL in seconds (converted to ms) |
|
|
150
|
+
* | `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` | number | Max cache entries |
|
|
150
151
|
*
|
|
151
152
|
* @example
|
|
152
153
|
* ```typescript
|
|
@@ -206,18 +207,20 @@ export declare class ConfigLoader {
|
|
|
206
207
|
*
|
|
207
208
|
* Environment variables take precedence over file-based configuration.
|
|
208
209
|
* Supported environment variables:
|
|
209
|
-
* - `
|
|
210
|
-
*
|
|
211
|
-
* - `
|
|
212
|
-
* - `
|
|
213
|
-
* - `
|
|
214
|
-
* - `
|
|
215
|
-
* - `
|
|
210
|
+
* - `TRACELATTICE_MAX_HISTORY_SIZE`, `TRACELATTICE_MAX_BRANCHES`,
|
|
211
|
+
* `TRACELATTICE_MAX_BRANCH_SIZE` (numbers)
|
|
212
|
+
* - `TRACELATTICE_LOG_LEVEL` (debug/info/warn/error)
|
|
213
|
+
* - `TRACELATTICE_PRETTY_LOG` ("false" to disable)
|
|
214
|
+
* - `TRACELATTICE_SKILL_DIRS` (colon-separated paths)
|
|
215
|
+
* - `TRACELATTICE_TOOL_DIRS` (colon-separated paths)
|
|
216
|
+
* - `TRACELATTICE_DISCOVERY_CACHE_TTL` (in seconds, converted to ms)
|
|
217
|
+
* - `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` (number)
|
|
216
218
|
*
|
|
217
219
|
* @param config - The configuration to apply overrides to
|
|
218
220
|
* @returns A new configuration object with environment overrides applied
|
|
219
221
|
*/
|
|
220
222
|
applyEnvironmentOverrides(config: ConfigFileOptions): ConfigFileOptions;
|
|
223
|
+
private cloneConfig;
|
|
221
224
|
/**
|
|
222
225
|
* Applies TRACELATTICE_FEATURES_* environment variable overrides for feature flags.
|
|
223
226
|
* Booleans accept 'true'/'false'/'1'/'0' (case-insensitive).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigLoader.d.ts","sourceRoot":"","sources":["../../src/config/ConfigLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC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;;;;;;OAgBG;IACI,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB;IAsF9E,OAAO,CAAC,WAAW;IAsBnB;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IAuCjC,OAAO,CAAC,uBAAuB;IAW/B;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAOpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;;;;;;;;;;;;;OAkBG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB;CAkBrE"}
|
|
@@ -33,8 +33,9 @@ const ConfigFileOptionsSchema = __rspack_external_valibot.looseObject({
|
|
|
33
33
|
class ConfigLoader {
|
|
34
34
|
_configPaths;
|
|
35
35
|
constructor(customPath){
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const configuredPath = customPath ?? process.env.TRACELATTICE_CONFIG;
|
|
37
|
+
this._configPaths = configuredPath ? [
|
|
38
|
+
configuredPath
|
|
38
39
|
] : [
|
|
39
40
|
'.claude/config.json',
|
|
40
41
|
'.claude/config.yaml',
|
|
@@ -55,7 +56,43 @@ class ConfigLoader {
|
|
|
55
56
|
return this.applyEnvironmentOverrides(config || {});
|
|
56
57
|
}
|
|
57
58
|
applyEnvironmentOverrides(config) {
|
|
58
|
-
const result =
|
|
59
|
+
const result = this.cloneConfig(config);
|
|
60
|
+
if (void 0 !== process.env.TRACELATTICE_MAX_HISTORY_SIZE) result.maxHistorySize = this.parseEnvironmentInteger('TRACELATTICE_MAX_HISTORY_SIZE', process.env.TRACELATTICE_MAX_HISTORY_SIZE);
|
|
61
|
+
if (void 0 !== process.env.TRACELATTICE_MAX_BRANCHES) result.maxBranches = this.parseEnvironmentInteger('TRACELATTICE_MAX_BRANCHES', process.env.TRACELATTICE_MAX_BRANCHES);
|
|
62
|
+
if (void 0 !== process.env.TRACELATTICE_MAX_BRANCH_SIZE) result.maxBranchSize = this.parseEnvironmentInteger('TRACELATTICE_MAX_BRANCH_SIZE', process.env.TRACELATTICE_MAX_BRANCH_SIZE);
|
|
63
|
+
if (process.env.TRACELATTICE_LOG_LEVEL && [
|
|
64
|
+
'debug',
|
|
65
|
+
'info',
|
|
66
|
+
'warn',
|
|
67
|
+
'error'
|
|
68
|
+
].includes(process.env.TRACELATTICE_LOG_LEVEL)) result.logLevel = process.env.TRACELATTICE_LOG_LEVEL;
|
|
69
|
+
if ('false' === process.env.TRACELATTICE_PRETTY_LOG) result.prettyLog = false;
|
|
70
|
+
if (void 0 !== process.env.TRACELATTICE_SKILL_DIRS) result.skillDirs = '' === process.env.TRACELATTICE_SKILL_DIRS ? [] : process.env.TRACELATTICE_SKILL_DIRS.split(':');
|
|
71
|
+
if (void 0 !== process.env.TRACELATTICE_TOOL_DIRS) result.toolDirs = '' === process.env.TRACELATTICE_TOOL_DIRS ? [] : process.env.TRACELATTICE_TOOL_DIRS.split(':');
|
|
72
|
+
if (void 0 !== process.env.TRACELATTICE_DISCOVERY_CACHE_TTL) {
|
|
73
|
+
const seconds = this.parseEnvironmentInteger('TRACELATTICE_DISCOVERY_CACHE_TTL', process.env.TRACELATTICE_DISCOVERY_CACHE_TTL);
|
|
74
|
+
const ttl = 1000 * seconds;
|
|
75
|
+
if (!Number.isSafeInteger(ttl)) throw new ConfigurationError('TRACELATTICE_DISCOVERY_CACHE_TTL exceeds the safe integer range');
|
|
76
|
+
result.discoveryCache = {
|
|
77
|
+
...result.discoveryCache,
|
|
78
|
+
ttl
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (void 0 !== process.env.TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE) {
|
|
82
|
+
const maxSize = this.parseEnvironmentInteger('TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE', process.env.TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE);
|
|
83
|
+
result.discoveryCache = {
|
|
84
|
+
...result.discoveryCache,
|
|
85
|
+
maxSize
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (void 0 !== process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS) result.toolInterleaveTtlMs = this.parseEnvironmentInteger('TRACELATTICE_TOOL_INTERLEAVE_TTL_MS', process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS);
|
|
89
|
+
if (void 0 !== process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS) result.toolInterleaveSweepMs = this.parseEnvironmentInteger('TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS', process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS);
|
|
90
|
+
if (void 0 !== process.env.TRACELATTICE_SESSION_MAX_PER_OWNER) result.maxSessionsPerOwner = this.parseEnvironmentInteger('TRACELATTICE_SESSION_MAX_PER_OWNER', process.env.TRACELATTICE_SESSION_MAX_PER_OWNER);
|
|
91
|
+
this.applyFeatureFlagOverrides(result);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
cloneConfig(config) {
|
|
95
|
+
return {
|
|
59
96
|
...config,
|
|
60
97
|
...void 0 === config.skillDirs ? {} : {
|
|
61
98
|
skillDirs: [
|
|
@@ -88,39 +125,6 @@ class ConfigLoader {
|
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
127
|
};
|
|
91
|
-
if (void 0 !== process.env.MAX_HISTORY_SIZE) result.maxHistorySize = this.parseEnvironmentInteger('MAX_HISTORY_SIZE', process.env.MAX_HISTORY_SIZE);
|
|
92
|
-
if (void 0 !== process.env.MAX_BRANCHES) result.maxBranches = this.parseEnvironmentInteger('MAX_BRANCHES', process.env.MAX_BRANCHES);
|
|
93
|
-
if (void 0 !== process.env.MAX_BRANCH_SIZE) result.maxBranchSize = this.parseEnvironmentInteger('MAX_BRANCH_SIZE', process.env.MAX_BRANCH_SIZE);
|
|
94
|
-
if (process.env.LOG_LEVEL && [
|
|
95
|
-
'debug',
|
|
96
|
-
'info',
|
|
97
|
-
'warn',
|
|
98
|
-
'error'
|
|
99
|
-
].includes(process.env.LOG_LEVEL)) result.logLevel = process.env.LOG_LEVEL;
|
|
100
|
-
if ('false' === process.env.PRETTY_LOG) result.prettyLog = false;
|
|
101
|
-
if (void 0 !== process.env.SKILL_DIRS) result.skillDirs = '' === process.env.SKILL_DIRS ? [] : process.env.SKILL_DIRS.split(':');
|
|
102
|
-
if (void 0 !== process.env.TOOL_DIRS) result.toolDirs = '' === process.env.TOOL_DIRS ? [] : process.env.TOOL_DIRS.split(':');
|
|
103
|
-
if (void 0 !== process.env.DISCOVERY_CACHE_TTL) {
|
|
104
|
-
const seconds = this.parseEnvironmentInteger('DISCOVERY_CACHE_TTL', process.env.DISCOVERY_CACHE_TTL);
|
|
105
|
-
const ttl = 1000 * seconds;
|
|
106
|
-
if (!Number.isSafeInteger(ttl)) throw new ConfigurationError('DISCOVERY_CACHE_TTL exceeds the safe integer range');
|
|
107
|
-
result.discoveryCache = {
|
|
108
|
-
...result.discoveryCache,
|
|
109
|
-
ttl
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (void 0 !== process.env.DISCOVERY_CACHE_MAX_SIZE) {
|
|
113
|
-
const maxSize = this.parseEnvironmentInteger('DISCOVERY_CACHE_MAX_SIZE', process.env.DISCOVERY_CACHE_MAX_SIZE);
|
|
114
|
-
result.discoveryCache = {
|
|
115
|
-
...result.discoveryCache,
|
|
116
|
-
maxSize
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (void 0 !== process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS) result.toolInterleaveTtlMs = this.parseEnvironmentInteger('TRACELATTICE_TOOL_INTERLEAVE_TTL_MS', process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS);
|
|
120
|
-
if (void 0 !== process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS) result.toolInterleaveSweepMs = this.parseEnvironmentInteger('TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS', process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS);
|
|
121
|
-
if (void 0 !== process.env.SESSION_MAX_PER_OWNER) result.maxSessionsPerOwner = this.parseEnvironmentInteger('SESSION_MAX_PER_OWNER', process.env.SESSION_MAX_PER_OWNER);
|
|
122
|
-
this.applyFeatureFlagOverrides(result);
|
|
123
|
-
return result;
|
|
124
128
|
}
|
|
125
129
|
applyFeatureFlagOverrides(result) {
|
|
126
130
|
const boolMap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config/ConfigLoader.js","sources":["../../src/config/ConfigLoader.ts"],"sourcesContent":["/**\n * Configuration file loading with environment variable override support.\n *\n * This module provides the `ConfigLoader` class which handles loading configuration\n * from YAML and JSON files in standard locations, with automatic environment variable\n * overrides for all settings.\n *\n * @module config\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport * as v from 'valibot';\nimport type { PersistenceConfig } from '../contracts/PersistenceBackend.js';\nimport { ConfigurationError, getErrorMessage } from '../errors.js';\nimport type { FeatureFlags } from '../contracts/features.js';\nimport type { ServerConfigOptions } from '../ServerConfig.js';\n\n/**\n * Lenient runtime schema for config files. Only validates top-level shape;\n * unknown extra fields are preserved by Valibot's default object behavior\n * being strict is avoided by using `v.looseObject`. All fields are optional.\n */\nconst ConfigFileOptionsSchema = v.looseObject({\n\tmaxHistorySize: v.optional(v.number()),\n\tmaxBranches: v.optional(v.number()),\n\tmaxBranchSize: v.optional(v.number()),\n\tlogLevel: v.optional(v.picklist(['debug', 'info', 'warn', 'error'])),\n\tprettyLog: v.optional(v.boolean()),\n\tskillDirs: v.optional(v.array(v.string())),\n\ttoolDirs: v.optional(v.array(v.string())),\n\tdiscoveryCache: v.optional(\n\t\tv.looseObject({\n\t\t\tttl: v.optional(v.number()),\n\t\t\tmaxSize: v.optional(v.number()),\n\t\t})\n\t),\n\tpersistence: v.optional(v.looseObject({})),\n\tpersistenceBufferSize: v.optional(v.number()),\n\tpersistenceFlushInterval: v.optional(v.number()),\n\tpersistenceMaxRetries: v.optional(v.number()),\n\tfeatures: v.optional(v.looseObject({})),\n\ttoolInterleaveTtlMs: v.optional(v.number()),\n\ttoolInterleaveSweepMs: v.optional(v.number()),\n\tmaxSessionsPerOwner: v.optional(v.number()),\n});\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\n/**\n * Configuration options loaded from config files.\n *\n * These options represent the structure of configuration files (JSON or YAML)\n * that can be loaded from standard locations. All values can be overridden\n * by environment variables.\n *\n * @example\n * ```yaml\n * # .claude/config.yaml\n * maxHistorySize: 500\n * maxBranches: 25\n * logLevel: debug\n * prettyLog: true\n * skillDirs:\n * - ./custom-skills\n * toolDirs:\n * - ./custom-tools\n * discoveryCache:\n * ttl: 600000\n * maxSize: 200\n * persistence:\n * enabled: true\n * backend: sqlite\n * options:\n * dbPath: ./data/history.db\n * ```\n */\nexport interface ConfigFileOptions {\n\t/**\n\t * Maximum number of thoughts to keep in history.\n\t * Can be overridden by `MAX_HISTORY_SIZE` environment variable.\n\t */\n\treadonly maxHistorySize?: number;\n\n\t/**\n\t * Maximum number of branches to maintain.\n\t * Can be overridden by `MAX_BRANCHES` environment variable.\n\t */\n\treadonly maxBranches?: number;\n\n\t/**\n\t * Maximum size of each branch.\n\t * Can be overridden by `MAX_BRANCH_SIZE` environment variable.\n\t */\n\treadonly maxBranchSize?: number;\n\n\t/**\n\t * Logging level for the application.\n\t * Can be overridden by `LOG_LEVEL` environment variable.\n\t */\n\treadonly logLevel?: 'debug' | 'info' | 'warn' | 'error';\n\n\t/**\n\t * Whether to enable pretty (formatted) logging output.\n\t * Can be overridden by `PRETTY_LOG` environment variable (set to \"false\" to disable).\n\t */\n\treadonly prettyLog?: boolean;\n\n\t/**\n\t * Directory paths to search for skills.\n\t * Can be overridden by `SKILL_DIRS` environment variable (colon-separated).\n\t */\n\treadonly skillDirs?: string[];\n\n\t/**\n\t * Directory paths to search for tools.\n\t * Can be overridden by `TOOL_DIRS` environment variable (colon-separated).\n\t */\n\treadonly toolDirs?: string[];\n\n\t/**\n\t * Discovery cache configuration.\n\t * Can be overridden by `DISCOVERY_CACHE_TTL` and `DISCOVERY_CACHE_MAX_SIZE` environment variables.\n\t */\n\treadonly discoveryCache?: {\n\t\t/**\n\t\t * Time-to-live for cache entries in milliseconds.\n\t\t * Environment variable `DISCOVERY_CACHE_TTL` accepts seconds.\n\t\t */\n\t\treadonly ttl?: number;\n\t\t/**\n\t\t * Maximum number of entries in the cache.\n\t\t */\n\t\treadonly maxSize?: number;\n\t};\n\n\t/**\n\t * Persistence configuration for storing history and state.\n\t */\n\treadonly persistence?: PersistenceConfig;\n\n\treadonly persistenceBufferSize?: number;\n\n\treadonly persistenceFlushInterval?: number;\n\n\treadonly persistenceMaxRetries?: number;\n\n\t/**\n\t * Feature flag overrides. Each field can be set independently.\n\t * Can be overridden by `TRACELATTICE_FEATURES_*` environment variables.\n\t */\n\treadonly features?: Partial<FeatureFlags>;\n\n\t/**\n\t * TTL in milliseconds for suspended tool-interleave entries.\n\t * Can be overridden by `TRACELATTICE_TOOL_INTERLEAVE_TTL_MS` environment variable.\n\t */\n\treadonly toolInterleaveTtlMs?: number;\n\n\t/**\n\t * Sweep interval in milliseconds for SuspensionStore expiration cleanup.\n\t * Can be overridden by `TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS` environment variable.\n\t */\n\treadonly toolInterleaveSweepMs?: number;\n\n\t/**\n\t * Maximum sessions per owner. Per-owner LRU bucket prevents one user from\n\t * consuming all session slots.\n\t * Can be overridden by `SESSION_MAX_PER_OWNER` environment variable.\n\t */\n\treadonly maxSessionsPerOwner?: number;\n}\n\n/**\n * Loads configuration from files with environment variable overrides.\n *\n * This class searches for configuration files in standard locations and applies\n * environment variable overrides. Files are searched in priority order, with the\n * first match being used. Environment variables always take precedence over file values.\n *\n * @remarks\n * **Config File Search Order (priority):**\n * 1. Custom path (if provided to constructor)\n * 2. `.claude/config.json` (project-local)\n * 3. `.claude/config.yaml` (project-local)\n * 4. `.claude/config.yml` (project-local)\n * 5. `~/.claude/config.json` (user-global)\n * 6. `~/.claude/config.yaml` (user-global)\n * 7. `~/.claude/config.yml` (user-global)\n *\n * **Environment Variable Overrides:**\n * | Variable | Type | Description |\n * |----------|------|-------------|\n * | `MAX_HISTORY_SIZE` | number | Max thoughts in history |\n * | `MAX_BRANCHES` | number | Max number of branches |\n * | `MAX_BRANCH_SIZE` | number | Max size of each branch |\n * | `LOG_LEVEL` | string | Logging level (debug/info/warn/error) |\n * | `PRETTY_LOG` | string | \"false\" to disable pretty logging |\n * | `SKILL_DIRS` | string | Colon-separated directory paths |\n * | `TOOL_DIRS` | string | Colon-separated directory paths |\n * | `DISCOVERY_CACHE_TTL` | number | TTL in seconds (converted to ms) |\n * | `DISCOVERY_CACHE_MAX_SIZE` | number | Max cache entries |\n *\n * @example\n * ```typescript\n * // Use default search paths\n * const loader1 = new ConfigLoader();\n * const config1 = loader1.load();\n *\n * // Use custom config path\n * const loader2 = new ConfigLoader('./my-config.yaml');\n * const config2 = loader2.load();\n *\n * // Convert to ServerConfig options\n * const serverOptions = loader2.toServerConfigOptions(config2);\n * ```\n */\nexport class ConfigLoader {\n\t/** Array of config file paths to search, in priority order. */\n\tprivate _configPaths: string[];\n\n\t/**\n\t * Creates a new ConfigLoader instance.\n\t *\n\t * @param customPath - Optional custom config file path. If provided, only this path will be checked.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Use default search paths\n\t * const loader1 = new ConfigLoader();\n\t *\n\t * // Use a specific config file\n\t * const loader2 = new ConfigLoader('./custom-config.json');\n\t * ```\n\t */\n\tconstructor(customPath?: string) {\n\t\tthis._configPaths = customPath\n\t\t\t? [customPath]\n\t\t\t: [\n\t\t\t\t\t'.claude/config.json',\n\t\t\t\t\t'.claude/config.yaml',\n\t\t\t\t\t'.claude/config.yml',\n\t\t\t\t\tjoin(homedir(), '.claude/config.json'),\n\t\t\t\t\tjoin(homedir(), '.claude/config.yaml'),\n\t\t\t\t\tjoin(homedir(), '.claude/config.yml'),\n\t\t\t\t];\n\t}\n\n\t/**\n\t * Loads configuration from files and applies environment overrides.\n\t *\n\t * Searches for config files in the configured paths (in priority order),\n\t * parses the first match, and applies environment variable overrides.\n\t * Returns null if no config file is found and no environment overrides are set.\n\t *\n\t * @returns The loaded configuration with environment overrides applied, or null if no config found\n\t *\n\t * @example\n\t * ```typescript\n\t * const loader = new ConfigLoader();\n\t * const config = loader.load();\n\t *\n\t * if (config) {\n\t * console.log('Max history size:', config.maxHistorySize);\n\t * console.log('Log level:', config.logLevel);\n\t * }\n\t * ```\n\t */\n\tload(): ConfigFileOptions | null {\n\t\tlet config: ConfigFileOptions | null = null;\n\n\t\tfor (const configPath of this._configPaths) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\ttry {\n\t\t\t\t\tconfig = this.parseConfig(configPath);\n\t\t\t\t\tbreak;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(`Failed to load config from ${configPath}:`, getErrorMessage(error));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.applyEnvironmentOverrides(config || {});\n\t}\n\n\t/**\n\t * Applies environment variable overrides to the configuration.\n\t *\n\t * Environment variables take precedence over file-based configuration.\n\t * Supported environment variables:\n\t * - `MAX_HISTORY_SIZE`, `MAX_BRANCHES`, `MAX_BRANCH_SIZE` (numbers)\n\t * - `LOG_LEVEL` (debug/info/warn/error)\n\t * - `PRETTY_LOG` (\"false\" to disable)\n\t * - `SKILL_DIRS` (colon-separated paths)\n\t * - `TOOL_DIRS` (colon-separated paths)\n\t * - `DISCOVERY_CACHE_TTL` (in seconds, converted to ms)\n\t * - `DISCOVERY_CACHE_MAX_SIZE` (number)\n\t *\n\t * @param config - The configuration to apply overrides to\n\t * @returns A new configuration object with environment overrides applied\n\t */\n\tpublic applyEnvironmentOverrides(config: ConfigFileOptions): ConfigFileOptions {\n\t\tconst result: Mutable<ConfigFileOptions> = {\n\t\t\t...config,\n\t\t\t...(config.skillDirs === undefined ? {} : { skillDirs: [...config.skillDirs] }),\n\t\t\t...(config.toolDirs === undefined ? {} : { toolDirs: [...config.toolDirs] }),\n\t\t\t...(config.discoveryCache === undefined\n\t\t\t\t? {}\n\t\t\t\t: { discoveryCache: { ...config.discoveryCache } }),\n\t\t\t...(config.persistence === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\tpersistence: {\n\t\t\t\t\t\t\t...config.persistence,\n\t\t\t\t\t\t\t...(config.persistence.options === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { options: { ...config.persistence.options } }),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t...(config.features === undefined ? {} : { features: { ...config.features } }),\n\t\t};\n\n\t\tif (process.env.MAX_HISTORY_SIZE !== undefined) {\n\t\t\tresult.maxHistorySize = this.parseEnvironmentInteger(\n\t\t\t\t'MAX_HISTORY_SIZE',\n\t\t\t\tprocess.env.MAX_HISTORY_SIZE\n\t\t\t);\n\t\t}\n\t\tif (process.env.MAX_BRANCHES !== undefined) {\n\t\t\tresult.maxBranches = this.parseEnvironmentInteger('MAX_BRANCHES', process.env.MAX_BRANCHES);\n\t\t}\n\t\tif (process.env.MAX_BRANCH_SIZE !== undefined) {\n\t\t\tresult.maxBranchSize = this.parseEnvironmentInteger(\n\t\t\t\t'MAX_BRANCH_SIZE',\n\t\t\t\tprocess.env.MAX_BRANCH_SIZE\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tprocess.env.LOG_LEVEL &&\n\t\t\t['debug', 'info', 'warn', 'error'].includes(process.env.LOG_LEVEL)\n\t\t) {\n\t\t\tresult.logLevel = process.env.LOG_LEVEL as 'debug' | 'info' | 'warn' | 'error';\n\t\t}\n\t\tif (process.env.PRETTY_LOG === 'false') {\n\t\t\tresult.prettyLog = false;\n\t\t}\n\t\tif (process.env.SKILL_DIRS !== undefined) {\n\t\t\tresult.skillDirs = process.env.SKILL_DIRS === '' ? [] : process.env.SKILL_DIRS.split(':');\n\t\t}\n\t\tif (process.env.TOOL_DIRS !== undefined) {\n\t\t\tresult.toolDirs = process.env.TOOL_DIRS === '' ? [] : process.env.TOOL_DIRS.split(':');\n\t\t}\n\t\tif (process.env.DISCOVERY_CACHE_TTL !== undefined) {\n\t\t\tconst seconds = this.parseEnvironmentInteger(\n\t\t\t\t'DISCOVERY_CACHE_TTL',\n\t\t\t\tprocess.env.DISCOVERY_CACHE_TTL\n\t\t\t);\n\t\t\tconst ttl = seconds * 1000;\n\t\t\tif (!Number.isSafeInteger(ttl)) {\n\t\t\t\tthrow new ConfigurationError('DISCOVERY_CACHE_TTL exceeds the safe integer range');\n\t\t\t}\n\t\t\tresult.discoveryCache = { ...result.discoveryCache, ttl };\n\t\t}\n\t\tif (process.env.DISCOVERY_CACHE_MAX_SIZE !== undefined) {\n\t\t\tconst maxSize = this.parseEnvironmentInteger(\n\t\t\t\t'DISCOVERY_CACHE_MAX_SIZE',\n\t\t\t\tprocess.env.DISCOVERY_CACHE_MAX_SIZE\n\t\t\t);\n\t\t\tresult.discoveryCache = { ...result.discoveryCache, maxSize };\n\t\t}\n\t\tif (process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS !== undefined) {\n\t\t\tresult.toolInterleaveTtlMs = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_TOOL_INTERLEAVE_TTL_MS',\n\t\t\t\tprocess.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS\n\t\t\t);\n\t\t}\n\t\tif (process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS !== undefined) {\n\t\t\tresult.toolInterleaveSweepMs = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS',\n\t\t\t\tprocess.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS\n\t\t\t);\n\t\t}\n\t\tif (process.env.SESSION_MAX_PER_OWNER !== undefined) {\n\t\t\tresult.maxSessionsPerOwner = this.parseEnvironmentInteger(\n\t\t\t\t'SESSION_MAX_PER_OWNER',\n\t\t\t\tprocess.env.SESSION_MAX_PER_OWNER\n\t\t\t);\n\t\t}\n\n\t\tthis.applyFeatureFlagOverrides(result);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Applies TRACELATTICE_FEATURES_* environment variable overrides for feature flags.\n\t * Booleans accept 'true'/'false'/'1'/'0' (case-insensitive).\n\t * Invalid reasoningStrategy values are rejected.\n\t *\n\t * @param result - Configuration object to mutate with feature flag overrides\n\t * @private\n\t */\n\tprivate applyFeatureFlagOverrides(result: Mutable<ConfigFileOptions>): void {\n\t\tconst boolMap: Record<string, Exclude<keyof FeatureFlags, 'reasoningStrategy'>> = {\n\t\t\tTRACELATTICE_FEATURES_DAG_EDGES: 'dagEdges',\n\t\t\tTRACELATTICE_FEATURES_CALIBRATION: 'calibration',\n\t\t\tTRACELATTICE_FEATURES_COMPRESSION: 'compression',\n\t\t\tTRACELATTICE_FEATURES_TOOL_INTERLEAVE: 'toolInterleave',\n\t\t\tTRACELATTICE_FEATURES_NEW_THOUGHT_TYPES: 'newThoughtTypes',\n\t\t\tTRACELATTICE_FEATURES_OUTCOME_RECORDING: 'outcomeRecording',\n\t\t};\n\t\tfor (const [envVar, key] of Object.entries(boolMap)) {\n\t\t\tconst raw = process.env[envVar];\n\t\t\tif (raw === undefined) continue;\n\t\t\tconst parsed = this.parseBoolean(raw);\n\t\t\tif (parsed === undefined) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Invalid boolean value for ${envVar}: \"${raw}\" (expected true/false/1/0). Ignoring.`\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst features: { -readonly [K in keyof FeatureFlags]?: FeatureFlags[K] } =\n\t\t\t\tresult.features ?? {};\n\t\t\tfeatures[key] = parsed;\n\t\t\tresult.features = features;\n\t\t}\n\n\t\tconst strategyRaw = process.env.TRACELATTICE_FEATURES_REASONING_STRATEGY;\n\t\tif (strategyRaw !== undefined) {\n\t\t\tif (strategyRaw !== 'sequential' && strategyRaw !== 'tot') {\n\t\t\t\tthrow new ConfigurationError(\n\t\t\t\t\t`TRACELATTICE_FEATURES_REASONING_STRATEGY must be one of sequential, tot, got ${strategyRaw}`\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst features: { -readonly [K in keyof FeatureFlags]?: FeatureFlags[K] } =\n\t\t\t\tresult.features ?? {};\n\t\t\tfeatures.reasoningStrategy = strategyRaw;\n\t\t\tresult.features = features;\n\t\t}\n\t}\n\n\tprivate parseEnvironmentInteger(environmentName: string, raw: string): number {\n\t\tif (!/^(0|[1-9]\\d*)$/.test(raw)) {\n\t\t\tthrow new ConfigurationError(`${environmentName} must be an integer, got ${raw}`);\n\t\t}\n\t\tconst parsed = Number(raw);\n\t\tif (!Number.isSafeInteger(parsed)) {\n\t\t\tthrow new ConfigurationError(`${environmentName} must be a safe integer, got ${raw}`);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\t/**\n\t * Parses a boolean from an environment variable string.\n\t * Accepts 'true'/'false'/'1'/'0' case-insensitively.\n\t *\n\t * @param raw - Raw environment variable string\n\t * @returns Parsed boolean, or undefined if the value is invalid\n\t * @private\n\t */\n\tprivate parseBoolean(raw: string): boolean | undefined {\n\t\tconst v = raw.trim().toLowerCase();\n\t\tif (v === 'true' || v === '1') return true;\n\t\tif (v === 'false' || v === '0') return false;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Parses a configuration file (JSON or YAML).\n\t *\n\t * Detects the file type by extension and uses the appropriate parser.\n\t * Supports `.json`, `.yaml`, and `.yml` file extensions.\n\t *\n\t * @param filePath - Path to the configuration file to parse\n\t * @returns The parsed configuration object\n\t * @throws {Error} If the file cannot be parsed\n\t * @private\n\t */\n\tprivate parseConfig(filePath: string): ConfigFileOptions {\n\t\tconst content = readFileSync(filePath, 'utf-8');\n\t\tconst ext = filePath.split('.').pop()?.toLowerCase();\n\n\t\tconst raw: unknown = ext === 'yaml' || ext === 'yml' ? parseYaml(content) : JSON.parse(content);\n\n\t\treturn v.parse(ConfigFileOptionsSchema, raw) as ConfigFileOptions;\n\t}\n\n\t/**\n\t * Converts file-based configuration to ServerConfig options.\n\t *\n\t * This is a convenience method for extracting the ServerConfig-relevant\n\t * options from a file-based configuration.\n\t *\n\t * @param config - The configuration to convert\n\t * @returns An object with ServerConfig-compatible options\n\t *\n\t * @example\n\t * ```typescript\n\t * const loader = new ConfigLoader();\n\t * const config = loader.load();\n\t * if (config) {\n\t * const serverOpts = loader.toServerConfigOptions(config);\n\t * const serverConfig = new ServerConfig(serverOpts);\n\t * }\n\t * ```\n\t */\n\ttoServerConfigOptions(config: ConfigFileOptions): ServerConfigOptions {\n\t\treturn {\n\t\t\tmaxHistorySize: config.maxHistorySize,\n\t\t\tmaxBranches: config.maxBranches,\n\t\t\tmaxBranchSize: config.maxBranchSize,\n\t\t\tskillDirs: config.skillDirs,\n\t\t\ttoolDirs: config.toolDirs,\n\t\t\tdiscoveryCache: config.discoveryCache,\n\t\t\tpersistence: config.persistence,\n\t\t\tpersistenceBufferSize: config.persistenceBufferSize,\n\t\t\tpersistenceFlushInterval: config.persistenceFlushInterval,\n\t\t\tpersistenceMaxRetries: config.persistenceMaxRetries,\n\t\t\tfeatures: config.features,\n\t\t\ttoolInterleaveTtlMs: config.toolInterleaveTtlMs,\n\t\t\ttoolInterleaveSweepMs: config.toolInterleaveSweepMs,\n\t\t\tmaxSessionsPerOwner: config.maxSessionsPerOwner,\n\t\t};\n\t}\n}\n"],"names":["ConfigFileOptionsSchema","v","ConfigLoader","customPath","join","homedir","config","configPath","existsSync","error","console","getErrorMessage","result","undefined","process","seconds","ttl","Number","ConfigurationError","maxSize","boolMap","envVar","key","Object","raw","parsed","features","strategyRaw","environmentName","filePath","content","readFileSync","ext","parseYaml","JSON"],"mappings":";;;;;;AAyBA,MAAMA,0BAA0BC,0BAAAA,WAAa,CAAC;IAC7C,gBAAgBA,0BAAAA,QAAU,CAACA,0BAAAA,MAAQ;IACnC,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;YAC/B,eAAeA,OAAO,aAAa;YACnC,WAAWA,OAAO,SAAS;YAC3B,UAAUA,OAAO,QAAQ;YACzB,gBAAgBA,OAAO,cAAc;YACrC,aAAaA,OAAO,WAAW;YAC/B,uBAAuBA,OAAO,qBAAqB;YACnD,0BAA0BA,OAAO,wBAAwB;YACzD,uBAAuBA,OAAO,qBAAqB;YACnD,UAAUA,OAAO,QAAQ;YACzB,qBAAqBA,OAAO,mBAAmB;YAC/C,uBAAuBA,OAAO,qBAAqB;YACnD,qBAAqBA,OAAO,mBAAmB;QAChD;IACD;AACD"}
|
|
1
|
+
{"version":3,"file":"config/ConfigLoader.js","sources":["../../src/config/ConfigLoader.ts"],"sourcesContent":["/**\n * Configuration file loading with environment variable override support.\n *\n * This module provides the `ConfigLoader` class which handles loading configuration\n * from YAML and JSON files in standard locations, with automatic environment variable\n * overrides for all settings.\n *\n * @module config\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport * as v from 'valibot';\nimport type { PersistenceConfig } from '../contracts/PersistenceBackend.js';\nimport { ConfigurationError, getErrorMessage } from '../errors.js';\nimport type { FeatureFlags } from '../contracts/features.js';\nimport type { ServerConfigOptions } from '../ServerConfig.js';\n\n/**\n * Lenient runtime schema for config files. Only validates top-level shape;\n * unknown extra fields are preserved by Valibot's default object behavior\n * being strict is avoided by using `v.looseObject`. All fields are optional.\n */\nconst ConfigFileOptionsSchema = v.looseObject({\n\tmaxHistorySize: v.optional(v.number()),\n\tmaxBranches: v.optional(v.number()),\n\tmaxBranchSize: v.optional(v.number()),\n\tlogLevel: v.optional(v.picklist(['debug', 'info', 'warn', 'error'])),\n\tprettyLog: v.optional(v.boolean()),\n\tskillDirs: v.optional(v.array(v.string())),\n\ttoolDirs: v.optional(v.array(v.string())),\n\tdiscoveryCache: v.optional(\n\t\tv.looseObject({\n\t\t\tttl: v.optional(v.number()),\n\t\t\tmaxSize: v.optional(v.number()),\n\t\t})\n\t),\n\tpersistence: v.optional(v.looseObject({})),\n\tpersistenceBufferSize: v.optional(v.number()),\n\tpersistenceFlushInterval: v.optional(v.number()),\n\tpersistenceMaxRetries: v.optional(v.number()),\n\tfeatures: v.optional(v.looseObject({})),\n\ttoolInterleaveTtlMs: v.optional(v.number()),\n\ttoolInterleaveSweepMs: v.optional(v.number()),\n\tmaxSessionsPerOwner: v.optional(v.number()),\n});\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\n/**\n * Configuration options loaded from config files.\n *\n * These options represent the structure of configuration files (JSON or YAML)\n * that can be loaded from standard locations. All values can be overridden\n * by environment variables.\n *\n * @example\n * ```yaml\n * # .claude/config.yaml\n * maxHistorySize: 500\n * maxBranches: 25\n * logLevel: debug\n * prettyLog: true\n * skillDirs:\n * - ./custom-skills\n * toolDirs:\n * - ./custom-tools\n * discoveryCache:\n * ttl: 600000\n * maxSize: 200\n * persistence:\n * enabled: true\n * backend: sqlite\n * options:\n * dbPath: ./data/history.db\n * ```\n */\nexport interface ConfigFileOptions {\n\t/**\n\t * Maximum number of thoughts to keep in history.\n\t * Can be overridden by `TRACELATTICE_MAX_HISTORY_SIZE` environment variable.\n\t */\n\treadonly maxHistorySize?: number;\n\n\t/**\n\t * Maximum number of branches to maintain.\n\t * Can be overridden by `TRACELATTICE_MAX_BRANCHES` environment variable.\n\t */\n\treadonly maxBranches?: number;\n\n\t/**\n\t * Maximum size of each branch.\n\t * Can be overridden by `TRACELATTICE_MAX_BRANCH_SIZE` environment variable.\n\t */\n\treadonly maxBranchSize?: number;\n\n\t/**\n\t * Logging level for the application.\n\t * Can be overridden by `TRACELATTICE_LOG_LEVEL` environment variable.\n\t */\n\treadonly logLevel?: 'debug' | 'info' | 'warn' | 'error';\n\n\t/**\n\t * Whether to enable pretty (formatted) logging output.\n\t * Can be overridden by `TRACELATTICE_PRETTY_LOG` environment variable (set to \"false\" to disable).\n\t */\n\treadonly prettyLog?: boolean;\n\n\t/**\n\t * Directory paths to search for skills.\n\t * Can be overridden by `TRACELATTICE_SKILL_DIRS` environment variable (colon-separated).\n\t */\n\treadonly skillDirs?: string[];\n\n\t/**\n\t * Directory paths to search for tools.\n\t * Can be overridden by `TRACELATTICE_TOOL_DIRS` environment variable (colon-separated).\n\t */\n\treadonly toolDirs?: string[];\n\n\t/**\n\t * Discovery cache configuration.\n\t * Can be overridden by `TRACELATTICE_DISCOVERY_CACHE_TTL` and\n\t * `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` environment variables.\n\t */\n\treadonly discoveryCache?: {\n\t\t/**\n\t\t * Time-to-live for cache entries in milliseconds.\n\t\t * Environment variable `TRACELATTICE_DISCOVERY_CACHE_TTL` accepts seconds.\n\t\t */\n\t\treadonly ttl?: number;\n\t\t/**\n\t\t * Maximum number of entries in the cache.\n\t\t */\n\t\treadonly maxSize?: number;\n\t};\n\n\t/**\n\t * Persistence configuration for storing history and state.\n\t */\n\treadonly persistence?: PersistenceConfig;\n\n\treadonly persistenceBufferSize?: number;\n\n\treadonly persistenceFlushInterval?: number;\n\n\treadonly persistenceMaxRetries?: number;\n\n\t/**\n\t * Feature flag overrides. Each field can be set independently.\n\t * Can be overridden by `TRACELATTICE_FEATURES_*` environment variables.\n\t */\n\treadonly features?: Partial<FeatureFlags>;\n\n\t/**\n\t * TTL in milliseconds for suspended tool-interleave entries.\n\t * Can be overridden by `TRACELATTICE_TOOL_INTERLEAVE_TTL_MS` environment variable.\n\t */\n\treadonly toolInterleaveTtlMs?: number;\n\n\t/**\n\t * Sweep interval in milliseconds for SuspensionStore expiration cleanup.\n\t * Can be overridden by `TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS` environment variable.\n\t */\n\treadonly toolInterleaveSweepMs?: number;\n\n\t/**\n\t * Maximum sessions per owner. Per-owner LRU bucket prevents one user from\n\t * consuming all session slots.\n\t * Can be overridden by `TRACELATTICE_SESSION_MAX_PER_OWNER` environment variable.\n\t */\n\treadonly maxSessionsPerOwner?: number;\n}\n\n/**\n * Loads configuration from files with environment variable overrides.\n *\n * This class searches for configuration files in standard locations and applies\n * environment variable overrides. Files are searched in priority order, with the\n * first match being used. Environment variables always take precedence over file values.\n *\n * @remarks\n * **Config File Search Order (priority):**\n * 1. Custom path (if provided to constructor)\n * 2. `.claude/config.json` (project-local)\n * 3. `.claude/config.yaml` (project-local)\n * 4. `.claude/config.yml` (project-local)\n * 5. `~/.claude/config.json` (user-global)\n * 6. `~/.claude/config.yaml` (user-global)\n * 7. `~/.claude/config.yml` (user-global)\n *\n * **Environment Variable Overrides:**\n * | Variable | Type | Description |\n * |----------|------|-------------|\n * | `TRACELATTICE_MAX_HISTORY_SIZE` | number | Max thoughts in history |\n * | `TRACELATTICE_MAX_BRANCHES` | number | Max number of branches |\n * | `TRACELATTICE_MAX_BRANCH_SIZE` | number | Max size of each branch |\n * | `TRACELATTICE_LOG_LEVEL` | string | Logging level (debug/info/warn/error) |\n * | `TRACELATTICE_PRETTY_LOG` | string | \"false\" to disable pretty logging |\n * | `TRACELATTICE_SKILL_DIRS` | string | Colon-separated directory paths |\n * | `TRACELATTICE_TOOL_DIRS` | string | Colon-separated directory paths |\n * | `TRACELATTICE_DISCOVERY_CACHE_TTL` | number | TTL in seconds (converted to ms) |\n * | `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` | number | Max cache entries |\n *\n * @example\n * ```typescript\n * // Use default search paths\n * const loader1 = new ConfigLoader();\n * const config1 = loader1.load();\n *\n * // Use custom config path\n * const loader2 = new ConfigLoader('./my-config.yaml');\n * const config2 = loader2.load();\n *\n * // Convert to ServerConfig options\n * const serverOptions = loader2.toServerConfigOptions(config2);\n * ```\n */\nexport class ConfigLoader {\n\t/** Array of config file paths to search, in priority order. */\n\tprivate _configPaths: string[];\n\n\t/**\n\t * Creates a new ConfigLoader instance.\n\t *\n\t * @param customPath - Optional custom config file path. If provided, only this path will be checked.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Use default search paths\n\t * const loader1 = new ConfigLoader();\n\t *\n\t * // Use a specific config file\n\t * const loader2 = new ConfigLoader('./custom-config.json');\n\t * ```\n\t */\n\tconstructor(customPath?: string) {\n\t\tconst configuredPath = customPath ?? process.env.TRACELATTICE_CONFIG;\n\t\tthis._configPaths = configuredPath\n\t\t\t? [configuredPath]\n\t\t\t: [\n\t\t\t\t\t'.claude/config.json',\n\t\t\t\t\t'.claude/config.yaml',\n\t\t\t\t\t'.claude/config.yml',\n\t\t\t\t\tjoin(homedir(), '.claude/config.json'),\n\t\t\t\t\tjoin(homedir(), '.claude/config.yaml'),\n\t\t\t\t\tjoin(homedir(), '.claude/config.yml'),\n\t\t\t\t];\n\t}\n\n\t/**\n\t * Loads configuration from files and applies environment overrides.\n\t *\n\t * Searches for config files in the configured paths (in priority order),\n\t * parses the first match, and applies environment variable overrides.\n\t * Returns null if no config file is found and no environment overrides are set.\n\t *\n\t * @returns The loaded configuration with environment overrides applied, or null if no config found\n\t *\n\t * @example\n\t * ```typescript\n\t * const loader = new ConfigLoader();\n\t * const config = loader.load();\n\t *\n\t * if (config) {\n\t * console.log('Max history size:', config.maxHistorySize);\n\t * console.log('Log level:', config.logLevel);\n\t * }\n\t * ```\n\t */\n\tload(): ConfigFileOptions | null {\n\t\tlet config: ConfigFileOptions | null = null;\n\n\t\tfor (const configPath of this._configPaths) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\ttry {\n\t\t\t\t\tconfig = this.parseConfig(configPath);\n\t\t\t\t\tbreak;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(`Failed to load config from ${configPath}:`, getErrorMessage(error));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.applyEnvironmentOverrides(config || {});\n\t}\n\n\t/**\n\t * Applies environment variable overrides to the configuration.\n\t *\n\t * Environment variables take precedence over file-based configuration.\n\t * Supported environment variables:\n\t * - `TRACELATTICE_MAX_HISTORY_SIZE`, `TRACELATTICE_MAX_BRANCHES`,\n\t * `TRACELATTICE_MAX_BRANCH_SIZE` (numbers)\n\t * - `TRACELATTICE_LOG_LEVEL` (debug/info/warn/error)\n\t * - `TRACELATTICE_PRETTY_LOG` (\"false\" to disable)\n\t * - `TRACELATTICE_SKILL_DIRS` (colon-separated paths)\n\t * - `TRACELATTICE_TOOL_DIRS` (colon-separated paths)\n\t * - `TRACELATTICE_DISCOVERY_CACHE_TTL` (in seconds, converted to ms)\n\t * - `TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE` (number)\n\t *\n\t * @param config - The configuration to apply overrides to\n\t * @returns A new configuration object with environment overrides applied\n\t */\n\tpublic applyEnvironmentOverrides(config: ConfigFileOptions): ConfigFileOptions {\n\t\tconst result = this.cloneConfig(config);\n\n\t\tif (process.env.TRACELATTICE_MAX_HISTORY_SIZE !== undefined) {\n\t\t\tresult.maxHistorySize = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_MAX_HISTORY_SIZE',\n\t\t\t\tprocess.env.TRACELATTICE_MAX_HISTORY_SIZE\n\t\t\t);\n\t\t}\n\t\tif (process.env.TRACELATTICE_MAX_BRANCHES !== undefined) {\n\t\t\tresult.maxBranches = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_MAX_BRANCHES',\n\t\t\t\tprocess.env.TRACELATTICE_MAX_BRANCHES\n\t\t\t);\n\t\t}\n\t\tif (process.env.TRACELATTICE_MAX_BRANCH_SIZE !== undefined) {\n\t\t\tresult.maxBranchSize = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_MAX_BRANCH_SIZE',\n\t\t\t\tprocess.env.TRACELATTICE_MAX_BRANCH_SIZE\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tprocess.env.TRACELATTICE_LOG_LEVEL &&\n\t\t\t['debug', 'info', 'warn', 'error'].includes(process.env.TRACELATTICE_LOG_LEVEL)\n\t\t) {\n\t\t\tresult.logLevel = process.env.TRACELATTICE_LOG_LEVEL as 'debug' | 'info' | 'warn' | 'error';\n\t\t}\n\t\tif (process.env.TRACELATTICE_PRETTY_LOG === 'false') {\n\t\t\tresult.prettyLog = false;\n\t\t}\n\t\tif (process.env.TRACELATTICE_SKILL_DIRS !== undefined) {\n\t\t\tresult.skillDirs =\n\t\t\t\tprocess.env.TRACELATTICE_SKILL_DIRS === ''\n\t\t\t\t\t? []\n\t\t\t\t\t: process.env.TRACELATTICE_SKILL_DIRS.split(':');\n\t\t}\n\t\tif (process.env.TRACELATTICE_TOOL_DIRS !== undefined) {\n\t\t\tresult.toolDirs =\n\t\t\t\tprocess.env.TRACELATTICE_TOOL_DIRS === ''\n\t\t\t\t\t? []\n\t\t\t\t\t: process.env.TRACELATTICE_TOOL_DIRS.split(':');\n\t\t}\n\t\tif (process.env.TRACELATTICE_DISCOVERY_CACHE_TTL !== undefined) {\n\t\t\tconst seconds = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_DISCOVERY_CACHE_TTL',\n\t\t\t\tprocess.env.TRACELATTICE_DISCOVERY_CACHE_TTL\n\t\t\t);\n\t\t\tconst ttl = seconds * 1000;\n\t\t\tif (!Number.isSafeInteger(ttl)) {\n\t\t\t\tthrow new ConfigurationError(\n\t\t\t\t\t'TRACELATTICE_DISCOVERY_CACHE_TTL exceeds the safe integer range'\n\t\t\t\t);\n\t\t\t}\n\t\t\tresult.discoveryCache = { ...result.discoveryCache, ttl };\n\t\t}\n\t\tif (process.env.TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE !== undefined) {\n\t\t\tconst maxSize = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE',\n\t\t\t\tprocess.env.TRACELATTICE_DISCOVERY_CACHE_MAX_SIZE\n\t\t\t);\n\t\t\tresult.discoveryCache = { ...result.discoveryCache, maxSize };\n\t\t}\n\t\tif (process.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS !== undefined) {\n\t\t\tresult.toolInterleaveTtlMs = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_TOOL_INTERLEAVE_TTL_MS',\n\t\t\t\tprocess.env.TRACELATTICE_TOOL_INTERLEAVE_TTL_MS\n\t\t\t);\n\t\t}\n\t\tif (process.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS !== undefined) {\n\t\t\tresult.toolInterleaveSweepMs = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS',\n\t\t\t\tprocess.env.TRACELATTICE_TOOL_INTERLEAVE_SWEEP_MS\n\t\t\t);\n\t\t}\n\t\tif (process.env.TRACELATTICE_SESSION_MAX_PER_OWNER !== undefined) {\n\t\t\tresult.maxSessionsPerOwner = this.parseEnvironmentInteger(\n\t\t\t\t'TRACELATTICE_SESSION_MAX_PER_OWNER',\n\t\t\t\tprocess.env.TRACELATTICE_SESSION_MAX_PER_OWNER\n\t\t\t);\n\t\t}\n\n\t\tthis.applyFeatureFlagOverrides(result);\n\n\t\treturn result;\n\t}\n\n\tprivate cloneConfig(config: ConfigFileOptions): Mutable<ConfigFileOptions> {\n\t\treturn {\n\t\t\t...config,\n\t\t\t...(config.skillDirs === undefined ? {} : { skillDirs: [...config.skillDirs] }),\n\t\t\t...(config.toolDirs === undefined ? {} : { toolDirs: [...config.toolDirs] }),\n\t\t\t...(config.discoveryCache === undefined\n\t\t\t\t? {}\n\t\t\t\t: { discoveryCache: { ...config.discoveryCache } }),\n\t\t\t...(config.persistence === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\tpersistence: {\n\t\t\t\t\t\t\t...config.persistence,\n\t\t\t\t\t\t\t...(config.persistence.options === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { options: { ...config.persistence.options } }),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t...(config.features === undefined ? {} : { features: { ...config.features } }),\n\t\t};\n\t}\n\n\t/**\n\t * Applies TRACELATTICE_FEATURES_* environment variable overrides for feature flags.\n\t * Booleans accept 'true'/'false'/'1'/'0' (case-insensitive).\n\t * Invalid reasoningStrategy values are rejected.\n\t *\n\t * @param result - Configuration object to mutate with feature flag overrides\n\t * @private\n\t */\n\tprivate applyFeatureFlagOverrides(result: Mutable<ConfigFileOptions>): void {\n\t\tconst boolMap: Record<string, Exclude<keyof FeatureFlags, 'reasoningStrategy'>> = {\n\t\t\tTRACELATTICE_FEATURES_DAG_EDGES: 'dagEdges',\n\t\t\tTRACELATTICE_FEATURES_CALIBRATION: 'calibration',\n\t\t\tTRACELATTICE_FEATURES_COMPRESSION: 'compression',\n\t\t\tTRACELATTICE_FEATURES_TOOL_INTERLEAVE: 'toolInterleave',\n\t\t\tTRACELATTICE_FEATURES_NEW_THOUGHT_TYPES: 'newThoughtTypes',\n\t\t\tTRACELATTICE_FEATURES_OUTCOME_RECORDING: 'outcomeRecording',\n\t\t};\n\t\tfor (const [envVar, key] of Object.entries(boolMap)) {\n\t\t\tconst raw = process.env[envVar];\n\t\t\tif (raw === undefined) continue;\n\t\t\tconst parsed = this.parseBoolean(raw);\n\t\t\tif (parsed === undefined) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Invalid boolean value for ${envVar}: \"${raw}\" (expected true/false/1/0). Ignoring.`\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst features: { -readonly [K in keyof FeatureFlags]?: FeatureFlags[K] } =\n\t\t\t\tresult.features ?? {};\n\t\t\tfeatures[key] = parsed;\n\t\t\tresult.features = features;\n\t\t}\n\n\t\tconst strategyRaw = process.env.TRACELATTICE_FEATURES_REASONING_STRATEGY;\n\t\tif (strategyRaw !== undefined) {\n\t\t\tif (strategyRaw !== 'sequential' && strategyRaw !== 'tot') {\n\t\t\t\tthrow new ConfigurationError(\n\t\t\t\t\t`TRACELATTICE_FEATURES_REASONING_STRATEGY must be one of sequential, tot, got ${strategyRaw}`\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst features: { -readonly [K in keyof FeatureFlags]?: FeatureFlags[K] } =\n\t\t\t\tresult.features ?? {};\n\t\t\tfeatures.reasoningStrategy = strategyRaw;\n\t\t\tresult.features = features;\n\t\t}\n\t}\n\n\tprivate parseEnvironmentInteger(environmentName: string, raw: string): number {\n\t\tif (!/^(0|[1-9]\\d*)$/.test(raw)) {\n\t\t\tthrow new ConfigurationError(`${environmentName} must be an integer, got ${raw}`);\n\t\t}\n\t\tconst parsed = Number(raw);\n\t\tif (!Number.isSafeInteger(parsed)) {\n\t\t\tthrow new ConfigurationError(`${environmentName} must be a safe integer, got ${raw}`);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\t/**\n\t * Parses a boolean from an environment variable string.\n\t * Accepts 'true'/'false'/'1'/'0' case-insensitively.\n\t *\n\t * @param raw - Raw environment variable string\n\t * @returns Parsed boolean, or undefined if the value is invalid\n\t * @private\n\t */\n\tprivate parseBoolean(raw: string): boolean | undefined {\n\t\tconst v = raw.trim().toLowerCase();\n\t\tif (v === 'true' || v === '1') return true;\n\t\tif (v === 'false' || v === '0') return false;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Parses a configuration file (JSON or YAML).\n\t *\n\t * Detects the file type by extension and uses the appropriate parser.\n\t * Supports `.json`, `.yaml`, and `.yml` file extensions.\n\t *\n\t * @param filePath - Path to the configuration file to parse\n\t * @returns The parsed configuration object\n\t * @throws {Error} If the file cannot be parsed\n\t * @private\n\t */\n\tprivate parseConfig(filePath: string): ConfigFileOptions {\n\t\tconst content = readFileSync(filePath, 'utf-8');\n\t\tconst ext = filePath.split('.').pop()?.toLowerCase();\n\n\t\tconst raw: unknown = ext === 'yaml' || ext === 'yml' ? parseYaml(content) : JSON.parse(content);\n\n\t\treturn v.parse(ConfigFileOptionsSchema, raw) as ConfigFileOptions;\n\t}\n\n\t/**\n\t * Converts file-based configuration to ServerConfig options.\n\t *\n\t * This is a convenience method for extracting the ServerConfig-relevant\n\t * options from a file-based configuration.\n\t *\n\t * @param config - The configuration to convert\n\t * @returns An object with ServerConfig-compatible options\n\t *\n\t * @example\n\t * ```typescript\n\t * const loader = new ConfigLoader();\n\t * const config = loader.load();\n\t * if (config) {\n\t * const serverOpts = loader.toServerConfigOptions(config);\n\t * const serverConfig = new ServerConfig(serverOpts);\n\t * }\n\t * ```\n\t */\n\ttoServerConfigOptions(config: ConfigFileOptions): ServerConfigOptions {\n\t\treturn {\n\t\t\tmaxHistorySize: config.maxHistorySize,\n\t\t\tmaxBranches: config.maxBranches,\n\t\t\tmaxBranchSize: config.maxBranchSize,\n\t\t\tskillDirs: config.skillDirs,\n\t\t\ttoolDirs: config.toolDirs,\n\t\t\tdiscoveryCache: config.discoveryCache,\n\t\t\tpersistence: config.persistence,\n\t\t\tpersistenceBufferSize: config.persistenceBufferSize,\n\t\t\tpersistenceFlushInterval: config.persistenceFlushInterval,\n\t\t\tpersistenceMaxRetries: config.persistenceMaxRetries,\n\t\t\tfeatures: config.features,\n\t\t\ttoolInterleaveTtlMs: config.toolInterleaveTtlMs,\n\t\t\ttoolInterleaveSweepMs: config.toolInterleaveSweepMs,\n\t\t\tmaxSessionsPerOwner: config.maxSessionsPerOwner,\n\t\t};\n\t}\n}\n"],"names":["ConfigFileOptionsSchema","v","ConfigLoader","customPath","configuredPath","process","join","homedir","config","configPath","existsSync","error","console","getErrorMessage","result","undefined","seconds","ttl","Number","ConfigurationError","maxSize","boolMap","envVar","key","Object","raw","parsed","features","strategyRaw","environmentName","filePath","content","readFileSync","ext","parseYaml","JSON"],"mappings":";;;;;;AAyBA,MAAMA,0BAA0BC,0BAAAA,WAAa,CAAC;IAC7C,gBAAgBA,0BAAAA,QAAU,CAACA,0BAAAA,MAAQ;IACnC,aAAaA,0BAAAA,QAAU,CAACA,0BAAAA,MAAQ;IAChC,eAAeA,0BAAAA,QAAU,CAACA,0BAAAA,MAAQ;IAClC,UAAUA,0BAAAA,QAAU,CAACA,0BAAAA,QAAU,CAAC;QAAC;QAAS;QAAQ;QAAQ;KAAQ;IAClE,WAAWA,0BAAAA,QAAU,CAACA,0BAAAA,OAAS;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O,QAAQ;YACzB,gBAAgBA,OAAO,cAAc;YACrC,aAAaA,OAAO,WAAW;YAC/B,uBAAuBA,OAAO,qBAAqB;YACnD,0BAA0BA,OAAO,wBAAwB;YACzD,uBAAuBA,OAAO,qBAAqB;YACnD,UAAUA,OAAO,QAAQ;YACzB,qBAAqBA,OAAO,mBAAmB;YAC/C,uBAAuBA,OAAO,qBAAqB;YACnD,qBAAqBA,OAAO,mBAAmB;QAChD;IACD;AACD"}
|
|
@@ -2,113 +2,7 @@ import type { ThoughtData } from '../core/thought.js';
|
|
|
2
2
|
import type { Edge } from '../core/graph/Edge.js';
|
|
3
3
|
import type { Summary } from '../core/compression/Summary.js';
|
|
4
4
|
import type { BranchId, SessionId } from './ids.js';
|
|
5
|
-
/**
|
|
6
|
-
* Persistence backend interface for storing thought history and branches.
|
|
7
|
-
*
|
|
8
|
-
* Implementations can store data in various formats (JSON files, SQLite, etc.)
|
|
9
|
-
* while providing a unified API for HistoryManager.
|
|
10
|
-
*/
|
|
11
5
|
export interface PersistenceBackend {
|
|
12
|
-
/**
|
|
13
|
-
* Save a single thought to persistent storage.
|
|
14
|
-
*
|
|
15
|
-
* @param thought - The thought data to persist
|
|
16
|
-
*/
|
|
17
|
-
saveThought(thought: ThoughtData): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Load all thoughts from persistent storage.
|
|
20
|
-
* Returns thoughts in chronological order (oldest first).
|
|
21
|
-
*
|
|
22
|
-
* @returns Array of all persisted thoughts
|
|
23
|
-
*/
|
|
24
|
-
loadHistory(): Promise<ThoughtData[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Save all thoughts in a branch to persistent storage.
|
|
27
|
-
*
|
|
28
|
-
* @param branchId - The unique identifier for the branch
|
|
29
|
-
* @param thoughts - Array of thoughts in branch
|
|
30
|
-
*/
|
|
31
|
-
saveBranch(branchId: BranchId, thoughts: ThoughtData[]): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Delete one global branch without treating an empty branch as deletion.
|
|
34
|
-
*
|
|
35
|
-
* Optional on legacy backends; the complete scoped capability requires it.
|
|
36
|
-
*
|
|
37
|
-
* @param branchId - The branch identifier to delete
|
|
38
|
-
*/
|
|
39
|
-
deleteBranch?(branchId: BranchId): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Load all thoughts for a specific branch.
|
|
42
|
-
*
|
|
43
|
-
* @param branchId - The unique identifier for the branch
|
|
44
|
-
* @returns Array of thoughts in branch, or undefined if branch doesn't exist
|
|
45
|
-
*/
|
|
46
|
-
loadBranch(branchId: BranchId): Promise<ThoughtData[] | undefined>;
|
|
47
|
-
/**
|
|
48
|
-
* List all branch IDs that are persisted.
|
|
49
|
-
*
|
|
50
|
-
* @returns Array of branch identifiers
|
|
51
|
-
*/
|
|
52
|
-
listBranches(): Promise<BranchId[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Check if backend is healthy.
|
|
55
|
-
* @returns Promise that resolves to true if healthy, false otherwise
|
|
56
|
-
*/
|
|
57
|
-
healthy(): Promise<boolean>;
|
|
58
|
-
/**
|
|
59
|
-
* Clear all persisted data (history and branches).
|
|
60
|
-
* Use with caution - this cannot be undone.
|
|
61
|
-
*/
|
|
62
|
-
clear(): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Close the backend and release resources.
|
|
65
|
-
* Should be called during graceful shutdown to ensure data is flushed.
|
|
66
|
-
*/
|
|
67
|
-
close(): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Save edges for a session, replacing any previously saved edges.
|
|
70
|
-
*
|
|
71
|
-
* @param sessionId - The session whose edges to persist
|
|
72
|
-
* @param edges - Array of edges to save
|
|
73
|
-
*/
|
|
74
|
-
saveEdges(sessionId: SessionId, edges: readonly Edge[]): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Load edges for a session from persistent storage.
|
|
77
|
-
* Returns edges in chronological order (by createdAt ascending).
|
|
78
|
-
* Returns empty array if no edges exist for the session.
|
|
79
|
-
*
|
|
80
|
-
* @param sessionId - The session whose edges to load
|
|
81
|
-
* @returns Array of persisted edges, sorted by createdAt
|
|
82
|
-
*/
|
|
83
|
-
loadEdges(sessionId: SessionId): Promise<Edge[]>;
|
|
84
|
-
/**
|
|
85
|
-
* List all session IDs that have persisted edge data.
|
|
86
|
-
*
|
|
87
|
-
* @returns Array of session identifiers with persisted edges
|
|
88
|
-
*/
|
|
89
|
-
listEdgeSessions(): Promise<SessionId[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Save summaries for a session, replacing any previously saved summaries.
|
|
92
|
-
*
|
|
93
|
-
* @param sessionId - The session whose summaries to persist
|
|
94
|
-
* @param summaries - Array of summaries to save
|
|
95
|
-
*/
|
|
96
|
-
saveSummaries(sessionId: SessionId, summaries: readonly Summary[]): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Load summaries for a session from persistent storage.
|
|
99
|
-
* Returns summaries in chronological order (by createdAt ascending).
|
|
100
|
-
* Returns empty array if no summaries exist for the session.
|
|
101
|
-
*
|
|
102
|
-
* @param sessionId - The session whose summaries to load
|
|
103
|
-
* @returns Array of persisted summaries, sorted by createdAt
|
|
104
|
-
*/
|
|
105
|
-
loadSummaries(sessionId: SessionId): Promise<Summary[]>;
|
|
106
|
-
}
|
|
107
|
-
/** Session-scoped persistence operations implemented as one indivisible capability. */
|
|
108
|
-
export type SessionScopedPersistenceOperation = 'saveThoughtForSession' | 'loadHistoryForSession' | 'saveBranchForSession' | 'deleteBranch' | 'deleteBranchForSession' | 'loadBranchForSession' | 'listBranchesForSession' | 'listSessions' | 'clearSession';
|
|
109
|
-
/** Persistence contract for durable named-session isolation. */
|
|
110
|
-
export interface SessionScopedPersistenceBackend extends PersistenceBackend {
|
|
111
|
-
deleteBranch(branchId: BranchId): Promise<void>;
|
|
112
6
|
saveThoughtForSession(sessionId: SessionId, thought: ThoughtData): Promise<void>;
|
|
113
7
|
loadHistoryForSession(sessionId: SessionId): Promise<ThoughtData[]>;
|
|
114
8
|
saveBranchForSession(sessionId: SessionId, branchId: BranchId, thoughts: readonly ThoughtData[]): Promise<void>;
|
|
@@ -116,10 +10,15 @@ export interface SessionScopedPersistenceBackend extends PersistenceBackend {
|
|
|
116
10
|
loadBranchForSession(sessionId: SessionId, branchId: BranchId): Promise<ThoughtData[] | undefined>;
|
|
117
11
|
listBranchesForSession(sessionId: SessionId): Promise<BranchId[]>;
|
|
118
12
|
listSessions(): Promise<SessionId[]>;
|
|
13
|
+
healthy(): Promise<boolean>;
|
|
119
14
|
clearSession(sessionId: SessionId): Promise<void>;
|
|
15
|
+
clearAll(): Promise<void>;
|
|
16
|
+
saveEdges(sessionId: SessionId, edges: readonly Edge[]): Promise<void>;
|
|
17
|
+
loadEdges(sessionId: SessionId): Promise<Edge[]>;
|
|
18
|
+
saveSummaries(sessionId: SessionId, summaries: readonly Summary[]): Promise<void>;
|
|
19
|
+
loadSummaries(sessionId: SessionId): Promise<Summary[]>;
|
|
20
|
+
close(): Promise<void>;
|
|
120
21
|
}
|
|
121
|
-
/** Return whether a backend implements every session-scoped operation. */
|
|
122
|
-
export declare function supportsSessionScopedPersistence(backend: PersistenceBackend): backend is SessionScopedPersistenceBackend;
|
|
123
22
|
export interface PersistenceConfig {
|
|
124
23
|
enabled?: boolean;
|
|
125
24
|
backend?: 'file' | 'sqlite' | 'memory';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistenceBackend.d.ts","sourceRoot":"","sources":["../../src/contracts/PersistenceBackend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"PersistenceBackend.d.ts","sourceRoot":"","sources":["../../src/contrac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C,IAAI,CAAC,CAAC;IACvE,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACvC,OAAO,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACF"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return 'saveThoughtForSession' in backend && 'function' == typeof backend.saveThoughtForSession && 'loadHistoryForSession' in backend && 'function' == typeof backend.loadHistoryForSession && 'saveBranchForSession' in backend && 'function' == typeof backend.saveBranchForSession && 'deleteBranch' in backend && 'function' == typeof backend.deleteBranch && 'deleteBranchForSession' in backend && 'function' == typeof backend.deleteBranchForSession && 'loadBranchForSession' in backend && 'function' == typeof backend.loadBranchForSession && 'listBranchesForSession' in backend && 'function' == typeof backend.listBranchesForSession && 'listSessions' in backend && 'function' == typeof backend.listSessions && 'clearSession' in backend && 'function' == typeof backend.clearSession;
|
|
3
|
-
}
|
|
4
|
-
export { supportsSessionScopedPersistence };
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=PersistenceBackend.js.map
|
|
1
|
+
export { };
|
|
@@ -73,25 +73,25 @@ export interface ICalibrator {
|
|
|
73
73
|
*/
|
|
74
74
|
calibrate(rawConfidence: number, type: ThoughtType, sessionId: SessionId): CalibrationResult;
|
|
75
75
|
/**
|
|
76
|
-
* Get calibration metrics for a session, or
|
|
76
|
+
* Get calibration metrics for a session, or aggregate metrics if `sessionId` is omitted.
|
|
77
77
|
*
|
|
78
|
-
* @param sessionId - Optional session id; omit for
|
|
78
|
+
* @param sessionId - Optional session id; omit for aggregate metrics.
|
|
79
79
|
* @returns Aggregate calibration metrics.
|
|
80
80
|
*/
|
|
81
81
|
metrics(sessionId?: SessionId): CalibrationMetrics;
|
|
82
82
|
/**
|
|
83
83
|
* Refit the calibration model from accumulated samples.
|
|
84
84
|
*
|
|
85
|
-
* @param sessionId -
|
|
85
|
+
* @param sessionId - Session id whose calibration model is refitted.
|
|
86
86
|
*/
|
|
87
|
-
refit(sessionId
|
|
87
|
+
refit(sessionId: SessionId): void;
|
|
88
88
|
/**
|
|
89
|
-
* Remove the fitted temperature for one session
|
|
89
|
+
* Remove the fitted temperature for one session.
|
|
90
90
|
*
|
|
91
91
|
* @param sessionId - Session identifier whose fitted temperature is removed.
|
|
92
92
|
*/
|
|
93
93
|
clearSession(sessionId: SessionId): void;
|
|
94
|
-
/** Remove all fitted session
|
|
94
|
+
/** Remove all fitted session temperatures. */
|
|
95
95
|
clearAll(): void;
|
|
96
96
|
}
|
|
97
97
|
//# sourceMappingURL=calibrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calibrator.d.ts","sourceRoot":"","sources":["../../src/contracts/calibrator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAA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ACnC,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IACjC,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,iBAAiB,CAAC;IAC7F;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,kBAAkB,CAAC;IACnD;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IACzC,8CAA8C;IAC9C,QAAQ,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/contracts/ids.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type SummaryId = Brand<string, 'SummaryId'>;
|
|
|
34
34
|
* Validate and brand a string as a {@link SessionId}.
|
|
35
35
|
*
|
|
36
36
|
* Enforces {@link SESSION_ID_PATTERN} and {@link MAX_SESSION_ID_LENGTH}.
|
|
37
|
-
* The
|
|
37
|
+
* The retired global session sentinel `__global__` is rejected.
|
|
38
38
|
*
|
|
39
39
|
* @throws {ValidationError} when the input is not a valid session id.
|
|
40
40
|
*/
|
|
@@ -57,12 +57,5 @@ export declare function generateEdgeId(): EdgeId;
|
|
|
57
57
|
export declare function generateSuspensionToken(): SuspensionToken;
|
|
58
58
|
/** Generate a fresh {@link SummaryId}. */
|
|
59
59
|
export declare function generateSummaryId(): SummaryId;
|
|
60
|
-
/**
|
|
61
|
-
* Reserved sentinel session id used when callers omit `session_id`.
|
|
62
|
-
*
|
|
63
|
-
* Branded once here so production and test code share one constant
|
|
64
|
-
* instead of casting `'__global__'` ad-hoc.
|
|
65
|
-
*/
|
|
66
|
-
export declare const GLOBAL_SESSION_ID: SessionId;
|
|
67
60
|
export {};
|
|
68
61
|
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/contracts/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/contracts/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AAErC;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEvE,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEnD,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEnD,+BAA+B;AAC/B,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAE/D,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEjD,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAkBpD;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEpD;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEhE;AAED,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAElD;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEpD;AAED,0CAA0C;AAC1C,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C;AAED,uCAAuC;AACvC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,gDAAgD;AAChD,wBAAgB,uBAAuB,IAAI,eAAe,CAEzD;AAED,0CAA0C;AAC1C,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C"}
|
package/dist/contracts/ids.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_SESSION_ID_LENGTH, SESSION_ID_PATTERN, generateUlid } from "../core/ids.js";
|
|
2
2
|
import { ValidationError } from "../errors.js";
|
|
3
3
|
function asSessionId(value) {
|
|
4
|
-
if ('__global__' === value)
|
|
4
|
+
if ('__global__' === value) throw new ValidationError('session_id', "reserved value '__global__' is retired; use an explicit named session");
|
|
5
5
|
if ('string' != typeof value || 0 === value.length) throw new ValidationError('session_id', 'must be a non-empty string');
|
|
6
6
|
if (value.length > MAX_SESSION_ID_LENGTH) throw new ValidationError('session_id', `exceeds max length of ${MAX_SESSION_ID_LENGTH}`);
|
|
7
7
|
if (!SESSION_ID_PATTERN.test(value)) throw new ValidationError('session_id', 'must match alphanumeric, hyphens, underscores');
|
|
@@ -34,7 +34,6 @@ function generateSuspensionToken() {
|
|
|
34
34
|
function generateSummaryId() {
|
|
35
35
|
return generateUlid();
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
export { GLOBAL_SESSION_ID, asBranchId, asEdgeId, asSessionId, asSummaryId, asSuspensionToken, asThoughtId, generateEdgeId, generateSummaryId, generateSuspensionToken, generateThoughtId };
|
|
37
|
+
export { asBranchId, asEdgeId, asSessionId, asSummaryId, asSuspensionToken, asThoughtId, generateEdgeId, generateSummaryId, generateSuspensionToken, generateThoughtId };
|
|
39
38
|
|
|
40
39
|
//# sourceMappingURL=ids.js.map
|