@iworkforces/tracelattice 2.2.1 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +6 -2
  2. package/dist/cli.js +10 -7
  3. package/dist/contracts/reasoning-types.d.ts +3 -3
  4. package/dist/contracts/reasoning-types.d.ts.map +1 -1
  5. package/dist/core/HistoryManager.d.ts +6 -1
  6. package/dist/core/HistoryManager.d.ts.map +1 -1
  7. package/dist/core/HistoryManager.js +38 -6
  8. package/dist/core/HistoryManager.js.map +1 -1
  9. package/dist/core/IHistoryManager.d.ts +2 -0
  10. package/dist/core/IHistoryManager.d.ts.map +1 -1
  11. package/dist/core/SessionErrors.d.ts +4 -0
  12. package/dist/core/SessionErrors.d.ts.map +1 -1
  13. package/dist/core/SessionErrors.js +9 -1
  14. package/dist/core/SessionErrors.js.map +1 -1
  15. package/dist/core/SessionResetCoordinator.d.ts +4 -0
  16. package/dist/core/SessionResetCoordinator.d.ts.map +1 -1
  17. package/dist/core/SessionResetCoordinator.js +6 -0
  18. package/dist/core/SessionResetCoordinator.js.map +1 -1
  19. package/dist/core/ThoughtEvaluator.d.ts +9 -2
  20. package/dist/core/ThoughtEvaluator.d.ts.map +1 -1
  21. package/dist/core/ThoughtEvaluator.js +9 -2
  22. package/dist/core/ThoughtEvaluator.js.map +1 -1
  23. package/dist/core/ThoughtProcessor.d.ts +1 -0
  24. package/dist/core/ThoughtProcessor.d.ts.map +1 -1
  25. package/dist/core/ThoughtProcessor.js +47 -20
  26. package/dist/core/ThoughtProcessor.js.map +1 -1
  27. package/dist/core/evaluator/GraphPatterns.d.ts +8 -0
  28. package/dist/core/evaluator/GraphPatterns.d.ts.map +1 -0
  29. package/dist/core/evaluator/GraphPatterns.js +88 -0
  30. package/dist/core/evaluator/GraphPatterns.js.map +1 -0
  31. package/dist/core/evaluator/GraphSignalComputer.d.ts +12 -0
  32. package/dist/core/evaluator/GraphSignalComputer.d.ts.map +1 -0
  33. package/dist/core/evaluator/GraphSignalComputer.js +17 -0
  34. package/dist/core/evaluator/GraphSignalComputer.js.map +1 -0
  35. package/dist/core/evaluator/PatternDetector.d.ts +4 -1
  36. package/dist/core/evaluator/PatternDetector.d.ts.map +1 -1
  37. package/dist/core/evaluator/PatternDetector.js +8 -2
  38. package/dist/core/evaluator/PatternDetector.js.map +1 -1
  39. package/dist/core/graph/EdgeEmitter.js +1 -1
  40. package/dist/core/graph/EdgeEmitter.js.map +1 -1
  41. package/dist/core/graph/GraphView.d.ts +60 -2
  42. package/dist/core/graph/GraphView.d.ts.map +1 -1
  43. package/dist/core/graph/GraphView.js +127 -11
  44. package/dist/core/graph/GraphView.js.map +1 -1
  45. package/dist/core/reasoning/GraphContext.d.ts +25 -0
  46. package/dist/core/reasoning/GraphContext.d.ts.map +1 -0
  47. package/dist/core/reasoning/GraphContext.js +32 -0
  48. package/dist/core/reasoning/GraphContext.js.map +1 -0
  49. package/dist/core/reasoning.d.ts +10 -0
  50. package/dist/core/reasoning.d.ts.map +1 -1
  51. package/dist/errors.d.ts +1 -0
  52. package/dist/errors.d.ts.map +1 -1
  53. package/dist/errors.js +1 -0
  54. package/dist/errors.js.map +1 -1
  55. package/dist/persistence/FileSnapshotV2.d.ts +6 -6
  56. package/dist/schema.d.ts +3 -3
  57. package/dist/schema.d.ts.map +1 -1
  58. package/dist/schema.js +9 -7
  59. package/dist/schema.js.map +1 -1
  60. package/package.json +12 -12
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GraphContext — describe a thought's position in the active-evidence graph.
3
+ * @module core/reasoning/GraphContext
4
+ */
5
+ import type { SessionId } from '../../contracts/ids.js';
6
+ import type { ActiveEvidenceProjection } from '../../contracts/strategy.js';
7
+ import type { EdgeKind } from '../graph/Edge.js';
8
+ import type { ThoughtData } from '../thought.js';
9
+ export interface GraphNeighbour {
10
+ readonly thought_number: number;
11
+ readonly kind: EdgeKind;
12
+ readonly branch_id?: string;
13
+ }
14
+ export interface GraphContext {
15
+ /** Shortest directed distance from a root; null when no root reaches the thought. */
16
+ readonly root_distance: number | null;
17
+ /** Distinct thoughts this thought transitively rests on (all edge kinds, incoming BFS). */
18
+ readonly ancestor_count: number;
19
+ /** Incoming edges (neighbour -> this thought), store order. */
20
+ readonly inbound: readonly GraphNeighbour[];
21
+ /** Outgoing edges (this thought -> neighbour), store order. */
22
+ readonly outbound: readonly GraphNeighbour[];
23
+ }
24
+ export declare function buildGraphContext(sessionId: SessionId, thought: ThoughtData, evidence: ActiveEvidenceProjection): GraphContext | undefined;
25
+ //# sourceMappingURL=GraphContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphContext.d.ts","sourceRoot":"","sources":["../../../src/core/reasoning/GraphContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;AAED,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,wBAAwB,GAChC,YAAY,GAAG,SAAS,CAiB1B"}
@@ -0,0 +1,32 @@
1
+ function buildGraphContext(sessionId, thought, evidence) {
2
+ const graph = evidence.graph;
3
+ if (void 0 === graph || void 0 === thought.id) return;
4
+ const inbound = graph.inbound(sessionId, thought.id);
5
+ const outbound = graph.outbound(sessionId, thought.id);
6
+ if (0 === inbound.length && 0 === outbound.length) return;
7
+ const thoughts = new Map();
8
+ for (const activeThought of evidence.activeThoughts)if (void 0 !== activeThought.id) thoughts.set(activeThought.id, activeThought);
9
+ return {
10
+ root_distance: graph.depthFromRoots(sessionId, thought.id) ?? null,
11
+ ancestor_count: graph.ancestors(sessionId, thought.id).length,
12
+ inbound: mapNeighbours(inbound, thoughts),
13
+ outbound: mapNeighbours(outbound, thoughts)
14
+ };
15
+ }
16
+ function mapNeighbours(relations, thoughts) {
17
+ return relations.flatMap(({ id, kind })=>{
18
+ const neighbour = thoughts.get(id);
19
+ return void 0 === neighbour ? [] : [
20
+ {
21
+ thought_number: neighbour.thought_number,
22
+ kind,
23
+ ...void 0 === neighbour.branch_id ? {} : {
24
+ branch_id: neighbour.branch_id
25
+ }
26
+ }
27
+ ];
28
+ });
29
+ }
30
+ export { buildGraphContext };
31
+
32
+ //# sourceMappingURL=GraphContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/reasoning/GraphContext.js","sources":["../../../src/core/reasoning/GraphContext.ts"],"sourcesContent":["/**\n * GraphContext — describe a thought's position in the active-evidence graph.\n * @module core/reasoning/GraphContext\n */\n\nimport type { SessionId, ThoughtId } from '../../contracts/ids.js';\nimport type { ActiveEvidenceProjection } from '../../contracts/strategy.js';\nimport type { EdgeKind } from '../graph/Edge.js';\nimport type { GraphRelation } from '../graph/GraphView.js';\nimport type { ThoughtData } from '../thought.js';\n\nexport interface GraphNeighbour {\n\treadonly thought_number: number;\n\treadonly kind: EdgeKind;\n\treadonly branch_id?: string;\n}\n\nexport interface GraphContext {\n\t/** Shortest directed distance from a root; null when no root reaches the thought. */\n\treadonly root_distance: number | null;\n\t/** Distinct thoughts this thought transitively rests on (all edge kinds, incoming BFS). */\n\treadonly ancestor_count: number;\n\t/** Incoming edges (neighbour -> this thought), store order. */\n\treadonly inbound: readonly GraphNeighbour[];\n\t/** Outgoing edges (this thought -> neighbour), store order. */\n\treadonly outbound: readonly GraphNeighbour[];\n}\n\nexport function buildGraphContext(\n\tsessionId: SessionId,\n\tthought: ThoughtData,\n\tevidence: ActiveEvidenceProjection\n): GraphContext | undefined {\n\tconst graph = evidence.graph;\n\tif (graph === undefined || thought.id === undefined) return undefined;\n\tconst inbound = graph.inbound(sessionId, thought.id);\n\tconst outbound = graph.outbound(sessionId, thought.id);\n\tif (inbound.length === 0 && outbound.length === 0) return undefined;\n\n\tconst thoughts = new Map<ThoughtId, ThoughtData>();\n\tfor (const activeThought of evidence.activeThoughts) {\n\t\tif (activeThought.id !== undefined) thoughts.set(activeThought.id, activeThought);\n\t}\n\treturn {\n\t\troot_distance: graph.depthFromRoots(sessionId, thought.id) ?? null,\n\t\tancestor_count: graph.ancestors(sessionId, thought.id).length,\n\t\tinbound: mapNeighbours(inbound, thoughts),\n\t\toutbound: mapNeighbours(outbound, thoughts),\n\t};\n}\n\nfunction mapNeighbours(\n\trelations: readonly GraphRelation[],\n\tthoughts: ReadonlyMap<ThoughtId, ThoughtData>\n): readonly GraphNeighbour[] {\n\treturn relations.flatMap(({ id, kind }) => {\n\t\tconst neighbour = thoughts.get(id);\n\t\treturn neighbour === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tthought_number: neighbour.thought_number,\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\t...(neighbour.branch_id === undefined ? {} : { branch_id: neighbour.branch_id }),\n\t\t\t\t\t},\n\t\t\t\t];\n\t});\n}\n"],"names":["buildGraphContext","sessionId","thought","evidence","graph","undefined","inbound","outbound","thoughts","Map","activeThought","mapNeighbours","relations","id","kind","neighbour"],"mappings":"AA4BO,SAASA,kBACfC,SAAoB,EACpBC,OAAoB,EACpBC,QAAkC;IAElC,MAAMC,QAAQD,SAAS,KAAK;IAC5B,IAAIC,AAAUC,WAAVD,SAAuBF,AAAeG,WAAfH,QAAQ,EAAE,EAAgB;IACrD,MAAMI,UAAUF,MAAM,OAAO,CAACH,WAAWC,QAAQ,EAAE;IACnD,MAAMK,WAAWH,MAAM,QAAQ,CAACH,WAAWC,QAAQ,EAAE;IACrD,IAAII,AAAmB,MAAnBA,QAAQ,MAAM,IAAUC,AAAoB,MAApBA,SAAS,MAAM,EAAQ;IAEnD,MAAMC,WAAW,IAAIC;IACrB,KAAK,MAAMC,iBAAiBP,SAAS,cAAc,CAClD,IAAIO,AAAqBL,WAArBK,cAAc,EAAE,EAAgBF,SAAS,GAAG,CAACE,cAAc,EAAE,EAAEA;IAEpE,OAAO;QACN,eAAeN,MAAM,cAAc,CAACH,WAAWC,QAAQ,EAAE,KAAK;QAC9D,gBAAgBE,MAAM,SAAS,CAACH,WAAWC,QAAQ,EAAE,EAAE,MAAM;QAC7D,SAASS,cAAcL,SAASE;QAChC,UAAUG,cAAcJ,UAAUC;IACnC;AACD;AAEA,SAASG,cACRC,SAAmC,EACnCJ,QAA6C;IAE7C,OAAOI,UAAU,OAAO,CAAC,CAAC,EAAEC,EAAE,EAAEC,IAAI,EAAE;QACrC,MAAMC,YAAYP,SAAS,GAAG,CAACK;QAC/B,OAAOE,AAAcV,WAAdU,YACJ,EAAE,GACF;YACA;gBACC,gBAAgBA,UAAU,cAAc;gBACxCD;gBACA,GAAIC,AAAwBV,WAAxBU,UAAU,SAAS,GAAiB,CAAC,IAAI;oBAAE,WAAWA,UAAU,SAAS;gBAAC,CAAC;YAChF;SACA;IACJ;AACD"}
@@ -8,6 +8,14 @@
8
8
  */
9
9
  import type { CalibrationMetrics } from '../contracts/calibrator.js';
10
10
  import type { PatternName, ThoughtType } from '../contracts/reasoning-types.js';
11
+ import type { GraphMetrics } from './graph/GraphView.js';
12
+ /** DAG topology plus derived measures of branching and explicit relations. */
13
+ export interface GraphSignals extends GraphMetrics {
14
+ /** Mean out-degree over nodes with at least one outgoing edge. */
15
+ readonly branching_factor: number;
16
+ /** Share of edges with a kind other than sequence, in [0, 1]. */
17
+ readonly relational_density: number;
18
+ }
11
19
  /**
12
20
  * A detected reasoning pattern — surfaced as metadata or a warning.
13
21
  *
@@ -66,6 +74,8 @@ export interface PatternSignal {
66
74
  * ```
67
75
  */
68
76
  export interface ConfidenceSignals {
77
+ /** Present only when an active graph with at least one edge is supplied. */
78
+ readonly graph_signals?: GraphSignals;
69
79
  /** Length of thought chain to this point. */
70
80
  readonly reasoning_depth: number;
71
81
  /** How many revisions in this chain. */
@@ -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;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC7B,2CAA2C;IAC3C,2CAA2C;IAC3C,OAAO,EAAE,WAAW,CAAC;IAErB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAEhB,wEAAwE;IACxE,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,iBAAiB;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,wCAAwC;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,uBAAuB;IACvB,Q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,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C"}
package/dist/errors.d.ts CHANGED
@@ -55,6 +55,7 @@ export declare const ERROR_CODES: {
55
55
  readonly LOCK_TIMEOUT: "LOCK_TIMEOUT";
56
56
  readonly CLI_SHUTDOWN_TIMEOUT: "CLI_SHUTDOWN_TIMEOUT";
57
57
  readonly SESSION_ACCESS_DENIED: "SESSION_ACCESS_DENIED";
58
+ readonly SESSION_EXPIRED: "SESSION_EXPIRED";
58
59
  readonly SESSION_LIFECYCLE_CLOSED: "SESSION_LIFECYCLE_CLOSED";
59
60
  readonly PERSISTENCE_OWNERSHIP: "PERSISTENCE_OWNERSHIP";
60
61
  readonly PERSISTENCE_CORRUPTION: "PERSISTENCE_CORRUPTION";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;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;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',
26
26
  CLI_SHUTDOWN_TIMEOUT: 'CLI_SHUTDOWN_TIMEOUT',
27
27
  SESSION_ACCESS_DENIED: 'SESSION_ACCESS_DENIED',
28
+ SESSION_EXPIRED: 'SESSION_EXPIRED',
28
29
  SESSION_LIFECYCLE_CLOSED: 'SESSION_LIFECYCLE_CLOSED',
29
30
  PERSISTENCE_OWNERSHIP: 'PERSISTENCE_OWNERSHIP',
30
31
  PERSISTENCE_CORRUPTION: 'PERSISTENCE_CORRUPTION',
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":["/**\n * Custom error types for the TraceLattice server.\n *\n * This module defines a hierarchy of error classes for handling various\n * error conditions that can occur in the sequential thinking server.\n * All errors extend the base `SequentialThinkingError` class with\n * specific error codes for programmatic handling.\n *\n * @example\n * ```typescript\n * import { ToolNotFoundError, SkillDiscoveryError } from './errors.js';\n *\n * // Throw a tool not found error\n * throw new ToolNotFoundError('my-tool');\n *\n * // Catch and handle specific errors\n * try {\n * await discoverSkills(dir);\n * } catch (error) {\n * if (error instanceof SkillDiscoveryError) {\n * console.error(`Failed to discover skills: ${error.message}`);\n * console.error(`Error code: ${error.code}`);\n * }\n * }\n * ```\n * @module errors\n */\n\n/**\n * All known error codes as a const object for exhaustive switching.\n */\nexport const ERROR_CODES = {\n\tCONFIGURATION_ERROR: 'CONFIGURATION_ERROR',\n\tTOOL_NOT_FOUND: 'TOOL_NOT_FOUND',\n\tSKILL_NOT_FOUND: 'SKILL_NOT_FOUND',\n\tINVALID_THOUGHT: 'INVALID_THOUGHT',\n\tSKILL_DISCOVERY_FAILED: 'SKILL_DISCOVERY_FAILED',\n\tHISTORY_LIMIT_EXCEEDED: 'HISTORY_LIMIT_EXCEEDED',\n\tDUPLICATE_SKILL: 'DUPLICATE_SKILL',\n\tINVALID_SKILL: 'INVALID_SKILL',\n\tDUPLICATE_TOOL: 'DUPLICATE_TOOL',\n\tINVALID_TOOL: 'INVALID_TOOL',\n\tSESSION_NOT_ACTIVE: 'SESSION_NOT_ACTIVE',\n\tSESSION_NOT_FOUND: 'SESSION_NOT_FOUND',\n\tMAX_SESSIONS_REACHED: 'MAX_SESSIONS_REACHED',\n\tPOOL_TERMINATED: 'POOL_TERMINATED',\n\tVALIDATION_ERROR: 'VALIDATION_ERROR',\n\tINVALID_EDGE: 'INVALID_EDGE',\n\tCYCLE_DETECTED: 'CYCLE_DETECTED',\n\tSUSPENSION_NOT_FOUND: 'SUSPENSION_NOT_FOUND',\n\tSUSPENSION_EXPIRED: 'SUSPENSION_EXPIRED',\n\tINVALID_TOOL_CALL: 'INVALID_TOOL_CALL',\n\tINVALID_BACKTRACK: 'INVALID_BACKTRACK',\n\tDUPLICATE_SUMMARY: 'DUPLICATE_SUMMARY',\n\tUNKNOWN_TOOL: 'UNKNOWN_TOOL',\n\tLOCK_TIMEOUT: 'LOCK_TIMEOUT',\n\tCLI_SHUTDOWN_TIMEOUT: 'CLI_SHUTDOWN_TIMEOUT',\n\tSESSION_ACCESS_DENIED: 'SESSION_ACCESS_DENIED',\n\tSESSION_LIFECYCLE_CLOSED: 'SESSION_LIFECYCLE_CLOSED',\n\tPERSISTENCE_OWNERSHIP: 'PERSISTENCE_OWNERSHIP',\n\tPERSISTENCE_CORRUPTION: 'PERSISTENCE_CORRUPTION',\n\tPERSISTENCE_PUBLICATION: 'PERSISTENCE_PUBLICATION',\n\tPERSISTENCE_CLOSED: 'PERSISTENCE_CLOSED',\n\tPERSISTENCE_DRAIN: 'PERSISTENCE_DRAIN',\n\tPERSISTENCE_SESSION_ADMISSION_CLOSED: 'PERSISTENCE_SESSION_ADMISSION_CLOSED',\n\tPERSISTENCE_SESSION_BARRIER_REENTRANCY: 'PERSISTENCE_SESSION_BARRIER_REENTRANCY',\n\tPERSISTENCE_SCOPE_MISMATCH: 'PERSISTENCE_SCOPE_MISMATCH',\n\tPERSISTENCE_UNAVAILABLE: 'PERSISTENCE_UNAVAILABLE',\n\tPERSISTENCE_COMPATIBILITY: 'PERSISTENCE_COMPATIBILITY',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/**\n * All known warning codes as a const object.\n * Warnings are non-fatal advisory signals returned alongside successful results.\n */\nexport const WARNING_CODES = {\n\tTOTAL_THOUGHTS_ADJUSTED: 'TOTAL_THOUGHTS_ADJUSTED',\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/**\n * Base error class for all Sequential Thinking server errors.\n *\n * This error extends the native `Error` class and adds a `code` property\n * for programmatic error identification and handling. All specific error\n * types in the system extend this base class.\n *\n * @remarks\n * **Error Codes:**\n * - `TOOL_NOT_FOUND` - A requested tool was not found\n * - `SKILL_NOT_FOUND` - A requested skill was not found\n * - `INVALID_THOUGHT` - Thought validation failed\n * - `SKILL_DISCOVERY_FAILED` - Skill discovery operation failed\n * - `HISTORY_LIMIT_EXCEEDED` - History size limit was exceeded\n * - `INVALID_EDGE` - An invalid edge operation was attempted\n *\n * @example\n * ```typescript\n * // Throw a custom sequential thinking error\n * throw new SequentialThinkingError('Custom error message', 'CUSTOM_CODE');\n *\n * // Check if an error is a SequentialThinkingError\n * if (error instanceof SequentialThinkingError) {\n * console.error(`Error [${error.code}]: ${error.message}`);\n * }\n * ```\n */\nexport class SequentialThinkingError extends Error {\n\t/** The error code for programmatic identification. */\n\tpublic readonly code: ErrorCode;\n\n\t/**\n\t * Creates a new SequentialThinkingError.\n\t *\n\t * @param message - Human-readable error message\n\t * @param code - Error code for programmatic handling\n\t *\n\t * @example\n\t * ```typescript\n\t * const error = new SequentialThinkingError(\n\t * 'Something went wrong',\n\t * 'CUSTOM_ERROR'\n\t * );\n\t * console.log(error.code); // 'CUSTOM_ERROR'\n\t * ```\n\t */\n\tconstructor(message: string, code: ErrorCode) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t\tthis.name = 'SequentialThinkingError';\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n\nexport class ConfigurationError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.CONFIGURATION_ERROR);\n\t\tthis.name = 'ConfigurationError';\n\t}\n}\n\n/**\n * Error thrown when a requested tool is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a tool that doesn't exist in the tool registry.\n *\n * @example\n * ```typescript\n * const tool = registry.get('non-existent-tool');\n * if (!tool) {\n * throw new ToolNotFoundError('non-existent-tool');\n * }\n * ```\n */\nexport class ToolNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new ToolNotFoundError.\n\t *\n\t * @param toolName - The name of the tool that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new ToolNotFoundError('my-custom-tool');\n\t * // Error: tool 'my-custom-tool' not found\n\t *\n\t * throw new ToolNotFoundError('my-custom-tool', 'remove');\n\t * // Error: tool 'my-custom-tool' not found, cannot remove\n\t * // Code: TOOL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(toolName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Tool '${toolName}' not found, cannot ${action}`\n\t\t\t: `Tool '${toolName}' not found`;\n\t\tsuper(message, ERROR_CODES.TOOL_NOT_FOUND);\n\t\tthis.name = 'ToolNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when a requested skill is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a skill that doesn't exist in the skill registry.\n *\n * @example\n * ```typescript\n * const skill = registry.get('non-existent-skill');\n * if (!skill) {\n * throw new SkillNotFoundError('non-existent-skill');\n * }\n * ```\n */\nexport class SkillNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new SkillNotFoundError.\n\t *\n\t * @param skillName - The name of the skill that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new SkillNotFoundError('my-custom-skill');\n\t * // Error: skill 'my-custom-skill' not found\n\t *\n\t * throw new SkillNotFoundError('my-custom-skill', 'remove');\n\t * // Error: skill 'my-custom-skill' not found, cannot remove\n\t * // Code: SKILL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(skillName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Skill '${skillName}' not found, cannot ${action}`\n\t\t\t: `Skill '${skillName}' not found`;\n\t\tsuper(message, ERROR_CODES.SKILL_NOT_FOUND);\n\t\tthis.name = 'SkillNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when thought validation fails.\n *\n * This error is thrown when a thought fails validation, typically due to\n * invalid values, missing required fields, or constraint violations.\n *\n * @example\n * ```typescript\n * // Validate thought number\n * if (thought.thought_number < 1) {\n * throw new InvalidThoughtError(thought.thought_number, 'thought_number must be >= 1');\n * }\n * ```\n */\nexport class InvalidThoughtError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidThoughtError.\n\t *\n\t * @param thoughtNumber - The thought number that failed validation\n\t * @param reason - Human-readable explanation of why validation failed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidThoughtError(5, 'thought_number exceeds total_thoughts');\n\t * // Error: Invalid thought 5: thought_number exceeds total_thoughts\n\t * // Code: INVALID_THOUGHT\n\t * ```\n\t */\n\tconstructor(thoughtNumber: number, reason: string) {\n\t\tsuper(`Invalid thought ${thoughtNumber}: ${reason}`, ERROR_CODES.INVALID_THOUGHT);\n\t\tthis.name = 'InvalidThoughtError';\n\t}\n}\n\n/**\n * Error thrown when skill discovery fails.\n *\n * This error is thrown when the skill discovery process encounters an issue,\n * such as filesystem errors, invalid skill files, or parsing failures.\n *\n * @remarks\n * The original error that caused the discovery failure is preserved in the\n * `cause` property for debugging purposes.\n *\n * @example\n * ```typescript\n * try {\n * await discoverSkills('./skills');\n * } catch (error) {\n * throw new SkillDiscoveryError('./skills', error as Error);\n * }\n * ```\n */\nexport class SkillDiscoveryError extends SequentialThinkingError {\n\t/** The underlying error that caused the discovery failure. */\n\tpublic override readonly cause: Error;\n\n\t/**\n\t * Creates a new SkillDiscoveryError.\n\t *\n\t * @param directory - The directory where discovery failed\n\t * @param cause - The underlying error that caused the failure\n\t *\n\t * @example\n\t * ```typescript\n\t * try {\n\t * const skills = await loadSkills('./invalid-directory');\n\t * } catch (error) {\n\t * throw new SkillDiscoveryError('./invalid-directory', error as Error);\n\t * }\n\t * ```\n\t */\n\tconstructor(directory: string, cause: Error) {\n\t\tsuper(\n\t\t\t`Failed to discover skills in ${directory}: ${cause.message}`,\n\t\t\tERROR_CODES.SKILL_DISCOVERY_FAILED\n\t\t);\n\t\tthis.name = 'SkillDiscoveryError';\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Error thrown when history size exceeds the configured limit.\n *\n * This error is thrown when an operation would cause the history size\n * to exceed the maximum configured size limit.\n *\n * @example\n * ```typescript\n * if (history.length >= maxSize) {\n * throw new HistoryLimitExceededError(history.length, maxSize);\n * }\n * ```\n */\nexport class HistoryLimitExceededError extends SequentialThinkingError {\n\t/**\n\t * Creates a new HistoryLimitExceededError.\n\t *\n\t * @param currentSize - The current history size\n\t * @param maxSize - The maximum allowed size\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new HistoryLimitExceededError(1500, 1000);\n\t * // Error: History size 1500 exceeds limit 1000\n\t * // Code: HISTORY_LIMIT_EXCEEDED\n\t * ```\n\t */\n\tconstructor(currentSize: number, maxSize: number) {\n\t\tsuper(\n\t\t\t`History size ${currentSize} exceeds limit ${maxSize}`,\n\t\t\tERROR_CODES.HISTORY_LIMIT_EXCEEDED\n\t\t);\n\t\tthis.name = 'HistoryLimitExceededError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a skill that already exists.\n *\n * This error is thrown when trying to register a skill with a name that\n * is already present in the skill registry.\n *\n * @example\n * ```typescript\n * if (registry.has(skill.name)) {\n * throw new DuplicateSkillError(skill.name);\n * }\n * ```\n */\nexport class DuplicateSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateSkillError.\n\t *\n\t * @param skillName - The name of the duplicate skill\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateSkillError('my-skill');\n\t * // Error: skill 'my-skill' already exists\n\t * // Code: DUPLICATE_SKILL\n\t * ```\n\t */\n\tconstructor(skillName: string) {\n\t\tsuper(`skill '${skillName}' already exists`, ERROR_CODES.DUPLICATE_SKILL);\n\t\tthis.name = 'DuplicateSkillError';\n\t}\n}\n\n/**\n * Error thrown when a skill has invalid data.\n *\n * This error is thrown when a skill fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!skill.name) {\n * throw new InvalidSkillError('Skill must have a valid name');\n * }\n * ```\n */\nexport class InvalidSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidSkillError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidSkillError('Skill must have a valid name');\n\t * // Error: Invalid skill: Skill must have a valid name\n\t * // Code: INVALID_SKILL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid skill: ${reason}`, ERROR_CODES.INVALID_SKILL);\n\t\tthis.name = 'InvalidSkillError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a tool that already exists.\n *\n * This error is thrown when trying to register a tool with a name that\n * is already present in the tool registry.\n *\n * @example\n * ```typescript\n * if (registry.has(tool.name)) {\n * throw new DuplicateToolError(tool.name);\n * }\n * ```\n */\nexport class DuplicateToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateToolError.\n\t *\n\t * @param toolName - The name of the duplicate tool\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateToolError('my-tool');\n\t * // Error: tool 'my-tool' already exists\n\t * // Code: DUPLICATE_TOOL\n\t * ```\n\t */\n\tconstructor(toolName: string) {\n\t\tsuper(`tool '${toolName}' already exists`, ERROR_CODES.DUPLICATE_TOOL);\n\t\tthis.name = 'DuplicateToolError';\n\t}\n}\n\n/**\n * Error thrown when a tool has invalid data.\n *\n * This error is thrown when a tool fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!tool.name) {\n * throw new InvalidToolError('Tool must have a valid name');\n * }\n * ```\n */\nexport class InvalidToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidToolError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidToolError('Tool must have a valid name');\n\t * // Error: Invalid tool: Tool must have a valid name\n\t * // Code: INVALID_TOOL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid tool: ${reason}`, ERROR_CODES.INVALID_TOOL);\n\t\tthis.name = 'InvalidToolError';\n\t}\n}\n\n/**\n * Error thrown when the maximum number of sessions has been reached.\n *\n * This error is thrown when trying to create a new session when the\n * pool has reached its configured maximum session limit.\n *\n * @example\n * ```typescript\n * if (pool.sessionCount >= pool.maxSessions) {\n * throw new MaxSessionsReachedError(pool.maxSessions);\n * }\n * ```\n */\nexport class MaxSessionsReachedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new MaxSessionsReachedError.\n\t *\n\t * @param maxSessions - The maximum number of sessions allowed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new MaxSessionsReachedError(100);\n\t * // Error: Max sessions (100) reached. Wait for a session to close or increase maxSessions.\n\t * // Code: MAX_SESSIONS_REACHED\n\t * ```\n\t */\n\tconstructor(maxSessions: number) {\n\t\tsuper(\n\t\t\t`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`,\n\t\t\tERROR_CODES.MAX_SESSIONS_REACHED\n\t\t);\n\t\tthis.name = 'MaxSessionsReachedError';\n\t}\n}\n\n/**\n * Error thrown when attempting to use a terminated connection pool.\n *\n * This error is thrown when trying to create sessions or process requests\n * after the connection pool has been terminated.\n *\n * @example\n * ```typescript\n * if (pool.isTerminated) {\n * throw new PoolTerminatedError();\n * }\n * ```\n */\nexport class PoolTerminatedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new PoolTerminatedError.\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new PoolTerminatedError();\n\t * // Error: ConnectionPool has been terminated\n\t * // Code: POOL_TERMINATED\n\t * ```\n\t */\n\tconstructor() {\n\t\tsuper('ConnectionPool has been terminated', ERROR_CODES.POOL_TERMINATED);\n\t\tthis.name = 'PoolTerminatedError';\n\t}\n}\n\n/**\n * Error thrown when input validation fails due to invalid or malicious data.\n *\n * This error is thrown when user input fails security or format validation,\n * such as path traversal attempts or invalid identifier formats.\n *\n * @example\n * ```typescript\n * if (!BRANCH_ID_PATTERN.test(branchId)) {\n * throw new ValidationError('branchId', 'Invalid format');\n * }\n * ```\n */\nexport class ValidationError extends SequentialThinkingError {\n\t/** The field that failed validation. */\n\tpublic readonly field: string;\n\n\tconstructor(field: string, reason: string) {\n\t\tsuper(`Validation failed for '${field}': ${reason}`, ERROR_CODES.VALIDATION_ERROR);\n\t\tthis.name = 'ValidationError';\n\t\tthis.field = field;\n\t}\n}\n\n/**\n * Error thrown when an invalid edge operation is attempted.\n *\n * This error is thrown when attempting to add an edge that violates\n * structural invariants of the thought DAG, such as a self-edge\n * (where `from` and `to` reference the same thought).\n *\n * @example\n * ```typescript\n * if (edge.from === edge.to) {\n * throw new InvalidEdgeError(\n * `Self-edge not allowed: from and to are the same (${edge.from})`\n * );\n * }\n * ```\n */\nexport class InvalidEdgeError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidEdgeError.\n\t *\n\t * @param message - Human-readable explanation of the invalid edge\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidEdgeError('Self-edge not allowed: from and to are the same (t1)');\n\t * // Code: INVALID_EDGE\n\t * ```\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_EDGE);\n\t\tthis.name = 'InvalidEdgeError';\n\t}\n}\n\n/**\n * Error thrown when a cycle is detected during graph traversal.\n *\n * This error is thrown by graph algorithms (such as topological sort)\n * when the thought DAG contains a cycle, violating the acyclic invariant.\n *\n * @example\n * ```typescript\n * try {\n * const order = graphView.topological(sessionId);\n * } catch (error) {\n * if (error instanceof CycleDetectedError) {\n * console.error('Cycle in thought graph:', error.message);\n * }\n * }\n * ```\n */\nexport class CycleDetectedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new CycleDetectedError.\n\t *\n\t * @param message - Human-readable explanation of the cycle\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new CycleDetectedError('Cycle detected in session s1');\n\t * // Code: CYCLE_DETECTED\n\t * ```\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.CYCLE_DETECTED);\n\t\tthis.name = 'CycleDetectedError';\n\t}\n}\n\n/**\n * Error thrown when a suspension record is not found.\n *\n * This error is thrown when attempting to resume a tool interleave\n * suspension that does not exist in the suspension store.\n */\nexport class SuspensionNotFoundError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.SUSPENSION_NOT_FOUND);\n\t\tthis.name = 'SuspensionNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when a suspension record has expired.\n *\n * This error is thrown when attempting to resume a tool interleave\n * suspension whose TTL has elapsed.\n */\nexport class SuspensionExpiredError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.SUSPENSION_EXPIRED);\n\t\tthis.name = 'SuspensionExpiredError';\n\t}\n}\n\n/**\n * Error thrown when a tool call payload is invalid.\n *\n * This error is thrown when a tool interleave invocation has malformed\n * arguments, missing identifiers, or otherwise fails validation.\n */\nexport class InvalidToolCallError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_TOOL_CALL);\n\t\tthis.name = 'InvalidToolCallError';\n\t}\n}\n\n/**\n * Error thrown when a backtrack operation is invalid.\n *\n * This error is thrown when an attempt to backtrack the reasoning\n * chain references an unreachable thought or violates DAG invariants.\n */\nexport class InvalidBacktrackError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_BACKTRACK);\n\t\tthis.name = 'InvalidBacktrackError';\n\t}\n}\n\n/**\n * Error thrown when a tool_call references a tool not registered with the server.\n *\n * Acts as an allowlist gate: only tools registered in the ToolRegistry may be\n * invoked through tool interleave. Prevents arbitrary tool name injection.\n */\nexport class UnknownToolError extends SequentialThinkingError {\n\tpublic readonly toolName: string;\n\n\tconstructor(toolName: string, message?: string) {\n\t\tsuper(\n\t\t\tmessage ?? `Unknown tool '${toolName}': not registered with the server`,\n\t\t\tERROR_CODES.UNKNOWN_TOOL\n\t\t);\n\t\tthis.name = 'UnknownToolError';\n\t\tthis.toolName = toolName;\n\t}\n}\n\n/** Error thrown when the CLI's complete shutdown exceeds its outer deadline. */\nexport class CliShutdownTimeoutError extends SequentialThinkingError {\n\tpublic readonly timeoutMs: number;\n\n\tconstructor(timeoutMs: number) {\n\t\tsuper(`CLI shutdown timed out after ${timeoutMs}ms`, ERROR_CODES.CLI_SHUTDOWN_TIMEOUT);\n\t\tthis.name = 'CliShutdownTimeoutError';\n\t\tthis.timeoutMs = timeoutMs;\n\t}\n}\n\nexport class PersistenceOwnershipError extends SequentialThinkingError {\n\tpublic readonly canonicalDataDir: string;\n\tpublic readonly lockPath: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(canonicalDataDir: string, lockPath: string, cause: unknown) {\n\t\tsuper(\n\t\t\t`Persistence directory '${canonicalDataDir}' already has an active writer`,\n\t\t\tERROR_CODES.PERSISTENCE_OWNERSHIP\n\t\t);\n\t\tthis.name = 'PersistenceOwnershipError';\n\t\tthis.canonicalDataDir = canonicalDataDir;\n\t\tthis.lockPath = lockPath;\n\t\tthis.cause = cause;\n\t}\n}\n\nexport class PersistenceCorruptionError extends SequentialThinkingError {\n\tpublic readonly path: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(path: string, cause: unknown) {\n\t\tsuper(\n\t\t\t`Persisted data at '${path}' is corrupt or incompatible`,\n\t\t\tERROR_CODES.PERSISTENCE_CORRUPTION\n\t\t);\n\t\tthis.name = 'PersistenceCorruptionError';\n\t\tthis.path = path;\n\t\tthis.cause = cause;\n\t}\n}\n\n/** Error raised when startup cannot read from an unhealthy persistence backend. */\nexport class PersistenceUnavailableError extends SequentialThinkingError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'Persistence backend is unavailable during startup restore',\n\t\t\tERROR_CODES.PERSISTENCE_UNAVAILABLE\n\t\t);\n\t\tthis.name = 'PersistenceUnavailableError';\n\t}\n}\n\nexport type PersistencePublicationStage = 'temporary-write' | 'atomic-replacement' | 'cleanup';\n\nexport class PersistencePublicationError extends SequentialThinkingError {\n\tpublic readonly path: string;\n\tpublic readonly stage: PersistencePublicationStage;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(path: string, stage: PersistencePublicationStage, cause: unknown) {\n\t\tsuper(\n\t\t\t`Failed persistence publication for '${path}' during ${stage}`,\n\t\t\tERROR_CODES.PERSISTENCE_PUBLICATION\n\t\t);\n\t\tthis.name = 'PersistencePublicationError';\n\t\tthis.path = path;\n\t\tthis.stage = stage;\n\t\tthis.cause = cause;\n\t}\n}\n\nexport class PersistenceClosedError extends SequentialThinkingError {\n\tpublic readonly dataDir: string;\n\n\tconstructor(dataDir: string) {\n\t\tsuper(`Persistence writer for '${dataDir}' is closed`, ERROR_CODES.PERSISTENCE_CLOSED);\n\t\tthis.name = 'PersistenceClosedError';\n\t\tthis.dataDir = dataDir;\n\t}\n}\n\n/** Error raised for well-formed but unsupported or drifted persisted data. */\nexport class PersistenceCompatibilityError extends SequentialThinkingError {\n\tpublic readonly sourcePath: string;\n\tpublic readonly detail: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(sourcePath: string, detail: string, cause?: unknown) {\n\t\tsuper(\n\t\t\t`Persisted data at '${sourcePath}' is incompatible: ${detail}`,\n\t\t\tERROR_CODES.PERSISTENCE_COMPATIBILITY\n\t\t);\n\t\tthis.name = 'PersistenceCompatibilityError';\n\t\tthis.sourcePath = sourcePath;\n\t\tthis.detail = detail;\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Type guard to check if an error has a specific error code.\n */\nexport function isErrorCode<C extends ErrorCode>(\n\terr: unknown,\n\tcode: C\n): err is SequentialThinkingError & { readonly code: C } {\n\treturn err instanceof SequentialThinkingError && err.code === code;\n}\n\n/**\n * Extract a human-readable message from an unknown error value.\n *\n * Standardizes the common `error instanceof Error ? error.message : String(error)`\n * pattern used in catch blocks across the codebase.\n *\n * @param error - The unknown error value to extract a message from\n * @returns The error message string\n *\n * @example\n * ```typescript\n * try {\n * await doSomething();\n * } catch (error) {\n * logger.error('Failed', { error: getErrorMessage(error) });\n * }\n * ```\n */\nexport function getErrorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"],"names":["ERROR_CODES","WARNING_CODES","SequentialThinkingError","Error","message","code","ConfigurationError","ToolNotFoundError","toolName","action","SkillNotFoundError","skillName","InvalidThoughtError","thoughtNumber","reason","SkillDiscoveryError","directory","cause","HistoryLimitExceededError","currentSize","maxSize","DuplicateSkillError","InvalidSkillError","DuplicateToolError","InvalidToolError","MaxSessionsReachedError","maxSessions","PoolTerminatedError","ValidationError","field","InvalidEdgeError","CycleDetectedError","SuspensionNotFoundError","SuspensionExpiredError","InvalidToolCallError","InvalidBacktrackError","UnknownToolError","CliShutdownTimeoutError","timeoutMs","PersistenceOwnershipError","canonicalDataDir","lockPath","PersistenceCorruptionError","path","PersistenceUnavailableError","PersistencePublicationError","stage","PersistenceClosedError","dataDir","PersistenceCompatibilityError","sourcePath","detail","isErrorCode","err","getErrorMessage","error","String"],"mappings":"AA+BO,MAAMA,cAAc;IAC1B,qBAAqB;IACrB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,wBAAwB;IACxB,wBAAwB;IACxB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;IACtB,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IAC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 {"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":["/**\n * Custom error types for the TraceLattice server.\n *\n * This module defines a hierarchy of error classes for handling various\n * error conditions that can occur in the sequential thinking server.\n * All errors extend the base `SequentialThinkingError` class with\n * specific error codes for programmatic handling.\n *\n * @example\n * ```typescript\n * import { ToolNotFoundError, SkillDiscoveryError } from './errors.js';\n *\n * // Throw a tool not found error\n * throw new ToolNotFoundError('my-tool');\n *\n * // Catch and handle specific errors\n * try {\n * await discoverSkills(dir);\n * } catch (error) {\n * if (error instanceof SkillDiscoveryError) {\n * console.error(`Failed to discover skills: ${error.message}`);\n * console.error(`Error code: ${error.code}`);\n * }\n * }\n * ```\n * @module errors\n */\n\n/**\n * All known error codes as a const object for exhaustive switching.\n */\nexport const ERROR_CODES = {\n\tCONFIGURATION_ERROR: 'CONFIGURATION_ERROR',\n\tTOOL_NOT_FOUND: 'TOOL_NOT_FOUND',\n\tSKILL_NOT_FOUND: 'SKILL_NOT_FOUND',\n\tINVALID_THOUGHT: 'INVALID_THOUGHT',\n\tSKILL_DISCOVERY_FAILED: 'SKILL_DISCOVERY_FAILED',\n\tHISTORY_LIMIT_EXCEEDED: 'HISTORY_LIMIT_EXCEEDED',\n\tDUPLICATE_SKILL: 'DUPLICATE_SKILL',\n\tINVALID_SKILL: 'INVALID_SKILL',\n\tDUPLICATE_TOOL: 'DUPLICATE_TOOL',\n\tINVALID_TOOL: 'INVALID_TOOL',\n\tSESSION_NOT_ACTIVE: 'SESSION_NOT_ACTIVE',\n\tSESSION_NOT_FOUND: 'SESSION_NOT_FOUND',\n\tMAX_SESSIONS_REACHED: 'MAX_SESSIONS_REACHED',\n\tPOOL_TERMINATED: 'POOL_TERMINATED',\n\tVALIDATION_ERROR: 'VALIDATION_ERROR',\n\tINVALID_EDGE: 'INVALID_EDGE',\n\tCYCLE_DETECTED: 'CYCLE_DETECTED',\n\tSUSPENSION_NOT_FOUND: 'SUSPENSION_NOT_FOUND',\n\tSUSPENSION_EXPIRED: 'SUSPENSION_EXPIRED',\n\tINVALID_TOOL_CALL: 'INVALID_TOOL_CALL',\n\tINVALID_BACKTRACK: 'INVALID_BACKTRACK',\n\tDUPLICATE_SUMMARY: 'DUPLICATE_SUMMARY',\n\tUNKNOWN_TOOL: 'UNKNOWN_TOOL',\n\tLOCK_TIMEOUT: 'LOCK_TIMEOUT',\n\tCLI_SHUTDOWN_TIMEOUT: 'CLI_SHUTDOWN_TIMEOUT',\n\tSESSION_ACCESS_DENIED: 'SESSION_ACCESS_DENIED',\n\tSESSION_EXPIRED: 'SESSION_EXPIRED',\n\tSESSION_LIFECYCLE_CLOSED: 'SESSION_LIFECYCLE_CLOSED',\n\tPERSISTENCE_OWNERSHIP: 'PERSISTENCE_OWNERSHIP',\n\tPERSISTENCE_CORRUPTION: 'PERSISTENCE_CORRUPTION',\n\tPERSISTENCE_PUBLICATION: 'PERSISTENCE_PUBLICATION',\n\tPERSISTENCE_CLOSED: 'PERSISTENCE_CLOSED',\n\tPERSISTENCE_DRAIN: 'PERSISTENCE_DRAIN',\n\tPERSISTENCE_SESSION_ADMISSION_CLOSED: 'PERSISTENCE_SESSION_ADMISSION_CLOSED',\n\tPERSISTENCE_SESSION_BARRIER_REENTRANCY: 'PERSISTENCE_SESSION_BARRIER_REENTRANCY',\n\tPERSISTENCE_SCOPE_MISMATCH: 'PERSISTENCE_SCOPE_MISMATCH',\n\tPERSISTENCE_UNAVAILABLE: 'PERSISTENCE_UNAVAILABLE',\n\tPERSISTENCE_COMPATIBILITY: 'PERSISTENCE_COMPATIBILITY',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/**\n * All known warning codes as a const object.\n * Warnings are non-fatal advisory signals returned alongside successful results.\n */\nexport const WARNING_CODES = {\n\tTOTAL_THOUGHTS_ADJUSTED: 'TOTAL_THOUGHTS_ADJUSTED',\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/**\n * Base error class for all Sequential Thinking server errors.\n *\n * This error extends the native `Error` class and adds a `code` property\n * for programmatic error identification and handling. All specific error\n * types in the system extend this base class.\n *\n * @remarks\n * **Error Codes:**\n * - `TOOL_NOT_FOUND` - A requested tool was not found\n * - `SKILL_NOT_FOUND` - A requested skill was not found\n * - `INVALID_THOUGHT` - Thought validation failed\n * - `SKILL_DISCOVERY_FAILED` - Skill discovery operation failed\n * - `HISTORY_LIMIT_EXCEEDED` - History size limit was exceeded\n * - `INVALID_EDGE` - An invalid edge operation was attempted\n *\n * @example\n * ```typescript\n * // Throw a custom sequential thinking error\n * throw new SequentialThinkingError('Custom error message', 'CUSTOM_CODE');\n *\n * // Check if an error is a SequentialThinkingError\n * if (error instanceof SequentialThinkingError) {\n * console.error(`Error [${error.code}]: ${error.message}`);\n * }\n * ```\n */\nexport class SequentialThinkingError extends Error {\n\t/** The error code for programmatic identification. */\n\tpublic readonly code: ErrorCode;\n\n\t/**\n\t * Creates a new SequentialThinkingError.\n\t *\n\t * @param message - Human-readable error message\n\t * @param code - Error code for programmatic handling\n\t *\n\t * @example\n\t * ```typescript\n\t * const error = new SequentialThinkingError(\n\t * 'Something went wrong',\n\t * 'CUSTOM_ERROR'\n\t * );\n\t * console.log(error.code); // 'CUSTOM_ERROR'\n\t * ```\n\t */\n\tconstructor(message: string, code: ErrorCode) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t\tthis.name = 'SequentialThinkingError';\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n\nexport class ConfigurationError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.CONFIGURATION_ERROR);\n\t\tthis.name = 'ConfigurationError';\n\t}\n}\n\n/**\n * Error thrown when a requested tool is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a tool that doesn't exist in the tool registry.\n *\n * @example\n * ```typescript\n * const tool = registry.get('non-existent-tool');\n * if (!tool) {\n * throw new ToolNotFoundError('non-existent-tool');\n * }\n * ```\n */\nexport class ToolNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new ToolNotFoundError.\n\t *\n\t * @param toolName - The name of the tool that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new ToolNotFoundError('my-custom-tool');\n\t * // Error: tool 'my-custom-tool' not found\n\t *\n\t * throw new ToolNotFoundError('my-custom-tool', 'remove');\n\t * // Error: tool 'my-custom-tool' not found, cannot remove\n\t * // Code: TOOL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(toolName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Tool '${toolName}' not found, cannot ${action}`\n\t\t\t: `Tool '${toolName}' not found`;\n\t\tsuper(message, ERROR_CODES.TOOL_NOT_FOUND);\n\t\tthis.name = 'ToolNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when a requested skill is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a skill that doesn't exist in the skill registry.\n *\n * @example\n * ```typescript\n * const skill = registry.get('non-existent-skill');\n * if (!skill) {\n * throw new SkillNotFoundError('non-existent-skill');\n * }\n * ```\n */\nexport class SkillNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new SkillNotFoundError.\n\t *\n\t * @param skillName - The name of the skill that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new SkillNotFoundError('my-custom-skill');\n\t * // Error: skill 'my-custom-skill' not found\n\t *\n\t * throw new SkillNotFoundError('my-custom-skill', 'remove');\n\t * // Error: skill 'my-custom-skill' not found, cannot remove\n\t * // Code: SKILL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(skillName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Skill '${skillName}' not found, cannot ${action}`\n\t\t\t: `Skill '${skillName}' not found`;\n\t\tsuper(message, ERROR_CODES.SKILL_NOT_FOUND);\n\t\tthis.name = 'SkillNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when thought validation fails.\n *\n * This error is thrown when a thought fails validation, typically due to\n * invalid values, missing required fields, or constraint violations.\n *\n * @example\n * ```typescript\n * // Validate thought number\n * if (thought.thought_number < 1) {\n * throw new InvalidThoughtError(thought.thought_number, 'thought_number must be >= 1');\n * }\n * ```\n */\nexport class InvalidThoughtError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidThoughtError.\n\t *\n\t * @param thoughtNumber - The thought number that failed validation\n\t * @param reason - Human-readable explanation of why validation failed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidThoughtError(5, 'thought_number exceeds total_thoughts');\n\t * // Error: Invalid thought 5: thought_number exceeds total_thoughts\n\t * // Code: INVALID_THOUGHT\n\t * ```\n\t */\n\tconstructor(thoughtNumber: number, reason: string) {\n\t\tsuper(`Invalid thought ${thoughtNumber}: ${reason}`, ERROR_CODES.INVALID_THOUGHT);\n\t\tthis.name = 'InvalidThoughtError';\n\t}\n}\n\n/**\n * Error thrown when skill discovery fails.\n *\n * This error is thrown when the skill discovery process encounters an issue,\n * such as filesystem errors, invalid skill files, or parsing failures.\n *\n * @remarks\n * The original error that caused the discovery failure is preserved in the\n * `cause` property for debugging purposes.\n *\n * @example\n * ```typescript\n * try {\n * await discoverSkills('./skills');\n * } catch (error) {\n * throw new SkillDiscoveryError('./skills', error as Error);\n * }\n * ```\n */\nexport class SkillDiscoveryError extends SequentialThinkingError {\n\t/** The underlying error that caused the discovery failure. */\n\tpublic override readonly cause: Error;\n\n\t/**\n\t * Creates a new SkillDiscoveryError.\n\t *\n\t * @param directory - The directory where discovery failed\n\t * @param cause - The underlying error that caused the failure\n\t *\n\t * @example\n\t * ```typescript\n\t * try {\n\t * const skills = await loadSkills('./invalid-directory');\n\t * } catch (error) {\n\t * throw new SkillDiscoveryError('./invalid-directory', error as Error);\n\t * }\n\t * ```\n\t */\n\tconstructor(directory: string, cause: Error) {\n\t\tsuper(\n\t\t\t`Failed to discover skills in ${directory}: ${cause.message}`,\n\t\t\tERROR_CODES.SKILL_DISCOVERY_FAILED\n\t\t);\n\t\tthis.name = 'SkillDiscoveryError';\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Error thrown when history size exceeds the configured limit.\n *\n * This error is thrown when an operation would cause the history size\n * to exceed the maximum configured size limit.\n *\n * @example\n * ```typescript\n * if (history.length >= maxSize) {\n * throw new HistoryLimitExceededError(history.length, maxSize);\n * }\n * ```\n */\nexport class HistoryLimitExceededError extends SequentialThinkingError {\n\t/**\n\t * Creates a new HistoryLimitExceededError.\n\t *\n\t * @param currentSize - The current history size\n\t * @param maxSize - The maximum allowed size\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new HistoryLimitExceededError(1500, 1000);\n\t * // Error: History size 1500 exceeds limit 1000\n\t * // Code: HISTORY_LIMIT_EXCEEDED\n\t * ```\n\t */\n\tconstructor(currentSize: number, maxSize: number) {\n\t\tsuper(\n\t\t\t`History size ${currentSize} exceeds limit ${maxSize}`,\n\t\t\tERROR_CODES.HISTORY_LIMIT_EXCEEDED\n\t\t);\n\t\tthis.name = 'HistoryLimitExceededError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a skill that already exists.\n *\n * This error is thrown when trying to register a skill with a name that\n * is already present in the skill registry.\n *\n * @example\n * ```typescript\n * if (registry.has(skill.name)) {\n * throw new DuplicateSkillError(skill.name);\n * }\n * ```\n */\nexport class DuplicateSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateSkillError.\n\t *\n\t * @param skillName - The name of the duplicate skill\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateSkillError('my-skill');\n\t * // Error: skill 'my-skill' already exists\n\t * // Code: DUPLICATE_SKILL\n\t * ```\n\t */\n\tconstructor(skillName: string) {\n\t\tsuper(`skill '${skillName}' already exists`, ERROR_CODES.DUPLICATE_SKILL);\n\t\tthis.name = 'DuplicateSkillError';\n\t}\n}\n\n/**\n * Error thrown when a skill has invalid data.\n *\n * This error is thrown when a skill fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!skill.name) {\n * throw new InvalidSkillError('Skill must have a valid name');\n * }\n * ```\n */\nexport class InvalidSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidSkillError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidSkillError('Skill must have a valid name');\n\t * // Error: Invalid skill: Skill must have a valid name\n\t * // Code: INVALID_SKILL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid skill: ${reason}`, ERROR_CODES.INVALID_SKILL);\n\t\tthis.name = 'InvalidSkillError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a tool that already exists.\n *\n * This error is thrown when trying to register a tool with a name that\n * is already present in the tool registry.\n *\n * @example\n * ```typescript\n * if (registry.has(tool.name)) {\n * throw new DuplicateToolError(tool.name);\n * }\n * ```\n */\nexport class DuplicateToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateToolError.\n\t *\n\t * @param toolName - The name of the duplicate tool\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateToolError('my-tool');\n\t * // Error: tool 'my-tool' already exists\n\t * // Code: DUPLICATE_TOOL\n\t * ```\n\t */\n\tconstructor(toolName: string) {\n\t\tsuper(`tool '${toolName}' already exists`, ERROR_CODES.DUPLICATE_TOOL);\n\t\tthis.name = 'DuplicateToolError';\n\t}\n}\n\n/**\n * Error thrown when a tool has invalid data.\n *\n * This error is thrown when a tool fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!tool.name) {\n * throw new InvalidToolError('Tool must have a valid name');\n * }\n * ```\n */\nexport class InvalidToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidToolError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidToolError('Tool must have a valid name');\n\t * // Error: Invalid tool: Tool must have a valid name\n\t * // Code: INVALID_TOOL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid tool: ${reason}`, ERROR_CODES.INVALID_TOOL);\n\t\tthis.name = 'InvalidToolError';\n\t}\n}\n\n/**\n * Error thrown when the maximum number of sessions has been reached.\n *\n * This error is thrown when trying to create a new session when the\n * pool has reached its configured maximum session limit.\n *\n * @example\n * ```typescript\n * if (pool.sessionCount >= pool.maxSessions) {\n * throw new MaxSessionsReachedError(pool.maxSessions);\n * }\n * ```\n */\nexport class MaxSessionsReachedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new MaxSessionsReachedError.\n\t *\n\t * @param maxSessions - The maximum number of sessions allowed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new MaxSessionsReachedError(100);\n\t * // Error: Max sessions (100) reached. Wait for a session to close or increase maxSessions.\n\t * // Code: MAX_SESSIONS_REACHED\n\t * ```\n\t */\n\tconstructor(maxSessions: number) {\n\t\tsuper(\n\t\t\t`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`,\n\t\t\tERROR_CODES.MAX_SESSIONS_REACHED\n\t\t);\n\t\tthis.name = 'MaxSessionsReachedError';\n\t}\n}\n\n/**\n * Error thrown when attempting to use a terminated connection pool.\n *\n * This error is thrown when trying to create sessions or process requests\n * after the connection pool has been terminated.\n *\n * @example\n * ```typescript\n * if (pool.isTerminated) {\n * throw new PoolTerminatedError();\n * }\n * ```\n */\nexport class PoolTerminatedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new PoolTerminatedError.\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new PoolTerminatedError();\n\t * // Error: ConnectionPool has been terminated\n\t * // Code: POOL_TERMINATED\n\t * ```\n\t */\n\tconstructor() {\n\t\tsuper('ConnectionPool has been terminated', ERROR_CODES.POOL_TERMINATED);\n\t\tthis.name = 'PoolTerminatedError';\n\t}\n}\n\n/**\n * Error thrown when input validation fails due to invalid or malicious data.\n *\n * This error is thrown when user input fails security or format validation,\n * such as path traversal attempts or invalid identifier formats.\n *\n * @example\n * ```typescript\n * if (!BRANCH_ID_PATTERN.test(branchId)) {\n * throw new ValidationError('branchId', 'Invalid format');\n * }\n * ```\n */\nexport class ValidationError extends SequentialThinkingError {\n\t/** The field that failed validation. */\n\tpublic readonly field: string;\n\n\tconstructor(field: string, reason: string) {\n\t\tsuper(`Validation failed for '${field}': ${reason}`, ERROR_CODES.VALIDATION_ERROR);\n\t\tthis.name = 'ValidationError';\n\t\tthis.field = field;\n\t}\n}\n\n/**\n * Error thrown when an invalid edge operation is attempted.\n *\n * This error is thrown when attempting to add an edge that violates\n * structural invariants of the thought DAG, such as a self-edge\n * (where `from` and `to` reference the same thought).\n *\n * @example\n * ```typescript\n * if (edge.from === edge.to) {\n * throw new InvalidEdgeError(\n * `Self-edge not allowed: from and to are the same (${edge.from})`\n * );\n * }\n * ```\n */\nexport class InvalidEdgeError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidEdgeError.\n\t *\n\t * @param message - Human-readable explanation of the invalid edge\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidEdgeError('Self-edge not allowed: from and to are the same (t1)');\n\t * // Code: INVALID_EDGE\n\t * ```\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_EDGE);\n\t\tthis.name = 'InvalidEdgeError';\n\t}\n}\n\n/**\n * Error thrown when a cycle is detected during graph traversal.\n *\n * This error is thrown by graph algorithms (such as topological sort)\n * when the thought DAG contains a cycle, violating the acyclic invariant.\n *\n * @example\n * ```typescript\n * try {\n * const order = graphView.topological(sessionId);\n * } catch (error) {\n * if (error instanceof CycleDetectedError) {\n * console.error('Cycle in thought graph:', error.message);\n * }\n * }\n * ```\n */\nexport class CycleDetectedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new CycleDetectedError.\n\t *\n\t * @param message - Human-readable explanation of the cycle\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new CycleDetectedError('Cycle detected in session s1');\n\t * // Code: CYCLE_DETECTED\n\t * ```\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.CYCLE_DETECTED);\n\t\tthis.name = 'CycleDetectedError';\n\t}\n}\n\n/**\n * Error thrown when a suspension record is not found.\n *\n * This error is thrown when attempting to resume a tool interleave\n * suspension that does not exist in the suspension store.\n */\nexport class SuspensionNotFoundError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.SUSPENSION_NOT_FOUND);\n\t\tthis.name = 'SuspensionNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when a suspension record has expired.\n *\n * This error is thrown when attempting to resume a tool interleave\n * suspension whose TTL has elapsed.\n */\nexport class SuspensionExpiredError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.SUSPENSION_EXPIRED);\n\t\tthis.name = 'SuspensionExpiredError';\n\t}\n}\n\n/**\n * Error thrown when a tool call payload is invalid.\n *\n * This error is thrown when a tool interleave invocation has malformed\n * arguments, missing identifiers, or otherwise fails validation.\n */\nexport class InvalidToolCallError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_TOOL_CALL);\n\t\tthis.name = 'InvalidToolCallError';\n\t}\n}\n\n/**\n * Error thrown when a backtrack operation is invalid.\n *\n * This error is thrown when an attempt to backtrack the reasoning\n * chain references an unreachable thought or violates DAG invariants.\n */\nexport class InvalidBacktrackError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, ERROR_CODES.INVALID_BACKTRACK);\n\t\tthis.name = 'InvalidBacktrackError';\n\t}\n}\n\n/**\n * Error thrown when a tool_call references a tool not registered with the server.\n *\n * Acts as an allowlist gate: only tools registered in the ToolRegistry may be\n * invoked through tool interleave. Prevents arbitrary tool name injection.\n */\nexport class UnknownToolError extends SequentialThinkingError {\n\tpublic readonly toolName: string;\n\n\tconstructor(toolName: string, message?: string) {\n\t\tsuper(\n\t\t\tmessage ?? `Unknown tool '${toolName}': not registered with the server`,\n\t\t\tERROR_CODES.UNKNOWN_TOOL\n\t\t);\n\t\tthis.name = 'UnknownToolError';\n\t\tthis.toolName = toolName;\n\t}\n}\n\n/** Error thrown when the CLI's complete shutdown exceeds its outer deadline. */\nexport class CliShutdownTimeoutError extends SequentialThinkingError {\n\tpublic readonly timeoutMs: number;\n\n\tconstructor(timeoutMs: number) {\n\t\tsuper(`CLI shutdown timed out after ${timeoutMs}ms`, ERROR_CODES.CLI_SHUTDOWN_TIMEOUT);\n\t\tthis.name = 'CliShutdownTimeoutError';\n\t\tthis.timeoutMs = timeoutMs;\n\t}\n}\n\nexport class PersistenceOwnershipError extends SequentialThinkingError {\n\tpublic readonly canonicalDataDir: string;\n\tpublic readonly lockPath: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(canonicalDataDir: string, lockPath: string, cause: unknown) {\n\t\tsuper(\n\t\t\t`Persistence directory '${canonicalDataDir}' already has an active writer`,\n\t\t\tERROR_CODES.PERSISTENCE_OWNERSHIP\n\t\t);\n\t\tthis.name = 'PersistenceOwnershipError';\n\t\tthis.canonicalDataDir = canonicalDataDir;\n\t\tthis.lockPath = lockPath;\n\t\tthis.cause = cause;\n\t}\n}\n\nexport class PersistenceCorruptionError extends SequentialThinkingError {\n\tpublic readonly path: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(path: string, cause: unknown) {\n\t\tsuper(\n\t\t\t`Persisted data at '${path}' is corrupt or incompatible`,\n\t\t\tERROR_CODES.PERSISTENCE_CORRUPTION\n\t\t);\n\t\tthis.name = 'PersistenceCorruptionError';\n\t\tthis.path = path;\n\t\tthis.cause = cause;\n\t}\n}\n\n/** Error raised when startup cannot read from an unhealthy persistence backend. */\nexport class PersistenceUnavailableError extends SequentialThinkingError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'Persistence backend is unavailable during startup restore',\n\t\t\tERROR_CODES.PERSISTENCE_UNAVAILABLE\n\t\t);\n\t\tthis.name = 'PersistenceUnavailableError';\n\t}\n}\n\nexport type PersistencePublicationStage = 'temporary-write' | 'atomic-replacement' | 'cleanup';\n\nexport class PersistencePublicationError extends SequentialThinkingError {\n\tpublic readonly path: string;\n\tpublic readonly stage: PersistencePublicationStage;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(path: string, stage: PersistencePublicationStage, cause: unknown) {\n\t\tsuper(\n\t\t\t`Failed persistence publication for '${path}' during ${stage}`,\n\t\t\tERROR_CODES.PERSISTENCE_PUBLICATION\n\t\t);\n\t\tthis.name = 'PersistencePublicationError';\n\t\tthis.path = path;\n\t\tthis.stage = stage;\n\t\tthis.cause = cause;\n\t}\n}\n\nexport class PersistenceClosedError extends SequentialThinkingError {\n\tpublic readonly dataDir: string;\n\n\tconstructor(dataDir: string) {\n\t\tsuper(`Persistence writer for '${dataDir}' is closed`, ERROR_CODES.PERSISTENCE_CLOSED);\n\t\tthis.name = 'PersistenceClosedError';\n\t\tthis.dataDir = dataDir;\n\t}\n}\n\n/** Error raised for well-formed but unsupported or drifted persisted data. */\nexport class PersistenceCompatibilityError extends SequentialThinkingError {\n\tpublic readonly sourcePath: string;\n\tpublic readonly detail: string;\n\tpublic override readonly cause: unknown;\n\n\tconstructor(sourcePath: string, detail: string, cause?: unknown) {\n\t\tsuper(\n\t\t\t`Persisted data at '${sourcePath}' is incompatible: ${detail}`,\n\t\t\tERROR_CODES.PERSISTENCE_COMPATIBILITY\n\t\t);\n\t\tthis.name = 'PersistenceCompatibilityError';\n\t\tthis.sourcePath = sourcePath;\n\t\tthis.detail = detail;\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Type guard to check if an error has a specific error code.\n */\nexport function isErrorCode<C extends ErrorCode>(\n\terr: unknown,\n\tcode: C\n): err is SequentialThinkingError & { readonly code: C } {\n\treturn err instanceof SequentialThinkingError && err.code === code;\n}\n\n/**\n * Extract a human-readable message from an unknown error value.\n *\n * Standardizes the common `error instanceof Error ? error.message : String(error)`\n * pattern used in catch blocks across the codebase.\n *\n * @param error - The unknown error value to extract a message from\n * @returns The error message string\n *\n * @example\n * ```typescript\n * try {\n * await doSomething();\n * } catch (error) {\n * logger.error('Failed', { error: getErrorMessage(error) });\n * }\n * ```\n */\nexport function getErrorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"],"names":["ERROR_CODES","WARNING_CODES","SequentialThinkingError","Error","message","code","ConfigurationError","ToolNotFoundError","toolName","action","SkillNotFoundError","skillName","InvalidThoughtError","thoughtNumber","reason","SkillDiscoveryError","directory","cause","HistoryLimitExceededError","currentSize","maxSize","DuplicateSkillError","InvalidSkillError","DuplicateToolError","InvalidToolError","MaxSessionsReachedError","maxSessions","PoolTerminatedError","ValidationError","field","InvalidEdgeError","CycleDetectedError","SuspensionNotFoundError","SuspensionExpiredError","InvalidToolCallError","InvalidBacktrackError","UnknownToolError","CliShutdownTimeoutError","timeoutMs","PersistenceOwnershipError","canonicalDataDir","lockPath","PersistenceCorruptionError","path","PersistenceUnavailableError","PersistencePublicationError","stage","PersistenceClosedError","dataDir","PersistenceCompatibilityError","sourcePath","detail","isErrorCode","err","getErrorMessage","error","String"],"mappings":"AA+BO,MAAMA,cAAc;IAC1B,qBAAqB;IACrB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,wBAAwB;IACxB,wBAAwB;IACxB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;IACtB,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IACd,gBAAgB;IAChB,sBAAsB;IACtB,oBAAoB;IACpB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,cAAc;IACd,cAAc;IACd,sBAAsB;IACtB,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,yBAAyB;IACzB,oBAAoB;IACpB,mBAAmB;IACnB,sCAAsC;IACtC,wCAAwC;IACxC,4BAA4B;IAC5B,yBA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B,KAAK,SAAS,EAAEG,OAAO,EAC9D9C,YAAY,uBAAuB;QAEpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,IAAI,GAAG2C;QACZ,IAAI,CAAC,KAAK,GAAGG;QACb,IAAI,CAAC,KAAK,GAAG7B;IACd;AACD;AAEO,MAAM8B,+BAA+B7C;IAC3B,QAAgB;IAEhC,YAAY8C,OAAe,CAAE;QAC5B,KAAK,CAAC,CAAC,wBAAwB,EAAEA,QAAQ,WAAW,CAAC,EAAEhD,YAAY,kBAAkB;QACrF,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,OAAO,GAAGgD;IAChB;AACD;AAGO,MAAMC,sCAAsC/C;IAClC,WAAmB;IACnB,OAAe;IACN,MAAe;IAExC,YAAYgD,UAAkB,EAAEC,MAAc,EAAElC,KAAe,CAAE;QAChE,KAAK,CACJ,CAAC,mBAAmB,EAAEiC,WAAW,mBAAmB,EAAEC,QAAQ,EAC9DnD,YAAY,yBAAyB;QAEtC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,UAAU,GAAGkD;QAClB,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,KAAK,GAAGlC;IACd;AACD;AAKO,SAASmC,YACfC,GAAY,EACZhD,IAAO;IAEP,OAAOgD,eAAenD,2BAA2BmD,IAAI,IAAI,KAAKhD;AAC/D;AAoBO,SAASiD,gBAAgBC,KAAc;IAC7C,OAAOA,iBAAiBpD,QAAQoD,MAAM,OAAO,GAAGC,OAAOD;AACxD"}
@@ -153,15 +153,15 @@ export declare const FileSnapshotV2Schema: v.StrictObjectSchema<{
153
153
  readonly quality_score: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Self-assessed quality score (0-1)">]>, undefined>;
154
154
  readonly confidence: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Explicit confidence in correctness (0-1)">]>, undefined>;
155
155
  readonly hypothesis_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Hypothesis ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 50, undefined>, v.DescriptionAction<string, "Identifier linking hypothesis to verification thoughts">]>, undefined>;
156
- readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Thought number being verified or critiqued">]>, undefined>;
156
+ readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Uniquely retained thought number being verified or critiqued; ambiguous numeric targets fail even though branch/revision number reuse is legal">]>, undefined>;
157
157
  readonly verification_result: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.LiteralSchema<0, undefined>, v.LiteralSchema<1, undefined>], undefined>, v.DescriptionAction<0 | 1, "Exact verification outcome label: 0 for incorrect, 1 for correct">]>, undefined>;
158
158
  readonly synthesis_sources: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers being synthesized">]>, undefined>;
159
159
  readonly merge_from_thoughts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers from other branches being merged (DAG)">]>, undefined>;
160
160
  readonly merge_branch_ids: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.MaxLengthAction<string, 50, undefined>]>, undefined>, v.DescriptionAction<string[], "Branch IDs being merged into current context">]>, undefined>;
161
161
  readonly meta_observation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Metacognitive observation about reasoning process">]>, undefined>;
162
162
  readonly reasoning_depth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["shallow", "moderate", "deep"], undefined>, v.DescriptionAction<"shallow" | "moderate" | "deep", "Effort signal: how deep reasoning should go">]>, undefined>;
163
- readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required session identifier for state isolation. Thought history, branches, and statistics are scoped to this explicit named session.">]>;
164
- readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "When true, clears all state for the target session before processing this thought. The thought is then processed as the first in a fresh session.">]>, undefined>;
163
+ readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required named session for state isolation. SESSION_EXPIRED after runtime eviction requires an authorized reset_state fresh chain or a new session_id; ordinary continuation cannot recreate it.">]>;
164
+ readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Authorized fresh-chain replacement, deleting target-session durable data and preserving its former owner. Recovers SESSION_EXPIRED only on successful reset; invalid or failed reset does not reopen it.">]>, undefined>;
165
165
  readonly tool_name: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "Name of the tool being invoked (for tool_call thoughts)">]>, undefined>;
166
166
  readonly tool_arguments: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
167
167
  [x: string]: unknown;
@@ -323,15 +323,15 @@ export declare const FileSnapshotV2Schema: v.StrictObjectSchema<{
323
323
  readonly quality_score: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Self-assessed quality score (0-1)">]>, undefined>;
324
324
  readonly confidence: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Explicit confidence in correctness (0-1)">]>, undefined>;
325
325
  readonly hypothesis_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Hypothesis ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 50, undefined>, v.DescriptionAction<string, "Identifier linking hypothesis to verification thoughts">]>, undefined>;
326
- readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Thought number being verified or critiqued">]>, undefined>;
326
+ readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Uniquely retained thought number being verified or critiqued; ambiguous numeric targets fail even though branch/revision number reuse is legal">]>, undefined>;
327
327
  readonly verification_result: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.LiteralSchema<0, undefined>, v.LiteralSchema<1, undefined>], undefined>, v.DescriptionAction<0 | 1, "Exact verification outcome label: 0 for incorrect, 1 for correct">]>, undefined>;
328
328
  readonly synthesis_sources: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers being synthesized">]>, undefined>;
329
329
  readonly merge_from_thoughts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers from other branches being merged (DAG)">]>, undefined>;
330
330
  readonly merge_branch_ids: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.MaxLengthAction<string, 50, undefined>]>, undefined>, v.DescriptionAction<string[], "Branch IDs being merged into current context">]>, undefined>;
331
331
  readonly meta_observation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Metacognitive observation about reasoning process">]>, undefined>;
332
332
  readonly reasoning_depth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["shallow", "moderate", "deep"], undefined>, v.DescriptionAction<"shallow" | "moderate" | "deep", "Effort signal: how deep reasoning should go">]>, undefined>;
333
- readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required session identifier for state isolation. Thought history, branches, and statistics are scoped to this explicit named session.">]>;
334
- readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "When true, clears all state for the target session before processing this thought. The thought is then processed as the first in a fresh session.">]>, undefined>;
333
+ readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required named session for state isolation. SESSION_EXPIRED after runtime eviction requires an authorized reset_state fresh chain or a new session_id; ordinary continuation cannot recreate it.">]>;
334
+ readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Authorized fresh-chain replacement, deleting target-session durable data and preserving its former owner. Recovers SESSION_EXPIRED only on successful reset; invalid or failed reset does not reopen it.">]>, undefined>;
335
335
  readonly tool_name: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "Name of the tool being invoked (for tool_call thoughts)">]>, undefined>;
336
336
  readonly tool_arguments: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
337
337
  [x: string]: unknown;
package/dist/schema.d.ts CHANGED
@@ -473,15 +473,15 @@ export declare const SequentialThinkingSchema: v.ObjectSchema<{
473
473
  readonly quality_score: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Self-assessed quality score (0-1)">]>, undefined>;
474
474
  readonly confidence: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "Explicit confidence in correctness (0-1)">]>, undefined>;
475
475
  readonly hypothesis_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Hypothesis ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 50, undefined>, v.DescriptionAction<string, "Identifier linking hypothesis to verification thoughts">]>, undefined>;
476
- readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Thought number being verified or critiqued">]>, undefined>;
476
+ readonly verification_target: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Uniquely retained thought number being verified or critiqued; ambiguous numeric targets fail even though branch/revision number reuse is legal">]>, undefined>;
477
477
  readonly verification_result: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.LiteralSchema<0, undefined>, v.LiteralSchema<1, undefined>], undefined>, v.DescriptionAction<0 | 1, "Exact verification outcome label: 0 for incorrect, 1 for correct">]>, undefined>;
478
478
  readonly synthesis_sources: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers being synthesized">]>, undefined>;
479
479
  readonly merge_from_thoughts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>, v.DescriptionAction<number[], "Thought numbers from other branches being merged (DAG)">]>, undefined>;
480
480
  readonly merge_branch_ids: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.MaxLengthAction<string, 50, undefined>]>, undefined>, v.DescriptionAction<string[], "Branch IDs being merged into current context">]>, undefined>;
481
481
  readonly meta_observation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Metacognitive observation about reasoning process">]>, undefined>;
482
482
  readonly reasoning_depth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["shallow", "moderate", "deep"], undefined>, v.DescriptionAction<"shallow" | "moderate" | "deep", "Effort signal: how deep reasoning should go">]>, undefined>;
483
- readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required session identifier for state isolation. Thought history, branches, and statistics are scoped to this explicit named session.">]>;
484
- readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "When true, clears all state for the target session before processing this thought. The thought is then processed as the first in a fresh session.">]>, undefined>;
483
+ readonly session_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Session ID must contain only letters, numbers, hyphens, and underscores">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>, v.NotValueAction<string, "__global__", "Session ID '__global__' is retired; use an explicit named session">, v.DescriptionAction<string, "Required named session for state isolation. SESSION_EXPIRED after runtime eviction requires an authorized reset_state fresh chain or a new session_id; ordinary continuation cannot recreate it.">]>;
484
+ readonly reset_state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Authorized fresh-chain replacement, deleting target-session durable data and preserving its former owner. Recovers SESSION_EXPIRED only on successful reset; invalid or failed reset does not reopen it.">]>, undefined>;
485
485
  readonly tool_name: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "Name of the tool being invoked (for tool_call thoughts)">]>, undefined>;
486
486
  readonly tool_arguments: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
487
487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;;;;;;;;;;;;;;;;;;;;;;;;;;;aAgPnC,CAAC;AAEH,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAItC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB;;;;;;;aAmB/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,kWASW,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;aAetB,CAAC"}
package/dist/schema.js CHANGED
@@ -66,7 +66,7 @@ Reasoning Enhancement Parameters:
66
66
  - quality_score: Self-assessed quality of this thought (0-1)
67
67
  - confidence: Confidence in this thought's correctness (0-1)
68
68
  - hypothesis_id: Links hypothesis to verification (alphanumeric, hyphens, underscores)
69
- - verification_target: For 'verification'/'critique' types, the thought_number being evaluated
69
+ - verification_target: For 'verification'/'critique', the thought_number of a uniquely retained identity. Branch/revision number reuse is legal, but ambiguous numeric targets fail. Result-bearing verification requires a non-retracted target with confidence.
70
70
  - verification_result: Optional exact outcome label (0 = incorrect, 1 = correct) for a verification_target; only has outcome semantics on thought_type='verification'
71
71
  - synthesis_sources: For 'synthesis' type, the thought_numbers being combined
72
72
  - merge_from_thoughts: Thought numbers from other branches merged (graph reasoning)
@@ -74,14 +74,16 @@ Reasoning Enhancement Parameters:
74
74
  - meta_observation: Observation about reasoning process (with thought_type 'meta')
75
75
  - reasoning_depth: How deep to reason: 'shallow' (quick), 'moderate' (default), 'deep' (thorough)
76
76
  - session_id: Required unique identifier that scopes thought history, branches, and statistics to an explicit session. Format: alphanumeric, hyphens, underscores, 1-100 chars; the retired value __global__ is rejected.
77
- - reset_state: (Optional) When true, clears all state for the required session_id before processing the current thought. Use this to start a fresh reasoning chain without accumulated state from previous chains.
77
+ - reset_state: (Optional) Authorized fresh-chain replacement for session_id, deleting its durable data and preserving its former owner. SESSION_EXPIRED requires this explicit recovery or a new session_id; invalid or failed reset does not reopen the expired scope.
78
78
 
79
79
  Response Enrichment:
80
80
  - When reasoning fields are set, response includes confidence_signals (depth, revision/branch count, type distribution, avg confidence, structural_quality, quality_components) and reasoning_stats (hypothesis tracking)
81
81
  - confidence_signals.structural_quality: Composite 0-1 score — weighted geometric mean of type_diversity (0.3), verification_coverage (0.3), depth_efficiency (0.2), confidence_stability (0.2). Weights: type_diversity=0.3, verification_coverage=0.3, depth_efficiency=0.2, confidence_stability=0.2 (weighted geometric mean). All components floored at 0.01 to prevent collapse.
82
82
  - confidence_signals.quality_components: Individual metrics — type_diversity (Shannon entropy/log₂(6)), verification_coverage (verified/total hypotheses, 1.0 if none), depth_efficiency (max(chain_depth, branch_count+1)/total, branching rewarded), confidence_stability (1 - stddev(confidence), default 0.5, null when fewer than 2 confidence values)
83
- - reasoning_hints: (Conditional) Array of actionable hint strings from cross-thought pattern analysis. Only warning-severity patterns produce hints. Max 3 hints per response, with 3-thought cooldown per pattern per session. Hints are prioritized: confidence_drift > unverified_hypothesis > no_alternatives_explored > consecutive_without_verification, so the most actionable patterns fill the cap first. Present only when warnings are detected.
84
- - Detected patterns (internal, not in response): consecutive_without_verification (3+ regular thoughts without verification), unverified_hypothesis (hypothesis without verification within 3 thoughts after it), no_alternatives_explored (5+ thoughts with no critique/branches), monotonic_type (5+ consecutive same type), confidence_drift (3+ consecutive decreasing confidence), healthy_verification (hypothesis verified within 3 thoughts — info only)
83
+ - confidence_signals.graph_signals: Present when the active thought graph has at least one edge: node/edge/root/leaf/component counts, longest_path (null on cycle), max in/out degree, edge_kind_counts, branching_factor, relational_density.
84
+ - graph_context: Current thought's root_distance, ancestor_count, inbound/outbound neighbours (thought_number + edge kind + optional branch_id). Omitted when the thought has no edges.
85
+ - reasoning_hints: (Conditional) Array of actionable hint strings from cross-thought pattern analysis. Only warning-severity patterns produce hints. Max 3 hints per response, with 3-thought cooldown per pattern per session. Hints are prioritized: refuted_hypothesis_dependency > confidence_drift > unverified_hypothesis > unaddressed_critique > no_alternatives_explored > consecutive_without_verification, so the most actionable patterns fill the cap first. Present only when warnings are detected.
86
+ - Detected patterns (internal, not in response): consecutive_without_verification (3+ regular thoughts without verification), unverified_hypothesis (hypothesis without verification within 3 thoughts after it), no_alternatives_explored (5+ thoughts with no critique/branches), monotonic_type (5+ consecutive same type), confidence_drift (3+ consecutive decreasing confidence), healthy_verification (hypothesis verified within 3 thoughts — info only), refuted_hypothesis_dependency (thoughts deriving/merging/branching from a hypothesis whose latest verification_result is 0, not revised/backtracked), unaddressed_critique (critiqued thought not revised or later verified within 3 thoughts)
85
87
  You should:
86
88
  1. Start with an initial estimate of needed thoughts, but be ready to adjust
87
89
  2. Feel free to question or revise previous thoughts
@@ -187,7 +189,7 @@ const SequentialThinkingSchema = __rspack_external_valibot.object({
187
189
  quality_score: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.number(), __rspack_external_valibot.minValue(0), __rspack_external_valibot.maxValue(1), __rspack_external_valibot.description('Self-assessed quality score (0-1)'))),
188
190
  confidence: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.number(), __rspack_external_valibot.minValue(0), __rspack_external_valibot.maxValue(1), __rspack_external_valibot.description('Explicit confidence in correctness (0-1)'))),
189
191
  hypothesis_id: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.string(), __rspack_external_valibot.regex(/^[a-zA-Z0-9_-]+$/, 'Hypothesis ID must contain only letters, numbers, hyphens, and underscores'), __rspack_external_valibot.minLength(1), __rspack_external_valibot.maxLength(50), __rspack_external_valibot.description('Identifier linking hypothesis to verification thoughts'))),
190
- verification_target: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.number(), __rspack_external_valibot.minValue(1), __rspack_external_valibot.description('Thought number being verified or critiqued'))),
192
+ verification_target: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.number(), __rspack_external_valibot.minValue(1), __rspack_external_valibot.description('Uniquely retained thought number being verified or critiqued; ambiguous numeric targets fail even though branch/revision number reuse is legal'))),
191
193
  verification_result: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.union([
192
194
  __rspack_external_valibot.literal(0),
193
195
  __rspack_external_valibot.literal(1)
@@ -201,8 +203,8 @@ const SequentialThinkingSchema = __rspack_external_valibot.object({
201
203
  'moderate',
202
204
  'deep'
203
205
  ]), __rspack_external_valibot.description('Effort signal: how deep reasoning should go'))),
204
- session_id: __rspack_external_valibot.pipe(__rspack_external_valibot.string(), __rspack_external_valibot.regex(/^[a-zA-Z0-9_-]+$/, 'Session ID must contain only letters, numbers, hyphens, and underscores'), __rspack_external_valibot.minLength(1), __rspack_external_valibot.maxLength(100), __rspack_external_valibot.notValue('__global__', "Session ID '__global__' is retired; use an explicit named session"), __rspack_external_valibot.description('Required session identifier for state isolation. Thought history, branches, and statistics are scoped to this explicit named session.')),
205
- reset_state: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.boolean(), __rspack_external_valibot.description('When true, clears all state for the target session before processing this thought. The thought is then processed as the first in a fresh session.'))),
206
+ session_id: __rspack_external_valibot.pipe(__rspack_external_valibot.string(), __rspack_external_valibot.regex(/^[a-zA-Z0-9_-]+$/, 'Session ID must contain only letters, numbers, hyphens, and underscores'), __rspack_external_valibot.minLength(1), __rspack_external_valibot.maxLength(100), __rspack_external_valibot.notValue('__global__', "Session ID '__global__' is retired; use an explicit named session"), __rspack_external_valibot.description('Required named session for state isolation. SESSION_EXPIRED after runtime eviction requires an authorized reset_state fresh chain or a new session_id; ordinary continuation cannot recreate it.')),
207
+ reset_state: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.boolean(), __rspack_external_valibot.description('Authorized fresh-chain replacement, deleting target-session durable data and preserving its former owner. Recovers SESSION_EXPIRED only on successful reset; invalid or failed reset does not reopen it.'))),
206
208
  tool_name: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.string(), __rspack_external_valibot.minLength(1), __rspack_external_valibot.description('Name of the tool being invoked (for tool_call thoughts)'))),
207
209
  tool_arguments: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.record(__rspack_external_valibot.string(), __rspack_external_valibot.unknown()), __rspack_external_valibot.description('Arguments passed to the tool (for tool_call thoughts)'))),
208
210
  tool_result: __rspack_external_valibot.optional(__rspack_external_valibot.pipe(__rspack_external_valibot.unknown(), __rspack_external_valibot.description('Result returned by the tool (for tool_observation thoughts)'))),