@outputai/cli 0.1.4-dev.0 → 0.1.4

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 (278) hide show
  1. package/package.json +4 -4
  2. package/dist/api/generated/api.d.ts +0 -820
  3. package/dist/api/generated/api.js +0 -226
  4. package/dist/api/http_client.d.ts +0 -27
  5. package/dist/api/http_client.js +0 -71
  6. package/dist/api/orval_post_process.d.ts +0 -11
  7. package/dist/api/orval_post_process.js +0 -46
  8. package/dist/api/parser.d.ts +0 -17
  9. package/dist/api/parser.js +0 -68
  10. package/dist/assets/config/costs.yml +0 -309
  11. package/dist/assets/docker/docker-compose-dev.yml +0 -146
  12. package/dist/commands/credentials/edit.d.ts +0 -10
  13. package/dist/commands/credentials/edit.js +0 -67
  14. package/dist/commands/credentials/edit.spec.d.ts +0 -1
  15. package/dist/commands/credentials/edit.spec.js +0 -73
  16. package/dist/commands/credentials/get.d.ts +0 -13
  17. package/dist/commands/credentials/get.js +0 -46
  18. package/dist/commands/credentials/get.spec.d.ts +0 -1
  19. package/dist/commands/credentials/get.spec.js +0 -74
  20. package/dist/commands/credentials/init.d.ts +0 -11
  21. package/dist/commands/credentials/init.js +0 -45
  22. package/dist/commands/credentials/init.spec.d.ts +0 -1
  23. package/dist/commands/credentials/init.spec.js +0 -68
  24. package/dist/commands/credentials/show.d.ts +0 -10
  25. package/dist/commands/credentials/show.js +0 -33
  26. package/dist/commands/credentials/show.spec.d.ts +0 -1
  27. package/dist/commands/credentials/show.spec.js +0 -57
  28. package/dist/commands/dev/eject.d.ts +0 -11
  29. package/dist/commands/dev/eject.js +0 -58
  30. package/dist/commands/dev/eject.spec.d.ts +0 -1
  31. package/dist/commands/dev/eject.spec.js +0 -109
  32. package/dist/commands/dev/index.d.ts +0 -14
  33. package/dist/commands/dev/index.js +0 -173
  34. package/dist/commands/dev/index.spec.d.ts +0 -1
  35. package/dist/commands/dev/index.spec.js +0 -239
  36. package/dist/commands/init.d.ts +0 -12
  37. package/dist/commands/init.js +0 -37
  38. package/dist/commands/init.spec.d.ts +0 -1
  39. package/dist/commands/init.spec.js +0 -100
  40. package/dist/commands/update.d.ts +0 -14
  41. package/dist/commands/update.js +0 -120
  42. package/dist/commands/update.spec.d.ts +0 -1
  43. package/dist/commands/update.spec.js +0 -178
  44. package/dist/commands/workflow/cost.d.ts +0 -16
  45. package/dist/commands/workflow/cost.js +0 -71
  46. package/dist/commands/workflow/cost.spec.d.ts +0 -1
  47. package/dist/commands/workflow/cost.spec.js +0 -47
  48. package/dist/commands/workflow/dataset/generate.d.ts +0 -22
  49. package/dist/commands/workflow/dataset/generate.js +0 -143
  50. package/dist/commands/workflow/dataset/list.d.ts +0 -12
  51. package/dist/commands/workflow/dataset/list.js +0 -87
  52. package/dist/commands/workflow/debug.d.ts +0 -16
  53. package/dist/commands/workflow/debug.js +0 -60
  54. package/dist/commands/workflow/debug.spec.d.ts +0 -1
  55. package/dist/commands/workflow/debug.spec.js +0 -34
  56. package/dist/commands/workflow/generate.d.ts +0 -17
  57. package/dist/commands/workflow/generate.js +0 -85
  58. package/dist/commands/workflow/generate.spec.d.ts +0 -1
  59. package/dist/commands/workflow/generate.spec.js +0 -115
  60. package/dist/commands/workflow/list.d.ts +0 -22
  61. package/dist/commands/workflow/list.js +0 -152
  62. package/dist/commands/workflow/list.spec.d.ts +0 -1
  63. package/dist/commands/workflow/list.spec.js +0 -99
  64. package/dist/commands/workflow/plan.d.ts +0 -12
  65. package/dist/commands/workflow/plan.js +0 -66
  66. package/dist/commands/workflow/plan.spec.d.ts +0 -1
  67. package/dist/commands/workflow/plan.spec.js +0 -341
  68. package/dist/commands/workflow/reset.d.ts +0 -14
  69. package/dist/commands/workflow/reset.js +0 -51
  70. package/dist/commands/workflow/result.d.ts +0 -13
  71. package/dist/commands/workflow/result.js +0 -46
  72. package/dist/commands/workflow/result.spec.d.ts +0 -1
  73. package/dist/commands/workflow/result.spec.js +0 -23
  74. package/dist/commands/workflow/run.d.ts +0 -16
  75. package/dist/commands/workflow/run.js +0 -97
  76. package/dist/commands/workflow/run.spec.d.ts +0 -1
  77. package/dist/commands/workflow/run.spec.js +0 -110
  78. package/dist/commands/workflow/runs/list.d.ts +0 -14
  79. package/dist/commands/workflow/runs/list.js +0 -104
  80. package/dist/commands/workflow/start.d.ts +0 -15
  81. package/dist/commands/workflow/start.js +0 -62
  82. package/dist/commands/workflow/start.spec.d.ts +0 -1
  83. package/dist/commands/workflow/start.spec.js +0 -28
  84. package/dist/commands/workflow/status.d.ts +0 -13
  85. package/dist/commands/workflow/status.js +0 -57
  86. package/dist/commands/workflow/status.spec.d.ts +0 -1
  87. package/dist/commands/workflow/status.spec.js +0 -33
  88. package/dist/commands/workflow/stop.d.ts +0 -10
  89. package/dist/commands/workflow/stop.js +0 -31
  90. package/dist/commands/workflow/stop.spec.d.ts +0 -1
  91. package/dist/commands/workflow/stop.spec.js +0 -17
  92. package/dist/commands/workflow/terminate.d.ts +0 -13
  93. package/dist/commands/workflow/terminate.js +0 -39
  94. package/dist/commands/workflow/test_eval.d.ts +0 -20
  95. package/dist/commands/workflow/test_eval.js +0 -151
  96. package/dist/config.d.ts +0 -47
  97. package/dist/config.js +0 -47
  98. package/dist/generated/framework_version.json +0 -3
  99. package/dist/hooks/init.d.ts +0 -3
  100. package/dist/hooks/init.js +0 -30
  101. package/dist/hooks/init.spec.d.ts +0 -1
  102. package/dist/hooks/init.spec.js +0 -54
  103. package/dist/index.d.ts +0 -1
  104. package/dist/index.js +0 -1
  105. package/dist/index.spec.d.ts +0 -1
  106. package/dist/index.spec.js +0 -6
  107. package/dist/services/claude_client.d.ts +0 -30
  108. package/dist/services/claude_client.integration.test.d.ts +0 -1
  109. package/dist/services/claude_client.integration.test.js +0 -43
  110. package/dist/services/claude_client.js +0 -215
  111. package/dist/services/claude_client.spec.d.ts +0 -1
  112. package/dist/services/claude_client.spec.js +0 -145
  113. package/dist/services/coding_agents.d.ts +0 -36
  114. package/dist/services/coding_agents.js +0 -236
  115. package/dist/services/coding_agents.spec.d.ts +0 -1
  116. package/dist/services/coding_agents.spec.js +0 -256
  117. package/dist/services/copy_assets.spec.d.ts +0 -1
  118. package/dist/services/copy_assets.spec.js +0 -22
  119. package/dist/services/cost_calculator.d.ts +0 -18
  120. package/dist/services/cost_calculator.js +0 -359
  121. package/dist/services/cost_calculator.spec.d.ts +0 -1
  122. package/dist/services/cost_calculator.spec.js +0 -540
  123. package/dist/services/credentials_service.d.ts +0 -12
  124. package/dist/services/credentials_service.integration.test.d.ts +0 -1
  125. package/dist/services/credentials_service.integration.test.js +0 -66
  126. package/dist/services/credentials_service.js +0 -64
  127. package/dist/services/credentials_service.spec.d.ts +0 -1
  128. package/dist/services/credentials_service.spec.js +0 -106
  129. package/dist/services/datasets.d.ts +0 -20
  130. package/dist/services/datasets.js +0 -132
  131. package/dist/services/docker.d.ts +0 -39
  132. package/dist/services/docker.js +0 -160
  133. package/dist/services/docker.spec.d.ts +0 -1
  134. package/dist/services/docker.spec.js +0 -124
  135. package/dist/services/env_configurator.d.ts +0 -15
  136. package/dist/services/env_configurator.js +0 -163
  137. package/dist/services/env_configurator.spec.d.ts +0 -1
  138. package/dist/services/env_configurator.spec.js +0 -192
  139. package/dist/services/generate_plan_name@v1.prompt +0 -24
  140. package/dist/services/messages.d.ts +0 -9
  141. package/dist/services/messages.js +0 -338
  142. package/dist/services/messages.spec.d.ts +0 -1
  143. package/dist/services/messages.spec.js +0 -55
  144. package/dist/services/npm_update_service.d.ts +0 -6
  145. package/dist/services/npm_update_service.js +0 -87
  146. package/dist/services/npm_update_service.spec.d.ts +0 -1
  147. package/dist/services/npm_update_service.spec.js +0 -104
  148. package/dist/services/project_scaffold.d.ts +0 -31
  149. package/dist/services/project_scaffold.js +0 -212
  150. package/dist/services/project_scaffold.spec.d.ts +0 -1
  151. package/dist/services/project_scaffold.spec.js +0 -122
  152. package/dist/services/s3_trace_downloader.d.ts +0 -12
  153. package/dist/services/s3_trace_downloader.js +0 -57
  154. package/dist/services/template_processor.d.ts +0 -14
  155. package/dist/services/template_processor.js +0 -57
  156. package/dist/services/trace_reader.d.ts +0 -16
  157. package/dist/services/trace_reader.js +0 -57
  158. package/dist/services/trace_reader.spec.d.ts +0 -1
  159. package/dist/services/trace_reader.spec.js +0 -78
  160. package/dist/services/version_check.d.ts +0 -6
  161. package/dist/services/version_check.js +0 -52
  162. package/dist/services/version_check.spec.d.ts +0 -1
  163. package/dist/services/version_check.spec.js +0 -106
  164. package/dist/services/workflow_builder.d.ts +0 -16
  165. package/dist/services/workflow_builder.js +0 -86
  166. package/dist/services/workflow_builder.spec.d.ts +0 -1
  167. package/dist/services/workflow_builder.spec.js +0 -165
  168. package/dist/services/workflow_generator.d.ts +0 -5
  169. package/dist/services/workflow_generator.js +0 -40
  170. package/dist/services/workflow_generator.spec.d.ts +0 -1
  171. package/dist/services/workflow_generator.spec.js +0 -77
  172. package/dist/services/workflow_planner.d.ts +0 -15
  173. package/dist/services/workflow_planner.js +0 -48
  174. package/dist/services/workflow_planner.spec.d.ts +0 -1
  175. package/dist/services/workflow_planner.spec.js +0 -122
  176. package/dist/services/workflow_runs.d.ts +0 -14
  177. package/dist/services/workflow_runs.js +0 -25
  178. package/dist/templates/agent_instructions/CLAUDE.md.template +0 -19
  179. package/dist/templates/agent_instructions/dotclaude/settings.json.template +0 -29
  180. package/dist/templates/project/.env.example.template +0 -9
  181. package/dist/templates/project/.gitignore.template +0 -35
  182. package/dist/templates/project/README.md.template +0 -100
  183. package/dist/templates/project/config/costs.yml.template +0 -29
  184. package/dist/templates/project/package.json.template +0 -25
  185. package/dist/templates/project/src/clients/jina.ts.template +0 -30
  186. package/dist/templates/project/src/shared/utils/string.ts.template +0 -3
  187. package/dist/templates/project/src/shared/utils/url.ts.template +0 -15
  188. package/dist/templates/project/src/workflows/blog_evaluator/evaluators.ts.template +0 -23
  189. package/dist/templates/project/src/workflows/blog_evaluator/prompts/signal_noise@v1.prompt.template +0 -26
  190. package/dist/templates/project/src/workflows/blog_evaluator/scenarios/paulgraham_hwh.json.template +0 -3
  191. package/dist/templates/project/src/workflows/blog_evaluator/steps.ts.template +0 -27
  192. package/dist/templates/project/src/workflows/blog_evaluator/types.ts.template +0 -30
  193. package/dist/templates/project/src/workflows/blog_evaluator/utils.ts.template +0 -15
  194. package/dist/templates/project/src/workflows/blog_evaluator/workflow.ts.template +0 -27
  195. package/dist/templates/project/tsconfig.json.template +0 -20
  196. package/dist/templates/workflow/README.md.template +0 -216
  197. package/dist/templates/workflow/evaluators.ts.template +0 -21
  198. package/dist/templates/workflow/prompts/example@v1.prompt.template +0 -15
  199. package/dist/templates/workflow/scenarios/test_input.json.template +0 -3
  200. package/dist/templates/workflow/steps.ts.template +0 -20
  201. package/dist/templates/workflow/types.ts.template +0 -13
  202. package/dist/templates/workflow/workflow.ts.template +0 -23
  203. package/dist/test_helpers/mocks.d.ts +0 -38
  204. package/dist/test_helpers/mocks.js +0 -77
  205. package/dist/types/cost.d.ts +0 -149
  206. package/dist/types/cost.js +0 -6
  207. package/dist/types/domain.d.ts +0 -20
  208. package/dist/types/domain.js +0 -4
  209. package/dist/types/errors.d.ts +0 -68
  210. package/dist/types/errors.js +0 -100
  211. package/dist/types/errors.spec.d.ts +0 -1
  212. package/dist/types/errors.spec.js +0 -18
  213. package/dist/types/generator.d.ts +0 -26
  214. package/dist/types/generator.js +0 -1
  215. package/dist/types/trace.d.ts +0 -161
  216. package/dist/types/trace.js +0 -18
  217. package/dist/utils/claude.d.ts +0 -5
  218. package/dist/utils/claude.js +0 -19
  219. package/dist/utils/claude.spec.d.ts +0 -1
  220. package/dist/utils/claude.spec.js +0 -119
  221. package/dist/utils/constants.d.ts +0 -5
  222. package/dist/utils/constants.js +0 -4
  223. package/dist/utils/cost_formatter.d.ts +0 -5
  224. package/dist/utils/cost_formatter.js +0 -218
  225. package/dist/utils/date_formatter.d.ts +0 -23
  226. package/dist/utils/date_formatter.js +0 -49
  227. package/dist/utils/env_loader.d.ts +0 -1
  228. package/dist/utils/env_loader.js +0 -22
  229. package/dist/utils/env_loader.spec.d.ts +0 -1
  230. package/dist/utils/env_loader.spec.js +0 -43
  231. package/dist/utils/error_handler.d.ts +0 -8
  232. package/dist/utils/error_handler.js +0 -71
  233. package/dist/utils/error_utils.d.ts +0 -24
  234. package/dist/utils/error_utils.js +0 -87
  235. package/dist/utils/file_system.d.ts +0 -3
  236. package/dist/utils/file_system.js +0 -33
  237. package/dist/utils/format_workflow_result.d.ts +0 -5
  238. package/dist/utils/format_workflow_result.js +0 -18
  239. package/dist/utils/format_workflow_result.spec.d.ts +0 -1
  240. package/dist/utils/format_workflow_result.spec.js +0 -81
  241. package/dist/utils/framework_version.d.ts +0 -4
  242. package/dist/utils/framework_version.js +0 -4
  243. package/dist/utils/framework_version.spec.d.ts +0 -1
  244. package/dist/utils/framework_version.spec.js +0 -13
  245. package/dist/utils/header_utils.d.ts +0 -12
  246. package/dist/utils/header_utils.js +0 -29
  247. package/dist/utils/header_utils.spec.d.ts +0 -1
  248. package/dist/utils/header_utils.spec.js +0 -52
  249. package/dist/utils/input_parser.d.ts +0 -1
  250. package/dist/utils/input_parser.js +0 -19
  251. package/dist/utils/output_formatter.d.ts +0 -2
  252. package/dist/utils/output_formatter.js +0 -11
  253. package/dist/utils/paths.d.ts +0 -25
  254. package/dist/utils/paths.js +0 -36
  255. package/dist/utils/process.d.ts +0 -4
  256. package/dist/utils/process.js +0 -50
  257. package/dist/utils/resolve_input.d.ts +0 -1
  258. package/dist/utils/resolve_input.js +0 -22
  259. package/dist/utils/scenario_resolver.d.ts +0 -9
  260. package/dist/utils/scenario_resolver.js +0 -93
  261. package/dist/utils/scenario_resolver.spec.d.ts +0 -1
  262. package/dist/utils/scenario_resolver.spec.js +0 -214
  263. package/dist/utils/secret_sanitizer.d.ts +0 -1
  264. package/dist/utils/secret_sanitizer.js +0 -29
  265. package/dist/utils/sleep.d.ts +0 -5
  266. package/dist/utils/sleep.js +0 -5
  267. package/dist/utils/template.d.ts +0 -9
  268. package/dist/utils/template.js +0 -30
  269. package/dist/utils/template.spec.d.ts +0 -1
  270. package/dist/utils/template.spec.js +0 -77
  271. package/dist/utils/trace_extractor.d.ts +0 -27
  272. package/dist/utils/trace_extractor.js +0 -53
  273. package/dist/utils/trace_formatter.d.ts +0 -11
  274. package/dist/utils/trace_formatter.js +0 -402
  275. package/dist/utils/validation.d.ts +0 -13
  276. package/dist/utils/validation.js +0 -25
  277. package/dist/utils/validation.spec.d.ts +0 -1
  278. package/dist/utils/validation.spec.js +0 -140
@@ -1,402 +0,0 @@
1
- import Table from 'cli-table3';
2
- import { ux } from '@oclif/core';
3
- import { formatOutput } from '#utils/output_formatter.js';
4
- import { formatDuration } from '#utils/date_formatter.js';
5
- import { getErrorMessage } from '#utils/error_utils.js';
6
- import { isTraceEvent, isValidTimestamp } from '#types/trace.js';
7
- export { formatDuration };
8
- const TRUNCATION = {
9
- SHORT: 50,
10
- STANDARD: 120,
11
- SUFFIX: '...',
12
- SUFFIX_VERBOSE: '... (truncated)'
13
- };
14
- const TREE_CHARS = {
15
- BRANCH: '├─ ',
16
- LAST: '└─ ',
17
- VERTICAL: '│ ',
18
- SPACE: ' ',
19
- DETAIL_BRANCH: '│ ',
20
- DETAIL_LAST: ' '
21
- };
22
- const HEADER_DIVIDER = '═'.repeat(60);
23
- const colors = {
24
- workflowHeader: (text) => ux.colorize('bold', ux.colorize('cyan', text)),
25
- stepHeader: (text) => ux.colorize('yellow', text),
26
- internalStep: (text) => ux.colorize('dim', text),
27
- label: (text) => ux.colorize('blue', text),
28
- error: (text) => ux.colorize('red', text),
29
- success: (text) => ux.colorize('green', text)
30
- };
31
- const truncate = (value, maxLength = TRUNCATION.STANDARD, suffix = TRUNCATION.SUFFIX_VERBOSE, recursive = false) => {
32
- if (value === null || value === undefined) {
33
- return value;
34
- }
35
- if (typeof value === 'string') {
36
- if (value.length <= maxLength) {
37
- return value;
38
- }
39
- return `${value.substring(0, maxLength)}${suffix}`;
40
- }
41
- if (typeof value === 'number' || typeof value === 'boolean') {
42
- if (recursive) {
43
- return value;
44
- }
45
- return String(value);
46
- }
47
- if (!recursive) {
48
- const str = JSON.stringify(value);
49
- if (str.length <= maxLength) {
50
- return str;
51
- }
52
- return `${str.substring(0, maxLength)}${suffix}`;
53
- }
54
- if (Array.isArray(value)) {
55
- return value.map(item => truncate(item, maxLength, suffix, true));
56
- }
57
- if (typeof value === 'object') {
58
- return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, truncate(v, maxLength, suffix, true)]));
59
- }
60
- return value;
61
- };
62
- const truncateShort = (value) => {
63
- return truncate(value, TRUNCATION.SHORT, TRUNCATION.SUFFIX, false);
64
- };
65
- const truncateRecursive = (value) => {
66
- return truncate(value, TRUNCATION.STANDARD, TRUNCATION.SUFFIX_VERBOSE, true);
67
- };
68
- const formatPhase = (phase) => {
69
- const phaseMap = {
70
- start: '[START]',
71
- end: '[END]',
72
- error: '[ERROR]'
73
- };
74
- return phaseMap[phase] ?? phase;
75
- };
76
- const getNodeName = (node) => {
77
- return node.name || node.workflowName || node.stepName || node.activityName || '';
78
- };
79
- const getNodeKind = (node) => {
80
- return node.kind || node.type || '';
81
- };
82
- const getEventName = (event) => {
83
- const { kind, workflowName, details } = event;
84
- if (kind === 'workflow') {
85
- return `Workflow: ${workflowName}`;
86
- }
87
- if (kind === 'activity') {
88
- return `Activity: ${details?.activityName || 'unknown'}`;
89
- }
90
- if (kind === 'step') {
91
- return `Step: ${details?.stepName || details?.name || 'unknown'}`;
92
- }
93
- return kind || 'Unknown Event';
94
- };
95
- const colorizeByKind = (kind, text) => {
96
- if (kind === 'workflow') {
97
- return colors.workflowHeader(text);
98
- }
99
- if (kind === 'internal_step') {
100
- return colors.internalStep(text);
101
- }
102
- if (kind === 'step' || kind === 'activity') {
103
- return colors.stepHeader(text);
104
- }
105
- return text;
106
- };
107
- const getStatusIndicator = (node) => {
108
- if (node.phase === 'error' || node.status === 'failed') {
109
- return colors.error('[FAILED]');
110
- }
111
- if (node.phase === 'end' || node.status === 'completed') {
112
- return colors.success('[COMPLETED]');
113
- }
114
- if (node.status === 'running') {
115
- return colors.label('[RUNNING]');
116
- }
117
- return '';
118
- };
119
- const getDebugNodeInfo = (node) => {
120
- if (typeof node === 'string') {
121
- return node;
122
- }
123
- if (typeof node !== 'object' || node === null) {
124
- return String(node);
125
- }
126
- const debugNode = node;
127
- const kind = getNodeKind(debugNode);
128
- const name = getNodeName(debugNode);
129
- const status = getStatusIndicator(debugNode);
130
- const parts = [];
131
- if (kind) {
132
- parts.push(colorizeByKind(kind, `[${kind}]`));
133
- }
134
- if (name) {
135
- parts.push(colorizeByKind(kind, name));
136
- }
137
- if (status) {
138
- parts.push(status);
139
- }
140
- if (parts.length === 0) {
141
- const keys = Object.keys(debugNode).filter(k => k !== 'children' && k !== 'parent');
142
- if (keys.length > 0) {
143
- return `Node {${keys.slice(0, 3).join(', ')}${keys.length > 3 ? ', ...' : ''}}`;
144
- }
145
- return 'Node';
146
- }
147
- return parts.join(' ');
148
- };
149
- const extractNodeInfo = (node) => {
150
- if (isTraceEvent(node)) {
151
- return {
152
- name: getEventName(node),
153
- phase: formatPhase(node.phase),
154
- duration: node.duration ? ` (${formatDuration(node.duration)})` : ''
155
- };
156
- }
157
- return {
158
- name: getDebugNodeInfo(node),
159
- phase: node.phase ? formatPhase(node.phase) : '',
160
- duration: node.duration ? ` (${formatDuration(node.duration)})` : ''
161
- };
162
- };
163
- const formatDetails = (details) => {
164
- if (!details) {
165
- return '-';
166
- }
167
- if (typeof details === 'string') {
168
- return details;
169
- }
170
- const info = [];
171
- if (details.input) {
172
- info.push(`Input: ${truncateShort(details.input)}`);
173
- }
174
- if (details.output) {
175
- info.push(`Output: ${truncateShort(details.output)}`);
176
- }
177
- if (details.activityName) {
178
- info.push(`Activity: ${details.activityName}`);
179
- }
180
- if (details.stepName || details.name) {
181
- info.push(`Step: ${details.stepName || details.name}`);
182
- }
183
- if (info.length > 0) {
184
- return info.join(', ');
185
- }
186
- return truncateShort(details);
187
- };
188
- const formatTreeDetails = (details, depth) => {
189
- const indent = ' '.repeat(depth);
190
- const lines = [];
191
- if (details.input !== null && details.input !== undefined) {
192
- lines.push(`${indent}Input: ${truncateShort(details.input)}`);
193
- }
194
- if (details.output !== null && details.output !== undefined) {
195
- lines.push(`${indent}Output: ${truncateShort(details.output)}`);
196
- }
197
- return lines;
198
- };
199
- const formatValueWithIndent = (value, indentPrefix) => {
200
- if (value === null || value === undefined) {
201
- return String(value);
202
- }
203
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
204
- return truncate(value, TRUNCATION.STANDARD, TRUNCATION.SUFFIX_VERBOSE, false);
205
- }
206
- const truncated = truncateRecursive(value);
207
- const jsonStr = JSON.stringify(truncated, null, 2);
208
- const lines = jsonStr.split('\n');
209
- if (lines.length <= 1) {
210
- return jsonStr;
211
- }
212
- return lines.map((line, i) => {
213
- if (i === 0) {
214
- return line;
215
- }
216
- return indentPrefix + line;
217
- }).join('\n');
218
- };
219
- const formatHeader = (root) => {
220
- const isTrace = isTraceEvent(root);
221
- const debugRoot = root;
222
- const workflowName = isTrace ? root.workflowName : (getNodeName(debugRoot) || 'Unknown');
223
- const workflowId = isTrace ? root.workflowId : 'N/A';
224
- const timestamp = isTrace ? root.timestamp : debugRoot.startTime;
225
- const phase = isTrace ? root.phase : debugRoot.phase;
226
- const status = !isTrace ? debugRoot.status : undefined;
227
- const lines = [
228
- HEADER_DIVIDER,
229
- `Workflow: ${workflowName}`,
230
- `Workflow ID: ${workflowId}`
231
- ];
232
- if (isValidTimestamp(timestamp)) {
233
- lines.push(`Start Time: ${new Date(timestamp).toISOString()}`);
234
- }
235
- if (root.duration) {
236
- lines.push(`Duration: ${formatDuration(root.duration)}`);
237
- }
238
- if ((phase === 'error' || status === 'failed') && root.error) {
239
- lines.push('Status: Failed', `Error: ${getErrorMessage(root.error)}`);
240
- }
241
- else if (phase === 'end' || status === 'completed') {
242
- lines.push('Status: Completed');
243
- }
244
- else {
245
- lines.push('Status: In Progress');
246
- }
247
- lines.push(HEADER_DIVIDER);
248
- return lines.join('\n');
249
- };
250
- const formatEventsTable = (events) => {
251
- const table = new Table({
252
- head: ['Time', 'Event', 'Phase', 'Duration', 'Details'],
253
- style: { head: ['cyan'] },
254
- colWidths: [20, 25, 10, 12, null],
255
- wordWrap: true
256
- });
257
- for (const event of events) {
258
- table.push([
259
- new Date(event.timestamp).toISOString().substring(11, 23),
260
- getEventName(event),
261
- formatPhase(event.phase),
262
- event.duration ? formatDuration(event.duration) : '-',
263
- formatDetails(event.details)
264
- ]);
265
- }
266
- return table.toString();
267
- };
268
- const formatTree = (node, depth) => {
269
- const indent = ' '.repeat(depth);
270
- const marker = depth === 0 ? '' : TREE_CHARS.BRANCH;
271
- const info = extractNodeInfo(node);
272
- const lines = [`${indent}${marker} ${info.name} ${info.phase}${info.duration}`];
273
- if (node.error) {
274
- lines.push(`${indent} ${TREE_CHARS.LAST.trim()} ERROR: ${getErrorMessage(node.error)}`);
275
- }
276
- if (node.details && typeof node.details === 'object') {
277
- lines.push(...formatTreeDetails(node.details, depth + 1));
278
- }
279
- if (node.children && node.children.length > 0) {
280
- for (const child of node.children) {
281
- lines.push(...formatTree(child, depth + 1));
282
- }
283
- }
284
- return lines;
285
- };
286
- const getDebugNodeDetails = (node, prefix) => {
287
- if (typeof node !== 'object' || node === null) {
288
- return [];
289
- }
290
- const details = [];
291
- const startedAt = node.startedAt || node.timestamp;
292
- const inputIndentPrefix = prefix + ' '.repeat(7);
293
- const outputIndentPrefix = prefix + ' '.repeat(8);
294
- if (isValidTimestamp(startedAt)) {
295
- const startDate = new Date(startedAt);
296
- if (!isNaN(startDate.getTime())) {
297
- details.push(`${prefix}${colors.label('Started:')} ${startDate.toISOString()}`);
298
- }
299
- }
300
- if (isValidTimestamp(node.endedAt)) {
301
- const endDate = new Date(node.endedAt);
302
- if (!isNaN(endDate.getTime())) {
303
- details.push(`${prefix}${colors.label('Ended:')} ${endDate.toISOString()}`);
304
- }
305
- }
306
- if (typeof node.startedAt === 'number' && typeof node.endedAt === 'number') {
307
- details.push(`${prefix}${colors.label('Duration:')} ${formatDuration(node.endedAt - node.startedAt)}`);
308
- }
309
- else if (node.duration) {
310
- details.push(`${prefix}${colors.label('Duration:')} ${formatDuration(node.duration)}`);
311
- }
312
- if (node.input !== null && node.input !== undefined) {
313
- details.push(`${prefix}${colors.label('Input:')} ${formatValueWithIndent(node.input, inputIndentPrefix)}`);
314
- }
315
- if (node.output !== null && node.output !== undefined) {
316
- details.push(`${prefix}${colors.label('Output:')} ${formatValueWithIndent(node.output, outputIndentPrefix)}`);
317
- }
318
- if (node.error) {
319
- details.push(`${prefix}${colors.error('Error:')} ${colors.error(getErrorMessage(node.error))}`);
320
- }
321
- if (details.length > 0) {
322
- details.push('');
323
- }
324
- return details;
325
- };
326
- const buildDebugTreeLines = (node, depth, isLast, prefix) => {
327
- if (node === null || node === undefined) {
328
- return [];
329
- }
330
- const isRoot = depth === 0;
331
- const getConnector = () => {
332
- if (isRoot) {
333
- return '';
334
- }
335
- return isLast ? TREE_CHARS.LAST : TREE_CHARS.BRANCH;
336
- };
337
- const connector = getConnector();
338
- const indent = isRoot ? '' : prefix + connector;
339
- const lines = [indent + getDebugNodeInfo(node)];
340
- const detailPrefix = isRoot ? ' ' : prefix + (isLast ? TREE_CHARS.DETAIL_LAST : TREE_CHARS.DETAIL_BRANCH);
341
- if (typeof node === 'object' && node !== null) {
342
- lines.push(...getDebugNodeDetails(node, detailPrefix));
343
- }
344
- const childPrefix = isRoot ? '' : prefix + (isLast ? TREE_CHARS.SPACE : TREE_CHARS.VERTICAL);
345
- if (typeof node === 'object' && node !== null) {
346
- const debugNode = node;
347
- if (Array.isArray(debugNode.children)) {
348
- debugNode.children.forEach((child, i) => {
349
- const isLastChild = i === debugNode.children.length - 1;
350
- lines.push(...buildDebugTreeLines(child, depth + 1, isLastChild, childPrefix));
351
- });
352
- }
353
- }
354
- return lines;
355
- };
356
- const formatAsText = (trace) => {
357
- const output = [];
358
- if (trace.root) {
359
- output.push(formatHeader(trace.root), '');
360
- }
361
- if (trace.events && trace.events.length > 0) {
362
- output.push('Execution Timeline:', formatEventsTable(trace.events), '');
363
- }
364
- if (trace.root) {
365
- output.push('Execution Tree:', ...formatTree(trace.root, 0));
366
- }
367
- return output.join('\n');
368
- };
369
- export function format(traceData, outputFormat = 'text') {
370
- const trace = typeof traceData === 'string' ? JSON.parse(traceData) : traceData;
371
- if (outputFormat === 'json') {
372
- return formatOutput(trace, 'json');
373
- }
374
- return formatAsText(trace);
375
- }
376
- export function getSummary(traceData) {
377
- const trace = typeof traceData === 'string' ? JSON.parse(traceData) : traceData;
378
- const stats = {
379
- totalDuration: trace.root?.duration || 0,
380
- totalEvents: trace.events?.length || 0,
381
- totalSteps: 0,
382
- totalActivities: 0,
383
- hasErrors: false
384
- };
385
- if (trace.events) {
386
- for (const event of trace.events) {
387
- if (event.kind === 'step') {
388
- stats.totalSteps++;
389
- }
390
- if (event.kind === 'activity') {
391
- stats.totalActivities++;
392
- }
393
- if (event.phase === 'error') {
394
- stats.hasErrors = true;
395
- }
396
- }
397
- }
398
- return stats;
399
- }
400
- export function displayDebugTree(node) {
401
- return buildDebugTreeLines(node, 0, false, '').join('\n');
402
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Validate workflow name format
3
- * Must contain only letters, numbers, hyphens, and underscores
4
- */
5
- export declare function isValidWorkflowName(name: string): boolean;
6
- /**
7
- * Validate workflow name and throw descriptive error if invalid
8
- */
9
- export declare function validateWorkflowName(name: string): void;
10
- /**
11
- * Validate that a directory path is safe to create
12
- */
13
- export declare function validateOutputDirectory(outputDir: string): void;
@@ -1,25 +0,0 @@
1
- import { InvalidNameError, InvalidOutputDirectoryError } from '#types/errors.js';
2
- /**
3
- * Validate workflow name format
4
- * Must contain only letters, numbers, hyphens, and underscores
5
- */
6
- export function isValidWorkflowName(name) {
7
- // Must start with a letter or underscore, followed by letters, numbers, hyphens, or underscores
8
- return /^[a-z_][a-z0-9_-]*$/i.test(name);
9
- }
10
- /**
11
- * Validate workflow name and throw descriptive error if invalid
12
- */
13
- export function validateWorkflowName(name) {
14
- if (!isValidWorkflowName(name)) {
15
- throw new InvalidNameError(name);
16
- }
17
- }
18
- /**
19
- * Validate that a directory path is safe to create
20
- */
21
- export function validateOutputDirectory(outputDir) {
22
- if (!outputDir || outputDir.trim() === '') {
23
- throw new InvalidOutputDirectoryError(outputDir, 'Output directory cannot be empty');
24
- }
25
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,140 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { isValidWorkflowName } from './validation.js';
3
- describe('isValidWorkflowName', () => {
4
- describe('valid workflow names', () => {
5
- it('should accept single letter', () => {
6
- expect(isValidWorkflowName('a')).toBe(true);
7
- expect(isValidWorkflowName('Z')).toBe(true);
8
- });
9
- it('should accept single underscore', () => {
10
- expect(isValidWorkflowName('_')).toBe(true);
11
- });
12
- it('should accept names starting with letter', () => {
13
- expect(isValidWorkflowName('workflow')).toBe(true);
14
- expect(isValidWorkflowName('MyWorkflow')).toBe(true);
15
- expect(isValidWorkflowName('simpleWorkflow123')).toBe(true);
16
- });
17
- it('should accept names starting with underscore', () => {
18
- expect(isValidWorkflowName('_workflow')).toBe(true);
19
- expect(isValidWorkflowName('_private_workflow')).toBe(true);
20
- expect(isValidWorkflowName('__double_underscore')).toBe(true);
21
- });
22
- it('should accept names with numbers after first character', () => {
23
- expect(isValidWorkflowName('workflow1')).toBe(true);
24
- expect(isValidWorkflowName('workflow_123')).toBe(true);
25
- expect(isValidWorkflowName('a123456789')).toBe(true);
26
- expect(isValidWorkflowName('_123')).toBe(true);
27
- });
28
- it('should accept names with hyphens', () => {
29
- expect(isValidWorkflowName('my-workflow')).toBe(true);
30
- expect(isValidWorkflowName('workflow-name')).toBe(true);
31
- expect(isValidWorkflowName('workflow-')).toBe(true);
32
- expect(isValidWorkflowName('my-workflow-name')).toBe(true);
33
- });
34
- it('should accept names with underscores in any position', () => {
35
- expect(isValidWorkflowName('my_workflow')).toBe(true);
36
- expect(isValidWorkflowName('workflow_name_here')).toBe(true);
37
- expect(isValidWorkflowName('a_b_c_d')).toBe(true);
38
- expect(isValidWorkflowName('workflow__double')).toBe(true);
39
- });
40
- it('should accept mixed case names', () => {
41
- expect(isValidWorkflowName('WorkFlow')).toBe(true);
42
- expect(isValidWorkflowName('myWorkFlow')).toBe(true);
43
- expect(isValidWorkflowName('MY_WORKFLOW')).toBe(true);
44
- expect(isValidWorkflowName('CamelCaseWorkflow')).toBe(true);
45
- });
46
- it('should accept long valid names', () => {
47
- const longName = 'a'.repeat(100) + '_' + '1'.repeat(100);
48
- expect(isValidWorkflowName(longName)).toBe(true);
49
- });
50
- });
51
- describe('invalid workflow names', () => {
52
- it('should reject empty string', () => {
53
- expect(isValidWorkflowName('')).toBe(false);
54
- });
55
- it('should reject names starting with numbers', () => {
56
- expect(isValidWorkflowName('1workflow')).toBe(false);
57
- expect(isValidWorkflowName('123')).toBe(false);
58
- expect(isValidWorkflowName('0_workflow')).toBe(false);
59
- expect(isValidWorkflowName('9abc')).toBe(false);
60
- });
61
- it('should reject names starting with hyphens', () => {
62
- expect(isValidWorkflowName('-workflow')).toBe(false);
63
- });
64
- it('should reject names with spaces', () => {
65
- expect(isValidWorkflowName('my workflow')).toBe(false);
66
- expect(isValidWorkflowName(' workflow')).toBe(false);
67
- expect(isValidWorkflowName('workflow ')).toBe(false);
68
- expect(isValidWorkflowName('work flow')).toBe(false);
69
- });
70
- it('should reject names with special characters', () => {
71
- expect(isValidWorkflowName('workflow!')).toBe(false);
72
- expect(isValidWorkflowName('work@flow')).toBe(false);
73
- expect(isValidWorkflowName('workflow#123')).toBe(false);
74
- expect(isValidWorkflowName('work$flow')).toBe(false);
75
- expect(isValidWorkflowName('workflow%')).toBe(false);
76
- expect(isValidWorkflowName('work^flow')).toBe(false);
77
- expect(isValidWorkflowName('workflow&')).toBe(false);
78
- expect(isValidWorkflowName('work*flow')).toBe(false);
79
- expect(isValidWorkflowName('workflow(')).toBe(false);
80
- expect(isValidWorkflowName('work)flow')).toBe(false);
81
- expect(isValidWorkflowName('work+flow')).toBe(false);
82
- expect(isValidWorkflowName('work=flow')).toBe(false);
83
- expect(isValidWorkflowName('work[flow')).toBe(false);
84
- expect(isValidWorkflowName('work]flow')).toBe(false);
85
- expect(isValidWorkflowName('work{flow')).toBe(false);
86
- expect(isValidWorkflowName('work}flow')).toBe(false);
87
- expect(isValidWorkflowName('work|flow')).toBe(false);
88
- expect(isValidWorkflowName('work\\flow')).toBe(false);
89
- expect(isValidWorkflowName('work/flow')).toBe(false);
90
- expect(isValidWorkflowName('work:flow')).toBe(false);
91
- expect(isValidWorkflowName('work;flow')).toBe(false);
92
- expect(isValidWorkflowName('work"flow')).toBe(false);
93
- expect(isValidWorkflowName('work\'flow')).toBe(false);
94
- expect(isValidWorkflowName('work<flow')).toBe(false);
95
- expect(isValidWorkflowName('work>flow')).toBe(false);
96
- expect(isValidWorkflowName('work,flow')).toBe(false);
97
- expect(isValidWorkflowName('work.flow')).toBe(false);
98
- expect(isValidWorkflowName('work?flow')).toBe(false);
99
- expect(isValidWorkflowName('work`flow')).toBe(false);
100
- expect(isValidWorkflowName('work~flow')).toBe(false);
101
- });
102
- it('should reject names with unicode characters', () => {
103
- expect(isValidWorkflowName('wørkflow')).toBe(false);
104
- expect(isValidWorkflowName('работа')).toBe(false);
105
- expect(isValidWorkflowName('工作流')).toBe(false);
106
- expect(isValidWorkflowName('workflow™')).toBe(false);
107
- expect(isValidWorkflowName('work✓flow')).toBe(false);
108
- expect(isValidWorkflowName('😀workflow')).toBe(false);
109
- });
110
- it('should reject names with tabs and newlines', () => {
111
- expect(isValidWorkflowName('work\tflow')).toBe(false);
112
- expect(isValidWorkflowName('work\nflow')).toBe(false);
113
- expect(isValidWorkflowName('work\rflow')).toBe(false);
114
- });
115
- it('should handle string versions of null and undefined', () => {
116
- // String(null) returns "null" which is actually a valid workflow name
117
- expect(isValidWorkflowName(String(null))).toBe(true);
118
- // String(undefined) returns "undefined" which is also a valid workflow name
119
- expect(isValidWorkflowName(String(undefined))).toBe(true);
120
- });
121
- });
122
- describe('edge cases', () => {
123
- it('should handle boundary conditions', () => {
124
- expect(isValidWorkflowName('a0')).toBe(true);
125
- expect(isValidWorkflowName('_0')).toBe(true);
126
- expect(isValidWorkflowName('Z9')).toBe(true);
127
- expect(isValidWorkflowName('_9')).toBe(true);
128
- });
129
- it('should be case-insensitive for letters', () => {
130
- expect(isValidWorkflowName('abc')).toBe(true);
131
- expect(isValidWorkflowName('ABC')).toBe(true);
132
- expect(isValidWorkflowName('AbC')).toBe(true);
133
- });
134
- it('should handle only underscores and numbers after initial character', () => {
135
- expect(isValidWorkflowName('a_________')).toBe(true);
136
- expect(isValidWorkflowName('_000000000')).toBe(true);
137
- expect(isValidWorkflowName('a_0_1_2_3')).toBe(true);
138
- });
139
- });
140
- });