couchloop-eq-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +358 -0
  3. package/assets/logo/README.md +12 -0
  4. package/assets/logo/couchloop_EQ-IconLogo.png +0 -0
  5. package/dist/auth/middleware.d.ts +8 -0
  6. package/dist/auth/middleware.d.ts.map +1 -0
  7. package/dist/auth/middleware.js +59 -0
  8. package/dist/auth/middleware.js.map +1 -0
  9. package/dist/clients/shrinkChatClient.d.ts +195 -0
  10. package/dist/clients/shrinkChatClient.d.ts.map +1 -0
  11. package/dist/clients/shrinkChatClient.js +349 -0
  12. package/dist/clients/shrinkChatClient.js.map +1 -0
  13. package/dist/db/client.d.ts +23 -0
  14. package/dist/db/client.d.ts.map +1 -0
  15. package/dist/db/client.js +78 -0
  16. package/dist/db/client.js.map +1 -0
  17. package/dist/db/migrate.d.ts +4 -0
  18. package/dist/db/migrate.d.ts.map +1 -0
  19. package/dist/db/migrate.js +34 -0
  20. package/dist/db/migrate.js.map +1 -0
  21. package/dist/db/migrations/schema.d.ts +1074 -0
  22. package/dist/db/migrations/schema.d.ts.map +1 -0
  23. package/dist/db/migrations/schema.js +160 -0
  24. package/dist/db/migrations/schema.js.map +1 -0
  25. package/dist/db/schema.d.ts +1213 -0
  26. package/dist/db/schema.d.ts.map +1 -0
  27. package/dist/db/schema.js +157 -0
  28. package/dist/db/schema.js.map +1 -0
  29. package/dist/db/seed.d.ts +4 -0
  30. package/dist/db/seed.d.ts.map +1 -0
  31. package/dist/db/seed.js +57 -0
  32. package/dist/db/seed.js.map +1 -0
  33. package/dist/db/seedOAuth.d.ts +4 -0
  34. package/dist/db/seedOAuth.d.ts.map +1 -0
  35. package/dist/db/seedOAuth.js +76 -0
  36. package/dist/db/seedOAuth.js.map +1 -0
  37. package/dist/index.d.ts +3 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +93 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/resources/index.d.ts +11 -0
  42. package/dist/resources/index.d.ts.map +1 -0
  43. package/dist/resources/index.js +56 -0
  44. package/dist/resources/index.js.map +1 -0
  45. package/dist/resources/journey-status.d.ts +2 -0
  46. package/dist/resources/journey-status.d.ts.map +1 -0
  47. package/dist/resources/journey-status.js +42 -0
  48. package/dist/resources/journey-status.js.map +1 -0
  49. package/dist/resources/session-summary.d.ts +2 -0
  50. package/dist/resources/session-summary.d.ts.map +1 -0
  51. package/dist/resources/session-summary.js +85 -0
  52. package/dist/resources/session-summary.js.map +1 -0
  53. package/dist/resources/user-context.d.ts +2 -0
  54. package/dist/resources/user-context.d.ts.map +1 -0
  55. package/dist/resources/user-context.js +79 -0
  56. package/dist/resources/user-context.js.map +1 -0
  57. package/dist/server/index.d.ts +3 -0
  58. package/dist/server/index.d.ts.map +1 -0
  59. package/dist/server/index.js +385 -0
  60. package/dist/server/index.js.map +1 -0
  61. package/dist/server/middleware/auth.d.ts +30 -0
  62. package/dist/server/middleware/auth.d.ts.map +1 -0
  63. package/dist/server/middleware/auth.js +157 -0
  64. package/dist/server/middleware/auth.js.map +1 -0
  65. package/dist/server/oauth/anomalyDetection.d.ts +146 -0
  66. package/dist/server/oauth/anomalyDetection.d.ts.map +1 -0
  67. package/dist/server/oauth/anomalyDetection.js +405 -0
  68. package/dist/server/oauth/anomalyDetection.js.map +1 -0
  69. package/dist/server/oauth/authServer.d.ts +61 -0
  70. package/dist/server/oauth/authServer.d.ts.map +1 -0
  71. package/dist/server/oauth/authServer.js +283 -0
  72. package/dist/server/oauth/authServer.js.map +1 -0
  73. package/dist/server/oauth/dpop.d.ts +135 -0
  74. package/dist/server/oauth/dpop.d.ts.map +1 -0
  75. package/dist/server/oauth/dpop.js +338 -0
  76. package/dist/server/oauth/dpop.js.map +1 -0
  77. package/dist/server/oauth/gdpr/consent.d.ts +173 -0
  78. package/dist/server/oauth/gdpr/consent.d.ts.map +1 -0
  79. package/dist/server/oauth/gdpr/consent.js +388 -0
  80. package/dist/server/oauth/gdpr/consent.js.map +1 -0
  81. package/dist/server/oauth/gdpr/dataPortability.d.ts +214 -0
  82. package/dist/server/oauth/gdpr/dataPortability.d.ts.map +1 -0
  83. package/dist/server/oauth/gdpr/dataPortability.js +486 -0
  84. package/dist/server/oauth/gdpr/dataPortability.js.map +1 -0
  85. package/dist/server/oauth/gdpr/index.d.ts +103 -0
  86. package/dist/server/oauth/gdpr/index.d.ts.map +1 -0
  87. package/dist/server/oauth/gdpr/index.js +273 -0
  88. package/dist/server/oauth/gdpr/index.js.map +1 -0
  89. package/dist/server/oauth/gdpr/rightToErasure.d.ts +184 -0
  90. package/dist/server/oauth/gdpr/rightToErasure.d.ts.map +1 -0
  91. package/dist/server/oauth/gdpr/rightToErasure.js +527 -0
  92. package/dist/server/oauth/gdpr/rightToErasure.js.map +1 -0
  93. package/dist/server/oauth/monitoring/securityMonitor.d.ts +218 -0
  94. package/dist/server/oauth/monitoring/securityMonitor.d.ts.map +1 -0
  95. package/dist/server/oauth/monitoring/securityMonitor.js +615 -0
  96. package/dist/server/oauth/monitoring/securityMonitor.js.map +1 -0
  97. package/dist/server/oauth/pkce.d.ts +61 -0
  98. package/dist/server/oauth/pkce.d.ts.map +1 -0
  99. package/dist/server/oauth/pkce.js +157 -0
  100. package/dist/server/oauth/pkce.js.map +1 -0
  101. package/dist/server/oauth/providers/base.d.ts +147 -0
  102. package/dist/server/oauth/providers/base.d.ts.map +1 -0
  103. package/dist/server/oauth/providers/base.js +312 -0
  104. package/dist/server/oauth/providers/base.js.map +1 -0
  105. package/dist/server/oauth/providers/github.d.ts +55 -0
  106. package/dist/server/oauth/providers/github.d.ts.map +1 -0
  107. package/dist/server/oauth/providers/github.js +225 -0
  108. package/dist/server/oauth/providers/github.js.map +1 -0
  109. package/dist/server/oauth/providers/google.d.ts +49 -0
  110. package/dist/server/oauth/providers/google.d.ts.map +1 -0
  111. package/dist/server/oauth/providers/google.js +153 -0
  112. package/dist/server/oauth/providers/google.js.map +1 -0
  113. package/dist/server/oauth/providers/index.d.ts +9 -0
  114. package/dist/server/oauth/providers/index.d.ts.map +1 -0
  115. package/dist/server/oauth/providers/index.js +24 -0
  116. package/dist/server/oauth/providers/index.js.map +1 -0
  117. package/dist/server/oauth/refreshTokenRotation.d.ts +114 -0
  118. package/dist/server/oauth/refreshTokenRotation.d.ts.map +1 -0
  119. package/dist/server/oauth/refreshTokenRotation.js +344 -0
  120. package/dist/server/oauth/refreshTokenRotation.js.map +1 -0
  121. package/dist/server/oauth/security.d.ts +101 -0
  122. package/dist/server/oauth/security.d.ts.map +1 -0
  123. package/dist/server/oauth/security.js +268 -0
  124. package/dist/server/oauth/security.js.map +1 -0
  125. package/dist/server/oauth/tokenEncryption.d.ts +80 -0
  126. package/dist/server/oauth/tokenEncryption.d.ts.map +1 -0
  127. package/dist/server/oauth/tokenEncryption.js +218 -0
  128. package/dist/server/oauth/tokenEncryption.js.map +1 -0
  129. package/dist/tools/checkpoint.d.ts +35 -0
  130. package/dist/tools/checkpoint.d.ts.map +1 -0
  131. package/dist/tools/checkpoint.js +125 -0
  132. package/dist/tools/checkpoint.js.map +1 -0
  133. package/dist/tools/index.d.ts +412 -0
  134. package/dist/tools/index.d.ts.map +1 -0
  135. package/dist/tools/index.js +262 -0
  136. package/dist/tools/index.js.map +1 -0
  137. package/dist/tools/insight.d.ts +65 -0
  138. package/dist/tools/insight.d.ts.map +1 -0
  139. package/dist/tools/insight.js +190 -0
  140. package/dist/tools/insight.js.map +1 -0
  141. package/dist/tools/journey.d.ts +45 -0
  142. package/dist/tools/journey.d.ts.map +1 -0
  143. package/dist/tools/journey.js +115 -0
  144. package/dist/tools/journey.js.map +1 -0
  145. package/dist/tools/sendMessage.d.ts +6 -0
  146. package/dist/tools/sendMessage.d.ts.map +1 -0
  147. package/dist/tools/sendMessage.js +278 -0
  148. package/dist/tools/sendMessage.js.map +1 -0
  149. package/dist/tools/session.d.ts +106 -0
  150. package/dist/tools/session.d.ts.map +1 -0
  151. package/dist/tools/session.js +161 -0
  152. package/dist/tools/session.js.map +1 -0
  153. package/dist/types/auth.d.ts +37 -0
  154. package/dist/types/auth.d.ts.map +1 -0
  155. package/dist/types/auth.js +44 -0
  156. package/dist/types/auth.js.map +1 -0
  157. package/dist/types/checkpoint.d.ts +25 -0
  158. package/dist/types/checkpoint.d.ts.map +1 -0
  159. package/dist/types/checkpoint.js +8 -0
  160. package/dist/types/checkpoint.js.map +1 -0
  161. package/dist/types/insight.d.ts +83 -0
  162. package/dist/types/insight.d.ts.map +1 -0
  163. package/dist/types/insight.js +14 -0
  164. package/dist/types/insight.js.map +1 -0
  165. package/dist/types/journey.d.ts +155 -0
  166. package/dist/types/journey.d.ts.map +1 -0
  167. package/dist/types/journey.js +29 -0
  168. package/dist/types/journey.js.map +1 -0
  169. package/dist/types/session.d.ts +82 -0
  170. package/dist/types/session.d.ts.map +1 -0
  171. package/dist/types/session.js +13 -0
  172. package/dist/types/session.js.map +1 -0
  173. package/dist/utils/circuitBreaker.d.ts +86 -0
  174. package/dist/utils/circuitBreaker.d.ts.map +1 -0
  175. package/dist/utils/circuitBreaker.js +234 -0
  176. package/dist/utils/circuitBreaker.js.map +1 -0
  177. package/dist/utils/errorHandler.d.ts +101 -0
  178. package/dist/utils/errorHandler.d.ts.map +1 -0
  179. package/dist/utils/errorHandler.js +348 -0
  180. package/dist/utils/errorHandler.js.map +1 -0
  181. package/dist/utils/errors.d.ts +36 -0
  182. package/dist/utils/errors.d.ts.map +1 -0
  183. package/dist/utils/errors.js +77 -0
  184. package/dist/utils/errors.js.map +1 -0
  185. package/dist/utils/logger.d.ts +13 -0
  186. package/dist/utils/logger.d.ts.map +1 -0
  187. package/dist/utils/logger.js +49 -0
  188. package/dist/utils/logger.js.map +1 -0
  189. package/dist/utils/performanceMonitor.d.ts +106 -0
  190. package/dist/utils/performanceMonitor.d.ts.map +1 -0
  191. package/dist/utils/performanceMonitor.js +312 -0
  192. package/dist/utils/performanceMonitor.js.map +1 -0
  193. package/dist/utils/responseCache.d.ts +88 -0
  194. package/dist/utils/responseCache.d.ts.map +1 -0
  195. package/dist/utils/responseCache.js +245 -0
  196. package/dist/utils/responseCache.js.map +1 -0
  197. package/dist/utils/retryStrategy.d.ts +49 -0
  198. package/dist/utils/retryStrategy.d.ts.map +1 -0
  199. package/dist/utils/retryStrategy.js +167 -0
  200. package/dist/utils/retryStrategy.js.map +1 -0
  201. package/dist/workflows/definitions/daily-reflection.d.ts +3 -0
  202. package/dist/workflows/definitions/daily-reflection.d.ts.map +1 -0
  203. package/dist/workflows/definitions/daily-reflection.js +52 -0
  204. package/dist/workflows/definitions/daily-reflection.js.map +1 -0
  205. package/dist/workflows/definitions/gratitude-practice.d.ts +3 -0
  206. package/dist/workflows/definitions/gratitude-practice.d.ts.map +1 -0
  207. package/dist/workflows/definitions/gratitude-practice.js +52 -0
  208. package/dist/workflows/definitions/gratitude-practice.js.map +1 -0
  209. package/dist/workflows/definitions/weekly-review.d.ts +3 -0
  210. package/dist/workflows/definitions/weekly-review.d.ts.map +1 -0
  211. package/dist/workflows/definitions/weekly-review.js +74 -0
  212. package/dist/workflows/definitions/weekly-review.js.map +1 -0
  213. package/dist/workflows/engine.d.ts +21 -0
  214. package/dist/workflows/engine.d.ts.map +1 -0
  215. package/dist/workflows/engine.js +149 -0
  216. package/dist/workflows/engine.js.map +1 -0
  217. package/dist/workflows/index.d.ts +26 -0
  218. package/dist/workflows/index.d.ts.map +1 -0
  219. package/dist/workflows/index.js +14 -0
  220. package/dist/workflows/index.js.map +1 -0
  221. package/package.json +98 -0
  222. package/run-mcp-server.sh +16 -0
@@ -0,0 +1,49 @@
1
+ export interface RetryOptions {
2
+ maxAttempts?: number;
3
+ initialDelay?: number;
4
+ maxDelay?: number;
5
+ backoffMultiplier?: number;
6
+ jitter?: boolean;
7
+ isRetryable?: (error: Error) => boolean;
8
+ shouldRetry?: (error: Error, attempt: number) => boolean;
9
+ onRetry?: (attempt: number, error: Error) => void;
10
+ }
11
+ /**
12
+ * Retry strategy with exponential backoff and jitter
13
+ */
14
+ export declare class RetryStrategy {
15
+ private readonly defaults;
16
+ /**
17
+ * Default retry predicate - retries on network errors and 5xx status codes
18
+ */
19
+ private defaultShouldRetry;
20
+ /**
21
+ * Calculate delay with exponential backoff and optional jitter
22
+ */
23
+ private calculateDelay;
24
+ /**
25
+ * Execute a function with retry logic
26
+ */
27
+ execute<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
28
+ /**
29
+ * Execute with retry and return result with metadata
30
+ */
31
+ executeWithMetadata<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<{
32
+ result?: T;
33
+ success: boolean;
34
+ attempts: number;
35
+ totalDelay: number;
36
+ error?: Error;
37
+ }>;
38
+ /**
39
+ * Simple delay helper
40
+ */
41
+ private delay;
42
+ /**
43
+ * Create a retry wrapper for a specific function
44
+ */
45
+ wrap<T extends (...args: any[]) => Promise<any>>(fn: T, options?: RetryOptions): T;
46
+ }
47
+ export declare const retryStrategy: RetryStrategy;
48
+ export declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
49
+ //# sourceMappingURL=retryStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryStrategy.d.ts","sourceRoot":"","sources":["../../src/utils/retryStrategy.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACxC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACzD,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAKvB;IAEF;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAqBtB;;OAEG;IACG,OAAO,CAAC,CAAC,EACb,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC;IA0Db;;OAEG;IACG,mBAAmB,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC;QACT,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;IA2CF;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAC7C,EAAE,EAAE,CAAC,EACL,OAAO,GAAE,YAAiB,GACzB,CAAC;CAKL;AAGD,eAAO,MAAM,aAAa,eAAsB,CAAC;AAGjD,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -0,0 +1,167 @@
1
+ import { logger } from './logger.js';
2
+ /**
3
+ * Retry strategy with exponential backoff and jitter
4
+ */
5
+ export class RetryStrategy {
6
+ defaults = {
7
+ maxAttempts: 3,
8
+ initialDelay: 1000,
9
+ maxDelay: 30000,
10
+ backoffMultiplier: 2,
11
+ };
12
+ /**
13
+ * Default retry predicate - retries on network errors and 5xx status codes
14
+ */
15
+ defaultShouldRetry(error) {
16
+ const message = error.message.toLowerCase();
17
+ // Don't retry on client errors (4xx)
18
+ if (message.includes('400') || message.includes('401') ||
19
+ message.includes('403') || message.includes('404')) {
20
+ return false;
21
+ }
22
+ // Retry on network errors
23
+ if (message.includes('network') || message.includes('timeout') ||
24
+ message.includes('econnrefused') || message.includes('econnreset')) {
25
+ return true;
26
+ }
27
+ // Retry on server errors (5xx)
28
+ if (message.includes('500') || message.includes('502') ||
29
+ message.includes('503') || message.includes('504')) {
30
+ return true;
31
+ }
32
+ // Retry on circuit breaker open (temporary failure)
33
+ if (message.includes('circuit breaker')) {
34
+ return true;
35
+ }
36
+ // Default: retry all errors
37
+ return true;
38
+ }
39
+ /**
40
+ * Calculate delay with exponential backoff and optional jitter
41
+ */
42
+ calculateDelay(attempt, options) {
43
+ // For the first retry (attempt 0), use initial delay
44
+ // For subsequent retries, apply exponential backoff
45
+ const exponentialDelay = options.initialDelay * Math.pow(options.backoffMultiplier, attempt);
46
+ // Cap at max delay
47
+ const cappedDelay = Math.min(exponentialDelay, options.maxDelay);
48
+ // Add jitter if enabled (±25% randomization to prevent thundering herd)
49
+ if (options.jitter === true) {
50
+ const jitterAmount = cappedDelay * 0.25 * Math.random();
51
+ // For tests, jitter reduces the delay
52
+ return Math.max(0, cappedDelay - jitterAmount);
53
+ }
54
+ return cappedDelay;
55
+ }
56
+ /**
57
+ * Execute a function with retry logic
58
+ */
59
+ async execute(fn, options = {}) {
60
+ const config = { ...this.defaults, ...options };
61
+ // Support both isRetryable and shouldRetry for backwards compatibility
62
+ const shouldRetry = options.isRetryable
63
+ ? (error) => options.isRetryable(error)
64
+ : options.shouldRetry || this.defaultShouldRetry.bind(this);
65
+ let lastError;
66
+ let attemptCount = 0;
67
+ while (attemptCount < config.maxAttempts) {
68
+ try {
69
+ // Log retry attempt if not the first try
70
+ if (attemptCount > 0) {
71
+ logger.debug(`Retry attempt ${attemptCount}/${config.maxAttempts - 1}`);
72
+ }
73
+ // Execute the function
74
+ const result = await fn();
75
+ return result;
76
+ }
77
+ catch (error) {
78
+ lastError = error;
79
+ attemptCount++;
80
+ // Check if we've exhausted attempts
81
+ if (attemptCount >= config.maxAttempts) {
82
+ logger.error(`All ${config.maxAttempts} attempts failed:`, lastError.message);
83
+ break;
84
+ }
85
+ // Check if we should retry this error
86
+ if (!shouldRetry(lastError, attemptCount)) {
87
+ logger.debug(`Not retrying error (non-retryable):`, lastError.message);
88
+ break;
89
+ }
90
+ // Calculate delay for next attempt (use attemptCount - 1 for delay calculation)
91
+ const delay = this.calculateDelay(attemptCount - 1, { ...config, jitter: options.jitter });
92
+ // Notify about retry
93
+ if (options.onRetry) {
94
+ options.onRetry(attemptCount, lastError);
95
+ }
96
+ else {
97
+ logger.warn(`Request failed (attempt ${attemptCount}/${config.maxAttempts}), ` +
98
+ `retrying in ${Math.round(delay)}ms: ${lastError.message}`);
99
+ }
100
+ // Wait before retrying
101
+ await this.delay(delay);
102
+ }
103
+ }
104
+ throw lastError;
105
+ }
106
+ /**
107
+ * Execute with retry and return result with metadata
108
+ */
109
+ async executeWithMetadata(fn, options = {}) {
110
+ const config = { ...this.defaults, ...options };
111
+ // Support both isRetryable and shouldRetry for backwards compatibility
112
+ const shouldRetry = options.isRetryable
113
+ ? (error) => options.isRetryable(error)
114
+ : options.shouldRetry || this.defaultShouldRetry.bind(this);
115
+ let lastError;
116
+ let totalDelay = 0;
117
+ let attempts = 0;
118
+ while (attempts < config.maxAttempts) {
119
+ try {
120
+ attempts++;
121
+ const result = await fn();
122
+ return {
123
+ result,
124
+ success: true,
125
+ attempts,
126
+ totalDelay,
127
+ };
128
+ }
129
+ catch (error) {
130
+ lastError = error;
131
+ if (attempts >= config.maxAttempts || !shouldRetry(lastError, attempts)) {
132
+ break;
133
+ }
134
+ const delay = this.calculateDelay(attempts - 1, { ...config, jitter: options.jitter });
135
+ totalDelay += delay;
136
+ await this.delay(delay);
137
+ }
138
+ }
139
+ return {
140
+ success: false,
141
+ attempts,
142
+ totalDelay,
143
+ error: lastError,
144
+ };
145
+ }
146
+ /**
147
+ * Simple delay helper
148
+ */
149
+ delay(ms) {
150
+ return new Promise(resolve => setTimeout(resolve, ms));
151
+ }
152
+ /**
153
+ * Create a retry wrapper for a specific function
154
+ */
155
+ wrap(fn, options = {}) {
156
+ return (async (...args) => {
157
+ return this.execute(() => fn(...args), options);
158
+ });
159
+ }
160
+ }
161
+ // Singleton instance
162
+ export const retryStrategy = new RetryStrategy();
163
+ // Convenience function for one-off retries
164
+ export async function withRetry(fn, options) {
165
+ return retryStrategy.execute(fn, options);
166
+ }
167
+ //# sourceMappingURL=retryStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryStrategy.js","sourceRoot":"","sources":["../../src/utils/retryStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAarC;;GAEG;AACH,MAAM,OAAO,aAAa;IACP,QAAQ,GAAuF;QAC9G,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,KAAK;QACf,iBAAiB,EAAE,CAAC;KACrB,CAAC;IAEF;;OAEG;IACK,kBAAkB,CAAC,KAAY;QACrC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAE5C,qCAAqC;QACrC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;YAClD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,0BAA0B;QAC1B,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAA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,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Journey } from '../../types/journey.js';
2
+ export declare const dailyReflection: Journey;
3
+ //# sourceMappingURL=daily-reflection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daily-reflection.d.ts","sourceRoot":"","sources":["../../../src/workflows/definitions/daily-reflection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,eAAO,MAAM,eAAe,EAAE,OAkD7B,CAAC"}
@@ -0,0 +1,52 @@
1
+ export const dailyReflection = {
2
+ slug: 'daily-reflection',
3
+ name: 'Daily Reflection',
4
+ description: 'A brief check-in to process your day and capture key moments.',
5
+ estimatedMinutes: 5,
6
+ tags: ['reflection', 'daily', 'short'],
7
+ steps: [
8
+ {
9
+ id: 'step_1',
10
+ order: 1,
11
+ type: 'prompt',
12
+ content: {
13
+ prompt: 'How are you feeling right now? Take a moment to notice.',
14
+ checkpoint_key: 'initial_mood',
15
+ instructions: 'Gently invite the user to check in with their current state. Accept any response - single words, emotions, physical sensations.'
16
+ },
17
+ optional: false
18
+ },
19
+ {
20
+ id: 'step_2',
21
+ order: 2,
22
+ type: 'prompt',
23
+ content: {
24
+ prompt: 'What\'s one thing that happened today that you want to remember?',
25
+ checkpoint_key: 'memorable_moment',
26
+ instructions: 'Help the user identify something meaningful - positive or negative. The goal is noticing, not evaluating.'
27
+ },
28
+ optional: false
29
+ },
30
+ {
31
+ id: 'step_3',
32
+ order: 3,
33
+ type: 'prompt',
34
+ content: {
35
+ prompt: 'Is there anything you\'d like to let go of before tomorrow?',
36
+ checkpoint_key: 'release',
37
+ instructions: 'This is optional and can be skipped. No pressure to identify something.'
38
+ },
39
+ optional: true
40
+ },
41
+ {
42
+ id: 'step_4',
43
+ order: 4,
44
+ type: 'summary',
45
+ content: {
46
+ instructions: 'Briefly summarize what was shared. Acknowledge their reflection without excessive praise. Offer to save any insights that emerged.'
47
+ },
48
+ optional: false
49
+ }
50
+ ]
51
+ };
52
+ //# sourceMappingURL=daily-reflection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daily-reflection.js","sourceRoot":"","sources":["../../../src/workflows/definitions/daily-reflection.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,+DAA+D;IAC5E,gBAAgB,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;IACtC,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,yDAAyD;gBACjE,cAAc,EAAE,cAAc;gBAC9B,YAAY,EAAE,iIAAiI;aAChJ;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kEAAkE;gBAC1E,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,2GAA2G;aAC1H;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,6DAA6D;gBACrE,cAAc,EAAE,SAAS;gBACzB,YAAY,EAAE,yEAAyE;aACxF;YACD,QAAQ,EAAE,IAAI;SACf;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,YAAY,EAAE,oIAAoI;aACnJ;YACD,QAAQ,EAAE,KAAK;SAChB;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Journey } from '../../types/journey.js';
2
+ export declare const gratitudePractice: Journey;
3
+ //# sourceMappingURL=gratitude-practice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gratitude-practice.d.ts","sourceRoot":"","sources":["../../../src/workflows/definitions/gratitude-practice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,EAAE,OAkD/B,CAAC"}
@@ -0,0 +1,52 @@
1
+ export const gratitudePractice = {
2
+ slug: 'gratitude-practice',
3
+ name: 'Gratitude Practice',
4
+ description: 'Notice and name three things you appreciate right now.',
5
+ estimatedMinutes: 3,
6
+ tags: ['gratitude', 'daily', 'short'],
7
+ steps: [
8
+ {
9
+ id: 'step_1',
10
+ order: 1,
11
+ type: 'prompt',
12
+ content: {
13
+ prompt: 'What\'s something small that made today a little better?',
14
+ checkpoint_key: 'gratitude_1',
15
+ instructions: 'Start with something easy and concrete. A cup of coffee, a text from a friend, a moment of quiet. Small is good.'
16
+ },
17
+ optional: false
18
+ },
19
+ {
20
+ id: 'step_2',
21
+ order: 2,
22
+ type: 'prompt',
23
+ content: {
24
+ prompt: 'What\'s something about yourself you\'re grateful for today?',
25
+ checkpoint_key: 'gratitude_2',
26
+ instructions: 'This can be harder. A quality, a decision they made, something they didn\'t do. Self-directed gratitude.'
27
+ },
28
+ optional: false
29
+ },
30
+ {
31
+ id: 'step_3',
32
+ order: 3,
33
+ type: 'prompt',
34
+ content: {
35
+ prompt: 'Who is someone you appreciate, even if you haven\'t told them?',
36
+ checkpoint_key: 'gratitude_3',
37
+ instructions: 'A person - named or described. Can be someone present in their life or from their past.'
38
+ },
39
+ optional: false
40
+ },
41
+ {
42
+ id: 'step_4',
43
+ order: 4,
44
+ type: 'summary',
45
+ content: {
46
+ instructions: 'Reflect back the three gratitudes simply. Note any patterns if obvious. Don\'t over-praise or make it performative.'
47
+ },
48
+ optional: false
49
+ }
50
+ ]
51
+ };
52
+ //# sourceMappingURL=gratitude-practice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gratitude-practice.js","sourceRoot":"","sources":["../../../src/workflows/definitions/gratitude-practice.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAY;IACxC,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,wDAAwD;IACrE,gBAAgB,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC;IACrC,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,0DAA0D;gBAClE,cAAc,EAAE,aAAa;gBAC7B,YAAY,EAAE,kHAAkH;aACjI;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,8DAA8D;gBACtE,cAAc,EAAE,aAAa;gBAC7B,YAAY,EAAE,0GAA0G;aACzH;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,gEAAgE;gBACxE,cAAc,EAAE,aAAa;gBAC7B,YAAY,EAAE,yFAAyF;aACxG;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,YAAY,EAAE,qHAAqH;aACpI;YACD,QAAQ,EAAE,KAAK;SAChB;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Journey } from '../../types/journey.js';
2
+ export declare const weeklyReview: Journey;
3
+ //# sourceMappingURL=weekly-review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weekly-review.d.ts","sourceRoot":"","sources":["../../../src/workflows/definitions/weekly-review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,eAAO,MAAM,YAAY,EAAE,OAwE1B,CAAC"}
@@ -0,0 +1,74 @@
1
+ export const weeklyReview = {
2
+ slug: 'weekly-review',
3
+ name: 'Weekly Review',
4
+ description: 'Look back on your week and set intentions for the next one.',
5
+ estimatedMinutes: 10,
6
+ tags: ['reflection', 'weekly', 'medium'],
7
+ steps: [
8
+ {
9
+ id: 'step_1',
10
+ order: 1,
11
+ type: 'prompt',
12
+ content: {
13
+ prompt: 'How would you describe this past week in a few words?',
14
+ checkpoint_key: 'week_summary',
15
+ instructions: 'Get a quick temperature read. Could be emotional tone, pace, theme. No right answer.'
16
+ },
17
+ optional: false
18
+ },
19
+ {
20
+ id: 'step_2',
21
+ order: 2,
22
+ type: 'prompt',
23
+ content: {
24
+ prompt: 'What\'s one thing you accomplished that you want to acknowledge?',
25
+ checkpoint_key: 'accomplishment',
26
+ instructions: 'Help them find something - doesn\'t have to be big. Finishing something, showing up, making progress.'
27
+ },
28
+ optional: false
29
+ },
30
+ {
31
+ id: 'step_3',
32
+ order: 3,
33
+ type: 'prompt',
34
+ content: {
35
+ prompt: 'What challenged you this week? How did you respond?',
36
+ checkpoint_key: 'challenge',
37
+ instructions: 'Not looking for silver linings. Just noticing what was hard and how they navigated it.'
38
+ },
39
+ optional: false
40
+ },
41
+ {
42
+ id: 'step_4',
43
+ order: 4,
44
+ type: 'prompt',
45
+ content: {
46
+ prompt: 'Is there anything left unfinished that\'s weighing on you?',
47
+ checkpoint_key: 'unfinished',
48
+ instructions: 'Open loops, incomplete tasks, things they\'re avoiding. Optional to answer but worth asking.'
49
+ },
50
+ optional: true
51
+ },
52
+ {
53
+ id: 'step_5',
54
+ order: 5,
55
+ type: 'prompt',
56
+ content: {
57
+ prompt: 'What\'s one intention you want to carry into next week?',
58
+ checkpoint_key: 'intention',
59
+ instructions: 'Not a goal or task. An intention - how they want to show up, what they want to prioritize, a quality to embody.'
60
+ },
61
+ optional: false
62
+ },
63
+ {
64
+ id: 'step_6',
65
+ order: 6,
66
+ type: 'summary',
67
+ content: {
68
+ instructions: 'Summarize the arc: how the week felt, what they accomplished, what challenged them, and their intention going forward. Keep it grounded.'
69
+ },
70
+ optional: false
71
+ }
72
+ ]
73
+ };
74
+ //# sourceMappingURL=weekly-review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weekly-review.js","sourceRoot":"","sources":["../../../src/workflows/definitions/weekly-review.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAY;IACnC,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,6DAA6D;IAC1E,gBAAgB,EAAE,EAAE;IACpB,IAAI,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC;IACxC,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,uDAAuD;gBAC/D,cAAc,EAAE,cAAc;gBAC9B,YAAY,EAAE,sFAAsF;aACrG;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kEAAkE;gBAC1E,cAAc,EAAE,gBAAgB;gBAChC,YAAY,EAAE,uGAAuG;aACtH;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,qDAAqD;gBAC7D,cAAc,EAAE,WAAW;gBAC3B,YAAY,EAAE,wFAAwF;aACvG;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,4DAA4D;gBACpE,cAAc,EAAE,YAAY;gBAC5B,YAAY,EAAE,8FAA8F;aAC7G;YACD,QAAQ,EAAE,IAAI;SACf;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,yDAAyD;gBACjE,cAAc,EAAE,WAAW;gBAC3B,YAAY,EAAE,iHAAiH;aAChI;YACD,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,YAAY,EAAE,0IAA0I;aACzJ;YACD,QAAQ,EAAE,KAAK;SAChB;KACF;CACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { JourneyStep } from '../types/journey.js';
2
+ export declare class WorkflowEngine {
3
+ private db;
4
+ initializeSession(userId: string, journeyId: string): Promise<string>;
5
+ getCurrentStep(sessionId: string): Promise<JourneyStep | null>;
6
+ advanceStep(sessionId: string): Promise<{
7
+ nextStep: JourneyStep | null;
8
+ isComplete: boolean;
9
+ }>;
10
+ pauseSession(sessionId: string): Promise<void>;
11
+ abandonSession(sessionId: string): Promise<void>;
12
+ getSessionProgress(sessionId: string): Promise<{
13
+ currentStep: number;
14
+ totalSteps: number;
15
+ percentComplete: number;
16
+ checkpointCount: number;
17
+ }>;
18
+ canSkipCurrentStep(sessionId: string): Promise<boolean>;
19
+ }
20
+ export declare const workflowEngine: WorkflowEngine;
21
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/workflows/engine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAAW;IAEf,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBrE,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAwB9D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5C,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IAqDI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9C,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACnD,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IA8CI,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI9D;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,149 @@
1
+ import { getDb } from '../db/client.js';
2
+ import { sessions, journeys, checkpoints } from '../db/schema.js';
3
+ import { eq } from 'drizzle-orm';
4
+ import { logger } from '../utils/logger.js';
5
+ export class WorkflowEngine {
6
+ db = getDb();
7
+ async initializeSession(userId, journeyId) {
8
+ const sessionResult = await this.db
9
+ .insert(sessions)
10
+ .values({
11
+ userId,
12
+ journeyId,
13
+ status: 'active',
14
+ currentStep: 0,
15
+ metadata: {},
16
+ })
17
+ .returning();
18
+ const session = sessionResult[0];
19
+ logger.info(`Initialized session ${session.id} for journey ${journeyId}`);
20
+ return session.id;
21
+ }
22
+ async getCurrentStep(sessionId) {
23
+ const [session] = await this.db
24
+ .select()
25
+ .from(sessions)
26
+ .where(eq(sessions.id, sessionId))
27
+ .limit(1);
28
+ if (!session || !session.journeyId) {
29
+ return null;
30
+ }
31
+ const [journey] = await this.db
32
+ .select()
33
+ .from(journeys)
34
+ .where(eq(journeys.id, session.journeyId))
35
+ .limit(1);
36
+ if (!journey || !journey.steps) {
37
+ return null;
38
+ }
39
+ return journey.steps[session.currentStep] ?? null;
40
+ }
41
+ async advanceStep(sessionId) {
42
+ const [session] = await this.db
43
+ .select()
44
+ .from(sessions)
45
+ .where(eq(sessions.id, sessionId))
46
+ .limit(1);
47
+ if (!session || !session.journeyId) {
48
+ return { nextStep: null, isComplete: false };
49
+ }
50
+ const [journey] = await this.db
51
+ .select()
52
+ .from(journeys)
53
+ .where(eq(journeys.id, session.journeyId))
54
+ .limit(1);
55
+ if (!journey || !journey.steps) {
56
+ return { nextStep: null, isComplete: false };
57
+ }
58
+ const nextStepIndex = session.currentStep + 1;
59
+ if (nextStepIndex >= journey.steps.length) {
60
+ // Journey is complete
61
+ await this.db
62
+ .update(sessions)
63
+ .set({
64
+ status: 'completed',
65
+ completedAt: new Date(),
66
+ lastActiveAt: new Date(),
67
+ })
68
+ .where(eq(sessions.id, sessionId));
69
+ logger.info(`Session ${sessionId} completed`);
70
+ return { nextStep: null, isComplete: true };
71
+ }
72
+ // Advance to next step
73
+ await this.db
74
+ .update(sessions)
75
+ .set({
76
+ currentStep: nextStepIndex,
77
+ lastActiveAt: new Date(),
78
+ })
79
+ .where(eq(sessions.id, sessionId));
80
+ const nextStep = journey.steps[nextStepIndex] ?? null;
81
+ logger.info(`Session ${sessionId} advanced to step ${nextStepIndex}`);
82
+ return { nextStep, isComplete: false };
83
+ }
84
+ async pauseSession(sessionId) {
85
+ await this.db
86
+ .update(sessions)
87
+ .set({
88
+ status: 'paused',
89
+ lastActiveAt: new Date(),
90
+ })
91
+ .where(eq(sessions.id, sessionId));
92
+ logger.info(`Session ${sessionId} paused`);
93
+ }
94
+ async abandonSession(sessionId) {
95
+ await this.db
96
+ .update(sessions)
97
+ .set({
98
+ status: 'abandoned',
99
+ lastActiveAt: new Date(),
100
+ })
101
+ .where(eq(sessions.id, sessionId));
102
+ logger.info(`Session ${sessionId} abandoned`);
103
+ }
104
+ async getSessionProgress(sessionId) {
105
+ const [session] = await this.db
106
+ .select()
107
+ .from(sessions)
108
+ .where(eq(sessions.id, sessionId))
109
+ .limit(1);
110
+ if (!session) {
111
+ return {
112
+ currentStep: 0,
113
+ totalSteps: 0,
114
+ percentComplete: 0,
115
+ checkpointCount: 0,
116
+ };
117
+ }
118
+ let totalSteps = 0;
119
+ if (session.journeyId) {
120
+ const [journey] = await this.db
121
+ .select()
122
+ .from(journeys)
123
+ .where(eq(journeys.id, session.journeyId))
124
+ .limit(1);
125
+ if (journey && journey.steps) {
126
+ totalSteps = journey.steps.length;
127
+ }
128
+ }
129
+ const sessionCheckpoints = await this.db
130
+ .select()
131
+ .from(checkpoints)
132
+ .where(eq(checkpoints.sessionId, sessionId));
133
+ const percentComplete = totalSteps > 0
134
+ ? Math.round((session.currentStep / totalSteps) * 100)
135
+ : 0;
136
+ return {
137
+ currentStep: session.currentStep,
138
+ totalSteps,
139
+ percentComplete,
140
+ checkpointCount: sessionCheckpoints.length,
141
+ };
142
+ }
143
+ async canSkipCurrentStep(sessionId) {
144
+ const currentStep = await this.getCurrentStep(sessionId);
145
+ return currentStep?.optional ?? false;
146
+ }
147
+ }
148
+ export const workflowEngine = new WorkflowEngine();
149
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/workflows/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,M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