task-o-matic 0.0.13 → 0.0.15

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 (144) hide show
  1. package/dist/cli/display/progress.d.ts +15 -2
  2. package/dist/cli/display/progress.d.ts.map +1 -1
  3. package/dist/cli/display/progress.js +72 -4
  4. package/dist/commands/benchmark.d.ts.map +1 -1
  5. package/dist/commands/benchmark.js +11 -3
  6. package/dist/commands/init.d.ts.map +1 -1
  7. package/dist/commands/init.js +60 -12
  8. package/dist/commands/prd.js +7 -1
  9. package/dist/commands/tasks/delete.d.ts.map +1 -1
  10. package/dist/commands/tasks/delete.js +2 -1
  11. package/dist/commands/tasks/document/add.d.ts.map +1 -1
  12. package/dist/commands/tasks/document/add.js +5 -4
  13. package/dist/commands/tasks/document/get.d.ts.map +1 -1
  14. package/dist/commands/tasks/document/get.js +2 -1
  15. package/dist/commands/tasks/list.js +2 -2
  16. package/dist/commands/tasks/next.js +4 -4
  17. package/dist/commands/tasks/plan/set.d.ts.map +1 -1
  18. package/dist/commands/tasks/plan/set.js +11 -3
  19. package/dist/commands/tasks/show.d.ts.map +1 -1
  20. package/dist/commands/tasks/show.js +2 -1
  21. package/dist/commands/tasks/status.d.ts.map +1 -1
  22. package/dist/commands/tasks/status.js +4 -3
  23. package/dist/commands/tasks/update.d.ts.map +1 -1
  24. package/dist/commands/tasks/update.js +7 -1
  25. package/dist/lib/ai-service/ai-operations.d.ts +1 -1
  26. package/dist/lib/ai-service/ai-operations.d.ts.map +1 -1
  27. package/dist/lib/ai-service/base-operations.d.ts +22 -0
  28. package/dist/lib/ai-service/base-operations.d.ts.map +1 -1
  29. package/dist/lib/ai-service/base-operations.js +29 -1
  30. package/dist/lib/ai-service/model-provider.d.ts.map +1 -1
  31. package/dist/lib/ai-service/model-provider.js +37 -6
  32. package/dist/lib/ai-service/task-operations.d.ts +2 -1
  33. package/dist/lib/ai-service/task-operations.d.ts.map +1 -1
  34. package/dist/lib/ai-service/task-operations.js +135 -173
  35. package/dist/lib/benchmark/registry.d.ts.map +1 -1
  36. package/dist/lib/benchmark/registry.js +6 -10
  37. package/dist/lib/better-t-stack-cli.d.ts +36 -21
  38. package/dist/lib/better-t-stack-cli.d.ts.map +1 -1
  39. package/dist/lib/better-t-stack-cli.js +212 -33
  40. package/dist/lib/bootstrap/cli-bootstrap.d.ts +14 -0
  41. package/dist/lib/bootstrap/cli-bootstrap.d.ts.map +1 -0
  42. package/dist/lib/bootstrap/cli-bootstrap.js +325 -0
  43. package/dist/lib/bootstrap/index.d.ts +4 -0
  44. package/dist/lib/bootstrap/index.d.ts.map +1 -0
  45. package/dist/lib/bootstrap/index.js +19 -0
  46. package/dist/lib/bootstrap/medusa-bootstrap.d.ts +14 -0
  47. package/dist/lib/bootstrap/medusa-bootstrap.d.ts.map +1 -0
  48. package/dist/lib/bootstrap/medusa-bootstrap.js +218 -0
  49. package/dist/lib/bootstrap/opentui-bootstrap.d.ts +11 -0
  50. package/dist/lib/bootstrap/opentui-bootstrap.d.ts.map +1 -0
  51. package/dist/lib/bootstrap/opentui-bootstrap.js +342 -0
  52. package/dist/lib/config-validation.d.ts +215 -0
  53. package/dist/lib/config-validation.d.ts.map +1 -0
  54. package/dist/lib/config-validation.js +246 -0
  55. package/dist/lib/config.d.ts +14 -0
  56. package/dist/lib/config.d.ts.map +1 -1
  57. package/dist/lib/config.js +37 -5
  58. package/dist/lib/storage/file-system.d.ts.map +1 -1
  59. package/dist/lib/storage/file-system.js +81 -21
  60. package/dist/lib/task-execution-core.d.ts.map +1 -1
  61. package/dist/lib/task-execution-core.js +3 -2
  62. package/dist/services/prd.d.ts +17 -0
  63. package/dist/services/prd.d.ts.map +1 -1
  64. package/dist/services/prd.js +67 -60
  65. package/dist/services/tasks.d.ts +317 -3
  66. package/dist/services/tasks.d.ts.map +1 -1
  67. package/dist/services/tasks.js +531 -185
  68. package/dist/services/workflow-ai-assistant.d.ts.map +1 -1
  69. package/dist/services/workflow-ai-assistant.js +19 -6
  70. package/dist/test/lib/ai-service/task-operations.test.d.ts +2 -0
  71. package/dist/test/lib/ai-service/task-operations.test.d.ts.map +1 -0
  72. package/dist/test/lib/ai-service/task-operations.test.js +362 -0
  73. package/dist/test/mocks/mock-ai-operations.d.ts +15 -0
  74. package/dist/test/mocks/mock-ai-operations.d.ts.map +1 -0
  75. package/dist/test/mocks/mock-ai-operations.js +107 -0
  76. package/dist/test/mocks/mock-context-builder.d.ts +10 -0
  77. package/dist/test/mocks/mock-context-builder.d.ts.map +1 -0
  78. package/dist/test/mocks/mock-context-builder.js +81 -0
  79. package/dist/test/mocks/mock-model-provider.d.ts +7 -0
  80. package/dist/test/mocks/mock-model-provider.d.ts.map +1 -0
  81. package/dist/test/mocks/mock-model-provider.js +21 -0
  82. package/dist/test/mocks/mock-service-factory.d.ts +11 -0
  83. package/dist/test/mocks/mock-service-factory.d.ts.map +1 -0
  84. package/dist/test/mocks/mock-service-factory.js +61 -0
  85. package/dist/test/mocks/mock-storage.d.ts +50 -0
  86. package/dist/test/mocks/mock-storage.d.ts.map +1 -0
  87. package/dist/test/mocks/mock-storage.js +145 -0
  88. package/dist/test/services/task-service.test.d.ts +2 -0
  89. package/dist/test/services/task-service.test.d.ts.map +1 -0
  90. package/dist/test/services/task-service.test.js +352 -0
  91. package/dist/test/test-mock-setup.d.ts +26 -0
  92. package/dist/test/test-mock-setup.d.ts.map +1 -0
  93. package/dist/test/test-mock-setup.js +41 -0
  94. package/dist/test/test-setup.d.ts +9 -0
  95. package/dist/test/test-setup.d.ts.map +1 -0
  96. package/dist/test/test-setup.js +44 -0
  97. package/dist/test/test-utils.d.ts +22 -0
  98. package/dist/test/test-utils.d.ts.map +1 -0
  99. package/dist/test/test-utils.js +37 -0
  100. package/dist/test/utils/ai-operation-utility.test.d.ts +2 -0
  101. package/dist/test/utils/ai-operation-utility.test.d.ts.map +1 -0
  102. package/dist/test/utils/ai-operation-utility.test.js +290 -0
  103. package/dist/test/utils/error-handling.test.d.ts +2 -0
  104. package/dist/test/utils/error-handling.test.d.ts.map +1 -0
  105. package/dist/test/utils/error-handling.test.js +231 -0
  106. package/dist/types/index.d.ts +36 -1
  107. package/dist/types/index.d.ts.map +1 -1
  108. package/dist/types/results.d.ts +60 -6
  109. package/dist/types/results.d.ts.map +1 -1
  110. package/dist/utils/ai-operation-utility.d.ts +142 -0
  111. package/dist/utils/ai-operation-utility.d.ts.map +1 -0
  112. package/dist/utils/ai-operation-utility.js +288 -0
  113. package/dist/utils/ai-service-factory.d.ts +10 -0
  114. package/dist/utils/ai-service-factory.d.ts.map +1 -1
  115. package/dist/utils/ai-service-factory.js +19 -1
  116. package/dist/utils/cli-validators.d.ts +2 -2
  117. package/dist/utils/cli-validators.d.ts.map +1 -1
  118. package/dist/utils/cli-validators.js +7 -6
  119. package/dist/utils/error-utils.d.ts +70 -0
  120. package/dist/utils/error-utils.d.ts.map +1 -0
  121. package/dist/utils/error-utils.js +104 -0
  122. package/dist/utils/file-utils.d.ts +49 -0
  123. package/dist/utils/file-utils.d.ts.map +1 -0
  124. package/dist/utils/file-utils.js +82 -0
  125. package/dist/utils/id-generator.d.ts +92 -0
  126. package/dist/utils/id-generator.d.ts.map +1 -0
  127. package/dist/utils/id-generator.js +146 -0
  128. package/dist/utils/model-executor-parser.d.ts +1 -1
  129. package/dist/utils/model-executor-parser.d.ts.map +1 -1
  130. package/dist/utils/model-executor-parser.js +3 -2
  131. package/dist/utils/stack-formatter.d.ts +2 -1
  132. package/dist/utils/stack-formatter.d.ts.map +1 -1
  133. package/dist/utils/stack-formatter.js +8 -2
  134. package/dist/utils/storage-utils.d.ts +49 -0
  135. package/dist/utils/storage-utils.d.ts.map +1 -0
  136. package/dist/utils/storage-utils.js +80 -0
  137. package/dist/utils/streaming-utils.d.ts +38 -0
  138. package/dist/utils/streaming-utils.d.ts.map +1 -0
  139. package/dist/utils/streaming-utils.js +56 -0
  140. package/dist/utils/task-o-matic-error.d.ts +206 -0
  141. package/dist/utils/task-o-matic-error.d.ts.map +1 -0
  142. package/dist/utils/task-o-matic-error.js +304 -0
  143. package/docs/agents/cli.md +58 -149
  144. package/package.json +2 -2
@@ -6,8 +6,11 @@ function formatStackInfo(stack) {
6
6
  if (!stack) {
7
7
  return "Not detected";
8
8
  }
9
+ const frontendStr = Array.isArray(stack.frontend)
10
+ ? stack.frontend.join(", ")
11
+ : stack.frontend;
9
12
  const parts = [
10
- `Frontend: ${stack.frontend}`,
13
+ `Frontend: ${frontendStr}`,
11
14
  `Backend: ${stack.backend}`
12
15
  ];
13
16
  if (stack.database !== 'none') {
@@ -26,5 +29,8 @@ function formatStackForContext(stack) {
26
29
  if (!stack) {
27
30
  return "";
28
31
  }
29
- return `Technology Stack: ${stack.frontend} + ${stack.backend} + ${stack.database}`;
32
+ const frontendStr = Array.isArray(stack.frontend)
33
+ ? stack.frontend.join(" + ")
34
+ : stack.frontend;
35
+ return `Technology Stack: ${frontendStr} + ${stack.backend} + ${stack.database}`;
30
36
  }
@@ -0,0 +1,49 @@
1
+ import { Task } from "../types/index.js";
2
+ /**
3
+ * Ensures a task is not null, throwing an error if it is.
4
+ * Useful for enforcing null checks after storage operations.
5
+ *
6
+ * @param task - Task that may be null
7
+ * @param taskId - ID of the task for error message
8
+ * @returns The task if not null
9
+ * @throws TaskOMaticError if task is null
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const task = await storage.getTask(taskId);
14
+ * const validTask = requireTask(task, taskId);
15
+ * console.log(validTask.title); // Safe - never null
16
+ * ```
17
+ */
18
+ export declare function requireTask(task: Task | null, taskId: string): Task;
19
+ /**
20
+ * Ensures multiple tasks are not null, throwing an error if any is null.
21
+ *
22
+ * @param tasks - Array of tasks that may contain nulls
23
+ * @param context - Context for error message (e.g., "subtasks", "dependencies")
24
+ * @returns Array of tasks with nulls filtered out
25
+ * @throws TaskOMaticError if any task is null
26
+ */
27
+ export declare function requireTasks(tasks: (Task | null)[], context?: string): Task[];
28
+ /**
29
+ * Filters out null tasks from an array, with type narrowing.
30
+ *
31
+ * @param tasks - Array of tasks that may contain nulls
32
+ * @returns Array of tasks with nulls removed
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const tasks = await Promise.all(ids.map(id => storage.getTask(id)));
37
+ * const validTasks = filterNullTasks(tasks);
38
+ * // validTasks has type Task[] (no null)
39
+ * ```
40
+ */
41
+ export declare function filterNullTasks(tasks: (Task | null)[]): Task[];
42
+ /**
43
+ * Validates that a task ID is a non-empty string.
44
+ *
45
+ * @param taskId - Task ID to validate
46
+ * @throws TaskOMaticError if task ID is invalid
47
+ */
48
+ export declare function validateTaskId(taskId: string): void;
49
+ //# sourceMappingURL=storage-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-utils.d.ts","sourceRoot":"","sources":["../../src/utils/storage-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKnE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EACtB,OAAO,GAAE,MAAgB,GACxB,IAAI,EAAE,CAoBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAOnD"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireTask = requireTask;
4
+ exports.requireTasks = requireTasks;
5
+ exports.filterNullTasks = filterNullTasks;
6
+ exports.validateTaskId = validateTaskId;
7
+ const task_o_matic_error_1 = require("./task-o-matic-error");
8
+ /**
9
+ * Ensures a task is not null, throwing an error if it is.
10
+ * Useful for enforcing null checks after storage operations.
11
+ *
12
+ * @param task - Task that may be null
13
+ * @param taskId - ID of the task for error message
14
+ * @returns The task if not null
15
+ * @throws TaskOMaticError if task is null
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const task = await storage.getTask(taskId);
20
+ * const validTask = requireTask(task, taskId);
21
+ * console.log(validTask.title); // Safe - never null
22
+ * ```
23
+ */
24
+ function requireTask(task, taskId) {
25
+ if (!task) {
26
+ throw (0, task_o_matic_error_1.formatTaskNotFoundError)(taskId);
27
+ }
28
+ return task;
29
+ }
30
+ /**
31
+ * Ensures multiple tasks are not null, throwing an error if any is null.
32
+ *
33
+ * @param tasks - Array of tasks that may contain nulls
34
+ * @param context - Context for error message (e.g., "subtasks", "dependencies")
35
+ * @returns Array of tasks with nulls filtered out
36
+ * @throws TaskOMaticError if any task is null
37
+ */
38
+ function requireTasks(tasks, context = "tasks") {
39
+ const validTasks = [];
40
+ const missingIds = [];
41
+ tasks.forEach((task, index) => {
42
+ if (!task) {
43
+ missingIds.push(`index ${index}`);
44
+ }
45
+ else {
46
+ validTasks.push(task);
47
+ }
48
+ });
49
+ if (missingIds.length > 0) {
50
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.STORAGE_INTEGRITY_ERROR, `Missing ${context}: ${missingIds.join(", ")}`);
51
+ }
52
+ return validTasks;
53
+ }
54
+ /**
55
+ * Filters out null tasks from an array, with type narrowing.
56
+ *
57
+ * @param tasks - Array of tasks that may contain nulls
58
+ * @returns Array of tasks with nulls removed
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const tasks = await Promise.all(ids.map(id => storage.getTask(id)));
63
+ * const validTasks = filterNullTasks(tasks);
64
+ * // validTasks has type Task[] (no null)
65
+ * ```
66
+ */
67
+ function filterNullTasks(tasks) {
68
+ return tasks.filter((task) => task !== null);
69
+ }
70
+ /**
71
+ * Validates that a task ID is a non-empty string.
72
+ *
73
+ * @param taskId - Task ID to validate
74
+ * @throws TaskOMaticError if task ID is invalid
75
+ */
76
+ function validateTaskId(taskId) {
77
+ if (!taskId || typeof taskId !== "string" || !taskId.trim()) {
78
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Invalid task ID: must be a non-empty string");
79
+ }
80
+ }
@@ -0,0 +1,38 @@
1
+ import { StreamingOptions } from "../types/index.js";
2
+ /**
3
+ * Token usage metrics from AI operations
4
+ */
5
+ export interface TokenUsage {
6
+ prompt: number;
7
+ completion: number;
8
+ total: number;
9
+ }
10
+ export interface MetricsTracker {
11
+ tokenUsage: TokenUsage;
12
+ timeToFirstToken: number | undefined;
13
+ }
14
+ export interface MetricsStreamingResult {
15
+ options: StreamingOptions;
16
+ getMetrics: () => MetricsTracker;
17
+ }
18
+ /**
19
+ * Creates streaming options with automatic metrics tracking.
20
+ * Wraps provided streaming callbacks to capture token usage and timing metrics.
21
+ *
22
+ * @param streamingOptions - Optional base streaming options to wrap
23
+ * @param aiStartTime - Optional timestamp when AI operation started (for measuring time to first token)
24
+ * @returns Object containing wrapped streaming options and metrics getter
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const aiStartTime = Date.now();
29
+ * const { options, getMetrics } = createMetricsStreamingOptions(userCallbacks, aiStartTime);
30
+ *
31
+ * await generateText({ model, prompt, ...options });
32
+ *
33
+ * const { tokenUsage, timeToFirstToken } = getMetrics();
34
+ * console.log(`Used ${tokenUsage.total} tokens in ${timeToFirstToken}ms`);
35
+ * ```
36
+ */
37
+ export declare function createMetricsStreamingOptions(streamingOptions?: StreamingOptions, aiStartTime?: number): MetricsStreamingResult;
38
+ //# sourceMappingURL=streaming-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming-utils.d.ts","sourceRoot":"","sources":["../../src/utils/streaming-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,MAAM,cAAc,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,MAAM,GACnB,sBAAsB,CAsCxB"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMetricsStreamingOptions = createMetricsStreamingOptions;
4
+ /**
5
+ * Creates streaming options with automatic metrics tracking.
6
+ * Wraps provided streaming callbacks to capture token usage and timing metrics.
7
+ *
8
+ * @param streamingOptions - Optional base streaming options to wrap
9
+ * @param aiStartTime - Optional timestamp when AI operation started (for measuring time to first token)
10
+ * @returns Object containing wrapped streaming options and metrics getter
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const aiStartTime = Date.now();
15
+ * const { options, getMetrics } = createMetricsStreamingOptions(userCallbacks, aiStartTime);
16
+ *
17
+ * await generateText({ model, prompt, ...options });
18
+ *
19
+ * const { tokenUsage, timeToFirstToken } = getMetrics();
20
+ * console.log(`Used ${tokenUsage.total} tokens in ${timeToFirstToken}ms`);
21
+ * ```
22
+ */
23
+ function createMetricsStreamingOptions(streamingOptions, aiStartTime) {
24
+ let tokenUsage = { prompt: 0, completion: 0, total: 0 };
25
+ let timeToFirstToken = undefined;
26
+ const wrappedOptions = {
27
+ onFinish: async (result) => {
28
+ // Extract token usage from result
29
+ if (result.usage) {
30
+ tokenUsage = {
31
+ prompt: result.usage.inputTokens || result.usage.promptTokens || 0,
32
+ completion: result.usage.outputTokens || result.usage.completionTokens || 0,
33
+ total: result.usage.totalTokens || 0,
34
+ };
35
+ }
36
+ // Call original onFinish callback if provided
37
+ await streamingOptions?.onFinish?.(result);
38
+ },
39
+ onChunk: (chunk) => {
40
+ // Measure time to first token (ignore empty/whitespace chunks)
41
+ if (chunk && chunk.trim() && !timeToFirstToken && aiStartTime) {
42
+ timeToFirstToken = Date.now() - aiStartTime;
43
+ }
44
+ // Call original onChunk callback if provided
45
+ streamingOptions?.onChunk?.(chunk);
46
+ },
47
+ onError: (error) => {
48
+ // Pass through error callback
49
+ streamingOptions?.onError?.(error);
50
+ },
51
+ };
52
+ return {
53
+ options: wrappedOptions,
54
+ getMetrics: () => ({ tokenUsage, timeToFirstToken }),
55
+ };
56
+ }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * TaskOMaticError - Standardized error class for TaskOMatic
3
+ *
4
+ * Provides consistent error handling with context, suggestions, and typing.
5
+ * All errors in the system should use this class or one of the helper functions
6
+ * to ensure consistent error reporting and debugging experience.
7
+ *
8
+ * @example Basic usage
9
+ * ```typescript
10
+ * throw new TaskOMaticError("Task not found", {
11
+ * code: "TASK_NOT_FOUND",
12
+ * context: "Attempted to retrieve task ID: 123",
13
+ * suggestions: [
14
+ * "Verify the task ID is correct",
15
+ * "Check if the task was deleted"
16
+ * ]
17
+ * });
18
+ * ```
19
+ *
20
+ * @example With cause chain
21
+ * ```typescript
22
+ * try {
23
+ * await storage.getTask(id);
24
+ * } catch (error) {
25
+ * throw new TaskOMaticError("Failed to retrieve task", {
26
+ * code: "STORAGE_ERROR",
27
+ * cause: error instanceof Error ? error : new Error(String(error)),
28
+ * context: `Task ID: ${id}`,
29
+ * suggestions: ["Check storage permissions", "Verify storage is initialized"]
30
+ * });
31
+ * }
32
+ * ```
33
+ *
34
+ * @example With metadata
35
+ * ```typescript
36
+ * throw new TaskOMaticError("AI operation timed out", {
37
+ * code: "AI_OPERATION_FAILED",
38
+ * metadata: {
39
+ * operation: "task-breakdown",
40
+ * duration: 30000,
41
+ * retryAttempts: 3
42
+ * },
43
+ * suggestions: ["Increase timeout", "Check AI service status"]
44
+ * });
45
+ * ```
46
+ */
47
+ export declare class TaskOMaticError extends Error {
48
+ /**
49
+ * Error code for categorization
50
+ */
51
+ code: string;
52
+ /**
53
+ * Additional context information
54
+ */
55
+ context?: string;
56
+ /**
57
+ * Actionable suggestions for resolving the error
58
+ */
59
+ suggestions?: string[];
60
+ /**
61
+ * Original error that caused this error (if applicable)
62
+ */
63
+ cause?: Error;
64
+ /**
65
+ * Timestamp when the error occurred
66
+ */
67
+ timestamp: number;
68
+ /**
69
+ * Additional metadata for debugging
70
+ */
71
+ metadata?: Record<string, unknown>;
72
+ /**
73
+ * Create a new TaskOMaticError
74
+ *
75
+ * @param message - Error message
76
+ * @param options - Additional error options
77
+ */
78
+ constructor(message: string, options: {
79
+ code: string;
80
+ context?: string;
81
+ suggestions?: string[];
82
+ cause?: Error;
83
+ metadata?: Record<string, unknown>;
84
+ });
85
+ /**
86
+ * Get full error details as a formatted string
87
+ */
88
+ getDetails(): string;
89
+ /**
90
+ * Get error details as a structured object
91
+ */
92
+ toJSON(): {
93
+ name: string;
94
+ code: string;
95
+ message: string;
96
+ context?: string;
97
+ suggestions?: string[];
98
+ cause?: string;
99
+ timestamp: number;
100
+ metadata?: Record<string, unknown>;
101
+ stack?: string;
102
+ };
103
+ }
104
+ /**
105
+ * Standard error codes for TaskOMatic
106
+ */
107
+ export declare const TaskOMaticErrorCodes: {
108
+ readonly UNEXPECTED_ERROR: "TASK_O_MATIC_001";
109
+ readonly INVALID_INPUT: "TASK_O_MATIC_002";
110
+ readonly CONFIGURATION_ERROR: "TASK_O_MATIC_003";
111
+ readonly TASK_NOT_FOUND: "TASK_O_MATIC_101";
112
+ readonly TASK_ALREADY_EXISTS: "TASK_O_MATIC_102";
113
+ readonly INVALID_TASK_STATUS: "TASK_O_MATIC_103";
114
+ readonly TASK_OPERATION_FAILED: "TASK_O_MATIC_104";
115
+ readonly STORAGE_ERROR: "TASK_O_MATIC_201";
116
+ readonly STORAGE_NOT_INITIALIZED: "TASK_O_MATIC_202";
117
+ readonly STORAGE_INTEGRITY_ERROR: "TASK_O_MATIC_203";
118
+ readonly AI_OPERATION_FAILED: "TASK_O_MATIC_301";
119
+ readonly AI_CONFIGURATION_ERROR: "TASK_O_MATIC_302";
120
+ readonly AI_RATE_LIMIT: "TASK_O_MATIC_303";
121
+ readonly WORKFLOW_VALIDATION_ERROR: "TASK_O_MATIC_401";
122
+ readonly WORKFLOW_EXECUTION_ERROR: "TASK_O_MATIC_402";
123
+ readonly PRD_PARSING_ERROR: "TASK_O_MATIC_501";
124
+ readonly PRD_GENERATION_ERROR: "TASK_O_MATIC_502";
125
+ readonly PRD_VALIDATION_ERROR: "TASK_O_MATIC_503";
126
+ };
127
+ type TaskOMaticErrorCode = (typeof TaskOMaticErrorCodes)[keyof typeof TaskOMaticErrorCodes];
128
+ /**
129
+ * Create a standardized error with context and suggestions
130
+ *
131
+ * Helper function to create TaskOMaticError instances with proper error codes
132
+ * from the TaskOMaticErrorCodes constants.
133
+ *
134
+ * @param code - Error code from TaskOMaticErrorCodes
135
+ * @param message - Human-readable error message
136
+ * @param options - Additional error options
137
+ * @returns Configured TaskOMaticError instance
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * throw createStandardError(
142
+ * TaskOMaticErrorCodes.TASK_NOT_FOUND,
143
+ * "Task with ID '123' not found",
144
+ * {
145
+ * context: "User attempted to retrieve non-existent task",
146
+ * suggestions: ["Verify task ID", "List all tasks to see available IDs"]
147
+ * }
148
+ * );
149
+ * ```
150
+ */
151
+ export declare function createStandardError(code: TaskOMaticErrorCode, message: string, options?: {
152
+ context?: string;
153
+ suggestions?: string[];
154
+ cause?: Error;
155
+ metadata?: Record<string, unknown>;
156
+ }): TaskOMaticError;
157
+ /**
158
+ * Format an existing error into a TaskOMaticError with context and suggestions
159
+ *
160
+ * Useful for wrapping caught errors with additional context while preserving
161
+ * the original error as the cause.
162
+ *
163
+ * @param error - Original error to wrap
164
+ * @param code - Error code from TaskOMaticErrorCodes
165
+ * @param options - Additional error options
166
+ * @returns TaskOMaticError wrapping the original error
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * try {
171
+ * await dangerousOperation();
172
+ * } catch (error) {
173
+ * throw formatStandardError(
174
+ * error,
175
+ * TaskOMaticErrorCodes.STORAGE_ERROR,
176
+ * {
177
+ * context: "Failed during task persistence",
178
+ * suggestions: ["Check disk space", "Verify write permissions"]
179
+ * }
180
+ * );
181
+ * }
182
+ * ```
183
+ */
184
+ export declare function formatStandardError(error: unknown, code: TaskOMaticErrorCode, options?: {
185
+ context?: string;
186
+ suggestions?: string[];
187
+ metadata?: Record<string, unknown>;
188
+ }): TaskOMaticError;
189
+ /**
190
+ * Type guard for TaskOMaticError
191
+ */
192
+ export declare function isTaskOMaticError(error: unknown): error is TaskOMaticError;
193
+ /**
194
+ * Common error formatting functions
195
+ */
196
+ export declare function formatTaskNotFoundError(taskId: string): TaskOMaticError;
197
+ export declare function formatInvalidStatusTransitionError(fromStatus: string, toStatus: string): TaskOMaticError;
198
+ export declare function formatStorageError(operation: string, cause?: Error): TaskOMaticError;
199
+ export declare function formatAIOperationError(operation: string, cause?: Error): TaskOMaticError;
200
+ /**
201
+ * Backward compatibility wrapper
202
+ * Maintains existing error handling patterns while using new error system
203
+ */
204
+ export declare function wrapErrorForBackwardCompatibility(error: unknown, context?: string): Error;
205
+ export {};
206
+ //# sourceMappingURL=task-o-matic-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-o-matic-error.d.ts","sourceRoot":"","sources":["../../src/utils/task-o-matic-error.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;OAEG;IACH,IAAI,EAAE,M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