@auto-engineer/model-factory 1.148.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/model-factory@1.148.0 build /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
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/
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/model-factory@1.147.0 test /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
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
   Test Files  1 passed (1)
11
11
   Tests  5 passed (5)
12
-  Start at  21:35:18
13
-  Duration  2.14s (transform 361ms, setup 0ms, collect 272ms, tests 162ms, environment 0ms, prepare 645ms)
12
+  Start at  07:22:24
13
+  Duration  2.21s (transform 375ms, setup 0ms, collect 300ms, tests 154ms, environment 0ms, prepare 661ms)
14
14
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @auto-engineer/model-factory@1.147.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
2
+ > @auto-engineer/model-factory@1.148.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
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
+
3
17
  ## 1.148.0
4
18
 
5
19
  ### 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` |
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "version": "1.148.0",
25
+ "version": "1.149.0",
26
26
  "scripts": {
27
27
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
28
28
  "test": "vitest run --reporter=dot",