ai-world-sdk 1.5.11 → 1.5.13
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/cli/commands/config-cmd.js +1 -1
- package/dist/cli/config.js +3 -2
- package/dist/config.d.ts +3 -3
- package/dist/config.js +11 -5
- package/dist/llm.js +3 -3
- package/dist/vite-plugin.js +3 -1
- package/package.json +3 -2
- package/skills/ai-world-sdk/SKILL.md +1 -0
- package/skills/ai-world-sdk/docs/cli-usage.md +7 -4
- package/pacakges/ai-sdk-provider/.changeset/README.md +0 -34
- package/pacakges/ai-sdk-provider/.changeset/config.json +0 -13
- package/pacakges/ai-sdk-provider/.github/PULL_REQUEST_TEMPLATE.md +0 -16
- package/pacakges/ai-sdk-provider/.github/workflows/ci.yaml +0 -24
- package/pacakges/ai-sdk-provider/.github/workflows/publish-manual.yaml +0 -36
- package/pacakges/ai-sdk-provider/.github/workflows/publish.yaml +0 -107
- package/pacakges/ai-sdk-provider/.vscode/settings.json +0 -32
- package/pacakges/ai-sdk-provider/CHANGELOG.md +0 -631
- package/pacakges/ai-sdk-provider/CLAUDE.md +0 -79
- package/pacakges/ai-sdk-provider/CONTRIBUTING.md +0 -241
- package/pacakges/ai-sdk-provider/LICENSE +0 -201
- package/pacakges/ai-sdk-provider/README.md +0 -426
- package/pacakges/ai-sdk-provider/biome.json +0 -122
- package/pacakges/ai-sdk-provider/e2e/cache-control.test.ts +0 -74
- package/pacakges/ai-sdk-provider/e2e/embeddings/index.test.ts +0 -128
- package/pacakges/ai-sdk-provider/e2e/fixtures/pdfs/generate-pdfs.sh +0 -181
- package/pacakges/ai-sdk-provider/e2e/fixtures/pdfs/large.json +0 -7
- package/pacakges/ai-sdk-provider/e2e/fixtures/pdfs/large.pdf +41 -12894
- package/pacakges/ai-sdk-provider/e2e/gemini/reasoning-multiturn.test.ts +0 -221
- package/pacakges/ai-sdk-provider/e2e/issues/issue-160-toolcallid-uniqueness.test.ts +0 -88
- package/pacakges/ai-sdk-provider/e2e/issues/issue-166-finish-reason-null.test.ts +0 -129
- package/pacakges/ai-sdk-provider/e2e/issues/issue-171-cache-tool-key-ordering.test.ts +0 -70
- package/pacakges/ai-sdk-provider/e2e/issues/issue-181-tool-response-image.test.ts +0 -199
- package/pacakges/ai-sdk-provider/e2e/issues/issue-190-streamobject-flush-error.test.ts +0 -114
- package/pacakges/ai-sdk-provider/e2e/issues/issue-194-grok-invalid-json.test.ts +0 -93
- package/pacakges/ai-sdk-provider/e2e/issues/issue-196-anthropic-1h-cache-ttl.test.ts +0 -85
- package/pacakges/ai-sdk-provider/e2e/issues/issue-199-openai-pdf-processing.test.ts +0 -102
- package/pacakges/ai-sdk-provider/e2e/issues/issue-212-anthropic-web-search-online.test.ts +0 -128
- package/pacakges/ai-sdk-provider/e2e/issues/issue-234-prompt-caching.test.ts +0 -201
- package/pacakges/ai-sdk-provider/e2e/issues/issue-237-reasoning-linebreaks.test.ts +0 -103
- package/pacakges/ai-sdk-provider/e2e/issues/issue-248-gemini-web-search-empty-response.test.ts +0 -210
- package/pacakges/ai-sdk-provider/e2e/issues/issue-269-image-size-parameter.test.ts +0 -208
- package/pacakges/ai-sdk-provider/e2e/issues/issue-287-tool-calls-missing-arguments.test.ts +0 -87
- package/pacakges/ai-sdk-provider/e2e/issues/issue-341-cache-control-last-text-part.test.ts +0 -138
- package/pacakges/ai-sdk-provider/e2e/issues/issue-383-video-url-support.test.ts +0 -120
- package/pacakges/ai-sdk-provider/e2e/issues/issue-386-image-files-parameter.test.ts +0 -109
- package/pacakges/ai-sdk-provider/e2e/issues/issue-387-temperature-settings.test.ts +0 -113
- package/pacakges/ai-sdk-provider/e2e/issues/issue-389-system-cache-control.test.ts +0 -107
- package/pacakges/ai-sdk-provider/e2e/issues/issue-391-reasoning-effort-values.test.ts +0 -121
- package/pacakges/ai-sdk-provider/e2e/issues/issue-392-auto-router-plugin.test.ts +0 -84
- package/pacakges/ai-sdk-provider/e2e/issues/issue-394-reasoning-end-signature.test.ts +0 -157
- package/pacakges/ai-sdk-provider/e2e/issues/issue-407-token-usage-details.test.ts +0 -141
- package/pacakges/ai-sdk-provider/e2e/issues/issue-411-output-object-tools-conflict.test.ts +0 -75
- package/pacakges/ai-sdk-provider/e2e/issues/issue-412-mid-stream-termination.test.ts +0 -217
- package/pacakges/ai-sdk-provider/e2e/issues/issue-413-reasoning-metadata-bloat.test.ts +0 -292
- package/pacakges/ai-sdk-provider/e2e/issues/issue-413-tool-input-end-streaming.test.ts +0 -167
- package/pacakges/ai-sdk-provider/e2e/issues/issue-418-gemini-thought-signature.test.ts +0 -171
- package/pacakges/ai-sdk-provider/e2e/issues/issue-419-420-finish-reason-usage-fallback.test.ts +0 -87
- package/pacakges/ai-sdk-provider/e2e/issues/issue-419-usage-fallback.test.ts +0 -106
- package/pacakges/ai-sdk-provider/e2e/issues/issue-422-incomplete-error-information.test.ts +0 -46
- package/pacakges/ai-sdk-provider/e2e/issues/issue-423-signature-stripped.test.ts +0 -165
- package/pacakges/ai-sdk-provider/e2e/issues/issue-423-streaming-signature-loss.test.ts +0 -161
- package/pacakges/ai-sdk-provider/e2e/issues/issue-423-uimessage-roundtrip.test.ts +0 -111
- package/pacakges/ai-sdk-provider/e2e/issues/issue-424-anthropic-auto-cache.test.ts +0 -66
- package/pacakges/ai-sdk-provider/e2e/issues/issue-432-raw-response-body.test.ts +0 -52
- package/pacakges/ai-sdk-provider/e2e/issues/issue-438-gemini-reasoning-redacted.test.ts +0 -120
- package/pacakges/ai-sdk-provider/e2e/issues/issue-439-exact-payload.test.ts +0 -108
- package/pacakges/ai-sdk-provider/e2e/issues/issue-443-eager-input-streaming.test.ts +0 -204
- package/pacakges/ai-sdk-provider/e2e/issues/issue-453-signature-reopen.test.ts +0 -203
- package/pacakges/ai-sdk-provider/e2e/issues/issue-474-web-search-server-tool.test.ts +0 -102
- package/pacakges/ai-sdk-provider/e2e/issues/issue-483-response-format-strict-option.test.ts +0 -199
- package/pacakges/ai-sdk-provider/e2e/issues/issue-484-image-url-query-params.test.ts +0 -165
- package/pacakges/ai-sdk-provider/e2e/issues/issue-63-web-search-annotations.test.ts +0 -159
- package/pacakges/ai-sdk-provider/e2e/parallel-tool-calls.test.ts +0 -425
- package/pacakges/ai-sdk-provider/e2e/pdf-blob/index.test.ts +0 -139
- package/pacakges/ai-sdk-provider/e2e/pdf-url/index.test.ts +0 -60
- package/pacakges/ai-sdk-provider/e2e/reasoning-effort.test.ts +0 -139
- package/pacakges/ai-sdk-provider/e2e/reasoning-multiturn/index.test.ts +0 -69
- package/pacakges/ai-sdk-provider/e2e/tools-with-reasoning.test.ts +0 -76
- package/pacakges/ai-sdk-provider/e2e/tools.ts +0 -61
- package/pacakges/ai-sdk-provider/e2e/usage-accounting.test.ts +0 -55
- package/pacakges/ai-sdk-provider/e2e/utils.ts +0 -15
- package/pacakges/ai-sdk-provider/e2e/video-generation.test.ts +0 -43
- package/pacakges/ai-sdk-provider/e2e/web-search/index.test.ts +0 -50
- package/pacakges/ai-sdk-provider/example.env.e2e +0 -3
- package/pacakges/ai-sdk-provider/pnpm-lock.yaml +0 -3075
- package/pacakges/ai-sdk-provider/pnpm-workspace.yaml +0 -6
- package/pacakges/ai-sdk-provider/src/chat/convert-to-openrouter-chat-messages.test.ts +0 -3079
- package/pacakges/ai-sdk-provider/src/chat/convert-to-openrouter-chat-messages.ts +0 -618
- package/pacakges/ai-sdk-provider/src/chat/errors.test.ts +0 -97
- package/pacakges/ai-sdk-provider/src/chat/file-parser-schema.test.ts +0 -112
- package/pacakges/ai-sdk-provider/src/chat/file-url-utils.ts +0 -167
- package/pacakges/ai-sdk-provider/src/chat/get-tool-choice.ts +0 -42
- package/pacakges/ai-sdk-provider/src/chat/index.test.ts +0 -6093
- package/pacakges/ai-sdk-provider/src/chat/index.ts +0 -1300
- package/pacakges/ai-sdk-provider/src/chat/is-url.ts +0 -15
- package/pacakges/ai-sdk-provider/src/chat/large-pdf-response.test.ts +0 -108
- package/pacakges/ai-sdk-provider/src/chat/payload-comparison.test.ts +0 -154
- package/pacakges/ai-sdk-provider/src/chat/schemas.ts +0 -288
- package/pacakges/ai-sdk-provider/src/chat/signature-roundtrip.test.ts +0 -777
- package/pacakges/ai-sdk-provider/src/completion/convert-to-openrouter-completion-prompt.ts +0 -150
- package/pacakges/ai-sdk-provider/src/completion/index.test.ts +0 -958
- package/pacakges/ai-sdk-provider/src/completion/index.ts +0 -441
- package/pacakges/ai-sdk-provider/src/completion/schemas.ts +0 -67
- package/pacakges/ai-sdk-provider/src/embedding/index.test.ts +0 -262
- package/pacakges/ai-sdk-provider/src/embedding/index.ts +0 -113
- package/pacakges/ai-sdk-provider/src/embedding/schemas.ts +0 -26
- package/pacakges/ai-sdk-provider/src/facade.ts +0 -131
- package/pacakges/ai-sdk-provider/src/image/index.test.ts +0 -769
- package/pacakges/ai-sdk-provider/src/image/index.ts +0 -206
- package/pacakges/ai-sdk-provider/src/image/schemas.ts +0 -48
- package/pacakges/ai-sdk-provider/src/index.ts +0 -3
- package/pacakges/ai-sdk-provider/src/internal/index.ts +0 -10
- package/pacakges/ai-sdk-provider/src/provider.ts +0 -327
- package/pacakges/ai-sdk-provider/src/schemas/error-response.test.ts +0 -171
- package/pacakges/ai-sdk-provider/src/schemas/error-response.ts +0 -105
- package/pacakges/ai-sdk-provider/src/schemas/format.ts +0 -12
- package/pacakges/ai-sdk-provider/src/schemas/image.ts +0 -23
- package/pacakges/ai-sdk-provider/src/schemas/provider-metadata.ts +0 -91
- package/pacakges/ai-sdk-provider/src/schemas/reasoning-details.ts +0 -92
- package/pacakges/ai-sdk-provider/src/tests/provider-options.test.ts +0 -234
- package/pacakges/ai-sdk-provider/src/tests/stream-usage-accounting.test.ts +0 -409
- package/pacakges/ai-sdk-provider/src/tests/usage-accounting.test.ts +0 -555
- package/pacakges/ai-sdk-provider/src/tests/web-search-tool.test.ts +0 -319
- package/pacakges/ai-sdk-provider/src/tool/web-search.ts +0 -52
- package/pacakges/ai-sdk-provider/src/types/index.ts +0 -114
- package/pacakges/ai-sdk-provider/src/types/openrouter-api-types.ts +0 -83
- package/pacakges/ai-sdk-provider/src/types/openrouter-chat-completions-input.ts +0 -116
- package/pacakges/ai-sdk-provider/src/types/openrouter-chat-settings.ts +0 -233
- package/pacakges/ai-sdk-provider/src/types/openrouter-completion-settings.ts +0 -39
- package/pacakges/ai-sdk-provider/src/types/openrouter-embedding-settings.ts +0 -56
- package/pacakges/ai-sdk-provider/src/types/openrouter-image-settings.ts +0 -49
- package/pacakges/ai-sdk-provider/src/types/openrouter-video-settings.ts +0 -26
- package/pacakges/ai-sdk-provider/src/utils/compute-token-usage.test.ts +0 -186
- package/pacakges/ai-sdk-provider/src/utils/compute-token-usage.ts +0 -55
- package/pacakges/ai-sdk-provider/src/utils/deterministic-stringify.test.ts +0 -87
- package/pacakges/ai-sdk-provider/src/utils/deterministic-stringify.ts +0 -35
- package/pacakges/ai-sdk-provider/src/utils/map-finish-reason.ts +0 -43
- package/pacakges/ai-sdk-provider/src/utils/reasoning-details-duplicate-tracker.test.ts +0 -324
- package/pacakges/ai-sdk-provider/src/utils/reasoning-details-duplicate-tracker.ts +0 -70
- package/pacakges/ai-sdk-provider/src/utils/remove-undefined.ts +0 -12
- package/pacakges/ai-sdk-provider/src/utils/type-guards.ts +0 -6
- package/pacakges/ai-sdk-provider/src/utils/with-stream-error-handling.test.ts +0 -119
- package/pacakges/ai-sdk-provider/src/utils/with-stream-error-handling.ts +0 -25
- package/pacakges/ai-sdk-provider/src/utils/with-user-agent-suffix.test.ts +0 -133
- package/pacakges/ai-sdk-provider/src/utils/with-user-agent-suffix.ts +0 -78
- package/pacakges/ai-sdk-provider/src/version.ts +0 -4
- package/pacakges/ai-sdk-provider/src/video/index.test.ts +0 -515
- package/pacakges/ai-sdk-provider/src/video/index.ts +0 -275
- package/pacakges/ai-sdk-provider/src/video/schemas.ts +0 -36
- package/pacakges/ai-sdk-provider/tsconfig.json +0 -42
- package/pacakges/ai-sdk-provider/tsup.config.ts +0 -28
- package/pacakges/ai-sdk-provider/turbo.json +0 -8
- package/pacakges/ai-sdk-provider/vitest.e2e.config.ts +0 -21
- package/pacakges/ai-sdk-provider/vitest.edge.config.ts +0 -16
- package/pacakges/ai-sdk-provider/vitest.issues.config.ts +0 -28
- package/pacakges/ai-sdk-provider/vitest.node.config.ts +0 -16
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
OpenRouter Provider for Vercel AI SDK (`@openrouter/ai-sdk-provider`) - A TypeScript provider that integrates OpenRouter's API with the Vercel AI SDK, enabling access to 300+ language models through a unified interface.
|
|
8
|
-
|
|
9
|
-
## Common Commands
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
pnpm build # Build with tsup (ESM + CJS outputs)
|
|
13
|
-
pnpm dev # Watch mode development build
|
|
14
|
-
pnpm test # Run all tests (node + edge environments)
|
|
15
|
-
pnpm test:node # Run Node.js tests only
|
|
16
|
-
pnpm test:edge # Run Edge runtime tests only
|
|
17
|
-
pnpm test:e2e # Run E2E tests (requires OPENROUTER_API_KEY in .env.e2e)
|
|
18
|
-
pnpm typecheck # TypeScript type checking
|
|
19
|
-
pnpm stylecheck # Biome linting + formatting check
|
|
20
|
-
pnpm format # Auto-fix formatting issues
|
|
21
|
-
pnpm changeset # Create a changeset for release
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Running a Single Test
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pnpm vitest run src/chat/index.test.ts # Single test file (node)
|
|
28
|
-
pnpm vitest run src/chat/index.test.ts -t "test name" # Specific test by name
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Architecture
|
|
32
|
-
|
|
33
|
-
### Source Structure
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
src/
|
|
37
|
-
├── provider.ts # Factory: createOpenRouter() and default openrouter instance
|
|
38
|
-
├── facade.ts # Deprecated OpenRouter class (legacy support)
|
|
39
|
-
├── chat/index.ts # OpenRouterChatLanguageModel - main chat implementation
|
|
40
|
-
├── completion/index.ts # OpenRouterCompletionLanguageModel - completions
|
|
41
|
-
├── embedding/index.ts # OpenRouterEmbeddingModel - embeddings
|
|
42
|
-
├── types/ # TypeScript interfaces for settings
|
|
43
|
-
├── schemas/ # Zod schemas for request/response validation
|
|
44
|
-
└── internal/ # Conditional export: @openrouter/ai-sdk-provider/internal
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Key Patterns
|
|
48
|
-
|
|
49
|
-
- **Provider Factory**: `createOpenRouter(options)` returns a provider with `.chat()`, `.completion()`, and `.textEmbeddingModel()` methods
|
|
50
|
-
- **Message Conversion**: `convert-to-openrouter-chat-messages.ts` transforms AI SDK messages to OpenRouter format (handles images, files, cache control, tool results)
|
|
51
|
-
- **Dual Build Output**: tsup generates both main (`dist/`) and internal (`dist/internal/`) exports
|
|
52
|
-
|
|
53
|
-
### Test Environments
|
|
54
|
-
|
|
55
|
-
Tests run in three environments via separate Vitest configs:
|
|
56
|
-
- **Node.js** (`vitest.node.config.ts`) - Server-side tests
|
|
57
|
-
- **Edge Runtime** (`vitest.edge.config.ts`) - Serverless compatibility
|
|
58
|
-
- **E2E** (`vitest.e2e.config.ts`) - Real API integration (uses `.env.e2e`)
|
|
59
|
-
|
|
60
|
-
Test files are co-located with source: `src/chat/index.test.ts` tests `src/chat/index.ts`.
|
|
61
|
-
|
|
62
|
-
## Code Style
|
|
63
|
-
|
|
64
|
-
- Biome for linting/formatting (2 spaces, single quotes, 80 char line width)
|
|
65
|
-
- Tests may use explicit any and console (configured in biome.json overrides)
|
|
66
|
-
- Import organization: type imports first, then regular imports, then aliases
|
|
67
|
-
|
|
68
|
-
## Dev Workflow
|
|
69
|
-
|
|
70
|
-
After completing any implementation task, automatically:
|
|
71
|
-
|
|
72
|
-
1. Commit **all** changes (including `package.json`, `pnpm-lock.yaml`)
|
|
73
|
-
2. Run `pnpm stylecheck && pnpm typecheck && pnpm test && pnpm build`
|
|
74
|
-
3. Add changeset (`pnpm changeset --empty` for non-user-facing changes)
|
|
75
|
-
4. Create PR on a `claude/` branch using the template in `.github/PULL_REQUEST_TEMPLATE.md`
|
|
76
|
-
5. Wait for CI to pass, fix any issues
|
|
77
|
-
6. Provide the PR link when complete
|
|
78
|
-
|
|
79
|
-
**Key principle**: Always ensure git state is clean and CI passes before considering work complete. Local tests can pass with uncommitted dependency changes - CI is the source of truth.
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# Contributing to the OpenRouter AI SDK Provider
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to the OpenRouter provider for the Vercel AI SDK! This guide will help you get started as a contributor.
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
### Prerequisites
|
|
8
|
-
|
|
9
|
-
- Node.js v18 or higher
|
|
10
|
-
- pnpm v9.15.0 or higher (the project uses pnpm as its package manager)
|
|
11
|
-
|
|
12
|
-
### Setting Up the Repository
|
|
13
|
-
|
|
14
|
-
1. Fork the repository on GitHub
|
|
15
|
-
2. Clone your fork locally:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
git clone https://github.com/YOUR-USERNAME/ai-sdk-provider.git
|
|
19
|
-
cd ai-sdk-provider
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
3. Install dependencies:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm install
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
4. Build the project:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pnpm build
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Development Workflow
|
|
35
|
-
|
|
36
|
-
### Building
|
|
37
|
-
|
|
38
|
-
To build the package during development:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# Build once
|
|
42
|
-
pnpm build
|
|
43
|
-
|
|
44
|
-
# Build in watch mode for continuous development
|
|
45
|
-
pnpm dev
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Code Style and Formatting
|
|
49
|
-
|
|
50
|
-
We use Biome for code linting and formatting. Before submitting a PR, make sure your code passes all checks:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Check both linting and formatting
|
|
54
|
-
pnpm stylecheck
|
|
55
|
-
|
|
56
|
-
# Fix formatting issues automatically
|
|
57
|
-
pnpm format
|
|
58
|
-
|
|
59
|
-
# Run linting and formatting checks
|
|
60
|
-
pnpm stylecheck
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Type Checking
|
|
64
|
-
|
|
65
|
-
Ensure your changes pass TypeScript type checking:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
pnpm typecheck
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Testing
|
|
72
|
-
|
|
73
|
-
The project includes tests for both Node.js and Edge environments. Make sure to run the tests before submitting a PR:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
# Run all tests
|
|
77
|
-
pnpm test
|
|
78
|
-
|
|
79
|
-
# Run only Node.js tests
|
|
80
|
-
pnpm test:node
|
|
81
|
-
|
|
82
|
-
# Run only Edge environment tests
|
|
83
|
-
pnpm test:edge
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Writing Tests
|
|
87
|
-
|
|
88
|
-
When adding new features or fixing bugs, please include tests. Test files follow the naming convention of `*.test.ts` and are located in the same directory as the files they test.
|
|
89
|
-
|
|
90
|
-
Examples of test files include:
|
|
91
|
-
|
|
92
|
-
- `openrouter-chat-language-model.test.ts`
|
|
93
|
-
- `openrouter-usage-accounting.test.ts`
|
|
94
|
-
- `openrouter-stream-usage-accounting.test.ts`
|
|
95
|
-
|
|
96
|
-
### Issue-Specific Regression Tests
|
|
97
|
-
|
|
98
|
-
When fixing bugs reported in GitHub issues, add a regression test to the `e2e/issues/` directory. This ensures the issue doesn't recur and provides traceability back to the original report.
|
|
99
|
-
|
|
100
|
-
**Running issue regression tests:**
|
|
101
|
-
```bash
|
|
102
|
-
# Run issue regression tests separately (not included in test:e2e)
|
|
103
|
-
pnpm test:issues
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
> **Note:** Issue regression tests are excluded from `pnpm test:e2e` because they may hit different models/APIs that could be slow or rate-limited. Run them separately when needed.
|
|
107
|
-
|
|
108
|
-
**File naming convention:** `issue-{number}-{brief-description}.test.ts`
|
|
109
|
-
|
|
110
|
-
**Required test file structure:**
|
|
111
|
-
```typescript
|
|
112
|
-
/**
|
|
113
|
-
* Regression test for GitHub issue #{number}
|
|
114
|
-
* https://github.com/OpenRouterTeam/ai-sdk-provider/issues/{number}
|
|
115
|
-
*
|
|
116
|
-
* Reported error: {exact error message from the issue}
|
|
117
|
-
* Model: {model ID if applicable}
|
|
118
|
-
*
|
|
119
|
-
* This test verifies that {what the test checks}.
|
|
120
|
-
*/
|
|
121
|
-
import { ... } from 'ai';
|
|
122
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
123
|
-
import { createOpenRouter } from '@/src';
|
|
124
|
-
|
|
125
|
-
describe('Issue #{number}: {brief description}', () => {
|
|
126
|
-
// Test cases that verify the issue is resolved
|
|
127
|
-
});
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
> **Note:** Only include known facts from the issue report (error message, model, SDK version). Do not include speculative root cause analysis.
|
|
131
|
-
|
|
132
|
-
**When to add issue regression tests:**
|
|
133
|
-
- Bug fixes that have a clear reproduction case
|
|
134
|
-
- Issues that could potentially regress
|
|
135
|
-
- API compatibility issues with specific models or features
|
|
136
|
-
|
|
137
|
-
**When NOT to add issue regression tests:**
|
|
138
|
-
- Documentation-only changes
|
|
139
|
-
- Issues that were user configuration errors
|
|
140
|
-
- Transient API issues that were fixed server-side (though you may still add one for monitoring)
|
|
141
|
-
|
|
142
|
-
## Adding New Features
|
|
143
|
-
|
|
144
|
-
When adding new features to the OpenRouter provider:
|
|
145
|
-
|
|
146
|
-
1. Start by understanding the existing architecture in the `src` directory
|
|
147
|
-
2. Update the relevant type definitions in `types.ts` if needed
|
|
148
|
-
3. Implement the feature in the appropriate files
|
|
149
|
-
4. Add tests to verify the functionality
|
|
150
|
-
5. Update the README.md to document the new feature
|
|
151
|
-
6. Update the CHANGELOG.md if applicable
|
|
152
|
-
|
|
153
|
-
### Example: Usage Accounting Feature
|
|
154
|
-
|
|
155
|
-
The usage accounting feature provides an example of how to add features to the provider:
|
|
156
|
-
|
|
157
|
-
1. Added types in `types.ts` for usage accounting
|
|
158
|
-
2. Enhanced response schemas to include usage data
|
|
159
|
-
3. Updated the implementation in `openrouter-chat-language-model.ts`
|
|
160
|
-
4. Added tests in `openrouter-usage-accounting.test.ts` and `openrouter-stream-usage-accounting.test.ts`
|
|
161
|
-
5. Updated README.md with usage examples
|
|
162
|
-
|
|
163
|
-
## Pull Request Process
|
|
164
|
-
|
|
165
|
-
> **Important:** All PRs that should trigger a release must include a changeset. Run `pnpm changeset` before submitting your PR.
|
|
166
|
-
|
|
167
|
-
1. Create a new branch for your changes
|
|
168
|
-
2. Make your changes, including tests and documentation updates
|
|
169
|
-
3. **Add a changeset** to describe your changes:
|
|
170
|
-
```bash
|
|
171
|
-
pnpm changeset
|
|
172
|
-
```
|
|
173
|
-
This will prompt you to select the type of change (patch/minor/major) and write a summary. The changeset will be used to automatically generate release notes and bump versions.
|
|
174
|
-
|
|
175
|
-
- **patch**: Bug fixes and small changes that don't affect the API
|
|
176
|
-
- **minor**: New features that are backwards-compatible
|
|
177
|
-
- **major**: Breaking changes
|
|
178
|
-
|
|
179
|
-
If your changes don't need a release (docs, tests, CI config), create an empty changeset:
|
|
180
|
-
```bash
|
|
181
|
-
pnpm changeset --empty
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
4. Run all checks locally before submitting:
|
|
185
|
-
```bash
|
|
186
|
-
pnpm stylecheck # Check formatting
|
|
187
|
-
pnpm typecheck # Check types
|
|
188
|
-
pnpm build # Build the project
|
|
189
|
-
pnpm test # Run all tests
|
|
190
|
-
```
|
|
191
|
-
5. Fix any issues found by the checks (use `pnpm format` for formatting)
|
|
192
|
-
6. Commit with clear, descriptive messages (including the changeset file)
|
|
193
|
-
7. Push to your fork and submit a pull request
|
|
194
|
-
8. Update the PR description with any relevant information
|
|
195
|
-
|
|
196
|
-
**Note:** Our CI will automatically run all these checks on your PR. PRs with failing checks cannot be merged.
|
|
197
|
-
|
|
198
|
-
### PR Title Convention
|
|
199
|
-
|
|
200
|
-
Use a descriptive title that explains the change:
|
|
201
|
-
|
|
202
|
-
- `fix: <description>` for bug fixes
|
|
203
|
-
- `feat: <description>` for new features
|
|
204
|
-
- `docs: <description>` for documentation changes
|
|
205
|
-
- `test: <description>` for test changes
|
|
206
|
-
- `chore: <description>` for maintenance tasks
|
|
207
|
-
|
|
208
|
-
## Release Process
|
|
209
|
-
|
|
210
|
-
This project uses [Changesets](https://github.com/changesets/changesets) for automated release management.
|
|
211
|
-
|
|
212
|
-
### How it works
|
|
213
|
-
|
|
214
|
-
1. **Contributors add changesets**: When you submit a PR with changes that affect the public API or fix bugs, you include a changeset file (created with `pnpm changeset`) that describes your changes.
|
|
215
|
-
|
|
216
|
-
2. **Automated version PR**: When PRs with changesets are merged to `main`, the Release workflow automatically creates or updates a "Version Packages" PR. This PR:
|
|
217
|
-
- Bumps the version in `package.json` based on all pending changesets
|
|
218
|
-
- Updates `CHANGELOG.md` with all changes since the last release
|
|
219
|
-
- Removes the changeset files that have been processed
|
|
220
|
-
|
|
221
|
-
3. **Publish to npm**: When a maintainer merges the "Version Packages" PR, the package is automatically published to npm with provenance.
|
|
222
|
-
|
|
223
|
-
### For Maintainers
|
|
224
|
-
|
|
225
|
-
To release a new version:
|
|
226
|
-
|
|
227
|
-
1. Review the automatically created "Version Packages" PR
|
|
228
|
-
2. Verify the version bump is appropriate
|
|
229
|
-
3. Verify the CHANGELOG entries are accurate
|
|
230
|
-
4. Merge the PR
|
|
231
|
-
5. The Release workflow will automatically publish to npm
|
|
232
|
-
|
|
233
|
-
### Manual releases (emergency only)
|
|
234
|
-
|
|
235
|
-
In case of emergency, a manual release can be triggered using the legacy `publish-manual.yaml` workflow by creating a GitHub Release. This should only be used when the automated process is unavailable.
|
|
236
|
-
|
|
237
|
-
## Getting Help
|
|
238
|
-
|
|
239
|
-
If you have questions about contributing, please open a GitHub issue in the repository.
|
|
240
|
-
|
|
241
|
-
Thank you for contributing to the OpenRouter AI SDK Provider!
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2025 OpenRouter Inc,
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|