@flowdot.ai/daemon 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 (85) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +51 -0
  3. package/dist/goals/DependencyResolver.d.ts +54 -0
  4. package/dist/goals/DependencyResolver.js +329 -0
  5. package/dist/goals/ErrorRecovery.d.ts +133 -0
  6. package/dist/goals/ErrorRecovery.js +489 -0
  7. package/dist/goals/GoalApiClient.d.ts +81 -0
  8. package/dist/goals/GoalApiClient.js +743 -0
  9. package/dist/goals/GoalCache.d.ts +65 -0
  10. package/dist/goals/GoalCache.js +243 -0
  11. package/dist/goals/GoalCommsHandler.d.ts +150 -0
  12. package/dist/goals/GoalCommsHandler.js +378 -0
  13. package/dist/goals/GoalExporter.d.ts +164 -0
  14. package/dist/goals/GoalExporter.js +318 -0
  15. package/dist/goals/GoalImporter.d.ts +107 -0
  16. package/dist/goals/GoalImporter.js +345 -0
  17. package/dist/goals/GoalManager.d.ts +110 -0
  18. package/dist/goals/GoalManager.js +535 -0
  19. package/dist/goals/GoalReporter.d.ts +105 -0
  20. package/dist/goals/GoalReporter.js +534 -0
  21. package/dist/goals/GoalScheduler.d.ts +102 -0
  22. package/dist/goals/GoalScheduler.js +209 -0
  23. package/dist/goals/GoalValidator.d.ts +72 -0
  24. package/dist/goals/GoalValidator.js +657 -0
  25. package/dist/goals/MetaGoalEnforcer.d.ts +111 -0
  26. package/dist/goals/MetaGoalEnforcer.js +536 -0
  27. package/dist/goals/MilestoneBreaker.d.ts +74 -0
  28. package/dist/goals/MilestoneBreaker.js +348 -0
  29. package/dist/goals/PermissionBridge.d.ts +109 -0
  30. package/dist/goals/PermissionBridge.js +326 -0
  31. package/dist/goals/ProgressTracker.d.ts +113 -0
  32. package/dist/goals/ProgressTracker.js +324 -0
  33. package/dist/goals/ReviewScheduler.d.ts +106 -0
  34. package/dist/goals/ReviewScheduler.js +360 -0
  35. package/dist/goals/TaskExecutor.d.ts +116 -0
  36. package/dist/goals/TaskExecutor.js +370 -0
  37. package/dist/goals/TaskFeedback.d.ts +126 -0
  38. package/dist/goals/TaskFeedback.js +402 -0
  39. package/dist/goals/TaskGenerator.d.ts +75 -0
  40. package/dist/goals/TaskGenerator.js +329 -0
  41. package/dist/goals/TaskQueue.d.ts +84 -0
  42. package/dist/goals/TaskQueue.js +331 -0
  43. package/dist/goals/TaskSanitizer.d.ts +61 -0
  44. package/dist/goals/TaskSanitizer.js +464 -0
  45. package/dist/goals/errors.d.ts +116 -0
  46. package/dist/goals/errors.js +299 -0
  47. package/dist/goals/index.d.ts +24 -0
  48. package/dist/goals/index.js +23 -0
  49. package/dist/goals/types.d.ts +395 -0
  50. package/dist/goals/types.js +230 -0
  51. package/dist/index.d.ts +4 -0
  52. package/dist/index.js +3 -0
  53. package/dist/loop/DaemonIPC.d.ts +67 -0
  54. package/dist/loop/DaemonIPC.js +358 -0
  55. package/dist/loop/IntervalParser.d.ts +39 -0
  56. package/dist/loop/IntervalParser.js +217 -0
  57. package/dist/loop/LoopDaemon.d.ts +123 -0
  58. package/dist/loop/LoopDaemon.js +1821 -0
  59. package/dist/loop/LoopExecutor.d.ts +93 -0
  60. package/dist/loop/LoopExecutor.js +326 -0
  61. package/dist/loop/LoopManager.d.ts +79 -0
  62. package/dist/loop/LoopManager.js +476 -0
  63. package/dist/loop/LoopScheduler.d.ts +69 -0
  64. package/dist/loop/LoopScheduler.js +329 -0
  65. package/dist/loop/LoopStore.d.ts +57 -0
  66. package/dist/loop/LoopStore.js +406 -0
  67. package/dist/loop/LoopValidator.d.ts +55 -0
  68. package/dist/loop/LoopValidator.js +603 -0
  69. package/dist/loop/errors.d.ts +115 -0
  70. package/dist/loop/errors.js +312 -0
  71. package/dist/loop/index.d.ts +11 -0
  72. package/dist/loop/index.js +10 -0
  73. package/dist/loop/notifications/Notifier.d.ts +28 -0
  74. package/dist/loop/notifications/Notifier.js +78 -0
  75. package/dist/loop/notifications/SlackNotifier.d.ts +28 -0
  76. package/dist/loop/notifications/SlackNotifier.js +203 -0
  77. package/dist/loop/notifications/TerminalNotifier.d.ts +18 -0
  78. package/dist/loop/notifications/TerminalNotifier.js +72 -0
  79. package/dist/loop/notifications/WebhookNotifier.d.ts +24 -0
  80. package/dist/loop/notifications/WebhookNotifier.js +123 -0
  81. package/dist/loop/notifications/index.d.ts +24 -0
  82. package/dist/loop/notifications/index.js +109 -0
  83. package/dist/loop/types.d.ts +280 -0
  84. package/dist/loop/types.js +222 -0
  85. package/package.json +92 -0
@@ -0,0 +1,395 @@
1
+ export type GoalHash = string;
2
+ export type MilestoneId = number;
3
+ export type TaskId = number;
4
+ export type MemoryId = number;
5
+ export type MetaGoalId = number;
6
+ export type MemoryCategory = 'general' | 'decision' | 'context' | 'preference';
7
+ export type ConstraintType = 'block' | 'require' | 'limit' | 'prefer';
8
+ export interface MetaGoalConstraint {
9
+ readonly type: ConstraintType;
10
+ readonly target: string;
11
+ readonly value?: unknown;
12
+ readonly description?: string;
13
+ }
14
+ export interface ListOptions {
15
+ readonly page?: number;
16
+ readonly perPage?: number;
17
+ readonly sortBy?: string;
18
+ readonly sortDir?: 'asc' | 'desc';
19
+ }
20
+ export interface ListTasksOptions extends ListOptions {
21
+ readonly status?: TaskStatus | TaskStatus[];
22
+ readonly taskType?: TaskType | TaskType[];
23
+ readonly milestoneId?: number;
24
+ }
25
+ export type GoalStatus = 'active' | 'paused' | 'completed' | 'abandoned';
26
+ export type GoalPriority = 'high' | 'medium' | 'low';
27
+ export type ApprovalMode = 'full' | 'category' | 'trusted';
28
+ export type TaskType = 'research' | 'draft' | 'code' | 'execute' | 'recipe' | 'loop' | 'notify';
29
+ export type TaskStatus = 'pending' | 'awaiting_approval' | 'in_progress' | 'completed' | 'failed' | 'skipped' | 'expired';
30
+ export type MemoryType = 'conversation' | 'decision' | 'learning';
31
+ export type MemorySource = 'manual' | 'auto';
32
+ export type FeedbackQuality = 'high' | 'medium' | 'low';
33
+ export interface GoalRestrictions {
34
+ readonly blockedActions?: string[];
35
+ readonly allowedCategories?: string[];
36
+ readonly maxCostPerTask?: number;
37
+ readonly requireConfirmation?: string[];
38
+ }
39
+ export interface GoalSchedule {
40
+ readonly days?: string[];
41
+ readonly timeWindows?: Array<{
42
+ start: string;
43
+ end: string;
44
+ }>;
45
+ readonly maxTasksPerDay?: number;
46
+ }
47
+ export interface GoalNotificationPreferences {
48
+ readonly onTaskComplete?: boolean;
49
+ readonly onTaskFailed?: boolean;
50
+ readonly onMilestoneComplete?: boolean;
51
+ readonly channels?: string[];
52
+ }
53
+ export interface GoalReviewSchedule {
54
+ readonly frequency?: string;
55
+ readonly dayOfWeek?: string;
56
+ readonly timeOfDay?: string;
57
+ }
58
+ export interface Goal {
59
+ readonly id: number;
60
+ readonly hash: GoalHash;
61
+ readonly userId: number;
62
+ readonly name: string;
63
+ readonly description: string | null;
64
+ readonly priority: GoalPriority;
65
+ status: GoalStatus;
66
+ readonly approvalMode: ApprovalMode;
67
+ readonly deadline: Date | null;
68
+ readonly restrictions: GoalRestrictions | null;
69
+ readonly schedule: GoalSchedule | null;
70
+ readonly notificationPreferences: GoalNotificationPreferences | null;
71
+ readonly reviewSchedule: GoalReviewSchedule | null;
72
+ readonly parentId: number | null;
73
+ readonly dependsOn: GoalHash[];
74
+ readonly createdAt: Date;
75
+ readonly updatedAt: Date;
76
+ progress?: number;
77
+ taskCount?: number;
78
+ completedTaskCount?: number;
79
+ milestoneCount?: number;
80
+ completedMilestoneCount?: number;
81
+ isBlocked?: boolean;
82
+ blockedBy?: GoalHash[];
83
+ totalCost?: number;
84
+ }
85
+ export interface Milestone {
86
+ readonly id: number;
87
+ readonly userId: number;
88
+ readonly goalId: number;
89
+ readonly title: string;
90
+ readonly description: string | null;
91
+ readonly targetDate: Date | null;
92
+ readonly isManual: boolean;
93
+ isComplete: boolean;
94
+ completedAt: Date | null;
95
+ readonly createdAt: Date;
96
+ readonly updatedAt: Date;
97
+ progress?: number;
98
+ taskCount?: number;
99
+ completedTaskCount?: number;
100
+ isOverdue?: boolean;
101
+ }
102
+ export interface TaskFeedback {
103
+ readonly quality: FeedbackQuality;
104
+ readonly comment: string | null;
105
+ readonly submittedAt: string;
106
+ }
107
+ export type TaskPriority = 'high' | 'medium' | 'low';
108
+ export interface Task {
109
+ readonly id: number;
110
+ readonly userId: number;
111
+ readonly goalId: number;
112
+ readonly milestoneId: number | null;
113
+ readonly title: string;
114
+ readonly description: string | null;
115
+ readonly taskType: TaskType;
116
+ status: TaskStatus;
117
+ readonly priority?: TaskPriority;
118
+ readonly permissionCategory: string | null;
119
+ readonly requiresApproval?: boolean;
120
+ readonly scheduledFor: Date | null;
121
+ readonly expiresAt?: Date | null;
122
+ readonly deadline?: Date | null;
123
+ executedAt: Date | null;
124
+ completedAt?: Date | null;
125
+ result: Record<string, unknown> | null;
126
+ params?: Record<string, unknown>;
127
+ feedback: TaskFeedback | null;
128
+ cost: number | null;
129
+ readonly createdAt: Date;
130
+ readonly updatedAt: Date;
131
+ }
132
+ export interface GoalMemory {
133
+ readonly id: number;
134
+ readonly userId: number;
135
+ readonly goalId: number;
136
+ readonly content: string;
137
+ readonly memoryType: MemoryType;
138
+ readonly source: MemorySource;
139
+ isEnabled: boolean;
140
+ readonly createdAt: Date;
141
+ readonly updatedAt: Date;
142
+ }
143
+ export type MetaGoalScope = 'all' | GoalHash[];
144
+ export interface MetaGoal {
145
+ readonly id: number;
146
+ readonly userId: number;
147
+ readonly description: string;
148
+ readonly priority: number;
149
+ readonly scope: MetaGoalScope;
150
+ isActive: boolean;
151
+ readonly createdAt: Date;
152
+ readonly updatedAt: Date;
153
+ }
154
+ export type ActionType = 'goal_created' | 'goal_updated' | 'goal_paused' | 'goal_resumed' | 'goal_completed' | 'goal_abandoned' | 'task_generated' | 'task_approved' | 'task_denied' | 'task_started' | 'task_completed' | 'task_failed' | 'milestone_created' | 'milestone_completed' | 'memory_added';
155
+ export type ActionLogStatus = 'success' | 'failed' | 'rolled_back';
156
+ export interface GoalActionLog {
157
+ readonly id: number;
158
+ readonly userId: number;
159
+ readonly goalId: number | null;
160
+ readonly taskId: number | null;
161
+ readonly actionType: ActionType;
162
+ readonly actionDetails: Record<string, unknown> | null;
163
+ readonly status: ActionLogStatus;
164
+ readonly errorMessage: string | null;
165
+ readonly durationMs: number | null;
166
+ readonly createdAt: Date;
167
+ }
168
+ export interface CreateGoalInput {
169
+ readonly name: string;
170
+ readonly description?: string;
171
+ readonly priority?: GoalPriority;
172
+ readonly approvalMode?: ApprovalMode;
173
+ readonly deadline?: string;
174
+ readonly restrictions?: GoalRestrictions;
175
+ readonly schedule?: GoalSchedule;
176
+ readonly notificationPreferences?: GoalNotificationPreferences;
177
+ readonly reviewSchedule?: GoalReviewSchedule;
178
+ readonly parentHash?: GoalHash;
179
+ readonly dependsOn?: GoalHash[];
180
+ }
181
+ export interface UpdateGoalInput {
182
+ readonly name?: string;
183
+ readonly description?: string;
184
+ readonly priority?: GoalPriority;
185
+ readonly approvalMode?: ApprovalMode;
186
+ readonly deadline?: string;
187
+ readonly restrictions?: GoalRestrictions;
188
+ readonly schedule?: GoalSchedule;
189
+ readonly notificationPreferences?: GoalNotificationPreferences;
190
+ readonly reviewSchedule?: GoalReviewSchedule;
191
+ readonly dependsOn?: GoalHash[];
192
+ }
193
+ export interface CreateMilestoneInput {
194
+ readonly title: string;
195
+ readonly description?: string;
196
+ readonly targetDate?: string;
197
+ readonly isManual?: boolean;
198
+ }
199
+ export interface UpdateMilestoneInput {
200
+ readonly title?: string;
201
+ readonly description?: string;
202
+ readonly targetDate?: string;
203
+ }
204
+ export interface CreateTaskInput {
205
+ readonly title: string;
206
+ readonly description?: string;
207
+ readonly taskType?: TaskType;
208
+ readonly permissionCategory?: string;
209
+ readonly scheduledFor?: string;
210
+ readonly milestoneId?: number;
211
+ }
212
+ export interface UpdateTaskInput {
213
+ readonly title?: string;
214
+ readonly description?: string;
215
+ readonly taskType?: TaskType;
216
+ readonly permissionCategory?: string;
217
+ readonly scheduledFor?: string;
218
+ readonly milestoneId?: number | null;
219
+ }
220
+ export interface CreateMemoryInput {
221
+ readonly content: string;
222
+ readonly memoryType?: MemoryType;
223
+ readonly source?: MemorySource;
224
+ }
225
+ export interface UpdateMemoryInput {
226
+ readonly content?: string;
227
+ readonly memoryType?: MemoryType;
228
+ readonly isEnabled?: boolean;
229
+ }
230
+ export interface CreateMetaGoalInput {
231
+ readonly description: string;
232
+ readonly priority?: number;
233
+ readonly scope?: MetaGoalScope;
234
+ }
235
+ export interface UpdateMetaGoalInput {
236
+ readonly description?: string;
237
+ readonly priority?: number;
238
+ readonly scope?: MetaGoalScope;
239
+ readonly isActive?: boolean;
240
+ }
241
+ export interface TaskFeedbackInput {
242
+ readonly quality: FeedbackQuality;
243
+ readonly comment?: string;
244
+ }
245
+ export interface TaskFailInput {
246
+ readonly error: string;
247
+ readonly result?: Record<string, unknown>;
248
+ }
249
+ export interface ApiResponse<T> {
250
+ readonly success: boolean;
251
+ readonly data?: T;
252
+ readonly message?: string;
253
+ readonly errors?: Record<string, string[]>;
254
+ }
255
+ export interface GoalProgress {
256
+ readonly progress: number;
257
+ readonly milestones: {
258
+ readonly total: number;
259
+ readonly completed: number;
260
+ };
261
+ readonly tasks: {
262
+ readonly total: number;
263
+ readonly completed: number;
264
+ readonly pending: number;
265
+ readonly inProgress: number;
266
+ readonly failed: number;
267
+ };
268
+ readonly totalCost: number;
269
+ readonly isBlocked: boolean;
270
+ readonly blockedBy: GoalHash[];
271
+ }
272
+ export declare function isGoalStatus(value: unknown): value is GoalStatus;
273
+ export declare function isGoalPriority(value: unknown): value is GoalPriority;
274
+ export declare function isApprovalMode(value: unknown): value is ApprovalMode;
275
+ export declare function isTaskType(value: unknown): value is TaskType;
276
+ export declare function isTaskStatus(value: unknown): value is TaskStatus;
277
+ export declare function isMemoryType(value: unknown): value is MemoryType;
278
+ export declare function isMemorySource(value: unknown): value is MemorySource;
279
+ export declare function isFeedbackQuality(value: unknown): value is FeedbackQuality;
280
+ export declare function isActionType(value: unknown): value is ActionType;
281
+ export declare function isValidGoalHash(value: unknown): value is GoalHash;
282
+ export interface SerializedGoal {
283
+ id: number;
284
+ hash: string;
285
+ userId: number;
286
+ name: string;
287
+ description: string | null;
288
+ priority: GoalPriority;
289
+ status: GoalStatus;
290
+ approvalMode: ApprovalMode;
291
+ deadline: string | null;
292
+ restrictions: GoalRestrictions | null;
293
+ schedule: GoalSchedule | null;
294
+ notificationPreferences: GoalNotificationPreferences | null;
295
+ reviewSchedule: GoalReviewSchedule | null;
296
+ parentId: number | null;
297
+ dependsOn: GoalHash[];
298
+ createdAt: string;
299
+ updatedAt: string;
300
+ progress?: number;
301
+ taskCount?: number;
302
+ completedTaskCount?: number;
303
+ milestoneCount?: number;
304
+ completedMilestoneCount?: number;
305
+ isBlocked?: boolean;
306
+ blockedBy?: GoalHash[];
307
+ totalCost?: number;
308
+ }
309
+ export declare function deserializeGoal(data: SerializedGoal): Goal;
310
+ export declare function serializeGoal(goal: Goal): SerializedGoal;
311
+ export interface SerializedTask {
312
+ id: number;
313
+ userId: number;
314
+ goalId: number;
315
+ milestoneId: number | null;
316
+ title: string;
317
+ description: string | null;
318
+ taskType: TaskType;
319
+ status: TaskStatus;
320
+ permissionCategory: string | null;
321
+ scheduledFor: string | null;
322
+ executedAt: string | null;
323
+ result: Record<string, unknown> | null;
324
+ feedback: TaskFeedback | null;
325
+ cost: number | null;
326
+ createdAt: string;
327
+ updatedAt: string;
328
+ }
329
+ export declare function deserializeTask(data: SerializedTask): Task;
330
+ export interface SerializedMilestone {
331
+ id: number;
332
+ userId: number;
333
+ goalId: number;
334
+ title: string;
335
+ description: string | null;
336
+ targetDate: string | null;
337
+ isManual: boolean;
338
+ isComplete: boolean;
339
+ completedAt: string | null;
340
+ createdAt: string;
341
+ updatedAt: string;
342
+ progress?: number;
343
+ taskCount?: number;
344
+ completedTaskCount?: number;
345
+ isOverdue?: boolean;
346
+ }
347
+ export declare function deserializeMilestone(data: SerializedMilestone): Milestone;
348
+ export interface SerializedMemory {
349
+ id: number;
350
+ userId: number;
351
+ goalId: number;
352
+ content: string;
353
+ memoryType: MemoryType;
354
+ source: MemorySource;
355
+ isEnabled: boolean;
356
+ createdAt: string;
357
+ updatedAt: string;
358
+ }
359
+ export declare function deserializeMemory(data: SerializedMemory): GoalMemory;
360
+ export interface SerializedMetaGoal {
361
+ id: number;
362
+ userId: number;
363
+ description: string;
364
+ priority: number;
365
+ scope: MetaGoalScope;
366
+ isActive: boolean;
367
+ createdAt: string;
368
+ updatedAt: string;
369
+ }
370
+ export declare function deserializeMetaGoal(data: SerializedMetaGoal): MetaGoal;
371
+ export declare const deserializeGoalMemory: typeof deserializeMemory;
372
+ export interface SerializedGoalActionLog {
373
+ id: number;
374
+ userId: number;
375
+ goalId: number | null;
376
+ taskId: number | null;
377
+ actionType: ActionType;
378
+ actionDetails: Record<string, unknown> | null;
379
+ status: ActionLogStatus;
380
+ errorMessage: string | null;
381
+ durationMs: number | null;
382
+ createdAt: string;
383
+ }
384
+ export declare function deserializeGoalActionLog(data: SerializedGoalActionLog): GoalActionLog;
385
+ export declare const TASK_TYPES: readonly TaskType[];
386
+ export declare function canGoalTransitionTo(from: GoalStatus, to: GoalStatus): boolean;
387
+ export declare function isTerminalGoalStatus(status: GoalStatus): boolean;
388
+ export declare function canTaskTransitionTo(from: TaskStatus, to: TaskStatus): boolean;
389
+ export declare function isTerminalTaskStatus(status: TaskStatus): boolean;
390
+ export interface Logger {
391
+ debug(category: string, message: string, data?: Record<string, unknown>): void;
392
+ info(category: string, message: string, data?: Record<string, unknown>): void;
393
+ warn(category: string, message: string, data?: Record<string, unknown>): void;
394
+ error(category: string, message: string, data?: Record<string, unknown>): void;
395
+ }
@@ -0,0 +1,230 @@
1
+ export function isGoalStatus(value) {
2
+ return (typeof value === 'string' &&
3
+ ['active', 'paused', 'completed', 'abandoned'].includes(value));
4
+ }
5
+ export function isGoalPriority(value) {
6
+ return (typeof value === 'string' &&
7
+ ['high', 'medium', 'low'].includes(value));
8
+ }
9
+ export function isApprovalMode(value) {
10
+ return (typeof value === 'string' &&
11
+ ['full', 'category', 'trusted'].includes(value));
12
+ }
13
+ export function isTaskType(value) {
14
+ return (typeof value === 'string' &&
15
+ ['research', 'draft', 'code', 'execute', 'recipe', 'loop', 'notify'].includes(value));
16
+ }
17
+ export function isTaskStatus(value) {
18
+ return (typeof value === 'string' &&
19
+ ['pending', 'awaiting_approval', 'in_progress', 'completed', 'failed', 'skipped', 'expired'].includes(value));
20
+ }
21
+ export function isMemoryType(value) {
22
+ return (typeof value === 'string' &&
23
+ ['conversation', 'decision', 'learning'].includes(value));
24
+ }
25
+ export function isMemorySource(value) {
26
+ return (typeof value === 'string' &&
27
+ ['manual', 'auto'].includes(value));
28
+ }
29
+ export function isFeedbackQuality(value) {
30
+ return (typeof value === 'string' &&
31
+ ['high', 'medium', 'low'].includes(value));
32
+ }
33
+ export function isActionType(value) {
34
+ const validTypes = [
35
+ 'goal_created', 'goal_updated', 'goal_paused', 'goal_resumed',
36
+ 'goal_completed', 'goal_abandoned', 'task_generated', 'task_approved',
37
+ 'task_denied', 'task_started', 'task_completed', 'task_failed',
38
+ 'milestone_created', 'milestone_completed', 'memory_added'
39
+ ];
40
+ return typeof value === 'string' && validTypes.includes(value);
41
+ }
42
+ export function isValidGoalHash(value) {
43
+ return typeof value === 'string' && value.length >= 8 && /^[a-zA-Z0-9]+$/.test(value);
44
+ }
45
+ export function deserializeGoal(data) {
46
+ return {
47
+ id: data.id,
48
+ hash: data.hash,
49
+ userId: data.userId,
50
+ name: data.name,
51
+ description: data.description,
52
+ priority: data.priority,
53
+ status: data.status,
54
+ approvalMode: data.approvalMode,
55
+ deadline: data.deadline ? new Date(data.deadline) : null,
56
+ restrictions: data.restrictions,
57
+ schedule: data.schedule,
58
+ notificationPreferences: data.notificationPreferences,
59
+ reviewSchedule: data.reviewSchedule,
60
+ parentId: data.parentId,
61
+ dependsOn: data.dependsOn || [],
62
+ createdAt: new Date(data.createdAt),
63
+ updatedAt: new Date(data.updatedAt),
64
+ progress: data.progress,
65
+ taskCount: data.taskCount,
66
+ completedTaskCount: data.completedTaskCount,
67
+ milestoneCount: data.milestoneCount,
68
+ completedMilestoneCount: data.completedMilestoneCount,
69
+ isBlocked: data.isBlocked,
70
+ blockedBy: data.blockedBy,
71
+ totalCost: data.totalCost,
72
+ };
73
+ }
74
+ export function serializeGoal(goal) {
75
+ return {
76
+ id: goal.id,
77
+ hash: goal.hash,
78
+ userId: goal.userId,
79
+ name: goal.name,
80
+ description: goal.description,
81
+ priority: goal.priority,
82
+ status: goal.status,
83
+ approvalMode: goal.approvalMode,
84
+ deadline: goal.deadline?.toISOString() ?? null,
85
+ restrictions: goal.restrictions,
86
+ schedule: goal.schedule,
87
+ notificationPreferences: goal.notificationPreferences,
88
+ reviewSchedule: goal.reviewSchedule,
89
+ parentId: goal.parentId,
90
+ dependsOn: goal.dependsOn,
91
+ createdAt: goal.createdAt.toISOString(),
92
+ updatedAt: goal.updatedAt.toISOString(),
93
+ progress: goal.progress,
94
+ taskCount: goal.taskCount,
95
+ completedTaskCount: goal.completedTaskCount,
96
+ milestoneCount: goal.milestoneCount,
97
+ completedMilestoneCount: goal.completedMilestoneCount,
98
+ isBlocked: goal.isBlocked,
99
+ blockedBy: goal.blockedBy,
100
+ totalCost: goal.totalCost,
101
+ };
102
+ }
103
+ export function deserializeTask(data) {
104
+ const raw = data;
105
+ console.log("[DEBUG deserializeTask] raw data keys:", Object.keys(raw));
106
+ console.log("[DEBUG deserializeTask] raw.taskType:", raw.taskType);
107
+ console.log("[DEBUG deserializeTask] raw.task_type:", raw.task_type);
108
+ const userId = (raw.userId ?? raw.user_id);
109
+ const goalId = (raw.goalId ?? raw.goal_id);
110
+ const milestoneId = (raw.milestoneId ?? raw.milestone_id);
111
+ const taskType = (raw.taskType ?? raw.task_type);
112
+ const permissionCategory = (raw.permissionCategory ?? raw.permission_category);
113
+ const scheduledFor = (raw.scheduledFor ?? raw.scheduled_for);
114
+ const executedAt = (raw.executedAt ?? raw.executed_at);
115
+ const createdAt = (raw.createdAt ?? raw.created_at);
116
+ const updatedAt = (raw.updatedAt ?? raw.updated_at);
117
+ return {
118
+ id: data.id,
119
+ userId,
120
+ goalId,
121
+ milestoneId,
122
+ title: data.title,
123
+ description: data.description,
124
+ taskType,
125
+ status: data.status,
126
+ permissionCategory,
127
+ scheduledFor: scheduledFor ? new Date(scheduledFor) : null,
128
+ executedAt: executedAt ? new Date(executedAt) : null,
129
+ result: data.result,
130
+ feedback: data.feedback,
131
+ cost: data.cost,
132
+ createdAt: new Date(createdAt),
133
+ updatedAt: new Date(updatedAt),
134
+ };
135
+ }
136
+ export function deserializeMilestone(data) {
137
+ return {
138
+ id: data.id,
139
+ userId: data.userId,
140
+ goalId: data.goalId,
141
+ title: data.title,
142
+ description: data.description,
143
+ targetDate: data.targetDate ? new Date(data.targetDate) : null,
144
+ isManual: data.isManual,
145
+ isComplete: data.isComplete,
146
+ completedAt: data.completedAt ? new Date(data.completedAt) : null,
147
+ createdAt: new Date(data.createdAt),
148
+ updatedAt: new Date(data.updatedAt),
149
+ progress: data.progress,
150
+ taskCount: data.taskCount,
151
+ completedTaskCount: data.completedTaskCount,
152
+ isOverdue: data.isOverdue,
153
+ };
154
+ }
155
+ export function deserializeMemory(data) {
156
+ return {
157
+ id: data.id,
158
+ userId: data.userId,
159
+ goalId: data.goalId,
160
+ content: data.content,
161
+ memoryType: data.memoryType,
162
+ source: data.source,
163
+ isEnabled: data.isEnabled,
164
+ createdAt: new Date(data.createdAt),
165
+ updatedAt: new Date(data.updatedAt),
166
+ };
167
+ }
168
+ export function deserializeMetaGoal(data) {
169
+ return {
170
+ id: data.id,
171
+ userId: data.userId,
172
+ description: data.description,
173
+ priority: data.priority,
174
+ scope: data.scope,
175
+ isActive: data.isActive,
176
+ createdAt: new Date(data.createdAt),
177
+ updatedAt: new Date(data.updatedAt),
178
+ };
179
+ }
180
+ export const deserializeGoalMemory = deserializeMemory;
181
+ export function deserializeGoalActionLog(data) {
182
+ return {
183
+ id: data.id,
184
+ userId: data.userId,
185
+ goalId: data.goalId,
186
+ taskId: data.taskId,
187
+ actionType: data.actionType,
188
+ actionDetails: data.actionDetails,
189
+ status: data.status,
190
+ errorMessage: data.errorMessage,
191
+ durationMs: data.durationMs,
192
+ createdAt: new Date(data.createdAt),
193
+ };
194
+ }
195
+ export const TASK_TYPES = [
196
+ 'research',
197
+ 'draft',
198
+ 'code',
199
+ 'execute',
200
+ 'recipe',
201
+ 'loop',
202
+ 'notify',
203
+ ];
204
+ const GOAL_STATUS_TRANSITIONS = {
205
+ active: ['paused', 'completed', 'abandoned'],
206
+ paused: ['active', 'abandoned'],
207
+ completed: [],
208
+ abandoned: [],
209
+ };
210
+ export function canGoalTransitionTo(from, to) {
211
+ return GOAL_STATUS_TRANSITIONS[from].includes(to);
212
+ }
213
+ export function isTerminalGoalStatus(status) {
214
+ return status === 'completed' || status === 'abandoned';
215
+ }
216
+ const TASK_STATUS_TRANSITIONS = {
217
+ pending: ['awaiting_approval', 'in_progress', 'skipped', 'expired'],
218
+ awaiting_approval: ['in_progress', 'skipped'],
219
+ in_progress: ['completed', 'failed'],
220
+ completed: [],
221
+ failed: [],
222
+ skipped: [],
223
+ expired: [],
224
+ };
225
+ export function canTaskTransitionTo(from, to) {
226
+ return TASK_STATUS_TRANSITIONS[from].includes(to);
227
+ }
228
+ export function isTerminalTaskStatus(status) {
229
+ return ['completed', 'failed', 'skipped', 'expired'].includes(status);
230
+ }
@@ -0,0 +1,4 @@
1
+ export * from './loop/index.js';
2
+ export { type GoalHash, type MilestoneId, type TaskId, type MemoryId, type MetaGoalId, type GoalStatus, type GoalPriority, type TaskType, type TaskStatus, type ApprovalMode, type MemoryCategory, type ConstraintType, type Goal, type Milestone, type Task, type GoalMemory, type MetaGoal, type MetaGoalConstraint, type CreateGoalInput, type UpdateGoalInput, type CreateMilestoneInput, type UpdateMilestoneInput, type CreateTaskInput, type UpdateTaskInput, type CreateMemoryInput, type UpdateMemoryInput, type CreateMetaGoalInput, type UpdateMetaGoalInput, type TaskFeedbackInput, type TaskFailInput, type ListOptions, type ListTasksOptions, isValidGoalHash, isGoalStatus, isGoalPriority, isTaskType, isTaskStatus, isApprovalMode, isMemoryType, isMemorySource, isFeedbackQuality, isActionType, serializeGoal, deserializeGoal, deserializeMilestone, deserializeTask, deserializeMemory, deserializeGoalMemory, deserializeMetaGoal, deserializeGoalActionLog, type SerializedGoalActionLog, TASK_TYPES, canGoalTransitionTo, isTerminalGoalStatus, canTaskTransitionTo, isTerminalTaskStatus, type GoalErrorCode, GoalError, GoalNotFoundError, GoalAlreadyExistsError, GoalInvalidStatusError, GoalBlockedError, GoalDependencyNotFoundError, GoalCircularDependencyError, MilestoneNotFoundError, MilestoneAlreadyCompleteError, TaskNotFoundError, TaskInvalidStatusError, TaskExecutionError, TaskExecutionTimeoutError, TaskApprovalRequiredError, TaskSanitizationFailedError, MemoryNotFoundError, MemoryContentTooLongError, MetaGoalNotFoundError, MetaGoalConstraintViolatedError, ApiRequestFailedError, ApiAuthenticationFailedError, ApiRateLimitedError, ApiResponseInvalidError, ApiNetworkError, ApiTimeoutError, InvalidInputError, InvalidGoalNameError, InvalidTaskTypeError, CacheError, CacheMissError, CacheStaleError, ManagerNotInitializedError, ManagerError, isGoalError, isNotFoundError, isApiError, GoalApiClient, createGoalApiClient, type GoalApiClientOptions, type TokenProvider, type PaginatedResponse, type ApiListOptions, GoalValidator, createGoalValidator, DEFAULT_GOAL_VALIDATION_CONSTRAINTS, type GoalValidationConstraints, GoalCache, createGoalCache, type GoalCacheOptions, type GoalCacheEvents, type CacheStats, type CacheType, GoalManager, createGoalManager, type GoalManagerOptions, type GoalManagerEvents, TaskGenerator, createTaskGenerator, type TaskGeneratorLLMFunction, type TaskGeneratorOptions, type TaskGeneratorEvents, type TaskSuggestion, type TaskGenerationOptions, type TaskGenerationResult, TaskSanitizer, createTaskSanitizer, type TaskSanitizerOptions, type SanitizationResult, type PathValidationResult, type SecurityIssue, MilestoneBreaker, createMilestoneBreaker, type MilestoneLLMFunction, type MilestoneBreakerOptions, type MilestoneBreakerEvents, type MilestoneSuggestion, type MilestoneBreakdownOptions, type MilestoneBreakdownResult, TaskQueue, createTaskQueue, type TaskQueueOptions, type TaskQueueEvents, type QueuedTask, type TaskFilterOptions, type TaskQueueStats, DependencyResolver, createDependencyResolver, getTransitiveDependencies, getTransitiveDependents, calculateCriticalPath, type DependencyResolverOptions, type DependencyNode, type GoalResolutionResult, type TaskDependencyNode, MetaGoalEnforcer, createMetaGoalEnforcer, metaGoalAppliesToGoal, sortMetaGoalsByPriority, getBlockingMetaGoalsForType, summarizeConstraints, type MetaGoalLLMFunction, type MetaGoalEnforcerOptions, type MetaGoalEnforcerEvents, type ConstraintViolation, type EnforcementResult, type ParsedConstraint, type ConstraintTarget, GoalCommsHandler, createGoalCommsHandler, type GoalCommsHandlerOptions, type GoalCommsHandlerEvents, type GoalNotificationSubtype, type ApprovalResponse, type ViewAction, type GoalNotification, type GoalApprovalRequest, type GoalViewRequest, type GoalViewResponse, type GoalModificationRedirect, type ProgressSummary, type CommsSendFunction, type ApprovalResponseHandler, TaskExecutor, createTaskExecutor, type TaskExecutorOptions, type TaskExecutorEvents, type PermissionCategory, type TaskExecutionHandler, type ApprovalRequestFunction, type ApprovalResult, PermissionBridge, createPermissionBridge, type PermissionBridgeOptions, type PermissionBridgeEvents, type PermissionDecision, type PermissionCheckOptions, type PermissionAuditEntry, type StoredPermission, type PermissionRule, ErrorRecovery, createErrorRecovery, type ErrorRecoveryOptions, type ErrorRecoveryEvents, type RecoveryStrategy, type ErrorCategory, type Checkpoint, type CheckpointState, type RecoveryAction, type RecoveryResult, type ErrorAnalysis, ProgressTracker, createProgressTracker, type ProgressTrackerOptions, type ProgressTrackerEvents, type GoalProgress, type MilestoneProgress, type TaskStats, type VelocityMetrics, type ProgressSnapshot, type TaskCompletionRecord, GoalReporter, createGoalReporter, type GoalReporterOptions, type GoalReporterEvents, type ReportFormat, type ReportDetailLevel, type ReportSection, type ProgressReport, type ReportPeriod, type ReportSectionContent, type ReportMetadata, type ReportOptions, type ActionItem, type RiskAssessment, ReviewScheduler, createReviewScheduler, type ReviewSchedulerOptions, type ReviewSchedulerEvents, type ReviewFrequency, type ReviewType, type ScheduledReview, type ReviewScheduleConfig, type ReviewTrigger, type ReviewResult, TaskFeedback, createTaskFeedback, type TaskFeedbackOptions, type TaskFeedbackEvents, type FeedbackRating, type FeedbackCategory, type FeedbackSentiment, type TaskFeedbackEntry, type FeedbackStatistics, type IssuePattern, type FeedbackTrend, type FeedbackQueryOptions, type FeedbackInput, type ImprovementSuggestion, GoalExporter, createGoalExporter, EXPORT_FORMAT_VERSION, type GoalExporterOptions, type GoalExporterEvents, type ExportType, type ExportScope, type ExportOptions, type ExportedGoal, type ExportedMilestone, type ExportedTask, type ExportedMemory, type ExportedMetaGoal, type ExportManifest, type ExportPackage, type ExportResult, type ExportDataProvider, GoalImporter, createGoalImporter, type GoalImporterOptions, type GoalImporterEvents, type ImportMode, type ConflictResolution, type ImportOptions, type ImportConflict, type ImportValidation, type ImportMapping, type ImportResult, type ImportDataWriter, GoalScheduler, createGoalScheduler, type GoalSchedulerOptions, type GoalSchedulerEvents, type ScheduledGoal, type GetDueGoalsFunction, type MarkGoalStartedFunction, type MarkGoalCompletedFunction, type ExecuteGoalFunction, } from './goals/index.js';
3
+ export type { ExecutionContext as TaskExecutionContext, ExecutionResult as TaskExecutionResult, Logger as GoalLogger, } from './goals/index.js';
4
+ export { ValidationError as GoalValidationError } from './goals/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './loop/index.js';
2
+ export { isValidGoalHash, isGoalStatus, isGoalPriority, isTaskType, isTaskStatus, isApprovalMode, isMemoryType, isMemorySource, isFeedbackQuality, isActionType, serializeGoal, deserializeGoal, deserializeMilestone, deserializeTask, deserializeMemory, deserializeGoalMemory, deserializeMetaGoal, deserializeGoalActionLog, TASK_TYPES, canGoalTransitionTo, isTerminalGoalStatus, canTaskTransitionTo, isTerminalTaskStatus, GoalError, GoalNotFoundError, GoalAlreadyExistsError, GoalInvalidStatusError, GoalBlockedError, GoalDependencyNotFoundError, GoalCircularDependencyError, MilestoneNotFoundError, MilestoneAlreadyCompleteError, TaskNotFoundError, TaskInvalidStatusError, TaskExecutionError, TaskExecutionTimeoutError, TaskApprovalRequiredError, TaskSanitizationFailedError, MemoryNotFoundError, MemoryContentTooLongError, MetaGoalNotFoundError, MetaGoalConstraintViolatedError, ApiRequestFailedError, ApiAuthenticationFailedError, ApiRateLimitedError, ApiResponseInvalidError, ApiNetworkError, ApiTimeoutError, InvalidInputError, InvalidGoalNameError, InvalidTaskTypeError, CacheError, CacheMissError, CacheStaleError, ManagerNotInitializedError, ManagerError, isGoalError, isNotFoundError, isApiError, GoalApiClient, createGoalApiClient, GoalValidator, createGoalValidator, DEFAULT_GOAL_VALIDATION_CONSTRAINTS, GoalCache, createGoalCache, GoalManager, createGoalManager, TaskGenerator, createTaskGenerator, TaskSanitizer, createTaskSanitizer, MilestoneBreaker, createMilestoneBreaker, TaskQueue, createTaskQueue, DependencyResolver, createDependencyResolver, getTransitiveDependencies, getTransitiveDependents, calculateCriticalPath, MetaGoalEnforcer, createMetaGoalEnforcer, metaGoalAppliesToGoal, sortMetaGoalsByPriority, getBlockingMetaGoalsForType, summarizeConstraints, GoalCommsHandler, createGoalCommsHandler, TaskExecutor, createTaskExecutor, PermissionBridge, createPermissionBridge, ErrorRecovery, createErrorRecovery, ProgressTracker, createProgressTracker, GoalReporter, createGoalReporter, ReviewScheduler, createReviewScheduler, TaskFeedback, createTaskFeedback, GoalExporter, createGoalExporter, EXPORT_FORMAT_VERSION, GoalImporter, createGoalImporter, GoalScheduler, createGoalScheduler, } from './goals/index.js';
3
+ export { ValidationError as GoalValidationError } from './goals/index.js';