@auto-engineer/model-factory 1.147.0 → 1.149.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +171 -0
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/model-factory@1.
|
|
2
|
+
> @auto-engineer/model-factory@1.149.0 build /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
|
|
3
3
|
> tsc && tsx ../../scripts/fix-esm-imports.ts
|
|
4
4
|
|
|
5
5
|
Fixed ESM imports in dist/
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/model-factory@1.
|
|
2
|
+
> @auto-engineer/model-factory@1.148.0 test /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
|
|
3
3
|
> vitest run --reporter=dot
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m5 passed[39m[22m[90m (5)[39m
|
|
12
|
-
[2m Start at [22m
|
|
13
|
-
[2m Duration [22m
|
|
12
|
+
[2m Start at [22m 07:22:24
|
|
13
|
+
[2m Duration [22m 2.21s[2m (transform 375ms, setup 0ms, collect 300ms, tests 154ms, environment 0ms, prepare 661ms)[22m
|
|
14
14
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @auto-engineer/model-factory
|
|
2
2
|
|
|
3
|
+
## 1.149.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
|
|
8
|
+
- **server-generator-apollo-emmett**: context-aware nonCommandField instructions
|
|
9
|
+
- **server-generator-apollo-emmett**: add state context instruction
|
|
10
|
+
- **server-generator-apollo-emmett**: extract shared template helpers
|
|
11
|
+
- **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
|
|
16
|
+
|
|
17
|
+
## 1.148.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [`d5ba3a0`](https://github.com/BeOnAuto/auto-engineer/commit/d5ba3a0e3fb0f6a9ad7a3a8b1815590ea77a5b42) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added state context instruction to generated decide handlers, preventing unnecessary narrowing when Given steps contain only state references
|
|
22
|
+
|
|
23
|
+
- [`e0cdc4e`](https://github.com/BeOnAuto/auto-engineer/commit/e0cdc4e3363ad84d4bc49996a600ac75c97ccc38) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added context-aware classification of non-command fields in generated decide.ts scaffolds, distinguishing between date-derived, state-derived, and not-yet-tested fields
|
|
24
|
+
|
|
25
|
+
- [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helpers into a dedicated module for cleaner code generation
|
|
26
|
+
|
|
27
|
+
- [`abb6540`](https://github.com/BeOnAuto/auto-engineer/commit/abb6540db7196ed7935c8a8610695828f9035fc3) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added status variant hints from Given state references to the state template, helping implementers create matching discriminated union variants
|
|
28
|
+
|
|
29
|
+
- [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helper functions into a dedicated module for better code reuse across generators
|
|
30
|
+
- Simplified template specs by removing inline duplicate definitions in favor of the shared helpers
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`88fb1da`](https://github.com/BeOnAuto/auto-engineer/commit/88fb1da2b222de04dd4959d87657395ee960a6ce) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: skip empty file plans in scaffold output
|
|
35
|
+
- **server-generator-apollo-emmett**: filter state refs from given() in decide.specs.ts.ejs
|
|
36
|
+
- **server-generator-apollo-emmett**: move CS Given states from events to states array
|
|
37
|
+
- **global**: version packages
|
|
38
|
+
- **server-generator-apollo-emmett**: mark G1+G2 ketchup plan complete
|
|
39
|
+
|
|
40
|
+
- [`4255f6d`](https://github.com/BeOnAuto/auto-engineer/commit/4255f6db0d128979e573244a615886482ce799b0) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Updated ketchup plan for state reference fix in decide template generator
|
|
41
|
+
- Marked generator bug fix milestones G1 and G2 as complete
|
|
42
|
+
|
|
43
|
+
- [`62f1ea3`](https://github.com/BeOnAuto/auto-engineer/commit/62f1ea3dd1b4275211574e3df9d9a6571ae9b27a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Fixed scaffold generation to correctly distinguish between event and state references in decision handlers
|
|
44
|
+
- Prevented contradictory instructions from appearing in generated code when Given clauses contain only state references
|
|
45
|
+
|
|
46
|
+
- [`ba4f5c9`](https://github.com/BeOnAuto/auto-engineer/commit/ba4f5c9749fb1c15d444e78ca9a2689817f039cb) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added implementation plan for decide.ts code generation fixes in the Apollo Emmett server generator
|
|
47
|
+
|
|
3
48
|
## 1.147.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @auto-engineer/model-factory
|
|
2
|
+
|
|
3
|
+
Creates a Vercel AI SDK `LanguageModel` from environment variables, connecting to any OpenAI-compatible provider.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Without `model-factory`, you would have to hard-code provider setup logic (provider name, base URL, API key, model ID) in every package that needs an LLM. This module centralises that configuration into four environment variables and returns a ready-to-use `LanguageModel` instance.
|
|
10
|
+
|
|
11
|
+
The design is deliberately minimal: one function, four env vars, no config files. Any OpenAI-compatible API gateway (LiteLLM, OpenRouter, a direct provider endpoint) works without code changes.
|
|
12
|
+
|
|
13
|
+
## Key Concepts
|
|
14
|
+
|
|
15
|
+
- **OpenAI-compatible provider** -- The factory uses `@ai-sdk/openai-compatible` under the hood, so any provider that exposes an OpenAI-shaped chat completions API is supported.
|
|
16
|
+
- **Environment-driven configuration** -- All connection details come from `CUSTOM_PROVIDER_*` environment variables. No constructor arguments, no config objects.
|
|
17
|
+
- **Vercel AI SDK integration** -- The returned object satisfies the AI SDK `LanguageModel` interface and can be passed directly to `generateText`, `streamText`, and other AI SDK functions.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @auto-engineer/model-factory
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Peer dependency:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add ai
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Set the required environment variables:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
export CUSTOM_PROVIDER_NAME="litellm"
|
|
41
|
+
export CUSTOM_PROVIDER_BASE_URL="https://gateway.example.com/v1"
|
|
42
|
+
export CUSTOM_PROVIDER_API_KEY="sk-..."
|
|
43
|
+
export CUSTOM_PROVIDER_DEFAULT_MODEL="xai/grok-code-fast-1"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then create and use a model:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { createModelFromEnv } from '@auto-engineer/model-factory';
|
|
50
|
+
import { generateText } from 'ai';
|
|
51
|
+
|
|
52
|
+
const model = createModelFromEnv();
|
|
53
|
+
|
|
54
|
+
const { text } = await generateText({
|
|
55
|
+
model,
|
|
56
|
+
prompt: 'Explain monads in one sentence.',
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## How-to Guides
|
|
63
|
+
|
|
64
|
+
### Connect to a different provider
|
|
65
|
+
|
|
66
|
+
Change the environment variables -- no code changes required:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# OpenRouter
|
|
70
|
+
export CUSTOM_PROVIDER_NAME="openrouter"
|
|
71
|
+
export CUSTOM_PROVIDER_BASE_URL="https://openrouter.ai/api/v1"
|
|
72
|
+
export CUSTOM_PROVIDER_API_KEY="sk-or-..."
|
|
73
|
+
export CUSTOM_PROVIDER_DEFAULT_MODEL="anthropic/claude-sonnet-4-20250514"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Use in tests
|
|
77
|
+
|
|
78
|
+
Mock the module or set test-specific env vars before importing:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
process.env.CUSTOM_PROVIDER_NAME = 'test-provider';
|
|
82
|
+
process.env.CUSTOM_PROVIDER_BASE_URL = 'http://localhost:4000/v1';
|
|
83
|
+
process.env.CUSTOM_PROVIDER_API_KEY = 'test-key';
|
|
84
|
+
process.env.CUSTOM_PROVIDER_DEFAULT_MODEL = 'test-model';
|
|
85
|
+
|
|
86
|
+
const { createModelFromEnv } = await import('@auto-engineer/model-factory');
|
|
87
|
+
const model = createModelFromEnv();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### Package Exports
|
|
95
|
+
|
|
96
|
+
| Export | Kind | Description |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `createModelFromEnv` | Function | Creates a `LanguageModel` from environment variables |
|
|
99
|
+
| `ChatMessage` | Interface | A single chat message with role and content |
|
|
100
|
+
| `ChatTurn` | Interface | A prompt/response pair |
|
|
101
|
+
|
|
102
|
+
### Functions
|
|
103
|
+
|
|
104
|
+
#### `createModelFromEnv()`
|
|
105
|
+
|
|
106
|
+
Creates a Vercel AI SDK `LanguageModel` by reading four required environment variables.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
function createModelFromEnv(): LanguageModel
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Environment variables (all required):**
|
|
113
|
+
|
|
114
|
+
| Variable | Description |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `CUSTOM_PROVIDER_NAME` | Identifier for the provider (e.g. `"litellm"`) |
|
|
117
|
+
| `CUSTOM_PROVIDER_BASE_URL` | Base URL of the OpenAI-compatible API |
|
|
118
|
+
| `CUSTOM_PROVIDER_API_KEY` | API key for authentication |
|
|
119
|
+
| `CUSTOM_PROVIDER_DEFAULT_MODEL` | Model identifier to use (e.g. `"xai/grok-code-fast-1"`) |
|
|
120
|
+
|
|
121
|
+
**Throws:** `Error` if any of the four environment variables is missing or empty.
|
|
122
|
+
|
|
123
|
+
**Returns:** A `LanguageModel` instance backed by the configured provider.
|
|
124
|
+
|
|
125
|
+
### Interfaces
|
|
126
|
+
|
|
127
|
+
#### `ChatMessage`
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface ChatMessage {
|
|
131
|
+
role: 'user' | 'assistant';
|
|
132
|
+
content: string;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `ChatTurn`
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface ChatTurn {
|
|
140
|
+
prompt: ChatMessage;
|
|
141
|
+
response: ChatMessage;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Architecture
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
src/
|
|
151
|
+
index.ts # createModelFromEnv, ChatMessage, ChatTurn
|
|
152
|
+
index.specs.ts # Unit tests
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Dependencies
|
|
156
|
+
|
|
157
|
+
| Package | Purpose |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `@ai-sdk/openai-compatible` | Creates the underlying provider client |
|
|
160
|
+
| `ai` (peer) | Provides the `LanguageModel` type |
|
|
161
|
+
|
|
162
|
+
### Unused direct dependencies
|
|
163
|
+
|
|
164
|
+
The following packages are listed in `dependencies` but are not currently imported in source code. They may be intended for future provider-specific factories:
|
|
165
|
+
|
|
166
|
+
| Package |
|
|
167
|
+
|---|
|
|
168
|
+
| `@ai-sdk/anthropic` |
|
|
169
|
+
| `@ai-sdk/google` |
|
|
170
|
+
| `@ai-sdk/openai` |
|
|
171
|
+
| `@ai-sdk/xai` |
|