@outputai/cli 0.1.3 → 0.1.4-dev.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.
- package/dist/api/generated/api.d.ts +820 -0
- package/dist/api/generated/api.js +226 -0
- package/dist/api/http_client.d.ts +27 -0
- package/dist/api/http_client.js +71 -0
- package/dist/api/orval_post_process.d.ts +11 -0
- package/dist/api/orval_post_process.js +46 -0
- package/dist/api/parser.d.ts +17 -0
- package/dist/api/parser.js +68 -0
- package/dist/assets/config/costs.yml +309 -0
- package/dist/assets/docker/docker-compose-dev.yml +146 -0
- package/dist/commands/credentials/edit.d.ts +10 -0
- package/dist/commands/credentials/edit.js +67 -0
- package/dist/commands/credentials/edit.spec.d.ts +1 -0
- package/dist/commands/credentials/edit.spec.js +73 -0
- package/dist/commands/credentials/get.d.ts +13 -0
- package/dist/commands/credentials/get.js +46 -0
- package/dist/commands/credentials/get.spec.d.ts +1 -0
- package/dist/commands/credentials/get.spec.js +74 -0
- package/dist/commands/credentials/init.d.ts +11 -0
- package/dist/commands/credentials/init.js +45 -0
- package/dist/commands/credentials/init.spec.d.ts +1 -0
- package/dist/commands/credentials/init.spec.js +68 -0
- package/dist/commands/credentials/show.d.ts +10 -0
- package/dist/commands/credentials/show.js +33 -0
- package/dist/commands/credentials/show.spec.d.ts +1 -0
- package/dist/commands/credentials/show.spec.js +57 -0
- package/dist/commands/dev/eject.d.ts +11 -0
- package/dist/commands/dev/eject.js +58 -0
- package/dist/commands/dev/eject.spec.d.ts +1 -0
- package/dist/commands/dev/eject.spec.js +109 -0
- package/dist/commands/dev/index.d.ts +14 -0
- package/dist/commands/dev/index.js +173 -0
- package/dist/commands/dev/index.spec.d.ts +1 -0
- package/dist/commands/dev/index.spec.js +239 -0
- package/dist/commands/init.d.ts +12 -0
- package/dist/commands/init.js +37 -0
- package/dist/commands/init.spec.d.ts +1 -0
- package/dist/commands/init.spec.js +100 -0
- package/dist/commands/update.d.ts +14 -0
- package/dist/commands/update.js +120 -0
- package/dist/commands/update.spec.d.ts +1 -0
- package/dist/commands/update.spec.js +178 -0
- package/dist/commands/workflow/cost.d.ts +16 -0
- package/dist/commands/workflow/cost.js +71 -0
- package/dist/commands/workflow/cost.spec.d.ts +1 -0
- package/dist/commands/workflow/cost.spec.js +47 -0
- package/dist/commands/workflow/dataset/generate.d.ts +22 -0
- package/dist/commands/workflow/dataset/generate.js +143 -0
- package/dist/commands/workflow/dataset/list.d.ts +12 -0
- package/dist/commands/workflow/dataset/list.js +87 -0
- package/dist/commands/workflow/debug.d.ts +16 -0
- package/dist/commands/workflow/debug.js +60 -0
- package/dist/commands/workflow/debug.spec.d.ts +1 -0
- package/dist/commands/workflow/debug.spec.js +34 -0
- package/dist/commands/workflow/generate.d.ts +17 -0
- package/dist/commands/workflow/generate.js +85 -0
- package/dist/commands/workflow/generate.spec.d.ts +1 -0
- package/dist/commands/workflow/generate.spec.js +115 -0
- package/dist/commands/workflow/list.d.ts +22 -0
- package/dist/commands/workflow/list.js +152 -0
- package/dist/commands/workflow/list.spec.d.ts +1 -0
- package/dist/commands/workflow/list.spec.js +99 -0
- package/dist/commands/workflow/plan.d.ts +12 -0
- package/dist/commands/workflow/plan.js +66 -0
- package/dist/commands/workflow/plan.spec.d.ts +1 -0
- package/dist/commands/workflow/plan.spec.js +341 -0
- package/dist/commands/workflow/reset.d.ts +14 -0
- package/dist/commands/workflow/reset.js +51 -0
- package/dist/commands/workflow/result.d.ts +13 -0
- package/dist/commands/workflow/result.js +46 -0
- package/dist/commands/workflow/result.spec.d.ts +1 -0
- package/dist/commands/workflow/result.spec.js +23 -0
- package/dist/commands/workflow/run.d.ts +16 -0
- package/dist/commands/workflow/run.js +97 -0
- package/dist/commands/workflow/run.spec.d.ts +1 -0
- package/dist/commands/workflow/run.spec.js +110 -0
- package/dist/commands/workflow/runs/list.d.ts +14 -0
- package/dist/commands/workflow/runs/list.js +104 -0
- package/dist/commands/workflow/start.d.ts +15 -0
- package/dist/commands/workflow/start.js +62 -0
- package/dist/commands/workflow/start.spec.d.ts +1 -0
- package/dist/commands/workflow/start.spec.js +28 -0
- package/dist/commands/workflow/status.d.ts +13 -0
- package/dist/commands/workflow/status.js +57 -0
- package/dist/commands/workflow/status.spec.d.ts +1 -0
- package/dist/commands/workflow/status.spec.js +33 -0
- package/dist/commands/workflow/stop.d.ts +10 -0
- package/dist/commands/workflow/stop.js +31 -0
- package/dist/commands/workflow/stop.spec.d.ts +1 -0
- package/dist/commands/workflow/stop.spec.js +17 -0
- package/dist/commands/workflow/terminate.d.ts +13 -0
- package/dist/commands/workflow/terminate.js +39 -0
- package/dist/commands/workflow/test_eval.d.ts +20 -0
- package/dist/commands/workflow/test_eval.js +151 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.js +47 -0
- package/dist/generated/framework_version.json +3 -0
- package/dist/hooks/init.d.ts +3 -0
- package/dist/hooks/init.js +30 -0
- package/dist/hooks/init.spec.d.ts +1 -0
- package/dist/hooks/init.spec.js +54 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.spec.d.ts +1 -0
- package/dist/index.spec.js +6 -0
- package/dist/services/claude_client.d.ts +30 -0
- package/dist/services/claude_client.integration.test.d.ts +1 -0
- package/dist/services/claude_client.integration.test.js +43 -0
- package/dist/services/claude_client.js +215 -0
- package/dist/services/claude_client.spec.d.ts +1 -0
- package/dist/services/claude_client.spec.js +145 -0
- package/dist/services/coding_agents.d.ts +36 -0
- package/dist/services/coding_agents.js +236 -0
- package/dist/services/coding_agents.spec.d.ts +1 -0
- package/dist/services/coding_agents.spec.js +256 -0
- package/dist/services/copy_assets.spec.d.ts +1 -0
- package/dist/services/copy_assets.spec.js +22 -0
- package/dist/services/cost_calculator.d.ts +18 -0
- package/dist/services/cost_calculator.js +359 -0
- package/dist/services/cost_calculator.spec.d.ts +1 -0
- package/dist/services/cost_calculator.spec.js +540 -0
- package/dist/services/credentials_service.d.ts +12 -0
- package/dist/services/credentials_service.integration.test.d.ts +1 -0
- package/dist/services/credentials_service.integration.test.js +66 -0
- package/dist/services/credentials_service.js +64 -0
- package/dist/services/credentials_service.spec.d.ts +1 -0
- package/dist/services/credentials_service.spec.js +106 -0
- package/dist/services/datasets.d.ts +20 -0
- package/dist/services/datasets.js +132 -0
- package/dist/services/docker.d.ts +39 -0
- package/dist/services/docker.js +160 -0
- package/dist/services/docker.spec.d.ts +1 -0
- package/dist/services/docker.spec.js +124 -0
- package/dist/services/env_configurator.d.ts +15 -0
- package/dist/services/env_configurator.js +163 -0
- package/dist/services/env_configurator.spec.d.ts +1 -0
- package/dist/services/env_configurator.spec.js +192 -0
- package/dist/services/generate_plan_name@v1.prompt +24 -0
- package/dist/services/messages.d.ts +9 -0
- package/dist/services/messages.js +338 -0
- package/dist/services/messages.spec.d.ts +1 -0
- package/dist/services/messages.spec.js +55 -0
- package/dist/services/npm_update_service.d.ts +6 -0
- package/dist/services/npm_update_service.js +87 -0
- package/dist/services/npm_update_service.spec.d.ts +1 -0
- package/dist/services/npm_update_service.spec.js +104 -0
- package/dist/services/project_scaffold.d.ts +31 -0
- package/dist/services/project_scaffold.js +212 -0
- package/dist/services/project_scaffold.spec.d.ts +1 -0
- package/dist/services/project_scaffold.spec.js +122 -0
- package/dist/services/s3_trace_downloader.d.ts +12 -0
- package/dist/services/s3_trace_downloader.js +57 -0
- package/dist/services/template_processor.d.ts +14 -0
- package/dist/services/template_processor.js +57 -0
- package/dist/services/trace_reader.d.ts +16 -0
- package/dist/services/trace_reader.js +57 -0
- package/dist/services/trace_reader.spec.d.ts +1 -0
- package/dist/services/trace_reader.spec.js +78 -0
- package/dist/services/version_check.d.ts +6 -0
- package/dist/services/version_check.js +52 -0
- package/dist/services/version_check.spec.d.ts +1 -0
- package/dist/services/version_check.spec.js +106 -0
- package/dist/services/workflow_builder.d.ts +16 -0
- package/dist/services/workflow_builder.js +86 -0
- package/dist/services/workflow_builder.spec.d.ts +1 -0
- package/dist/services/workflow_builder.spec.js +165 -0
- package/dist/services/workflow_generator.d.ts +5 -0
- package/dist/services/workflow_generator.js +40 -0
- package/dist/services/workflow_generator.spec.d.ts +1 -0
- package/dist/services/workflow_generator.spec.js +77 -0
- package/dist/services/workflow_planner.d.ts +15 -0
- package/dist/services/workflow_planner.js +48 -0
- package/dist/services/workflow_planner.spec.d.ts +1 -0
- package/dist/services/workflow_planner.spec.js +122 -0
- package/dist/services/workflow_runs.d.ts +14 -0
- package/dist/services/workflow_runs.js +25 -0
- package/dist/templates/agent_instructions/CLAUDE.md.template +19 -0
- package/dist/templates/agent_instructions/dotclaude/settings.json.template +29 -0
- package/dist/templates/project/.env.example.template +9 -0
- package/dist/templates/project/.gitignore.template +35 -0
- package/dist/templates/project/README.md.template +100 -0
- package/dist/templates/project/config/costs.yml.template +29 -0
- package/dist/templates/project/package.json.template +25 -0
- package/dist/templates/project/src/clients/jina.ts.template +30 -0
- package/dist/templates/project/src/shared/utils/string.ts.template +3 -0
- package/dist/templates/project/src/shared/utils/url.ts.template +15 -0
- package/dist/templates/project/src/workflows/blog_evaluator/evaluators.ts.template +23 -0
- package/dist/templates/project/src/workflows/blog_evaluator/prompts/signal_noise@v1.prompt.template +26 -0
- package/dist/templates/project/src/workflows/blog_evaluator/scenarios/paulgraham_hwh.json.template +3 -0
- package/dist/templates/project/src/workflows/blog_evaluator/steps.ts.template +27 -0
- package/dist/templates/project/src/workflows/blog_evaluator/types.ts.template +30 -0
- package/dist/templates/project/src/workflows/blog_evaluator/utils.ts.template +15 -0
- package/dist/templates/project/src/workflows/blog_evaluator/workflow.ts.template +27 -0
- package/dist/templates/project/tsconfig.json.template +20 -0
- package/dist/templates/workflow/README.md.template +216 -0
- package/dist/templates/workflow/evaluators.ts.template +21 -0
- package/dist/templates/workflow/prompts/example@v1.prompt.template +15 -0
- package/dist/templates/workflow/scenarios/test_input.json.template +3 -0
- package/dist/templates/workflow/steps.ts.template +20 -0
- package/dist/templates/workflow/types.ts.template +13 -0
- package/dist/templates/workflow/workflow.ts.template +23 -0
- package/dist/test_helpers/mocks.d.ts +38 -0
- package/dist/test_helpers/mocks.js +77 -0
- package/dist/types/cost.d.ts +149 -0
- package/dist/types/cost.js +6 -0
- package/dist/types/domain.d.ts +20 -0
- package/dist/types/domain.js +4 -0
- package/dist/types/errors.d.ts +68 -0
- package/dist/types/errors.js +100 -0
- package/dist/types/errors.spec.d.ts +1 -0
- package/dist/types/errors.spec.js +18 -0
- package/dist/types/generator.d.ts +26 -0
- package/dist/types/generator.js +1 -0
- package/dist/types/trace.d.ts +161 -0
- package/dist/types/trace.js +18 -0
- package/dist/utils/claude.d.ts +5 -0
- package/dist/utils/claude.js +19 -0
- package/dist/utils/claude.spec.d.ts +1 -0
- package/dist/utils/claude.spec.js +119 -0
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.js +4 -0
- package/dist/utils/cost_formatter.d.ts +5 -0
- package/dist/utils/cost_formatter.js +218 -0
- package/dist/utils/date_formatter.d.ts +23 -0
- package/dist/utils/date_formatter.js +49 -0
- package/dist/utils/env_loader.d.ts +1 -0
- package/dist/utils/env_loader.js +22 -0
- package/dist/utils/env_loader.spec.d.ts +1 -0
- package/dist/utils/env_loader.spec.js +43 -0
- package/dist/utils/error_handler.d.ts +8 -0
- package/dist/utils/error_handler.js +71 -0
- package/dist/utils/error_utils.d.ts +24 -0
- package/dist/utils/error_utils.js +87 -0
- package/dist/utils/file_system.d.ts +3 -0
- package/dist/utils/file_system.js +33 -0
- package/dist/utils/format_workflow_result.d.ts +5 -0
- package/dist/utils/format_workflow_result.js +18 -0
- package/dist/utils/format_workflow_result.spec.d.ts +1 -0
- package/dist/utils/format_workflow_result.spec.js +81 -0
- package/dist/utils/framework_version.d.ts +4 -0
- package/dist/utils/framework_version.js +4 -0
- package/dist/utils/framework_version.spec.d.ts +1 -0
- package/dist/utils/framework_version.spec.js +13 -0
- package/dist/utils/header_utils.d.ts +12 -0
- package/dist/utils/header_utils.js +29 -0
- package/dist/utils/header_utils.spec.d.ts +1 -0
- package/dist/utils/header_utils.spec.js +52 -0
- package/dist/utils/input_parser.d.ts +1 -0
- package/dist/utils/input_parser.js +19 -0
- package/dist/utils/output_formatter.d.ts +2 -0
- package/dist/utils/output_formatter.js +11 -0
- package/dist/utils/paths.d.ts +25 -0
- package/dist/utils/paths.js +36 -0
- package/dist/utils/process.d.ts +4 -0
- package/dist/utils/process.js +50 -0
- package/dist/utils/resolve_input.d.ts +1 -0
- package/dist/utils/resolve_input.js +22 -0
- package/dist/utils/scenario_resolver.d.ts +9 -0
- package/dist/utils/scenario_resolver.js +93 -0
- package/dist/utils/scenario_resolver.spec.d.ts +1 -0
- package/dist/utils/scenario_resolver.spec.js +214 -0
- package/dist/utils/secret_sanitizer.d.ts +1 -0
- package/dist/utils/secret_sanitizer.js +29 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.js +5 -0
- package/dist/utils/template.d.ts +9 -0
- package/dist/utils/template.js +30 -0
- package/dist/utils/template.spec.d.ts +1 -0
- package/dist/utils/template.spec.js +77 -0
- package/dist/utils/trace_extractor.d.ts +27 -0
- package/dist/utils/trace_extractor.js +53 -0
- package/dist/utils/trace_formatter.d.ts +11 -0
- package/dist/utils/trace_formatter.js +402 -0
- package/dist/utils/validation.d.ts +13 -0
- package/dist/utils/validation.js +25 -0
- package/dist/utils/validation.spec.d.ts +1 -0
- package/dist/utils/validation.spec.js +140 -0
- package/package.json +4 -4
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# {{WorkflowName}} Workflow
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This was generated using the Output.ai CLI. It provides a starting point for building AI applications with production-ready LLM integration, built-in prompt management, evaluation, and observability.
|
|
8
|
+
|
|
9
|
+
## Files
|
|
10
|
+
|
|
11
|
+
- `workflow.ts` - Main workflow definition with input/output schemas
|
|
12
|
+
- `steps.ts` - Activity/step definitions with input/output schemas
|
|
13
|
+
- `evaluators.ts` - Quality evaluators for workflow outputs
|
|
14
|
+
- `types.ts` - Shared Zod schemas and TypeScript types
|
|
15
|
+
- `prompts/` - LLM prompt templates
|
|
16
|
+
- `scenarios/` - Test input scenarios
|
|
17
|
+
|
|
18
|
+
## File Organization
|
|
19
|
+
|
|
20
|
+
You can organize your workflow files in two ways:
|
|
21
|
+
|
|
22
|
+
**Flat files:**
|
|
23
|
+
```
|
|
24
|
+
workflow/
|
|
25
|
+
├── workflow.ts
|
|
26
|
+
├── steps.ts
|
|
27
|
+
├── evaluators.ts
|
|
28
|
+
├── types.ts
|
|
29
|
+
└── utils.ts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Folder-based:**
|
|
33
|
+
```
|
|
34
|
+
workflow/
|
|
35
|
+
├── workflow.ts
|
|
36
|
+
├── steps/
|
|
37
|
+
│ ├── fetch_data.ts
|
|
38
|
+
│ └── process_data.ts
|
|
39
|
+
├── evaluators/
|
|
40
|
+
│ └── quality.ts
|
|
41
|
+
└── utils/
|
|
42
|
+
└── helpers.ts
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Import Rules
|
|
46
|
+
|
|
47
|
+
**Important:** Steps and evaluators are isolated execution units that cannot call each other.
|
|
48
|
+
|
|
49
|
+
**Steps can import from:**
|
|
50
|
+
- Local utilities (`./utils.ts`, `./utils/*.ts`)
|
|
51
|
+
- Shared utilities (`../../shared/utils/*.ts`)
|
|
52
|
+
- Clients (`../../clients/*.ts`)
|
|
53
|
+
|
|
54
|
+
**Steps cannot import from:**
|
|
55
|
+
- Other steps or evaluators (activity isolation)
|
|
56
|
+
- Workflow files
|
|
57
|
+
|
|
58
|
+
**Workflows can import from:**
|
|
59
|
+
- Steps, evaluators, and utilities (local and shared)
|
|
60
|
+
|
|
61
|
+
## Setup
|
|
62
|
+
|
|
63
|
+
### Environment Variables
|
|
64
|
+
|
|
65
|
+
Before running the workflow, configure your API keys in the `.env` file:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Required for LLM functionality
|
|
69
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
70
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
### Workflow Input
|
|
76
|
+
|
|
77
|
+
The workflow expects input matching the input schema defined in `types.ts`.
|
|
78
|
+
|
|
79
|
+
Example:
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"text": "Your input text"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Workflow Output
|
|
87
|
+
|
|
88
|
+
The workflow returns output matching the output schema defined in `types.ts`.
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"result": "The processed result"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
### Workflow Structure
|
|
100
|
+
|
|
101
|
+
The workflow follows the Output.ai conventions:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { workflow } from '@outputai/core';
|
|
105
|
+
import { myStep } from './steps.js';
|
|
106
|
+
import { workflowInputSchema, workflowOutputSchema } from './types.js';
|
|
107
|
+
|
|
108
|
+
export default workflow( {
|
|
109
|
+
name: 'workflowName',
|
|
110
|
+
description: 'Workflow description',
|
|
111
|
+
inputSchema: workflowInputSchema,
|
|
112
|
+
outputSchema: workflowOutputSchema,
|
|
113
|
+
fn: async ( input ) => {
|
|
114
|
+
const result = await myStep( input );
|
|
115
|
+
return { result };
|
|
116
|
+
}
|
|
117
|
+
} );
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Adding New Steps
|
|
121
|
+
|
|
122
|
+
Define steps in `steps.ts` with schemas:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { step, z } from '@outputai/core';
|
|
126
|
+
import { generateText, Output } from '@outputai/llm';
|
|
127
|
+
|
|
128
|
+
export const myStep = step( {
|
|
129
|
+
name: 'my_step',
|
|
130
|
+
description: 'Description of what this step does',
|
|
131
|
+
inputSchema: z.object( {
|
|
132
|
+
text: z.string()
|
|
133
|
+
} ),
|
|
134
|
+
outputSchema: z.object( {
|
|
135
|
+
result: z.string()
|
|
136
|
+
} ),
|
|
137
|
+
fn: async ( { text } ) => {
|
|
138
|
+
const { output } = await generateText( {
|
|
139
|
+
prompt: 'my_prompt@v1',
|
|
140
|
+
variables: { text },
|
|
141
|
+
output: Output.object( {
|
|
142
|
+
schema: z.object( { result: z.string() } )
|
|
143
|
+
} )
|
|
144
|
+
} );
|
|
145
|
+
return output;
|
|
146
|
+
}
|
|
147
|
+
} );
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Adding Evaluators
|
|
151
|
+
|
|
152
|
+
Define evaluators in `evaluators.ts`:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { evaluator, z, EvaluationVerdictResult } from '@outputai/core';
|
|
156
|
+
import { generateText, Output } from '@outputai/llm';
|
|
157
|
+
|
|
158
|
+
export const evaluateQuality = evaluator( {
|
|
159
|
+
name: 'evaluate_quality',
|
|
160
|
+
description: 'Evaluate output quality',
|
|
161
|
+
inputSchema: z.object( {
|
|
162
|
+
input: z.string(),
|
|
163
|
+
output: z.string()
|
|
164
|
+
} ),
|
|
165
|
+
fn: async ( { input, output } ) => {
|
|
166
|
+
const { output: evaluation } = await generateText( {
|
|
167
|
+
prompt: 'evaluate@v1',
|
|
168
|
+
variables: { input, output },
|
|
169
|
+
output: Output.object( { schema: EvaluationVerdictResult.schema } )
|
|
170
|
+
} );
|
|
171
|
+
|
|
172
|
+
return new EvaluationVerdictResult( evaluation );
|
|
173
|
+
}
|
|
174
|
+
} );
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Creating Prompt Templates
|
|
178
|
+
|
|
179
|
+
Create prompt files in `prompts/` following the pattern:
|
|
180
|
+
- File naming: `promptName@v1.prompt`
|
|
181
|
+
- Include YAML frontmatter with provider, model, temperature, and maxTokens
|
|
182
|
+
- Use LiquidJS syntax for variables: `{{ variableName }}`
|
|
183
|
+
|
|
184
|
+
Example prompt file:
|
|
185
|
+
```
|
|
186
|
+
---
|
|
187
|
+
provider: anthropic
|
|
188
|
+
model: claude-haiku-4-5
|
|
189
|
+
temperature: 0.3
|
|
190
|
+
maxTokens: 1024
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
<system>
|
|
194
|
+
You are an expert analyst.
|
|
195
|
+
</system>
|
|
196
|
+
|
|
197
|
+
<user>
|
|
198
|
+
{{ text }}
|
|
199
|
+
</user>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Testing
|
|
203
|
+
|
|
204
|
+
To test your workflow:
|
|
205
|
+
|
|
206
|
+
1. Start development services with `npx output dev`
|
|
207
|
+
2. Execute the workflow in a new terminal:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npx output workflow run {{workflowName}} test_input
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Resources
|
|
214
|
+
|
|
215
|
+
- [Output.ai Documentation](https://docs.output.ai)
|
|
216
|
+
- [Temporal Documentation](https://docs.temporal.io)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { evaluator, z, EvaluationVerdictResult } from '@outputai/core';
|
|
2
|
+
import { generateText, Output } from '@outputai/llm';
|
|
3
|
+
|
|
4
|
+
// TODO: Update the evaluator to assess your workflow's output quality
|
|
5
|
+
export const evaluate{{WorkflowName}} = evaluator( {
|
|
6
|
+
name: 'evaluate_{{workflowName}}',
|
|
7
|
+
description: 'Evaluate the quality of {{workflowName}} output',
|
|
8
|
+
inputSchema: z.object( {
|
|
9
|
+
input: z.string(),
|
|
10
|
+
output: z.string()
|
|
11
|
+
} ),
|
|
12
|
+
fn: async ( { input, output } ) => {
|
|
13
|
+
const { output: evaluation } = await generateText( {
|
|
14
|
+
prompt: 'example@v1',
|
|
15
|
+
variables: { text: `Input: ${input}\nOutput: ${output}\n\nDoes the output adequately address the input?` },
|
|
16
|
+
output: Output.object( { schema: EvaluationVerdictResult.schema } )
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
return new EvaluationVerdictResult( evaluation );
|
|
20
|
+
}
|
|
21
|
+
} );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
provider: anthropic
|
|
3
|
+
model: claude-haiku-4-5
|
|
4
|
+
temperature: 0.3
|
|
5
|
+
maxTokens: 4096
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<system>
|
|
9
|
+
You are a helpful assistant for the {{workflowName}} workflow.
|
|
10
|
+
</system>
|
|
11
|
+
|
|
12
|
+
<!-- TODO: Update this prompt to fit your use case -->
|
|
13
|
+
<user>
|
|
14
|
+
\{{ text }}
|
|
15
|
+
</user>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{
|
|
2
|
+
"text": "Artificial intelligence has transformed industries from healthcare to finance. Machine learning models now diagnose diseases, predict market trends, and automate complex decision-making processes. However, challenges remain around bias, interpretability, and the ethical implications of automated systems."
|
|
3
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { step, z } from '@outputai/core';
|
|
2
|
+
import { generateText } from '@outputai/llm';
|
|
3
|
+
|
|
4
|
+
export const processText = step( {
|
|
5
|
+
name: 'process_text',
|
|
6
|
+
description: 'Process text using an LLM',
|
|
7
|
+
inputSchema: z.object( {
|
|
8
|
+
text: z.string()
|
|
9
|
+
} ),
|
|
10
|
+
outputSchema: z.string(),
|
|
11
|
+
// TODO: Update or replace the generateText call to fit your use case
|
|
12
|
+
fn: async ( { text } ) => {
|
|
13
|
+
const { result } = await generateText( {
|
|
14
|
+
prompt: 'example@v1',
|
|
15
|
+
variables: { text }
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
} );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from '@outputai/core';
|
|
2
|
+
|
|
3
|
+
// TODO: Define schemas that match your workflow's input and output
|
|
4
|
+
export const workflowInputSchema = z.object( {
|
|
5
|
+
text: z.string().describe( 'The input text to process' )
|
|
6
|
+
} );
|
|
7
|
+
|
|
8
|
+
export const workflowOutputSchema = z.object( {
|
|
9
|
+
result: z.string().describe( 'The processed result' )
|
|
10
|
+
} );
|
|
11
|
+
|
|
12
|
+
export type WorkflowInput = z.infer<typeof workflowInputSchema>;
|
|
13
|
+
export type WorkflowOutput = z.infer<typeof workflowOutputSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { workflow } from '@outputai/core';
|
|
2
|
+
import { processText } from './steps.js';
|
|
3
|
+
import { workflowInputSchema, workflowOutputSchema } from './types.js';
|
|
4
|
+
|
|
5
|
+
export default workflow( {
|
|
6
|
+
name: '{{workflowName}}',
|
|
7
|
+
description: '{{description}}',
|
|
8
|
+
inputSchema: workflowInputSchema,
|
|
9
|
+
outputSchema: workflowOutputSchema,
|
|
10
|
+
// TODO: Update the workflow function to match your use case
|
|
11
|
+
fn: async ( { text } ) => {
|
|
12
|
+
const result = await processText( { text } );
|
|
13
|
+
|
|
14
|
+
return { result };
|
|
15
|
+
},
|
|
16
|
+
options: {
|
|
17
|
+
activityOptions: {
|
|
18
|
+
retry: {
|
|
19
|
+
maximumAttempts: 3
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} );
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Mock } from 'vitest';
|
|
2
|
+
/**
|
|
3
|
+
* Mock for @anthropic-ai/claude-agent-sdk
|
|
4
|
+
*/
|
|
5
|
+
export declare const mockClaudeAgentSDK: {
|
|
6
|
+
Agent: Mock;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Mock for @outputai/llm
|
|
10
|
+
*/
|
|
11
|
+
export declare const mockLLM: {
|
|
12
|
+
generateText: Mock;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Mock for child_process spawn (for agent commands)
|
|
16
|
+
*/
|
|
17
|
+
export declare const mockSpawn: Mock;
|
|
18
|
+
/**
|
|
19
|
+
* Mock for fs/promises
|
|
20
|
+
*/
|
|
21
|
+
export declare const mockFS: {
|
|
22
|
+
access: Mock;
|
|
23
|
+
mkdir: Mock;
|
|
24
|
+
writeFile: Mock;
|
|
25
|
+
readFile: Mock;
|
|
26
|
+
stat: Mock;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Mock for @inquirer/prompts
|
|
30
|
+
*/
|
|
31
|
+
export declare const mockInquirer: {
|
|
32
|
+
input: Mock;
|
|
33
|
+
confirm: Mock;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reset all mocks
|
|
37
|
+
*/
|
|
38
|
+
export declare function resetAllMocks(): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test mocks for workflow plan command
|
|
3
|
+
*/
|
|
4
|
+
import { vi } from 'vitest';
|
|
5
|
+
/**
|
|
6
|
+
* Mock for @anthropic-ai/claude-agent-sdk
|
|
7
|
+
*/
|
|
8
|
+
export const mockClaudeAgentSDK = {
|
|
9
|
+
Agent: vi.fn().mockImplementation(() => ({
|
|
10
|
+
execute: vi.fn().mockResolvedValue({
|
|
11
|
+
output: 'Mock plan output from claude-code'
|
|
12
|
+
})
|
|
13
|
+
}))
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mock for @outputai/llm
|
|
17
|
+
*/
|
|
18
|
+
export const mockLLM = {
|
|
19
|
+
generateText: vi.fn().mockResolvedValue({
|
|
20
|
+
text: 'workflow_plan_name',
|
|
21
|
+
sources: [],
|
|
22
|
+
usage: { inputTokens: 10, outputTokens: 5, totalTokens: 15 },
|
|
23
|
+
finishReason: 'stop'
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Mock for child_process spawn (for agent commands)
|
|
28
|
+
*/
|
|
29
|
+
export const mockSpawn = vi.fn().mockImplementation(() => {
|
|
30
|
+
const mockChild = {
|
|
31
|
+
on: vi.fn((event, callback) => {
|
|
32
|
+
if (event === 'close') {
|
|
33
|
+
// Simulate successful process exit
|
|
34
|
+
setTimeout(() => callback(0), 0);
|
|
35
|
+
}
|
|
36
|
+
return mockChild;
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
return mockChild;
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Mock for fs/promises
|
|
43
|
+
*/
|
|
44
|
+
export const mockFS = {
|
|
45
|
+
access: vi.fn().mockRejectedValue({ code: 'ENOENT' }), // Default: file doesn't exist
|
|
46
|
+
mkdir: vi.fn().mockResolvedValue(undefined),
|
|
47
|
+
writeFile: vi.fn().mockResolvedValue(undefined),
|
|
48
|
+
readFile: vi.fn().mockResolvedValue('template content'),
|
|
49
|
+
stat: vi.fn().mockRejectedValue({ code: 'ENOENT' })
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Mock for @inquirer/prompts
|
|
53
|
+
*/
|
|
54
|
+
export const mockInquirer = {
|
|
55
|
+
input: vi.fn().mockResolvedValue('Mock workflow description'),
|
|
56
|
+
confirm: vi.fn().mockResolvedValue(true)
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Reset all mocks
|
|
60
|
+
*/
|
|
61
|
+
export function resetAllMocks() {
|
|
62
|
+
vi.clearAllMocks();
|
|
63
|
+
// Reset mock implementations to defaults
|
|
64
|
+
mockFS.access.mockRejectedValue({ code: 'ENOENT' });
|
|
65
|
+
mockFS.mkdir.mockResolvedValue(undefined);
|
|
66
|
+
mockFS.writeFile.mockResolvedValue(undefined);
|
|
67
|
+
mockFS.readFile.mockResolvedValue('template content');
|
|
68
|
+
mockFS.stat.mockRejectedValue({ code: 'ENOENT' });
|
|
69
|
+
mockLLM.generateText.mockResolvedValue({
|
|
70
|
+
text: 'workflow_plan_name',
|
|
71
|
+
sources: [],
|
|
72
|
+
usage: { inputTokens: 10, outputTokens: 5, totalTokens: 15 },
|
|
73
|
+
finishReason: 'stop'
|
|
74
|
+
});
|
|
75
|
+
mockInquirer.input.mockResolvedValue('Mock workflow description');
|
|
76
|
+
mockInquirer.confirm.mockResolvedValue(true);
|
|
77
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost Calculator Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interfaces for trace parsing, pricing configuration, and cost reports.
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenUsage {
|
|
7
|
+
inputTokens?: number;
|
|
8
|
+
outputTokens?: number;
|
|
9
|
+
cachedInputTokens?: number;
|
|
10
|
+
reasoningTokens?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TraceNode {
|
|
13
|
+
id?: string;
|
|
14
|
+
kind: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
startedAt?: number;
|
|
17
|
+
endedAt?: number;
|
|
18
|
+
children?: TraceNode[];
|
|
19
|
+
input?: Record<string, unknown>;
|
|
20
|
+
output?: Record<string, unknown> & {
|
|
21
|
+
usage?: TokenUsage;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface LLMCall {
|
|
25
|
+
stepName: string;
|
|
26
|
+
llmName: string;
|
|
27
|
+
model: string;
|
|
28
|
+
usage: TokenUsage;
|
|
29
|
+
}
|
|
30
|
+
export interface HTTPCall {
|
|
31
|
+
stepName: string;
|
|
32
|
+
url: string;
|
|
33
|
+
method: string;
|
|
34
|
+
input: Record<string, unknown>;
|
|
35
|
+
output: Record<string, unknown>;
|
|
36
|
+
status?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ModelPricing {
|
|
39
|
+
provider: string;
|
|
40
|
+
input: number;
|
|
41
|
+
output: number;
|
|
42
|
+
cached_input?: number;
|
|
43
|
+
reasoning?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface EndpointConfig {
|
|
46
|
+
pattern: string;
|
|
47
|
+
units_per_request?: number;
|
|
48
|
+
units_per_line?: number;
|
|
49
|
+
price?: number;
|
|
50
|
+
price_per_item?: number;
|
|
51
|
+
items_path?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ServiceConfig {
|
|
54
|
+
type: 'token' | 'unit' | 'request' | 'response_cost';
|
|
55
|
+
url_pattern: string;
|
|
56
|
+
usage_path?: string;
|
|
57
|
+
per_million?: number;
|
|
58
|
+
input_field?: string;
|
|
59
|
+
output_field?: string;
|
|
60
|
+
input_per_million?: number;
|
|
61
|
+
output_per_million?: number;
|
|
62
|
+
price_per_unit?: number;
|
|
63
|
+
endpoints?: Record<string, EndpointConfig>;
|
|
64
|
+
model_path?: string;
|
|
65
|
+
models?: Record<string, number>;
|
|
66
|
+
default_price?: number;
|
|
67
|
+
cost_path?: string;
|
|
68
|
+
billable_method?: string;
|
|
69
|
+
fallback_models?: Record<string, number>;
|
|
70
|
+
default_fallback?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface PricingConfig {
|
|
73
|
+
models: Record<string, ModelPricing>;
|
|
74
|
+
services: Record<string, ServiceConfig>;
|
|
75
|
+
}
|
|
76
|
+
export interface LLMCostResult {
|
|
77
|
+
step: string;
|
|
78
|
+
model: string;
|
|
79
|
+
input: number;
|
|
80
|
+
output: number;
|
|
81
|
+
cached: number;
|
|
82
|
+
reasoning: number;
|
|
83
|
+
cost: number;
|
|
84
|
+
warning?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ServiceCostResult {
|
|
87
|
+
step: string;
|
|
88
|
+
cost: number;
|
|
89
|
+
usage: string;
|
|
90
|
+
model?: string;
|
|
91
|
+
endpoint?: string;
|
|
92
|
+
warning?: string;
|
|
93
|
+
details?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
export interface ServiceCostSummary {
|
|
96
|
+
serviceName: string;
|
|
97
|
+
calls: ServiceCostResult[];
|
|
98
|
+
totalCost: number;
|
|
99
|
+
}
|
|
100
|
+
export interface CostReport {
|
|
101
|
+
traceFile: string;
|
|
102
|
+
workflowName: string;
|
|
103
|
+
durationMs: number | null;
|
|
104
|
+
llmCalls: LLMCostResult[];
|
|
105
|
+
llmTotalCost: number;
|
|
106
|
+
totalInputTokens: number;
|
|
107
|
+
totalOutputTokens: number;
|
|
108
|
+
totalCachedTokens: number;
|
|
109
|
+
totalReasoningTokens: number;
|
|
110
|
+
unknownModels: string[];
|
|
111
|
+
services: ServiceCostSummary[];
|
|
112
|
+
serviceTotalCost: number;
|
|
113
|
+
totalCost: number;
|
|
114
|
+
}
|
|
115
|
+
export interface LLMModelSummary {
|
|
116
|
+
model: string;
|
|
117
|
+
count: number;
|
|
118
|
+
cost: number;
|
|
119
|
+
}
|
|
120
|
+
export interface ServiceSummary {
|
|
121
|
+
serviceName: string;
|
|
122
|
+
callCount: number;
|
|
123
|
+
cost: number;
|
|
124
|
+
}
|
|
125
|
+
export interface VerboseFlags {
|
|
126
|
+
hasReasoning: boolean;
|
|
127
|
+
hasCached: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface ParsedCostData {
|
|
130
|
+
traceFile: string;
|
|
131
|
+
workflowName: string;
|
|
132
|
+
duration: string;
|
|
133
|
+
llmModels: LLMModelSummary[];
|
|
134
|
+
llmTotalCalls: number;
|
|
135
|
+
llmTotalCost: number;
|
|
136
|
+
services: ServiceSummary[];
|
|
137
|
+
serviceTotalCalls: number;
|
|
138
|
+
serviceTotalCost: number;
|
|
139
|
+
verbose: VerboseFlags;
|
|
140
|
+
llmCalls: LLMCostResult[];
|
|
141
|
+
serviceDetails: ServiceCostSummary[];
|
|
142
|
+
totalInputTokens: number;
|
|
143
|
+
totalOutputTokens: number;
|
|
144
|
+
totalCachedTokens: number;
|
|
145
|
+
totalReasoningTokens: number;
|
|
146
|
+
totalCost: number;
|
|
147
|
+
unknownModels: string[];
|
|
148
|
+
isEmpty: boolean;
|
|
149
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain-specific types for improved type safety
|
|
3
|
+
*/
|
|
4
|
+
export type TodoStatus = 'pending' | 'in_progress' | 'completed';
|
|
5
|
+
export type FileMappingType = 'template' | 'symlink' | 'copy';
|
|
6
|
+
export type InstructionsType = 'plan' | 'build';
|
|
7
|
+
export interface Todo {
|
|
8
|
+
content: string;
|
|
9
|
+
activeForm: string;
|
|
10
|
+
status: TodoStatus;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidationResult {
|
|
13
|
+
isValid: boolean;
|
|
14
|
+
errors: string[];
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface SystemValidation {
|
|
18
|
+
missingCommands: string[];
|
|
19
|
+
hasIssues: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a workflow already exists
|
|
3
|
+
*/
|
|
4
|
+
export declare class WorkflowExistsError extends Error {
|
|
5
|
+
constructor(workflowName: string, targetPath: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when workflow name is invalid
|
|
9
|
+
*/
|
|
10
|
+
export declare class InvalidNameError extends Error {
|
|
11
|
+
constructor(name: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when template file is not found
|
|
15
|
+
*/
|
|
16
|
+
export declare class TemplateNotFoundError extends Error {
|
|
17
|
+
constructor(templateFile: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when output directory is invalid or inaccessible
|
|
21
|
+
*/
|
|
22
|
+
export declare class InvalidOutputDirectoryError extends Error {
|
|
23
|
+
constructor(outputDir: string, reason?: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error thrown when folder already exists during initialization
|
|
27
|
+
*/
|
|
28
|
+
export declare class FolderAlreadyExistsError extends Error {
|
|
29
|
+
folderPath: string;
|
|
30
|
+
constructor(folderPath: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when user cancels initialization
|
|
34
|
+
*/
|
|
35
|
+
export declare class UserCancelledError extends Error {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Type-safe error wrapper that preserves original error with context
|
|
40
|
+
*/
|
|
41
|
+
export declare class ProjectInitError extends Error {
|
|
42
|
+
readonly originalError: Error;
|
|
43
|
+
readonly projectPath: string | null;
|
|
44
|
+
constructor(message: string, originalError: Error, projectPath?: string | null);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when directory creation fails with project context
|
|
48
|
+
*/
|
|
49
|
+
export declare class DirectoryCreationError extends Error {
|
|
50
|
+
readonly projectPath: string;
|
|
51
|
+
/**
|
|
52
|
+
* @param message - The error message
|
|
53
|
+
* @param projectPath - The path where directory creation failed
|
|
54
|
+
*/
|
|
55
|
+
constructor(message: string, projectPath: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when a Claude CLI plugin command fails
|
|
59
|
+
*/
|
|
60
|
+
export declare class ClaudePluginError extends Error {
|
|
61
|
+
readonly commandName: string;
|
|
62
|
+
readonly originalError?: Error | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* @param commandName - The Claude command that failed (e.g., 'plugin update outputai')
|
|
65
|
+
* @param originalError - The underlying error from the command execution
|
|
66
|
+
*/
|
|
67
|
+
constructor(commandName: string, originalError?: Error | undefined);
|
|
68
|
+
}
|