@mariozechner/pi-ai 0.43.0 → 0.45.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/README.md +87 -0
- package/dist/models.generated.d.ts +922 -17
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +932 -27
- package/dist/models.generated.js.map +1 -1
- package/dist/providers/amazon-bedrock.d.ts +14 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +435 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +3 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/google-gemini-cli.d.ts +43 -1
- package/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/dist/providers/google-gemini-cli.js +369 -182
- package/dist/providers/google-gemini-cli.js.map +1 -1
- package/dist/providers/google-shared.d.ts +4 -0
- package/dist/providers/google-shared.d.ts.map +1 -1
- package/dist/providers/google-shared.js +32 -5
- package/dist/providers/google-shared.js.map +1 -1
- package/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/dist/providers/openai-codex-responses.js +1 -1
- package/dist/providers/openai-codex-responses.js.map +1 -1
- package/dist/providers/openai-completions.d.ts.map +1 -1
- package/dist/providers/openai-completions.js +30 -1
- package/dist/providers/openai-completions.js.map +1 -1
- package/dist/providers/openai-responses.d.ts +2 -0
- package/dist/providers/openai-responses.d.ts.map +1 -1
- package/dist/providers/openai-responses.js +25 -1
- package/dist/providers/openai-responses.js.map +1 -1
- package/dist/providers/{transorm-messages.d.ts → transform-messages.d.ts} +1 -1
- package/dist/providers/transform-messages.d.ts.map +1 -0
- package/dist/providers/{transorm-messages.js → transform-messages.js} +1 -1
- package/dist/providers/transform-messages.js.map +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +28 -0
- package/dist/stream.js.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +3 -0
- package/dist/utils/overflow.js.map +1 -1
- package/package.json +3 -1
- package/dist/providers/transorm-messages.d.ts.map +0 -1
- package/dist/providers/transorm-messages.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,9 +56,11 @@ Unified LLM API with automatic model discovery, provider configuration, token an
|
|
|
56
56
|
- **Cerebras**
|
|
57
57
|
- **xAI**
|
|
58
58
|
- **OpenRouter**
|
|
59
|
+
- **MiniMax**
|
|
59
60
|
- **GitHub Copilot** (requires OAuth, see below)
|
|
60
61
|
- **Google Gemini CLI** (requires OAuth, see below)
|
|
61
62
|
- **Antigravity** (requires OAuth, see below)
|
|
63
|
+
- **Amazon Bedrock**
|
|
62
64
|
- **Any OpenAI-compatible API**: Ollama, vLLM, LM Studio, etc.
|
|
63
65
|
|
|
64
66
|
## Installation
|
|
@@ -861,6 +863,7 @@ In Node.js environments, you can set environment variables to avoid passing API
|
|
|
861
863
|
| xAI | `XAI_API_KEY` |
|
|
862
864
|
| OpenRouter | `OPENROUTER_API_KEY` |
|
|
863
865
|
| zAI | `ZAI_API_KEY` |
|
|
866
|
+
| MiniMax | `MINIMAX_API_KEY` |
|
|
864
867
|
| GitHub Copilot | `COPILOT_GITHUB_TOKEN` or `GH_TOKEN` or `GITHUB_TOKEN` |
|
|
865
868
|
|
|
866
869
|
When set, the library automatically uses these keys:
|
|
@@ -1026,6 +1029,90 @@ const response = await complete(model, {
|
|
|
1026
1029
|
|
|
1027
1030
|
**Google Gemini CLI / Antigravity**: These use Google Cloud OAuth. The `apiKey` returned by `getOAuthApiKey()` is a JSON string containing both the token and project ID, which the library handles automatically.
|
|
1028
1031
|
|
|
1032
|
+
## Development
|
|
1033
|
+
|
|
1034
|
+
### Adding a New Provider
|
|
1035
|
+
|
|
1036
|
+
Adding a new LLM provider requires changes across multiple files. This checklist covers all necessary steps:
|
|
1037
|
+
|
|
1038
|
+
#### 1. Core Types (`src/types.ts`)
|
|
1039
|
+
|
|
1040
|
+
- Add the API identifier to the `Api` type union (e.g., `"bedrock-converse-stream"`)
|
|
1041
|
+
- Create an options interface extending `StreamOptions` (e.g., `BedrockOptions`)
|
|
1042
|
+
- Add the mapping to `ApiOptionsMap`
|
|
1043
|
+
- Add the provider name to `KnownProvider` type union (e.g., `"amazon-bedrock"`)
|
|
1044
|
+
|
|
1045
|
+
#### 2. Provider Implementation (`src/providers/`)
|
|
1046
|
+
|
|
1047
|
+
Create a new provider file (e.g., `amazon-bedrock.ts`) that exports:
|
|
1048
|
+
|
|
1049
|
+
- `stream<Provider>()` function returning `AssistantMessageEventStream`
|
|
1050
|
+
- Provider-specific options interface
|
|
1051
|
+
- Message conversion functions to transform `Context` to provider format
|
|
1052
|
+
- Tool conversion if the provider supports tools
|
|
1053
|
+
- Response parsing to emit standardized events (`text`, `tool_call`, `thinking`, `usage`, `stop`)
|
|
1054
|
+
|
|
1055
|
+
#### 3. Stream Integration (`src/stream.ts`)
|
|
1056
|
+
|
|
1057
|
+
- Import the provider's stream function and options type
|
|
1058
|
+
- Add credential detection in `getEnvApiKey()` for the new provider
|
|
1059
|
+
- Add a case in `mapOptionsForApi()` to map `SimpleStreamOptions` to provider options
|
|
1060
|
+
- Add the provider's stream function to the `streamFunctions` map
|
|
1061
|
+
|
|
1062
|
+
#### 4. Model Generation (`scripts/generate-models.ts`)
|
|
1063
|
+
|
|
1064
|
+
- Add logic to fetch and parse models from the provider's source (e.g., models.dev API)
|
|
1065
|
+
- Map provider model data to the standardized `Model` interface
|
|
1066
|
+
- Handle provider-specific quirks (pricing format, capability flags, model ID transformations)
|
|
1067
|
+
|
|
1068
|
+
#### 5. Tests (`test/`)
|
|
1069
|
+
|
|
1070
|
+
Create or update test files to cover the new provider:
|
|
1071
|
+
|
|
1072
|
+
- `stream.test.ts` - Basic streaming and tool use
|
|
1073
|
+
- `tokens.test.ts` - Token usage reporting
|
|
1074
|
+
- `abort.test.ts` - Request cancellation
|
|
1075
|
+
- `empty.test.ts` - Empty message handling
|
|
1076
|
+
- `context-overflow.test.ts` - Context limit errors
|
|
1077
|
+
- `image-limits.test.ts` - Image support (if applicable)
|
|
1078
|
+
- `unicode-surrogate.test.ts` - Unicode handling
|
|
1079
|
+
- `tool-call-without-result.test.ts` - Orphaned tool calls
|
|
1080
|
+
- `image-tool-result.test.ts` - Images in tool results
|
|
1081
|
+
- `total-tokens.test.ts` - Token counting accuracy
|
|
1082
|
+
|
|
1083
|
+
For providers with non-standard auth (AWS, Google Vertex), create a utility like `bedrock-utils.ts` with credential detection helpers.
|
|
1084
|
+
|
|
1085
|
+
#### 6. Coding Agent Integration (`../coding-agent/`)
|
|
1086
|
+
|
|
1087
|
+
Update `src/core/model-resolver.ts`:
|
|
1088
|
+
|
|
1089
|
+
- Add a default model ID for the provider in `DEFAULT_MODELS`
|
|
1090
|
+
|
|
1091
|
+
Update `src/cli/args.ts`:
|
|
1092
|
+
|
|
1093
|
+
- Add environment variable documentation in the help text
|
|
1094
|
+
|
|
1095
|
+
Update `README.md`:
|
|
1096
|
+
|
|
1097
|
+
- Add the provider to the providers section with setup instructions
|
|
1098
|
+
|
|
1099
|
+
#### 7. Documentation
|
|
1100
|
+
|
|
1101
|
+
Update `packages/ai/README.md`:
|
|
1102
|
+
|
|
1103
|
+
- Add to the Supported Providers table
|
|
1104
|
+
- Document any provider-specific options or authentication requirements
|
|
1105
|
+
- Add environment variable to the Environment Variables section
|
|
1106
|
+
|
|
1107
|
+
#### 8. Changelog
|
|
1108
|
+
|
|
1109
|
+
Add an entry to `packages/ai/CHANGELOG.md` under `## [Unreleased]`:
|
|
1110
|
+
|
|
1111
|
+
```markdown
|
|
1112
|
+
### Added
|
|
1113
|
+
- Added support for [Provider Name] provider ([#PR](link) by [@author](link))
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1029
1116
|
## License
|
|
1030
1117
|
|
|
1031
1118
|
MIT
|