tracelattice 1.3.2 → 1.3.3
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 +25 -25
- package/dist/ServerConfig.d.ts +2 -23
- package/dist/ServerConfig.d.ts.map +1 -1
- package/dist/ServerConfig.js.map +1 -1
- package/dist/__tests__/eval/fixtures/scenarios.d.ts.map +1 -1
- package/dist/__tests__/helpers/factories.d.ts +13 -1
- package/dist/__tests__/helpers/factories.d.ts.map +1 -1
- package/dist/cache/DiscoveryCache.d.ts +1 -1
- package/dist/cache/DiscoveryCache.d.ts.map +1 -1
- package/dist/cache/DiscoveryCache.js.map +1 -1
- package/dist/cli.js +3483 -8
- package/dist/config/ConfigLoader.d.ts +2 -2
- package/dist/config/ConfigLoader.d.ts.map +1 -1
- package/dist/config/ConfigLoader.js +6 -4
- package/dist/config/ConfigLoader.js.map +1 -1
- package/dist/contracts/PersistenceBackend.d.ts.map +1 -0
- package/dist/contracts/features.d.ts +39 -0
- package/dist/contracts/features.d.ts.map +1 -0
- package/dist/contracts/features.js +15 -0
- package/dist/contracts/features.js.map +1 -0
- package/dist/contracts/ids.d.ts +58 -0
- package/dist/contracts/ids.d.ts.map +1 -0
- package/dist/contracts/ids.js +31 -0
- package/dist/contracts/ids.js.map +1 -0
- package/dist/contracts/interfaces.d.ts +6 -3
- package/dist/contracts/interfaces.d.ts.map +1 -1
- package/dist/contracts/strategy.d.ts +2 -2
- package/dist/contracts/strategy.d.ts.map +1 -1
- package/dist/contracts/suspension.d.ts +3 -2
- package/dist/contracts/suspension.d.ts.map +1 -1
- package/dist/contracts/transport.d.ts +25 -0
- package/dist/contracts/transport.d.ts.map +1 -0
- package/dist/core/HistoryManager.d.ts +2 -3
- package/dist/core/HistoryManager.d.ts.map +1 -1
- package/dist/core/HistoryManager.js.map +1 -1
- package/dist/core/IHistoryManager.d.ts +10 -0
- package/dist/core/IHistoryManager.d.ts.map +1 -1
- package/dist/core/IThoughtFormatter.d.ts +51 -0
- package/dist/core/IThoughtFormatter.d.ts.map +1 -0
- package/dist/core/IThoughtFormatter.js +1 -0
- package/dist/core/InputNormalizer.d.ts.map +1 -1
- package/dist/core/InputNormalizer.js +4 -3
- package/dist/core/InputNormalizer.js.map +1 -1
- package/dist/core/PersistenceBuffer.d.ts +1 -1
- package/dist/core/PersistenceBuffer.d.ts.map +1 -1
- package/dist/core/PersistenceBuffer.js.map +1 -1
- package/dist/core/ThoughtFormatter.d.ts +2 -1
- package/dist/core/ThoughtFormatter.d.ts.map +1 -1
- package/dist/core/ThoughtFormatter.js +3 -0
- package/dist/core/ThoughtFormatter.js.map +1 -1
- package/dist/core/ThoughtProcessor.d.ts +2 -2
- package/dist/core/ThoughtProcessor.d.ts.map +1 -1
- package/dist/core/ThoughtProcessor.js +8 -3
- package/dist/core/ThoughtProcessor.js.map +1 -1
- package/dist/core/compression/CompressionService.js +3 -3
- package/dist/core/compression/CompressionService.js.map +1 -1
- package/dist/core/compression/Summary.d.ts +4 -3
- package/dist/core/compression/Summary.d.ts.map +1 -1
- package/dist/core/graph/Edge.d.ts +11 -4
- package/dist/core/graph/Edge.d.ts.map +1 -1
- package/dist/core/graph/EdgeEmitter.js +5 -5
- package/dist/core/graph/EdgeEmitter.js.map +1 -1
- package/dist/core/reasoning/strategies/StrategyFactory.d.ts +1 -1
- package/dist/core/reasoning/strategies/StrategyFactory.d.ts.map +1 -1
- package/dist/core/reasoning/strategies/StrategyFactory.js.map +1 -1
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.d.ts.map +1 -1
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js +5 -0
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js.map +1 -1
- package/dist/core/reasoning.d.ts +8 -1
- package/dist/core/reasoning.d.ts.map +1 -1
- package/dist/core/step.d.ts +5 -0
- package/dist/core/step.d.ts.map +1 -1
- package/dist/core/thought.d.ts +4 -3
- package/dist/core/thought.d.ts.map +1 -1
- package/dist/core/tools/InMemorySuspensionStore.d.ts +3 -1
- package/dist/core/tools/InMemorySuspensionStore.d.ts.map +1 -1
- package/dist/core/tools/InMemorySuspensionStore.js +2 -2
- package/dist/core/tools/InMemorySuspensionStore.js.map +1 -1
- package/dist/di/Container.d.ts +6 -3
- package/dist/di/Container.d.ts.map +1 -1
- package/dist/di/Container.js.map +1 -1
- package/dist/di/ServiceRegistry.d.ts +3 -3
- package/dist/di/ServiceRegistry.d.ts.map +1 -1
- package/dist/errors.d.ts +36 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +49 -22
- package/dist/errors.js.map +1 -1
- package/dist/health/HealthChecker.d.ts +1 -1
- package/dist/health/HealthChecker.d.ts.map +1 -1
- package/dist/health/HealthChecker.js.map +1 -1
- package/dist/lib.d.ts +60 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/persistence/FilePersistence.d.ts +2 -2
- package/dist/persistence/FilePersistence.d.ts.map +1 -1
- package/dist/persistence/FilePersistence.js.map +1 -1
- package/dist/persistence/MemoryPersistence.d.ts +1 -1
- package/dist/persistence/MemoryPersistence.d.ts.map +1 -1
- package/dist/persistence/MemoryPersistence.js.map +1 -1
- package/dist/persistence/PersistenceFactory.d.ts +1 -1
- package/dist/persistence/PersistenceFactory.d.ts.map +1 -1
- package/dist/persistence/PersistenceFactory.js.map +1 -1
- package/dist/persistence/SqlitePersistence.d.ts +1 -1
- package/dist/persistence/SqlitePersistence.d.ts.map +1 -1
- package/dist/persistence/SqlitePersistence.js.map +1 -1
- package/dist/pool/ConnectionPool.d.ts +11 -13
- package/dist/pool/ConnectionPool.d.ts.map +1 -1
- package/dist/pool/ConnectionPool.js.map +1 -1
- package/dist/pool/IConnectionPool.d.ts +100 -0
- package/dist/pool/IConnectionPool.d.ts.map +1 -0
- package/dist/pool/IConnectionPool.js +1 -0
- package/dist/registry/BaseRegistry.d.ts +1 -1
- package/dist/registry/BaseRegistry.d.ts.map +1 -1
- package/dist/registry/BaseRegistry.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js.map +1 -1
- package/dist/transport/BaseTransport.d.ts +3 -2
- package/dist/transport/BaseTransport.d.ts.map +1 -1
- package/dist/transport/BaseTransport.js +1 -1
- package/dist/transport/BaseTransport.js.map +1 -1
- package/dist/transport/HttpTransport.d.ts +4 -2
- package/dist/transport/HttpTransport.d.ts.map +1 -1
- package/dist/transport/HttpTransport.js +4 -1
- package/dist/transport/HttpTransport.js.map +1 -1
- package/dist/transport/SseTransport.d.ts +4 -2
- package/dist/transport/SseTransport.d.ts.map +1 -1
- package/dist/transport/SseTransport.js +3 -0
- package/dist/transport/SseTransport.js.map +1 -1
- package/dist/transport/StreamableHttpTransport.d.ts +4 -2
- package/dist/transport/StreamableHttpTransport.d.ts.map +1 -1
- package/dist/transport/StreamableHttpTransport.js +4 -1
- package/dist/transport/StreamableHttpTransport.js.map +1 -1
- package/dist/types/skill.d.ts +5 -0
- package/dist/types/skill.d.ts.map +1 -1
- package/dist/types/tool.d.ts +5 -0
- package/dist/types/tool.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/__tests__/helpers/index.d.ts +0 -3
- package/dist/__tests__/helpers/index.d.ts.map +0 -1
- package/dist/contracts/index.d.ts +0 -14
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/persistence/PersistenceBackend.d.ts.map +0 -1
- /package/dist/{persistence → contracts}/PersistenceBackend.d.ts +0 -0
- /package/dist/{persistence → contracts}/PersistenceBackend.js +0 -0
- /package/dist/contracts/{index.js → transport.js} +0 -0
package/dist/core/reasoning.d.ts
CHANGED
|
@@ -21,6 +21,12 @@ import type { CalibrationMetrics } from '../contracts/calibrator.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export type ThoughtType = 'regular' | 'hypothesis' | 'verification' | 'critique' | 'synthesis' | 'meta' | 'tool_call' | 'tool_observation' | 'assumption' | 'decomposition' | 'backtrack';
|
|
24
|
+
/**
|
|
25
|
+
* Machine-readable names for the 6 detected reasoning patterns.
|
|
26
|
+
*
|
|
27
|
+
* Each name corresponds to a private detector method in PatternDetector.
|
|
28
|
+
*/
|
|
29
|
+
export type PatternName = 'consecutive_without_verification' | 'unverified_hypothesis' | 'monotonic_type' | 'no_alternatives_explored' | 'confidence_drift' | 'healthy_verification';
|
|
24
30
|
/**
|
|
25
31
|
* A detected reasoning pattern — surfaced as metadata or a warning.
|
|
26
32
|
*
|
|
@@ -36,7 +42,8 @@ export type ThoughtType = 'regular' | 'hypothesis' | 'verification' | 'critique'
|
|
|
36
42
|
*/
|
|
37
43
|
export interface PatternSignal {
|
|
38
44
|
/** Machine-readable pattern identifier. */
|
|
39
|
-
pattern
|
|
45
|
+
/** Machine-readable pattern identifier. */
|
|
46
|
+
pattern: PatternName;
|
|
40
47
|
/** Severity: 'warning' surfaces as a hint, 'info' is metadata only. */
|
|
41
48
|
severity: 'info' | 'warning';
|
|
42
49
|
/** Human-readable description of the detected pattern. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../src/core/reasoning.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GACpB,SAAS,GACT,YAAY,GACZ,cAAc,GACd,UAAU,GACV,WAAW,GACX,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,YAAY,GACZ,eAAe,GACf,WAAW,CAAC;AAEf;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC7B,2CAA2C;IAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../src/core/reasoning.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO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ts
CHANGED
|
@@ -29,6 +29,11 @@ import type { ToolRecommendation } from '../types/tool.js';
|
|
|
29
29
|
* next_step_conditions: ['If no results found, try broader search terms']
|
|
30
30
|
* };
|
|
31
31
|
* ```
|
|
32
|
+
*
|
|
33
|
+
* NOTE: Kept as a hand-written interface (not inferred from `StepRecommendationSchema`)
|
|
34
|
+
* because it composes `ToolRecommendation` / `SkillRecommendation`, which are themselves
|
|
35
|
+
* stricter than their schemas (required vs optional fields). An inferred type would
|
|
36
|
+
* weaken those nested guarantees.
|
|
32
37
|
*/
|
|
33
38
|
export interface StepRecommendation {
|
|
34
39
|
/** Human-readable description of what needs to be done in this step. */
|
package/dist/core/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/core/step.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/core/step.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,kBAAkB;IAClC,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAC;IAEzB,qEAAqE;IACrE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;IAExC,0DAA0D;IAC1D,kBAAkB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE3C,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC"}
|
package/dist/core/thought.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module types/thought
|
|
5
5
|
*/
|
|
6
|
+
import type { SessionId, ThoughtId, SuspensionToken } from '../contracts/ids.js';
|
|
6
7
|
import type { ThoughtType } from './reasoning.js';
|
|
7
8
|
import type { StepRecommendation } from './step.js';
|
|
8
9
|
/**
|
|
@@ -57,7 +58,7 @@ export interface ThoughtData {
|
|
|
57
58
|
* const thought: ThoughtData = { ...base, id: '01H0X0X0X0X0X0X0X0X0X0X0X0' };
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
|
-
id?:
|
|
61
|
+
id?: ThoughtId;
|
|
61
62
|
/** Current thought number in the sequence (1-indexed). */
|
|
62
63
|
thought_number: number;
|
|
63
64
|
/** Estimated total number of thoughts (can be adjusted during processing). */
|
|
@@ -186,7 +187,7 @@ export interface ThoughtData {
|
|
|
186
187
|
* const thought: ThoughtData = { ...base, session_id: 'analysis-task-42' };
|
|
187
188
|
* ```
|
|
188
189
|
*/
|
|
189
|
-
session_id?:
|
|
190
|
+
session_id?: SessionId;
|
|
190
191
|
/**
|
|
191
192
|
* When true, clears all state for the target session before processing this thought.
|
|
192
193
|
* The thought is then processed as the first in a fresh session.
|
|
@@ -204,7 +205,7 @@ export interface ThoughtData {
|
|
|
204
205
|
/** Result returned by the tool (for tool_observation) */
|
|
205
206
|
tool_result?: unknown;
|
|
206
207
|
/** Continuation token linking tool_observation back to suspended tool_call */
|
|
207
|
-
continuation_token?:
|
|
208
|
+
continuation_token?: SuspensionToken;
|
|
208
209
|
/** Sub-problem labels for decomposition thoughts */
|
|
209
210
|
decomposition_children?: string[];
|
|
210
211
|
/** Thought number being backtracked from */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thought.d.ts","sourceRoot":"","sources":["../../src/core/thought.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA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9E,kBAAkB,CAAC,EAAE,eAAe,CAAC;IAErC,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module core/tools/InMemorySuspensionStore
|
|
9
9
|
*/
|
|
10
10
|
import type { ISuspensionStore, SuspensionRecord } from '../../contracts/suspension.js';
|
|
11
|
+
import type { Logger } from '../../logger/StructuredLogger.js';
|
|
11
12
|
/**
|
|
12
13
|
* Configuration for {@link InMemorySuspensionStore}.
|
|
13
14
|
*/
|
|
@@ -17,7 +18,8 @@ export interface InMemorySuspensionStoreConfig {
|
|
|
17
18
|
/** Sweep interval for the background expiry timer. Defaults to 60_000ms. */
|
|
18
19
|
sweepIntervalMs?: number;
|
|
19
20
|
/** Optional logger; reserved for future diagnostic output. */
|
|
20
|
-
logger
|
|
21
|
+
/** Optional logger for diagnostic output. */
|
|
22
|
+
logger?: Logger;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* In-memory suspension store with TTL expiry and background sweep.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemorySuspensionStore.d.ts","sourceRoot":"","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"InMemorySuspensionStore.d.ts","sourceRoot":"","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,C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FAULT_SWEEP_INTERVAL_MS = 60000;
|
|
4
4
|
class InMemorySuspensionStore {
|
|
@@ -12,7 +12,7 @@ class InMemorySuspensionStore {
|
|
|
12
12
|
this._sweepIntervalMs = config.sweepIntervalMs ?? DEFAULT_SWEEP_INTERVAL_MS;
|
|
13
13
|
}
|
|
14
14
|
suspend(record) {
|
|
15
|
-
const token =
|
|
15
|
+
const token = generateSuspensionToken();
|
|
16
16
|
const createdAt = Date.now();
|
|
17
17
|
const ttlMs = record.ttlMs ?? this._ttlMs;
|
|
18
18
|
const expiresAt = createdAt + ttlMs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core/tools/InMemorySuspensionStore.js","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"sourcesContent":["/**\n * In-memory implementation of {@link ISuspensionStore}.\n *\n * Stores suspension records in process memory with optional background\n * sweeping of expired entries. Suitable for single-process deployments;\n * cluster setups should provide a shared backend.\n *\n * @module core/tools/InMemorySuspensionStore\n */\n\nimport type { ISuspensionStore, SuspensionRecord } from '../../contracts/suspension.js';\nimport {
|
|
1
|
+
{"version":3,"file":"core/tools/InMemorySuspensionStore.js","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"sourcesContent":["/**\n * In-memory implementation of {@link ISuspensionStore}.\n *\n * Stores suspension records in process memory with optional background\n * sweeping of expired entries. Suitable for single-process deployments;\n * cluster setups should provide a shared backend.\n *\n * @module core/tools/InMemorySuspensionStore\n */\n\nimport type { ISuspensionStore, SuspensionRecord } from '../../contracts/suspension.js';\nimport { generateSuspensionToken } from '../../contracts/ids.js';\nimport type { Logger } from '../../logger/StructuredLogger.js';\n\n/**\n * Configuration for {@link InMemorySuspensionStore}.\n */\nexport interface InMemorySuspensionStoreConfig {\n\t/** Default TTL applied to records that omit `ttlMs`. Defaults to 60_000ms. */\n\tttlMs?: number;\n\t/** Sweep interval for the background expiry timer. Defaults to 60_000ms. */\n\tsweepIntervalMs?: number;\n\t/** Optional logger; reserved for future diagnostic output. */\n\t/** Optional logger for diagnostic output. */\n\tlogger?: Logger;\n}\n\nconst DEFAULT_TTL_MS = 300_000;\nconst DEFAULT_SWEEP_INTERVAL_MS = 60_000;\n\n/**\n * In-memory suspension store with TTL expiry and background sweep.\n *\n * @example\n * ```typescript\n * const store = new InMemorySuspensionStore({ ttlMs: 30_000 });\n * store.start();\n * const rec = store.suspend({\n * sessionId: 's1',\n * toolCallThoughtNumber: 3,\n * toolName: 'search',\n * toolArguments: { q: 'foo' },\n * expiresAt: 0,\n * });\n * const resumed = store.resume(rec.token);\n * store.stop();\n * ```\n */\nexport class InMemorySuspensionStore implements ISuspensionStore {\n\tprivate readonly _byToken: Map<string, SuspensionRecord> = new Map();\n\tprivate readonly _bySession: Map<string, Set<string>> = new Map();\n\tprivate readonly _ttlMs: number;\n\tprivate readonly _sweepIntervalMs: number;\n\tprivate _timer: ReturnType<typeof setInterval> | null = null;\n\n\tconstructor(config: InMemorySuspensionStoreConfig = {}) {\n\t\tthis._ttlMs = config.ttlMs ?? DEFAULT_TTL_MS;\n\t\tthis._sweepIntervalMs = config.sweepIntervalMs ?? DEFAULT_SWEEP_INTERVAL_MS;\n\t}\n\n\tsuspend(\n\t\trecord: Omit<SuspensionRecord, 'token' | 'createdAt'> & { ttlMs?: number },\n\t): SuspensionRecord {\n\t\tconst token = generateSuspensionToken();\n\t\tconst createdAt = Date.now();\n\t\tconst ttlMs = record.ttlMs ?? this._ttlMs;\n\t\tconst expiresAt = createdAt + ttlMs;\n\n\t\tconst full: SuspensionRecord = {\n\t\t\ttoken,\n\t\t\tsessionId: record.sessionId,\n\t\t\ttoolCallThoughtNumber: record.toolCallThoughtNumber,\n\t\t\ttoolName: record.toolName,\n\t\t\ttoolArguments: record.toolArguments,\n\t\t\tcreatedAt,\n\t\t\texpiresAt,\n\t\t};\n\n\t\tthis._byToken.set(token, full);\n\t\tlet bucket = this._bySession.get(full.sessionId);\n\t\tif (!bucket) {\n\t\t\tbucket = new Set();\n\t\t\tthis._bySession.set(full.sessionId, bucket);\n\t\t}\n\t\tbucket.add(token);\n\n\t\treturn full;\n\t}\n\n\tresume(token: string): SuspensionRecord | null {\n\t\tconst rec = this._byToken.get(token);\n\t\tif (!rec) return null;\n\t\tif (rec.expiresAt <= Date.now()) {\n\t\t\tthis._delete(token, rec.sessionId);\n\t\t\treturn null;\n\t\t}\n\t\tthis._delete(token, rec.sessionId);\n\t\treturn rec;\n\t}\n\n\tpeek(token: string): SuspensionRecord | null {\n\t\treturn this._byToken.get(token) ?? null;\n\t}\n\n\texpireOlderThan(now: number): number {\n\t\tlet removed = 0;\n\t\tfor (const [token, rec] of this._byToken) {\n\t\t\tif (rec.expiresAt <= now) {\n\t\t\t\tthis._delete(token, rec.sessionId);\n\t\t\t\tremoved++;\n\t\t\t}\n\t\t}\n\t\treturn removed;\n\t}\n\n\tclearSession(sessionId: string): void {\n\t\tconst bucket = this._bySession.get(sessionId);\n\t\tif (!bucket) return;\n\t\tfor (const token of bucket) {\n\t\t\tthis._byToken.delete(token);\n\t\t}\n\t\tthis._bySession.delete(sessionId);\n\t}\n\n\tsize(sessionId?: string): number {\n\t\tif (sessionId === undefined) return this._byToken.size;\n\t\treturn this._bySession.get(sessionId)?.size ?? 0;\n\t}\n\n\tstart(): void {\n\t\tif (this._timer !== null) return;\n\t\tthis._timer = setInterval(() => {\n\t\t\tthis.expireOlderThan(Date.now());\n\t\t}, this._sweepIntervalMs);\n\t\tthis._timer.unref?.();\n\t}\n\n\tstop(): void {\n\t\tif (this._timer === null) return;\n\t\tclearInterval(this._timer);\n\t\tthis._timer = null;\n\t}\n\n\tprivate _delete(token: string, sessionId: string): void {\n\t\tthis._byToken.delete(token);\n\t\tconst bucket = this._bySession.get(sessionId);\n\t\tif (bucket) {\n\t\t\tbucket.delete(token);\n\t\t\tif (bucket.size === 0) this._bySession.delete(sessionId);\n\t\t}\n\t}\n}\n"],"names":["DEFAULT_TTL_MS","DEFAULT_SWEEP_INTERVAL_MS","InMemorySuspensionStore","Map","config","record","token","generateSuspensionToken","createdAt","Date","ttlMs","expiresAt","full","bucket","Set","rec","now","removed","sessionId","undefined","setInterval","clearInterval"],"mappings":";AA2BA,MAAMA,iBAAiB;AACvB,MAAMC,4BAA4B;AAoB3B,MAAMC;IACK,WAA0C,IAAIC,MAAM;IACpD,aAAuC,IAAIA,MAAM;IACjD,OAAe;IACf,iBAAyB;IAClC,SAAgD,KAAK;IAE7D,YAAYC,SAAwC,CAAC,CAAC,CAAE;QACvD,IAAI,CAAC,MAAM,GAAGA,OAAO,KAAK,IAAIJ;QAC9B,IAAI,CAAC,gBAAgB,GAAGI,OAAO,eAAe,IAAIH;IACnD;IAEA,QACCI,MAA0E,EACvD;QACnB,MAAMC,QAAQC;QACd,MAAMC,YAAYC,KAAK,GAAG;QAC1B,MAAMC,QAAQL,OAAO,KAAK,IAAI,IAAI,CAAC,MAAM;QACzC,MAAMM,YAAYH,YAAYE;QAE9B,MAAME,OAAyB;YAC9BN;YACA,WAAWD,OAAO,SAAS;YAC3B,uBAAuBA,OAAO,qBAAqB;YACnD,UAAUA,OAAO,QAAQ;YACzB,eAAeA,OAAO,aAAa;YACnCG;YACAG;QACD;QAEA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACL,OAAOM;QACzB,IAAIC,SAAS,IAAI,CAAC,UAAU,CAAC,GAAG,CAACD,KAAK,SAAS;QAC/C,IAAI,CAACC,QAAQ;YACZA,SAAS,IAAIC;YACb,IAAI,CAAC,UAAU,CAAC,GAAG,CAACF,KAAK,SAAS,EAAEC;QACrC;QACAA,OAAO,GAAG,CAACP;QAEX,OAAOM;IACR;IAEA,OAAON,KAAa,EAA2B;QAC9C,MAAMS,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACT;QAC9B,IAAI,CAACS,KAAK,OAAO;QACjB,IAAIA,IAAI,SAAS,IAAIN,KAAK,GAAG,IAAI;YAChC,IAAI,CAAC,OAAO,CAACH,OAAOS,IAAI,SAAS;YACjC,OAAO;QACR;QACA,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AAU,CAAC,GAAG,CAACK;QACnC,IAAIL,QAAQ;YACXA,OAAO,MAAM,CAACP;YACd,IAAIO,AAAgB,MAAhBA,OAAO,IAAI,EAAQ,IAAI,CAAC,UAAU,CAAC,MAAM,CAACK;QAC/C;IACD;AACD"}
|
package/dist/di/Container.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Logger } from '../logger/StructuredLogger.js';
|
|
2
|
+
import type { ServerConfig } from '../ServerConfig.js';
|
|
3
|
+
import type { ConfigFileOptions } from '../config/ConfigLoader.js';
|
|
1
4
|
import type { IDisposable } from '../types/disposable.js';
|
|
2
5
|
import type { ServiceKey, ServiceRegistry } from './ServiceRegistry.js';
|
|
3
6
|
/**
|
|
@@ -218,9 +221,9 @@ export declare class Container {
|
|
|
218
221
|
* ```
|
|
219
222
|
*/
|
|
220
223
|
export interface CreateContainerOptions {
|
|
221
|
-
logger?:
|
|
222
|
-
config?:
|
|
223
|
-
fileConfig?:
|
|
224
|
+
logger?: Logger;
|
|
225
|
+
config?: ServerConfig;
|
|
226
|
+
fileConfig?: ConfigFileOptions;
|
|
224
227
|
}
|
|
225
228
|
export declare function createDefaultContainer(options?: CreateContainerOptions): Container;
|
|
226
229
|
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/di/Container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,mBAAmB,CAAyC;IACpE,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CA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package/dist/di/Container.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di/Container.js","sources":["../../src/di/Container.ts"],"sourcesContent":["import type { IDisposable } from '../types/disposable.js';\nimport type { ServiceKey, ServiceRegistry } from './ServiceRegistry.js';\n\n/**\n * Lightweight dependency injection container for managing service dependencies.\n *\n * This container supports:\n * - Instance registration (singleton-like behavior)\n * - Factory registration (lazy instantiation with caching)\n * - Transient factory registration (new instance each time)\n *\n * The container is type-safe when using ServiceKey from ServiceRegistry.\n * For dynamic/unknown services, use string keys with generic type parameters.\n *\n * @example\n * ```typescript\n * const container = new Container();\n *\n * // Type-safe registration with ServiceKey (recommended)\n * container.registerInstance('Logger', new StructuredLogger());\n *\n * // Type inference works automatically\n * const logger = container.resolve('Logger'); // Type: StructuredLogger\n *\n * // Register a factory with caching (singleton per container)\n * container.register('HistoryManager', () =>\n * new HistoryManager({ logger: container.resolve('Logger') })\n * );\n *\n * // Register a transient factory (new instance each time)\n * container.registerFactory('RequestContext', () =>\n * new RequestContext()\n * );\n *\n * // For dynamic services not in ServiceRegistry\n * container.registerInstance<MyService>('MyService', myService);\n * const service = container.resolve<MyService>('MyService');\n * ```\n */\nexport class Container {\n\tprivate _services: Map<string, unknown> = new Map();\n\tprivate _factories: Map<string, () => unknown> = new Map();\n\tprivate _transientFactories: Map<string, () => unknown> = new Map();\n\tprivate _resolving: Set<string> = new Set();\n\tprivate _disposables: Map<string, IDisposable> = new Map();\n\n\t/**\n\t * Register a singleton instance that will be returned for all resolutions.\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param instance - The instance to register\n\t *\n\t * @example\n\t * ```typescript\n\t * container.registerInstance('Config', new ServerConfig({ ... }));\n\t * ```\n\t */\n\tregisterInstance<K extends ServiceKey>(name: K, instance: ServiceRegistry[K]): void;\n\tregisterInstance<T>(name: string, instance: T): void;\n\tregisterInstance(name: string, instance: unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._services.set(name, instance);\n\t}\n\n\t/**\n\t * Register a factory function that will be called once and cached.\n\t * The first call to `resolve` will invoke the factory and cache the result.\n\t * Subsequent calls will return the cached instance (singleton behavior).\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param factory - A factory function that creates the service\n\t *\n\t * @example\n\t * ```typescript\n\t * container.register('HistoryManager', () =>\n\t * new HistoryManager({ logger: container.resolve('Logger') })\n\t * );\n\t * ```\n\t */\n\tregister<K extends ServiceKey>(name: K, factory: () => ServiceRegistry[K]): void;\n\tregister<T>(name: string, factory: () => T): void;\n\tregister(name: string, factory: () => unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._factories.set(name, factory);\n\t}\n\n\t/**\n\t * Register a transient factory function that will be called on every resolution.\n\t * Each call to `resolve` will invoke the factory and return a new instance.\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param factory - A factory function that creates the service\n\t *\n\t * @example\n\t * ```typescript\n\t * container.registerFactory('RequestContext', () =>\n\t * new RequestContext()\n\t * );\n\t * ```\n\t */\n\tregisterFactory<K extends ServiceKey>(name: K, factory: () => ServiceRegistry[K]): void;\n\tregisterFactory<T>(name: string, factory: () => T): void;\n\tregisterFactory(name: string, factory: () => unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._transientFactories.set(name, factory);\n\t}\n\n\t/**\n\t * Resolve a service by name.\n\t *\n\t * Resolution order:\n\t * 1. If a registered instance exists, return it\n\t * 2. If a cached factory exists, return it\n\t * 3. If a factory exists, invoke it, cache the result, and return it\n\t * 4. If a transient factory exists, invoke it and return a new instance\n\t * 5. Throw an error if the service is not found\n\t *\n\t * @param name - The name/identifier of service to resolve\n\t * @returns The resolved service instance\n\t * @throws {Error} If the service is not registered\n\t *\n\t * @example\n\t * ```typescript\n\t * // Type-safe: ServiceRegistry provides autocomplete\n\t * const logger = container.resolve('Logger'); // Type: StructuredLogger\n\t * const config = container.resolve('Config'); // Type: ServerConfig\n\t *\n\t * // Dynamic: For services not in ServiceRegistry\n\t * const service = container.resolve<MyService>('MyService');\n\t * ```\n\t */\n\tresolve<K extends ServiceKey>(name: K): ServiceRegistry[K];\n\tresolve<T>(name: string): T;\n\tresolve(name: string): unknown {\n\t\tif (this._resolving.has(name)) {\n\t\t\tthrow new Error(`Circular dependency detected while resolving service: ${name}`);\n\t\t}\n\n\t\tthis._resolving.add(name);\n\n\t\ttry {\n\t\t\t// Check for registered instance first\n\t\t\tif (this._services.has(name)) {\n\t\t\t\treturn this._services.get(name);\n\t\t\t}\n\n\t\t\t// Check for cached factory result\n\t\t\tif (this._factories.has(name)) {\n\t\t\t\tconst factory = this._factories.get(name)!;\n\t\t\t\tconst instance = factory();\n\t\t\t\t// Cache the result for future calls (singleton behavior)\n\t\t\t\tthis._services.set(name, instance);\n\t\t\t\tthis._factories.delete(name);\n\t\t\t\treturn instance;\n\t\t\t}\n\n\t\t\t// Check for transient factory (call every time)\n\t\t\tif (this._transientFactories.has(name)) {\n\t\t\t\tconst factory = this._transientFactories.get(name)!;\n\t\t\t\treturn factory();\n\t\t\t}\n\n\t\t\tthrow new Error(`Service not found: ${name}. Did you forget to register it?`);\n\t\t} finally {\n\t\t\tthis._resolving.delete(name);\n\t\t}\n\t}\n\n\t/**\n\t * Check if a service is registered (either as instance or factory).\n\t *\n\t * @param name - The name/identifier of the service to check\n\t * @returns `true` if the service is registered, `false` otherwise\n\t *\n\t * @example\n\t * ```typescript\n\t * if (!container.has('Logger')) {\n\t * container.registerInstance('Logger', new StructuredLogger());\n\t * }\n\t * ```\n\t */\n\thas(name: string): boolean {\n\t\treturn (\n\t\t\tthis._services.has(name) || this._factories.has(name) || this._transientFactories.has(name)\n\t\t);\n\t}\n\n\t/**\n\t * Remove a registered service from the container.\n\t *\n\t * @param name - The name/identifier of the service to unregister\n\t * @returns `true` if the service was found and removed, `false` otherwise\n\t *\n\t * @example\n\t * ```typescript\n\t * container.unregister('HistoryManager');\n\t * ```\n\t */\n\tunregister(name: string): boolean {\n\t\tconst hadInstance = this._services.delete(name);\n\t\tconst hadFactory = this._factories.delete(name);\n\t\tconst hadTransient = this._transientFactories.delete(name);\n\t\tthis._disposables.delete(name);\n\t\treturn hadInstance || hadFactory || hadTransient;\n\t}\n\n\t/**\n\t * Clear all registered services and factories from the container.\n\t *\n\t * @example\n\t * ```typescript\n\t * container.clear();\n\t * ```\n\t */\n\tclear(): void {\n\t\tthis._services.clear();\n\t\tthis._factories.clear();\n\t\tthis._transientFactories.clear();\n\t\tthis._resolving.clear();\n\t\tthis._disposables.clear();\n\t}\n\n\t/**\n\t * Get the number of registered services (including instances, factories, and transient factories).\n\t *\n\t * @returns The total count of registered services\n\t *\n\t * @example\n\t * ```typescript\n\t * console.log(`Registered services: ${container.size}`);\n\t * ```\n\t */\n\tget size(): number {\n\t\treturn this._services.size + this._factories.size + this._transientFactories.size;\n\t}\n\n\t/**\n\t * Get an array of all registered service names.\n\t *\n\t * @returns An array of service names\n\t *\n\t * @example\n\t * ```typescript\n\t * const names = container.registeredServices();\n\t * console.log('Registered:', names.join(', '));\n\t * ```\n\t */\n\tregisteredServices(): string[] {\n\t\tconst names = new Set<string>();\n\t\tfor (const name of this._services.keys()) names.add(name);\n\t\tfor (const name of this._factories.keys()) names.add(name);\n\t\tfor (const name of this._transientFactories.keys()) names.add(name);\n\t\treturn Array.from(names);\n\t}\n\n\t/**\n\t * Register an instance as disposable for lifecycle management.\n\t * The instance will have its `dispose()` method called when the container is disposed.\n\t *\n\t * @param name - The service name (must already be registered)\n\t * @param instance - The disposable instance to track\n\t *\n\t * @example\n\t * ```typescript\n\t * const pool = new ConnectionPool();\n\t * container.registerInstance('ConnectionPool', pool);\n\t * container.registerDisposable('ConnectionPool', pool);\n\t * ```\n\t */\n\tregisterDisposable(name: string, instance: IDisposable): void {\n\t\tthis._disposables.set(name, instance);\n\t}\n\n\t/**\n\t * Dispose of all registered disposable services.\n\t * Calls `dispose()` on each registered disposable in reverse registration order.\n\t * Errors during individual disposal are caught and logged to prevent cascading failures.\n\t *\n\t * @example\n\t * ```typescript\n\t * await container.dispose();\n\t * ```\n\t */\n\tasync dispose(): Promise<void> {\n\t\tconst entries = Array.from(this._disposables.entries()).reverse();\n\t\tconst errors: Array<{ name: string; error: unknown }> = [];\n\n\t\tfor (const [name, disposable] of entries) {\n\t\t\ttry {\n\t\t\t\tawait disposable.dispose();\n\t\t\t} catch (error) {\n\t\t\t\terrors.push({ name, error });\n\t\t\t}\n\t\t}\n\n\t\tthis._disposables.clear();\n\n\t\tif (errors.length > 0) {\n\t\t\tconst messages = errors.map(\n\t\t\t\t(e) => `${e.name}: ${e.error instanceof Error ? e.error.message : String(e.error)}`\n\t\t\t);\n\t\t\tthrow new Error(`Failed to dispose services: ${messages.join(', ')}`);\n\t\t}\n\t}\n}\n\n/**\n * Create a pre-configured container with all default services registered.\n *\n * This factory function creates a container with all standard services\n * for the ToolAwareSequentialThinkingServer.\n *\n * @param options - Configuration options for the container\n * @returns A configured container ready to use\n *\n * @example\n * ```typescript\n * const container = createDefaultContainer({\n * logger: customLogger,\n * config: customConfig\n * });\n * const server = new ToolAwareSequentialThinkingServer({ container });\n * ```\n */\nexport interface CreateContainerOptions {\n\tlogger?: unknown;\n\tconfig?: unknown;\n\tfileConfig?: Record<string, unknown>;\n}\n\nexport function createDefaultContainer(options: CreateContainerOptions = {}): Container {\n\tconst container = new Container();\n\n\t// Register logger if provided\n\tif (options.logger) {\n\t\tcontainer.registerInstance('Logger', options.logger);\n\t}\n\n\t// Register config if provided\n\tif (options.config) {\n\t\tcontainer.registerInstance('Config', options.config);\n\t}\n\n\treturn container;\n}\n"],"names":["Container","Map","Set","name","instance","Error","factory","hadInstance","hadFactory","hadTransient","names","Array","entries","errors","disposable","error","messages","e","String","createDefaultContainer","options","container"],"mappings":"AAuCO,MAAMA;IACJ,YAAkC,IAAIC,MAAM;IAC5C,aAAyC,IAAIA,MAAM;IACnD,sBAAkD,IAAIA,MAAM;IAC5D,aAA0B,IAAIC,MAAM;IACpC,eAAyC,IAAID,MAAM;IAe3D,iBAAiBE,IAAY,EAAEC,QAAiB,EAAQ;QACvD,IACC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACD,SACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,SACpB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAACA,OAE7B,MAAM,IAAIE,MAAM,CAAC,SAAS,EAAEF,KAAK,uBAAuB,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,MAAMC;IAC1B;IAmBA,SAASD,IAAY,EAAEG,OAAsB,EAAQ;QACpD,IACC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACH,SACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,SACpB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAACA,OAE7B,MAAM,IAAIE,MAAM,CAAC,SAAS,EAAEF,KAAK,uBAAuB,CAAC;QAE1D,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,MAAMG;IAC3B;IAkBA,gBAAgBH,IAAY,EAAEG,OAAsB,EAAQ;QAC3D,IACC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACH,SACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,SACpB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAACA,OAE7B,MAAM,IAAIE,MAAM,CAAC,SAAS,EAAEF,KAAK,uBAAuB,CAAC;QAE1D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAACA,MAAMG;IACpC;IA4BA,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KAAK,YAAYZ,QAAQY,EAAE,KAAK,CAAC,OAAO,GAAGC,OAAOD,EAAE,KAAK,GAAG;YAEpF,MAAM,IAAIZ,MAAM,CAAC,4BAA4B,EAAEW,SAAS,IAAI,CAAC,OAAO;QACrE;IACD;AACD;AA0BO,SAASG,uBAAuBC,UAAkC,CAAC,CAAC;IAC1E,MAAMC,YAAY,IAAIrB;IAGtB,IAAIoB,QAAQ,MAAM,EACjBC,UAAU,gBAAgB,CAAC,UAAUD,QAAQ,MAAM;IAIpD,IAAIA,QAAQ,MAAM,EACjBC,UAAU,gBAAgB,CAAC,UAAUD,QAAQ,MAAM;IAGpD,OAAOC;AACR"}
|
|
1
|
+
{"version":3,"file":"di/Container.js","sources":["../../src/di/Container.ts"],"sourcesContent":["import type { Logger } from '../logger/StructuredLogger.js';\nimport type { ServerConfig } from '../ServerConfig.js';\nimport type { ConfigFileOptions } from '../config/ConfigLoader.js';\n\nimport type { IDisposable } from '../types/disposable.js';\nimport type { ServiceKey, ServiceRegistry } from './ServiceRegistry.js';\n\n/**\n * Lightweight dependency injection container for managing service dependencies.\n *\n * This container supports:\n * - Instance registration (singleton-like behavior)\n * - Factory registration (lazy instantiation with caching)\n * - Transient factory registration (new instance each time)\n *\n * The container is type-safe when using ServiceKey from ServiceRegistry.\n * For dynamic/unknown services, use string keys with generic type parameters.\n *\n * @example\n * ```typescript\n * const container = new Container();\n *\n * // Type-safe registration with ServiceKey (recommended)\n * container.registerInstance('Logger', new StructuredLogger());\n *\n * // Type inference works automatically\n * const logger = container.resolve('Logger'); // Type: StructuredLogger\n *\n * // Register a factory with caching (singleton per container)\n * container.register('HistoryManager', () =>\n * new HistoryManager({ logger: container.resolve('Logger') })\n * );\n *\n * // Register a transient factory (new instance each time)\n * container.registerFactory('RequestContext', () =>\n * new RequestContext()\n * );\n *\n * // For dynamic services not in ServiceRegistry\n * container.registerInstance<MyService>('MyService', myService);\n * const service = container.resolve<MyService>('MyService');\n * ```\n */\nexport class Container {\n\tprivate _services: Map<string, unknown> = new Map();\n\tprivate _factories: Map<string, () => unknown> = new Map();\n\tprivate _transientFactories: Map<string, () => unknown> = new Map();\n\tprivate _resolving: Set<string> = new Set();\n\tprivate _disposables: Map<string, IDisposable> = new Map();\n\n\t/**\n\t * Register a singleton instance that will be returned for all resolutions.\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param instance - The instance to register\n\t *\n\t * @example\n\t * ```typescript\n\t * container.registerInstance('Config', new ServerConfig({ ... }));\n\t * ```\n\t */\n\tregisterInstance<K extends ServiceKey>(name: K, instance: ServiceRegistry[K]): void;\n\tregisterInstance<T>(name: string, instance: T): void;\n\tregisterInstance(name: string, instance: unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._services.set(name, instance);\n\t}\n\n\t/**\n\t * Register a factory function that will be called once and cached.\n\t * The first call to `resolve` will invoke the factory and cache the result.\n\t * Subsequent calls will return the cached instance (singleton behavior).\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param factory - A factory function that creates the service\n\t *\n\t * @example\n\t * ```typescript\n\t * container.register('HistoryManager', () =>\n\t * new HistoryManager({ logger: container.resolve('Logger') })\n\t * );\n\t * ```\n\t */\n\tregister<K extends ServiceKey>(name: K, factory: () => ServiceRegistry[K]): void;\n\tregister<T>(name: string, factory: () => T): void;\n\tregister(name: string, factory: () => unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._factories.set(name, factory);\n\t}\n\n\t/**\n\t * Register a transient factory function that will be called on every resolution.\n\t * Each call to `resolve` will invoke the factory and return a new instance.\n\t *\n\t * @param name - The unique name/identifier for the service\n\t * @param factory - A factory function that creates the service\n\t *\n\t * @example\n\t * ```typescript\n\t * container.registerFactory('RequestContext', () =>\n\t * new RequestContext()\n\t * );\n\t * ```\n\t */\n\tregisterFactory<K extends ServiceKey>(name: K, factory: () => ServiceRegistry[K]): void;\n\tregisterFactory<T>(name: string, factory: () => T): void;\n\tregisterFactory(name: string, factory: () => unknown): void {\n\t\tif (\n\t\t\tthis._services.has(name) ||\n\t\t\tthis._factories.has(name) ||\n\t\t\tthis._transientFactories.has(name)\n\t\t) {\n\t\t\tthrow new Error(`Service '${name}' is already registered`);\n\t\t}\n\t\tthis._transientFactories.set(name, factory);\n\t}\n\n\t/**\n\t * Resolve a service by name.\n\t *\n\t * Resolution order:\n\t * 1. If a registered instance exists, return it\n\t * 2. If a cached factory exists, return it\n\t * 3. If a factory exists, invoke it, cache the result, and return it\n\t * 4. If a transient factory exists, invoke it and return a new instance\n\t * 5. Throw an error if the service is not found\n\t *\n\t * @param name - The name/identifier of service to resolve\n\t * @returns The resolved service instance\n\t * @throws {Error} If the service is not registered\n\t *\n\t * @example\n\t * ```typescript\n\t * // Type-safe: ServiceRegistry provides autocomplete\n\t * const logger = container.resolve('Logger'); // Type: StructuredLogger\n\t * const config = container.resolve('Config'); // Type: ServerConfig\n\t *\n\t * // Dynamic: For services not in ServiceRegistry\n\t * const service = container.resolve<MyService>('MyService');\n\t * ```\n\t */\n\tresolve<K extends ServiceKey>(name: K): ServiceRegistry[K];\n\tresolve<T>(name: string): T;\n\tresolve(name: string): unknown {\n\t\tif (this._resolving.has(name)) {\n\t\t\tthrow new Error(`Circular dependency detected while resolving service: ${name}`);\n\t\t}\n\n\t\tthis._resolving.add(name);\n\n\t\ttry {\n\t\t\t// Check for registered instance first\n\t\t\tif (this._services.has(name)) {\n\t\t\t\treturn this._services.get(name);\n\t\t\t}\n\n\t\t\t// Check for cached factory result\n\t\t\tif (this._factories.has(name)) {\n\t\t\t\tconst factory = this._factories.get(name)!;\n\t\t\t\tconst instance = factory();\n\t\t\t\t// Cache the result for future calls (singleton behavior)\n\t\t\t\tthis._services.set(name, instance);\n\t\t\t\tthis._factories.delete(name);\n\t\t\t\treturn instance;\n\t\t\t}\n\n\t\t\t// Check for transient factory (call every time)\n\t\t\tif (this._transientFactories.has(name)) {\n\t\t\t\tconst factory = this._transientFactories.get(name)!;\n\t\t\t\treturn factory();\n\t\t\t}\n\n\t\t\tthrow new Error(`Service not found: ${name}. Did you forget to register it?`);\n\t\t} finally {\n\t\t\tthis._resolving.delete(name);\n\t\t}\n\t}\n\n\t/**\n\t * Check if a service is registered (either as instance or factory).\n\t *\n\t * @param name - The name/identifier of the service to check\n\t * @returns `true` if the service is registered, `false` otherwise\n\t *\n\t * @example\n\t * ```typescript\n\t * if (!container.has('Logger')) {\n\t * container.registerInstance('Logger', new StructuredLogger());\n\t * }\n\t * ```\n\t */\n\thas(name: string): boolean {\n\t\treturn (\n\t\t\tthis._services.has(name) || this._factories.has(name) || this._transientFactories.has(name)\n\t\t);\n\t}\n\n\t/**\n\t * Remove a registered service from the container.\n\t *\n\t * @param name - The name/identifier of the service to unregister\n\t * @returns `true` if the service was found and removed, `false` otherwise\n\t *\n\t * @example\n\t * ```typescript\n\t * container.unregister('HistoryManager');\n\t * ```\n\t */\n\tunregister(name: string): boolean {\n\t\tconst hadInstance = this._services.delete(name);\n\t\tconst hadFactory = this._factories.delete(name);\n\t\tconst hadTransient = this._transientFactories.delete(name);\n\t\tthis._disposables.delete(name);\n\t\treturn hadInstance || hadFactory || hadTransient;\n\t}\n\n\t/**\n\t * Clear all registered services and factories from the container.\n\t *\n\t * @example\n\t * ```typescript\n\t * container.clear();\n\t * ```\n\t */\n\tclear(): void {\n\t\tthis._services.clear();\n\t\tthis._factories.clear();\n\t\tthis._transientFactories.clear();\n\t\tthis._resolving.clear();\n\t\tthis._disposables.clear();\n\t}\n\n\t/**\n\t * Get the number of registered services (including instances, factories, and transient factories).\n\t *\n\t * @returns The total count of registered services\n\t *\n\t * @example\n\t * ```typescript\n\t * console.log(`Registered services: ${container.size}`);\n\t * ```\n\t */\n\tget size(): number {\n\t\treturn this._services.size + this._factories.size + this._transientFactories.size;\n\t}\n\n\t/**\n\t * Get an array of all registered service names.\n\t *\n\t * @returns An array of service names\n\t *\n\t * @example\n\t * ```typescript\n\t * const names = container.registeredServices();\n\t * console.log('Registered:', names.join(', '));\n\t * ```\n\t */\n\tregisteredServices(): string[] {\n\t\tconst names = new Set<string>();\n\t\tfor (const name of this._services.keys()) names.add(name);\n\t\tfor (const name of this._factories.keys()) names.add(name);\n\t\tfor (const name of this._transientFactories.keys()) names.add(name);\n\t\treturn Array.from(names);\n\t}\n\n\t/**\n\t * Register an instance as disposable for lifecycle management.\n\t * The instance will have its `dispose()` method called when the container is disposed.\n\t *\n\t * @param name - The service name (must already be registered)\n\t * @param instance - The disposable instance to track\n\t *\n\t * @example\n\t * ```typescript\n\t * const pool = new ConnectionPool();\n\t * container.registerInstance('ConnectionPool', pool);\n\t * container.registerDisposable('ConnectionPool', pool);\n\t * ```\n\t */\n\tregisterDisposable(name: string, instance: IDisposable): void {\n\t\tthis._disposables.set(name, instance);\n\t}\n\n\t/**\n\t * Dispose of all registered disposable services.\n\t * Calls `dispose()` on each registered disposable in reverse registration order.\n\t * Errors during individual disposal are caught and logged to prevent cascading failures.\n\t *\n\t * @example\n\t * ```typescript\n\t * await container.dispose();\n\t * ```\n\t */\n\tasync dispose(): Promise<void> {\n\t\tconst entries = Array.from(this._disposables.entries()).reverse();\n\t\tconst errors: Array<{ name: string; error: unknown }> = [];\n\n\t\tfor (const [name, disposable] of entries) {\n\t\t\ttry {\n\t\t\t\tawait disposable.dispose();\n\t\t\t} catch (error) {\n\t\t\t\terrors.push({ name, error });\n\t\t\t}\n\t\t}\n\n\t\tthis._disposables.clear();\n\n\t\tif (errors.length > 0) {\n\t\t\tconst messages = errors.map(\n\t\t\t\t(e) => `${e.name}: ${e.error instanceof Error ? e.error.message : String(e.error)}`\n\t\t\t);\n\t\t\tthrow new Error(`Failed to dispose services: ${messages.join(', ')}`);\n\t\t}\n\t}\n}\n\n/**\n * Create a pre-configured container with all default services registered.\n *\n * This factory function creates a container with all standard services\n * for the ToolAwareSequentialThinkingServer.\n *\n * @param options - Configuration options for the container\n * @returns A configured container ready to use\n *\n * @example\n * ```typescript\n * const container = createDefaultContainer({\n * logger: customLogger,\n * config: customConfig\n * });\n * const server = new ToolAwareSequentialThinkingServer({ container });\n * ```\n */\nexport interface CreateContainerOptions {\n\tlogger?: Logger;\n\tconfig?: ServerConfig;\n\tfileConfig?: ConfigFileOptions;\n}\n\nexport function createDefaultContainer(options: CreateContainerOptions = {}): Container {\n\tconst container = new Container();\n\n\t// Register logger if provided\n\tif (options.logger) {\n\t\tcontainer.registerInstance('Logger', options.logger);\n\t}\n\n\t// Register config if provided\n\tif (options.config) {\n\t\tcontainer.registerInstance('Config', options.config);\n\t}\n\n\treturn container;\n}\n"],"names":["Container","Map","Set","name","instance","Error","factory","hadInstance","hadFactory","hadTransient","names","Array","entries","errors","disposable","error","messages","e","String","createDefaultContainer","options","container"],"mappings":"AA2CO,MAAMA;IACJ,YAAkC,IAAIC,MAAM;IAC5C,aAAyC,IAAIA,MAAM;IACnD,sBAAkD,IAAIA,MAAM;IAC5D,aAA0B,IAAIC,MAAM;IACpC,eAAyC,IAAID,MAAM;IAe3D,iBAAiBE,IAAY,EAAEC,QAAiB,EAAQ;QACvD,IACC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACD,SACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,SACpB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAACA,OAE7B,MAAM,IAAIE,MAAM,CAAC,SAAS,EAAEF,KAAK,uBAAuB,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,MAAMC;IAC1B;IAmBA,SAASD,IAAY,EAAEG,OAAsB,EAAQ;QACpD,IACC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACH,SACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA,SACpB,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MAAMC;IAC7B;IAYA,MAAM,UAAyB;QAC9B,MAAMQ,UAAUD,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,OAAO;QAC/D,MAAME,SAAkD,EAAE;QAE1D,KAAK,MAAM,CAACV,MAAMW,WAAW,IAAIF,QAChC,IAAI;YACH,MAAME,WAAW,OAAO;QACzB,EAAE,OAAOC,OAAO;YACfF,OAAO,IAAI,CAAC;gBAAEV;gBAAMY;YAAM;QAC3B;QAGD,IAAI,CAAC,YAAY,CAAC,KAAK;QAEvB,IAAIF,OAAO,MAAM,GAAG,GAAG;YACtB,MAAMG,WAAWH,OAAO,GAAG,CAC1B,CAACI,IAAM,GAAGA,EAAE,IAAI,CAAC,EAAE,EAAEA,EAAE,KAAK,YAAYZ,QAAQY,EAAE,KAAK,CAAC,OAAO,GAAGC,OAAOD,EAAE,KAAK,GAAG;YAEpF,MAAM,IAAIZ,MAAM,CAAC,4BAA4B,EAAEW,SAAS,IAAI,CAAC,OAAO;QACrE;IACD;AACD;AA0BO,SAASG,uBAAuBC,UAAkC,CAAC,CAAC;IAC1E,MAAMC,YAAY,IAAIrB;IAGtB,IAAIoB,QAAQ,MAAM,EACjBC,UAAU,gBAAgB,CAAC,UAAUD,QAAQ,MAAM;IAIpD,IAAIA,QAAQ,MAAM,EACjBC,UAAU,gBAAgB,CAAC,UAAUD,QAAQ,MAAM;IAGpD,OAAOC;AACR"}
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* Interface types are imported from contracts/ to reduce coupling.
|
|
6
6
|
* Concrete types are imported only where needed for DI resolution.
|
|
7
7
|
*/
|
|
8
|
-
import type { PersistenceBackend } from '../
|
|
8
|
+
import type { PersistenceBackend } from '../contracts/PersistenceBackend.js';
|
|
9
9
|
import type { HistoryManager } from '../core/HistoryManager.js';
|
|
10
10
|
import type { EdgeStore } from '../core/graph/EdgeStore.js';
|
|
11
11
|
import type { ICalibrator } from '../contracts/calibrator.js';
|
|
12
12
|
import type { IOutcomeRecorder } from '../contracts/interfaces.js';
|
|
13
13
|
import type { IReasoningStrategy } from '../contracts/strategy.js';
|
|
14
14
|
import type { ThoughtEvaluator } from '../core/ThoughtEvaluator.js';
|
|
15
|
-
import type {
|
|
15
|
+
import type { IThoughtFormatter } from '../core/IThoughtFormatter.js';
|
|
16
16
|
import type { ThoughtProcessor } from '../core/ThoughtProcessor.js';
|
|
17
17
|
import type { StructuredLogger } from '../logger/StructuredLogger.js';
|
|
18
18
|
import type { Metrics } from '../metrics/metrics.impl.js';
|
|
@@ -28,7 +28,7 @@ export interface ServiceRegistry {
|
|
|
28
28
|
FileConfig: Record<string, unknown>;
|
|
29
29
|
HistoryManager: HistoryManager;
|
|
30
30
|
ThoughtProcessor: ThoughtProcessor;
|
|
31
|
-
ThoughtFormatter:
|
|
31
|
+
ThoughtFormatter: IThoughtFormatter;
|
|
32
32
|
ThoughtEvaluator: ThoughtEvaluator;
|
|
33
33
|
Persistence: PersistenceBackend | null;
|
|
34
34
|
ToolRegistry: ToolRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceRegistry.d.ts","sourceRoot":"","sources":["../../src/di/ServiceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ServiceRegistry.d.ts","sourceRoot":"","sources":["../../src/di/ServiceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,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AC;IACxB,YAAY,EAAE,aAAa,CAAC;IAC5B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,eAAe,EAAE,gBAAgB,CAAC;CAClC;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -25,6 +25,34 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
* @module errors
|
|
27
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* All known error codes as a const object for exhaustive switching.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ERROR_CODES: {
|
|
32
|
+
readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR";
|
|
33
|
+
readonly TOOL_NOT_FOUND: "TOOL_NOT_FOUND";
|
|
34
|
+
readonly SKILL_NOT_FOUND: "SKILL_NOT_FOUND";
|
|
35
|
+
readonly INVALID_THOUGHT: "INVALID_THOUGHT";
|
|
36
|
+
readonly SKILL_DISCOVERY_FAILED: "SKILL_DISCOVERY_FAILED";
|
|
37
|
+
readonly HISTORY_LIMIT_EXCEEDED: "HISTORY_LIMIT_EXCEEDED";
|
|
38
|
+
readonly DUPLICATE_SKILL: "DUPLICATE_SKILL";
|
|
39
|
+
readonly INVALID_SKILL: "INVALID_SKILL";
|
|
40
|
+
readonly DUPLICATE_TOOL: "DUPLICATE_TOOL";
|
|
41
|
+
readonly INVALID_TOOL: "INVALID_TOOL";
|
|
42
|
+
readonly SESSION_NOT_ACTIVE: "SESSION_NOT_ACTIVE";
|
|
43
|
+
readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
44
|
+
readonly MAX_SESSIONS_REACHED: "MAX_SESSIONS_REACHED";
|
|
45
|
+
readonly POOL_TERMINATED: "POOL_TERMINATED";
|
|
46
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
47
|
+
readonly INVALID_EDGE: "INVALID_EDGE";
|
|
48
|
+
readonly CYCLE_DETECTED: "CYCLE_DETECTED";
|
|
49
|
+
readonly SUSPENSION_NOT_FOUND: "SUSPENSION_NOT_FOUND";
|
|
50
|
+
readonly SUSPENSION_EXPIRED: "SUSPENSION_EXPIRED";
|
|
51
|
+
readonly INVALID_TOOL_CALL: "INVALID_TOOL_CALL";
|
|
52
|
+
readonly INVALID_BACKTRACK: "INVALID_BACKTRACK";
|
|
53
|
+
readonly DUPLICATE_SUMMARY: "DUPLICATE_SUMMARY";
|
|
54
|
+
};
|
|
55
|
+
export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
28
56
|
/**
|
|
29
57
|
* Base error class for all Sequential Thinking server errors.
|
|
30
58
|
*
|
|
@@ -54,7 +82,7 @@
|
|
|
54
82
|
*/
|
|
55
83
|
export declare class SequentialThinkingError extends Error {
|
|
56
84
|
/** The error code for programmatic identification. */
|
|
57
|
-
readonly code:
|
|
85
|
+
readonly code: ErrorCode;
|
|
58
86
|
/**
|
|
59
87
|
* Creates a new SequentialThinkingError.
|
|
60
88
|
*
|
|
@@ -70,7 +98,7 @@ export declare class SequentialThinkingError extends Error {
|
|
|
70
98
|
* console.log(error.code); // 'CUSTOM_ERROR'
|
|
71
99
|
* ```
|
|
72
100
|
*/
|
|
73
|
-
constructor(message: string, code:
|
|
101
|
+
constructor(message: string, code: ErrorCode);
|
|
74
102
|
}
|
|
75
103
|
export declare class ConfigurationError extends SequentialThinkingError {
|
|
76
104
|
constructor(message: string);
|
|
@@ -577,6 +605,12 @@ export declare class InvalidToolCallError extends SequentialThinkingError {
|
|
|
577
605
|
export declare class InvalidBacktrackError extends SequentialThinkingError {
|
|
578
606
|
constructor(message: string);
|
|
579
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Type guard to check if an error has a specific error code.
|
|
610
|
+
*/
|
|
611
|
+
export declare function isErrorCode<C extends ErrorCode>(err: unknown, code: C): err is SequentialThinkingError & {
|
|
612
|
+
readonly code: C;
|
|
613
|
+
};
|
|
580
614
|
/**
|
|
581
615
|
* Extract a human-readable message from an unknown error value.
|
|
582
616
|
*
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,sDAAsD;IACtD,SAAgB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;CAuBd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,sDAAsD;IACtD,SAAgB,IAAI,EAAE,SAAS,CAAC;IAEhC;;;;;;;;;;;;;;OAcG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;CAM5C;AAED,qBAAa,kBAAmB,SAAQ,uBAAuB;gBAClD,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,uBAAuB;IAC7D;;;;;;;;;;;;;;;OAeG;gBACS,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO7C;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,SAAQ,uBAAuB;IAC9D;;;;;;;;;;;;;;;OAeG;gBACS,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO9C;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAC/D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: 'CONFIGURATION_ERROR',
|
|
3
|
+
TOOL_NOT_FOUND: 'TOOL_NOT_FOUND',
|
|
4
|
+
SKILL_NOT_FOUND: 'SKILL_NOT_FOUND',
|
|
5
|
+
INVALID_THOUGHT: 'INVALID_THOUGHT',
|
|
6
|
+
SKILL_DISCOVERY_FAILED: 'SKILL_DISCOVERY_FAILED',
|
|
7
|
+
HISTORY_LIMIT_EXCEEDED: 'HISTORY_LIMIT_EXCEEDED',
|
|
8
|
+
DUPLICATE_SKILL: 'DUPLICATE_SKILL',
|
|
9
|
+
INVALID_SKILL: 'INVALID_SKILL',
|
|
10
|
+
DUPLICATE_TOOL: 'DUPLICATE_TOOL',
|
|
11
|
+
INVALID_TOOL: 'INVALID_TOOL',
|
|
12
|
+
SESSION_NOT_ACTIVE: 'SESSION_NOT_ACTIVE',
|
|
13
|
+
SESSION_NOT_FOUND: 'SESSION_NOT_FOUND',
|
|
14
|
+
MAX_SESSIONS_REACHED: 'MAX_SESSIONS_REACHED',
|
|
15
|
+
POOL_TERMINATED: 'POOL_TERMINATED',
|
|
16
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
17
|
+
INVALID_EDGE: 'INVALID_EDGE',
|
|
18
|
+
CYCLE_DETECTED: 'CYCLE_DETECTED',
|
|
19
|
+
SUSPENSION_NOT_FOUND: 'SUSPENSION_NOT_FOUND',
|
|
20
|
+
SUSPENSION_EXPIRED: 'SUSPENSION_EXPIRED',
|
|
21
|
+
INVALID_TOOL_CALL: 'INVALID_TOOL_CALL',
|
|
22
|
+
INVALID_BACKTRACK: 'INVALID_BACKTRACK',
|
|
23
|
+
DUPLICATE_SUMMARY: 'DUPLICATE_SUMMARY'
|
|
24
|
+
};
|
|
1
25
|
class SequentialThinkingError extends Error {
|
|
2
26
|
code;
|
|
3
27
|
constructor(message, code){
|
|
@@ -9,139 +33,142 @@ class SequentialThinkingError extends Error {
|
|
|
9
33
|
}
|
|
10
34
|
class ConfigurationError extends SequentialThinkingError {
|
|
11
35
|
constructor(message){
|
|
12
|
-
super(message,
|
|
36
|
+
super(message, ERROR_CODES.CONFIGURATION_ERROR);
|
|
13
37
|
this.name = 'ConfigurationError';
|
|
14
38
|
}
|
|
15
39
|
}
|
|
16
40
|
class ToolNotFoundError extends SequentialThinkingError {
|
|
17
41
|
constructor(toolName, action){
|
|
18
42
|
const message = action ? `Tool '${toolName}' not found, cannot ${action}` : `Tool '${toolName}' not found`;
|
|
19
|
-
super(message,
|
|
43
|
+
super(message, ERROR_CODES.TOOL_NOT_FOUND);
|
|
20
44
|
this.name = 'ToolNotFoundError';
|
|
21
45
|
}
|
|
22
46
|
}
|
|
23
47
|
class SkillNotFoundError extends SequentialThinkingError {
|
|
24
48
|
constructor(skillName, action){
|
|
25
49
|
const message = action ? `Skill '${skillName}' not found, cannot ${action}` : `Skill '${skillName}' not found`;
|
|
26
|
-
super(message,
|
|
50
|
+
super(message, ERROR_CODES.SKILL_NOT_FOUND);
|
|
27
51
|
this.name = 'SkillNotFoundError';
|
|
28
52
|
}
|
|
29
53
|
}
|
|
30
54
|
class InvalidThoughtError extends SequentialThinkingError {
|
|
31
55
|
constructor(thoughtNumber, reason){
|
|
32
|
-
super(`Invalid thought ${thoughtNumber}: ${reason}`,
|
|
56
|
+
super(`Invalid thought ${thoughtNumber}: ${reason}`, ERROR_CODES.INVALID_THOUGHT);
|
|
33
57
|
this.name = 'InvalidThoughtError';
|
|
34
58
|
}
|
|
35
59
|
}
|
|
36
60
|
class SkillDiscoveryError extends SequentialThinkingError {
|
|
37
61
|
cause;
|
|
38
62
|
constructor(directory, cause){
|
|
39
|
-
super(`Failed to discover skills in ${directory}: ${cause.message}`,
|
|
63
|
+
super(`Failed to discover skills in ${directory}: ${cause.message}`, ERROR_CODES.SKILL_DISCOVERY_FAILED);
|
|
40
64
|
this.name = 'SkillDiscoveryError';
|
|
41
65
|
this.cause = cause;
|
|
42
66
|
}
|
|
43
67
|
}
|
|
44
68
|
class HistoryLimitExceededError extends SequentialThinkingError {
|
|
45
69
|
constructor(currentSize, maxSize){
|
|
46
|
-
super(`History size ${currentSize} exceeds limit ${maxSize}`,
|
|
70
|
+
super(`History size ${currentSize} exceeds limit ${maxSize}`, ERROR_CODES.HISTORY_LIMIT_EXCEEDED);
|
|
47
71
|
this.name = 'HistoryLimitExceededError';
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
class DuplicateSkillError extends SequentialThinkingError {
|
|
51
75
|
constructor(skillName){
|
|
52
|
-
super(`skill '${skillName}' already exists`,
|
|
76
|
+
super(`skill '${skillName}' already exists`, ERROR_CODES.DUPLICATE_SKILL);
|
|
53
77
|
this.name = 'DuplicateSkillError';
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
class InvalidSkillError extends SequentialThinkingError {
|
|
57
81
|
constructor(reason){
|
|
58
|
-
super(`Invalid skill: ${reason}`,
|
|
82
|
+
super(`Invalid skill: ${reason}`, ERROR_CODES.INVALID_SKILL);
|
|
59
83
|
this.name = 'InvalidSkillError';
|
|
60
84
|
}
|
|
61
85
|
}
|
|
62
86
|
class DuplicateToolError extends SequentialThinkingError {
|
|
63
87
|
constructor(toolName){
|
|
64
|
-
super(`tool '${toolName}' already exists`,
|
|
88
|
+
super(`tool '${toolName}' already exists`, ERROR_CODES.DUPLICATE_TOOL);
|
|
65
89
|
this.name = 'DuplicateToolError';
|
|
66
90
|
}
|
|
67
91
|
}
|
|
68
92
|
class InvalidToolError extends SequentialThinkingError {
|
|
69
93
|
constructor(reason){
|
|
70
|
-
super(`Invalid tool: ${reason}`,
|
|
94
|
+
super(`Invalid tool: ${reason}`, ERROR_CODES.INVALID_TOOL);
|
|
71
95
|
this.name = 'InvalidToolError';
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
98
|
class SessionNotActiveError extends SequentialThinkingError {
|
|
75
99
|
constructor(sessionId){
|
|
76
|
-
super(`Session '${sessionId}' is not active`,
|
|
100
|
+
super(`Session '${sessionId}' is not active`, ERROR_CODES.SESSION_NOT_ACTIVE);
|
|
77
101
|
this.name = 'SessionNotActiveError';
|
|
78
102
|
}
|
|
79
103
|
}
|
|
80
104
|
class SessionNotFoundError extends SequentialThinkingError {
|
|
81
105
|
constructor(sessionId){
|
|
82
|
-
super(`Session not found: ${sessionId}`,
|
|
106
|
+
super(`Session not found: ${sessionId}`, ERROR_CODES.SESSION_NOT_FOUND);
|
|
83
107
|
this.name = 'SessionNotFoundError';
|
|
84
108
|
}
|
|
85
109
|
}
|
|
86
110
|
class MaxSessionsReachedError extends SequentialThinkingError {
|
|
87
111
|
constructor(maxSessions){
|
|
88
|
-
super(`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`,
|
|
112
|
+
super(`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`, ERROR_CODES.MAX_SESSIONS_REACHED);
|
|
89
113
|
this.name = 'MaxSessionsReachedError';
|
|
90
114
|
}
|
|
91
115
|
}
|
|
92
116
|
class PoolTerminatedError extends SequentialThinkingError {
|
|
93
117
|
constructor(){
|
|
94
|
-
super('ConnectionPool has been terminated',
|
|
118
|
+
super('ConnectionPool has been terminated', ERROR_CODES.POOL_TERMINATED);
|
|
95
119
|
this.name = 'PoolTerminatedError';
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
class ValidationError extends SequentialThinkingError {
|
|
99
123
|
field;
|
|
100
124
|
constructor(field, reason){
|
|
101
|
-
super(`Validation failed for '${field}': ${reason}`,
|
|
125
|
+
super(`Validation failed for '${field}': ${reason}`, ERROR_CODES.VALIDATION_ERROR);
|
|
102
126
|
this.name = 'ValidationError';
|
|
103
127
|
this.field = field;
|
|
104
128
|
}
|
|
105
129
|
}
|
|
106
130
|
class InvalidEdgeError extends SequentialThinkingError {
|
|
107
131
|
constructor(message){
|
|
108
|
-
super(message,
|
|
132
|
+
super(message, ERROR_CODES.INVALID_EDGE);
|
|
109
133
|
this.name = 'InvalidEdgeError';
|
|
110
134
|
}
|
|
111
135
|
}
|
|
112
136
|
class CycleDetectedError extends SequentialThinkingError {
|
|
113
137
|
constructor(message){
|
|
114
|
-
super(message,
|
|
138
|
+
super(message, ERROR_CODES.CYCLE_DETECTED);
|
|
115
139
|
this.name = 'CycleDetectedError';
|
|
116
140
|
}
|
|
117
141
|
}
|
|
118
142
|
class SuspensionNotFoundError extends SequentialThinkingError {
|
|
119
143
|
constructor(message){
|
|
120
|
-
super(message,
|
|
144
|
+
super(message, ERROR_CODES.SUSPENSION_NOT_FOUND);
|
|
121
145
|
this.name = 'SuspensionNotFoundError';
|
|
122
146
|
}
|
|
123
147
|
}
|
|
124
148
|
class SuspensionExpiredError extends SequentialThinkingError {
|
|
125
149
|
constructor(message){
|
|
126
|
-
super(message,
|
|
150
|
+
super(message, ERROR_CODES.SUSPENSION_EXPIRED);
|
|
127
151
|
this.name = 'SuspensionExpiredError';
|
|
128
152
|
}
|
|
129
153
|
}
|
|
130
154
|
class InvalidToolCallError extends SequentialThinkingError {
|
|
131
155
|
constructor(message){
|
|
132
|
-
super(message,
|
|
156
|
+
super(message, ERROR_CODES.INVALID_TOOL_CALL);
|
|
133
157
|
this.name = 'InvalidToolCallError';
|
|
134
158
|
}
|
|
135
159
|
}
|
|
136
160
|
class InvalidBacktrackError extends SequentialThinkingError {
|
|
137
161
|
constructor(message){
|
|
138
|
-
super(message,
|
|
162
|
+
super(message, ERROR_CODES.INVALID_BACKTRACK);
|
|
139
163
|
this.name = 'InvalidBacktrackError';
|
|
140
164
|
}
|
|
141
165
|
}
|
|
166
|
+
function isErrorCode(err, code) {
|
|
167
|
+
return err instanceof SequentialThinkingError && err.code === code;
|
|
168
|
+
}
|
|
142
169
|
function getErrorMessage(error) {
|
|
143
170
|
return error instanceof Error ? error.message : String(error);
|
|
144
171
|
}
|
|
145
|
-
export { ConfigurationError, CycleDetectedError, DuplicateSkillError, DuplicateToolError, HistoryLimitExceededError, InvalidBacktrackError, InvalidEdgeError, InvalidSkillError, InvalidThoughtError, InvalidToolCallError, InvalidToolError, MaxSessionsReachedError, PoolTerminatedError, SequentialThinkingError, SessionNotActiveError, SessionNotFoundError, SkillDiscoveryError, SkillNotFoundError, SuspensionExpiredError, SuspensionNotFoundError, ToolNotFoundError, ValidationError, getErrorMessage };
|
|
172
|
+
export { ConfigurationError, CycleDetectedError, DuplicateSkillError, DuplicateToolError, ERROR_CODES, HistoryLimitExceededError, InvalidBacktrackError, InvalidEdgeError, InvalidSkillError, InvalidThoughtError, InvalidToolCallError, InvalidToolError, MaxSessionsReachedError, PoolTerminatedError, SequentialThinkingError, SessionNotActiveError, SessionNotFoundError, SkillDiscoveryError, SkillNotFoundError, SuspensionExpiredError, SuspensionNotFoundError, ToolNotFoundError, ValidationError, getErrorMessage, isErrorCode };
|
|
146
173
|
|
|
147
174
|
//# sourceMappingURL=errors.js.map
|