nuwaxcode 1.1.34 → 1.1.44
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/bin/nuwaxcode +19 -1
- package/package.json +15 -117
- package/{script/postinstall.mjs → postinstall.mjs} +18 -6
- package/AGENTS.md +0 -27
- package/Dockerfile +0 -18
- package/README.md +0 -15
- package/bunfig.toml +0 -7
- package/parsers-config.ts +0 -253
- package/script/build.ts +0 -172
- package/script/publish-registries.ts +0 -187
- package/script/publish.ts +0 -70
- package/script/schema.ts +0 -47
- package/src/acp/README.md +0 -164
- package/src/acp/agent.ts +0 -1280
- package/src/acp/session.ts +0 -111
- package/src/acp/types.ts +0 -24
- package/src/agent/agent.ts +0 -332
- package/src/agent/generate.txt +0 -75
- package/src/agent/prompt/compaction.txt +0 -12
- package/src/agent/prompt/explore.txt +0 -18
- package/src/agent/prompt/summary.txt +0 -11
- package/src/agent/prompt/title.txt +0 -43
- package/src/auth/index.ts +0 -73
- package/src/bun/index.ts +0 -134
- package/src/bus/bus-event.ts +0 -43
- package/src/bus/global.ts +0 -10
- package/src/bus/index.ts +0 -105
- package/src/cli/bootstrap.ts +0 -17
- package/src/cli/cmd/acp.ts +0 -69
- package/src/cli/cmd/agent.ts +0 -257
- package/src/cli/cmd/auth.ts +0 -400
- package/src/cli/cmd/cmd.ts +0 -7
- package/src/cli/cmd/debug/agent.ts +0 -166
- package/src/cli/cmd/debug/config.ts +0 -16
- package/src/cli/cmd/debug/file.ts +0 -97
- package/src/cli/cmd/debug/index.ts +0 -48
- package/src/cli/cmd/debug/lsp.ts +0 -52
- package/src/cli/cmd/debug/ripgrep.ts +0 -87
- package/src/cli/cmd/debug/scrap.ts +0 -16
- package/src/cli/cmd/debug/skill.ts +0 -16
- package/src/cli/cmd/debug/snapshot.ts +0 -52
- package/src/cli/cmd/export.ts +0 -88
- package/src/cli/cmd/generate.ts +0 -38
- package/src/cli/cmd/github.ts +0 -1548
- package/src/cli/cmd/import.ts +0 -98
- package/src/cli/cmd/mcp.ts +0 -755
- package/src/cli/cmd/models.ts +0 -77
- package/src/cli/cmd/pr.ts +0 -112
- package/src/cli/cmd/run.ts +0 -395
- package/src/cli/cmd/serve.ts +0 -20
- package/src/cli/cmd/session.ts +0 -135
- package/src/cli/cmd/stats.ts +0 -402
- package/src/cli/cmd/tui/app.tsx +0 -761
- package/src/cli/cmd/tui/attach.ts +0 -31
- package/src/cli/cmd/tui/component/border.tsx +0 -21
- package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-command.tsx +0 -148
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
- package/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
- package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -256
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -114
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
- package/src/cli/cmd/tui/component/dialog-status.tsx +0 -164
- package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
- package/src/cli/cmd/tui/component/logo.tsx +0 -88
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -632
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
- package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
- package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1096
- package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
- package/src/cli/cmd/tui/component/tips.tsx +0 -153
- package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
- package/src/cli/cmd/tui/context/args.tsx +0 -14
- package/src/cli/cmd/tui/context/directory.ts +0 -13
- package/src/cli/cmd/tui/context/exit.tsx +0 -23
- package/src/cli/cmd/tui/context/helper.tsx +0 -25
- package/src/cli/cmd/tui/context/keybind.tsx +0 -101
- package/src/cli/cmd/tui/context/kv.tsx +0 -52
- package/src/cli/cmd/tui/context/local.tsx +0 -402
- package/src/cli/cmd/tui/context/prompt.tsx +0 -18
- package/src/cli/cmd/tui/context/route.tsx +0 -46
- package/src/cli/cmd/tui/context/sdk.tsx +0 -94
- package/src/cli/cmd/tui/context/sync.tsx +0 -427
- package/src/cli/cmd/tui/context/theme/aura.json +0 -69
- package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
- package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
- package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
- package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
- package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
- package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
- package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
- package/src/cli/cmd/tui/context/theme/github.json +0 -233
- package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
- package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
- package/src/cli/cmd/tui/context/theme/material.json +0 -235
- package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
- package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
- package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
- package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
- package/src/cli/cmd/tui/context/theme/nord.json +0 -223
- package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
- package/src/cli/cmd/tui/context/theme/orng.json +0 -249
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
- package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
- package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
- package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
- package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
- package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
- package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
- package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
- package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
- package/src/cli/cmd/tui/context/theme.tsx +0 -1152
- package/src/cli/cmd/tui/event.ts +0 -48
- package/src/cli/cmd/tui/routes/home.tsx +0 -140
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
- package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
- package/src/cli/cmd/tui/routes/session/header.tsx +0 -136
- package/src/cli/cmd/tui/routes/session/index.tsx +0 -2050
- package/src/cli/cmd/tui/routes/session/permission.tsx +0 -495
- package/src/cli/cmd/tui/routes/session/question.tsx +0 -435
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -312
- package/src/cli/cmd/tui/thread.ts +0 -165
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
- package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
- package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -354
- package/src/cli/cmd/tui/ui/dialog.tsx +0 -167
- package/src/cli/cmd/tui/ui/link.tsx +0 -28
- package/src/cli/cmd/tui/ui/spinner.ts +0 -368
- package/src/cli/cmd/tui/ui/toast.tsx +0 -100
- package/src/cli/cmd/tui/util/clipboard.ts +0 -160
- package/src/cli/cmd/tui/util/editor.ts +0 -32
- package/src/cli/cmd/tui/util/signal.ts +0 -7
- package/src/cli/cmd/tui/util/terminal.ts +0 -114
- package/src/cli/cmd/tui/util/transcript.ts +0 -98
- package/src/cli/cmd/tui/worker.ts +0 -152
- package/src/cli/cmd/uninstall.ts +0 -357
- package/src/cli/cmd/upgrade.ts +0 -73
- package/src/cli/cmd/web.ts +0 -81
- package/src/cli/error.ts +0 -57
- package/src/cli/network.ts +0 -53
- package/src/cli/ui.ts +0 -84
- package/src/cli/upgrade.ts +0 -25
- package/src/command/index.ts +0 -131
- package/src/command/template/initialize.txt +0 -10
- package/src/command/template/review.txt +0 -99
- package/src/config/config.ts +0 -1255
- package/src/config/markdown.ts +0 -93
- package/src/env/index.ts +0 -26
- package/src/file/ignore.ts +0 -83
- package/src/file/index.ts +0 -411
- package/src/file/ripgrep.ts +0 -409
- package/src/file/time.ts +0 -64
- package/src/file/watcher.ts +0 -118
- package/src/flag/flag.ts +0 -54
- package/src/format/formatter.ts +0 -359
- package/src/format/index.ts +0 -137
- package/src/global/index.ts +0 -55
- package/src/id/id.ts +0 -83
- package/src/ide/index.ts +0 -76
- package/src/index.ts +0 -159
- package/src/installation/index.ts +0 -246
- package/src/lsp/client.ts +0 -252
- package/src/lsp/index.ts +0 -485
- package/src/lsp/language.ts +0 -119
- package/src/lsp/server.ts +0 -2046
- package/src/mcp/auth.ts +0 -135
- package/src/mcp/index.ts +0 -926
- package/src/mcp/oauth-callback.ts +0 -200
- package/src/mcp/oauth-provider.ts +0 -154
- package/src/patch/index.ts +0 -680
- package/src/permission/arity.ts +0 -163
- package/src/permission/index.ts +0 -210
- package/src/permission/next.ts +0 -269
- package/src/plugin/codex.ts +0 -493
- package/src/plugin/copilot.ts +0 -269
- package/src/plugin/index.ts +0 -135
- package/src/project/bootstrap.ts +0 -35
- package/src/project/instance.ts +0 -91
- package/src/project/project.ts +0 -320
- package/src/project/state.ts +0 -66
- package/src/project/vcs.ts +0 -76
- package/src/provider/auth.ts +0 -147
- package/src/provider/models-macro.ts +0 -11
- package/src/provider/models.ts +0 -112
- package/src/provider/provider.ts +0 -1219
- package/src/provider/sdk/openai-compatible/src/README.md +0 -5
- package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
- package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
- package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
- package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -22
- package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
- package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1732
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
- package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
- package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
- package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
- package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
- package/src/provider/transform.ts +0 -724
- package/src/pty/index.ts +0 -229
- package/src/question/index.ts +0 -171
- package/src/scheduler/index.ts +0 -61
- package/src/server/error.ts +0 -36
- package/src/server/mdns.ts +0 -59
- package/src/server/routes/config.ts +0 -92
- package/src/server/routes/experimental.ts +0 -157
- package/src/server/routes/file.ts +0 -197
- package/src/server/routes/global.ts +0 -135
- package/src/server/routes/mcp.ts +0 -225
- package/src/server/routes/permission.ts +0 -68
- package/src/server/routes/project.ts +0 -82
- package/src/server/routes/provider.ts +0 -165
- package/src/server/routes/pty.ts +0 -169
- package/src/server/routes/question.ts +0 -98
- package/src/server/routes/session.ts +0 -935
- package/src/server/routes/tui.ts +0 -379
- package/src/server/server.ts +0 -578
- package/src/session/compaction.ts +0 -225
- package/src/session/index.ts +0 -488
- package/src/session/llm.ts +0 -279
- package/src/session/message-v2.ts +0 -702
- package/src/session/message.ts +0 -189
- package/src/session/processor.ts +0 -406
- package/src/session/prompt/anthropic-20250930.txt +0 -166
- package/src/session/prompt/anthropic.txt +0 -105
- package/src/session/prompt/anthropic_spoof.txt +0 -1
- package/src/session/prompt/beast.txt +0 -147
- package/src/session/prompt/build-switch.txt +0 -5
- package/src/session/prompt/codex.txt +0 -73
- package/src/session/prompt/codex_header.txt +0 -72
- package/src/session/prompt/copilot-gpt-5.txt +0 -143
- package/src/session/prompt/gemini.txt +0 -155
- package/src/session/prompt/max-steps.txt +0 -16
- package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
- package/src/session/prompt/plan.txt +0 -26
- package/src/session/prompt/qwen.txt +0 -109
- package/src/session/prompt.ts +0 -1805
- package/src/session/retry.ts +0 -90
- package/src/session/revert.ts +0 -108
- package/src/session/status.ts +0 -76
- package/src/session/summary.ts +0 -150
- package/src/session/system.ts +0 -138
- package/src/session/todo.ts +0 -37
- package/src/share/share-next.ts +0 -194
- package/src/share/share.ts +0 -87
- package/src/shell/shell.ts +0 -67
- package/src/skill/index.ts +0 -1
- package/src/skill/skill.ts +0 -136
- package/src/snapshot/index.ts +0 -236
- package/src/storage/storage.ts +0 -227
- package/src/tool/apply_patch.ts +0 -277
- package/src/tool/apply_patch.txt +0 -1
- package/src/tool/bash.ts +0 -258
- package/src/tool/bash.txt +0 -115
- package/src/tool/batch.ts +0 -175
- package/src/tool/batch.txt +0 -24
- package/src/tool/codesearch.ts +0 -132
- package/src/tool/codesearch.txt +0 -12
- package/src/tool/edit.ts +0 -645
- package/src/tool/edit.txt +0 -10
- package/src/tool/external-directory.ts +0 -32
- package/src/tool/glob.ts +0 -77
- package/src/tool/glob.txt +0 -6
- package/src/tool/grep.ts +0 -154
- package/src/tool/grep.txt +0 -8
- package/src/tool/invalid.ts +0 -17
- package/src/tool/ls.ts +0 -121
- package/src/tool/ls.txt +0 -1
- package/src/tool/lsp.ts +0 -96
- package/src/tool/lsp.txt +0 -19
- package/src/tool/multiedit.ts +0 -46
- package/src/tool/multiedit.txt +0 -41
- package/src/tool/plan-enter.txt +0 -14
- package/src/tool/plan-exit.txt +0 -13
- package/src/tool/plan.ts +0 -130
- package/src/tool/question.ts +0 -33
- package/src/tool/question.txt +0 -10
- package/src/tool/read.ts +0 -202
- package/src/tool/read.txt +0 -12
- package/src/tool/registry.ts +0 -158
- package/src/tool/skill.ts +0 -75
- package/src/tool/task.ts +0 -188
- package/src/tool/task.txt +0 -60
- package/src/tool/todo.ts +0 -53
- package/src/tool/todoread.txt +0 -14
- package/src/tool/todowrite.txt +0 -167
- package/src/tool/tool.ts +0 -88
- package/src/tool/truncation.ts +0 -106
- package/src/tool/webfetch.ts +0 -182
- package/src/tool/webfetch.txt +0 -13
- package/src/tool/websearch.ts +0 -150
- package/src/tool/websearch.txt +0 -14
- package/src/tool/write.ts +0 -80
- package/src/tool/write.txt +0 -8
- package/src/util/archive.ts +0 -16
- package/src/util/color.ts +0 -19
- package/src/util/context.ts +0 -25
- package/src/util/defer.ts +0 -12
- package/src/util/eventloop.ts +0 -20
- package/src/util/filesystem.ts +0 -93
- package/src/util/fn.ts +0 -11
- package/src/util/format.ts +0 -20
- package/src/util/iife.ts +0 -3
- package/src/util/keybind.ts +0 -103
- package/src/util/lazy.ts +0 -18
- package/src/util/locale.ts +0 -81
- package/src/util/lock.ts +0 -98
- package/src/util/log.ts +0 -180
- package/src/util/queue.ts +0 -32
- package/src/util/rpc.ts +0 -66
- package/src/util/scrap.ts +0 -10
- package/src/util/signal.ts +0 -12
- package/src/util/timeout.ts +0 -14
- package/src/util/token.ts +0 -7
- package/src/util/wildcard.ts +0 -56
- package/src/worktree/index.ts +0 -217
- package/sst-env.d.ts +0 -9
- package/test/acp/event-subscription.test.ts +0 -436
- package/test/acp/system-prompt.test.ts +0 -262
- package/test/agent/agent.test.ts +0 -638
- package/test/bun.test.ts +0 -53
- package/test/cli/github-action.test.ts +0 -129
- package/test/cli/github-remote.test.ts +0 -80
- package/test/cli/tui/transcript.test.ts +0 -297
- package/test/config/agent-color.test.ts +0 -66
- package/test/config/config.test.ts +0 -1414
- package/test/config/fixtures/empty-frontmatter.md +0 -4
- package/test/config/fixtures/frontmatter.md +0 -28
- package/test/config/fixtures/no-frontmatter.md +0 -1
- package/test/config/markdown.test.ts +0 -192
- package/test/file/ignore.test.ts +0 -10
- package/test/file/path-traversal.test.ts +0 -198
- package/test/fixture/fixture.ts +0 -45
- package/test/fixture/lsp/fake-lsp-server.js +0 -77
- package/test/ide/ide.test.ts +0 -82
- package/test/keybind.test.ts +0 -421
- package/test/lsp/client.test.ts +0 -95
- package/test/mcp/headers.test.ts +0 -153
- package/test/mcp/oauth-browser.test.ts +0 -261
- package/test/patch/patch.test.ts +0 -348
- package/test/permission/arity.test.ts +0 -33
- package/test/permission/next.test.ts +0 -652
- package/test/permission-task.test.ts +0 -319
- package/test/plugin/codex.test.ts +0 -123
- package/test/preload.ts +0 -65
- package/test/project/project.test.ts +0 -120
- package/test/provider/amazon-bedrock.test.ts +0 -268
- package/test/provider/gitlab-duo.test.ts +0 -286
- package/test/provider/provider.test.ts +0 -2149
- package/test/provider/transform.test.ts +0 -1596
- package/test/question/question.test.ts +0 -300
- package/test/scheduler.test.ts +0 -73
- package/test/server/session-list.test.ts +0 -39
- package/test/server/session-select.test.ts +0 -78
- package/test/session/compaction.test.ts +0 -293
- package/test/session/llm.test.ts +0 -90
- package/test/session/message-v2.test.ts +0 -662
- package/test/session/retry.test.ts +0 -131
- package/test/session/revert-compact.test.ts +0 -285
- package/test/session/session.test.ts +0 -71
- package/test/skill/skill.test.ts +0 -185
- package/test/snapshot/snapshot.test.ts +0 -939
- package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
- package/test/tool/apply_patch.test.ts +0 -515
- package/test/tool/bash.test.ts +0 -320
- package/test/tool/external-directory.test.ts +0 -126
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +0 -33453
- package/test/tool/grep.test.ts +0 -109
- package/test/tool/question.test.ts +0 -105
- package/test/tool/read.test.ts +0 -332
- package/test/tool/registry.test.ts +0 -76
- package/test/tool/truncation.test.ts +0 -159
- package/test/util/filesystem.test.ts +0 -39
- package/test/util/format.test.ts +0 -59
- package/test/util/iife.test.ts +0 -36
- package/test/util/lazy.test.ts +0 -50
- package/test/util/lock.test.ts +0 -72
- package/test/util/timeout.test.ts +0 -21
- package/test/util/wildcard.test.ts +0 -75
- package/tsconfig.json +0 -16
|
@@ -1,1596 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { ProviderTransform } from "../../src/provider/transform"
|
|
3
|
-
|
|
4
|
-
const OUTPUT_TOKEN_MAX = 32000
|
|
5
|
-
|
|
6
|
-
describe("ProviderTransform.options - setCacheKey", () => {
|
|
7
|
-
const sessionID = "test-session-123"
|
|
8
|
-
|
|
9
|
-
const mockModel = {
|
|
10
|
-
id: "anthropic/claude-3-5-sonnet",
|
|
11
|
-
providerID: "anthropic",
|
|
12
|
-
api: {
|
|
13
|
-
id: "claude-3-5-sonnet-20241022",
|
|
14
|
-
url: "https://api.anthropic.com",
|
|
15
|
-
npm: "@ai-sdk/anthropic",
|
|
16
|
-
},
|
|
17
|
-
name: "Claude 3.5 Sonnet",
|
|
18
|
-
capabilities: {
|
|
19
|
-
temperature: true,
|
|
20
|
-
reasoning: false,
|
|
21
|
-
attachment: true,
|
|
22
|
-
toolcall: true,
|
|
23
|
-
input: { text: true, audio: false, image: true, video: false, pdf: true },
|
|
24
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
25
|
-
interleaved: false,
|
|
26
|
-
},
|
|
27
|
-
cost: {
|
|
28
|
-
input: 0.003,
|
|
29
|
-
output: 0.015,
|
|
30
|
-
cache: { read: 0.0003, write: 0.00375 },
|
|
31
|
-
},
|
|
32
|
-
limit: {
|
|
33
|
-
context: 200000,
|
|
34
|
-
output: 8192,
|
|
35
|
-
},
|
|
36
|
-
status: "active",
|
|
37
|
-
options: {},
|
|
38
|
-
headers: {},
|
|
39
|
-
} as any
|
|
40
|
-
|
|
41
|
-
test("should set promptCacheKey when providerOptions.setCacheKey is true", () => {
|
|
42
|
-
const result = ProviderTransform.options({
|
|
43
|
-
model: mockModel,
|
|
44
|
-
sessionID,
|
|
45
|
-
providerOptions: { setCacheKey: true },
|
|
46
|
-
})
|
|
47
|
-
expect(result.promptCacheKey).toBe(sessionID)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test("should not set promptCacheKey when providerOptions.setCacheKey is false", () => {
|
|
51
|
-
const result = ProviderTransform.options({
|
|
52
|
-
model: mockModel,
|
|
53
|
-
sessionID,
|
|
54
|
-
providerOptions: { setCacheKey: false },
|
|
55
|
-
})
|
|
56
|
-
expect(result.promptCacheKey).toBeUndefined()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test("should not set promptCacheKey when providerOptions is undefined", () => {
|
|
60
|
-
const result = ProviderTransform.options({
|
|
61
|
-
model: mockModel,
|
|
62
|
-
sessionID,
|
|
63
|
-
providerOptions: undefined,
|
|
64
|
-
})
|
|
65
|
-
expect(result.promptCacheKey).toBeUndefined()
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test("should not set promptCacheKey when providerOptions does not have setCacheKey", () => {
|
|
69
|
-
const result = ProviderTransform.options({ model: mockModel, sessionID, providerOptions: {} })
|
|
70
|
-
expect(result.promptCacheKey).toBeUndefined()
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test("should set promptCacheKey for openai provider regardless of setCacheKey", () => {
|
|
74
|
-
const openaiModel = {
|
|
75
|
-
...mockModel,
|
|
76
|
-
providerID: "openai",
|
|
77
|
-
api: {
|
|
78
|
-
id: "gpt-4",
|
|
79
|
-
url: "https://api.openai.com",
|
|
80
|
-
npm: "@ai-sdk/openai",
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
const result = ProviderTransform.options({ model: openaiModel, sessionID, providerOptions: {} })
|
|
84
|
-
expect(result.promptCacheKey).toBe(sessionID)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
test("should set store=false for openai provider", () => {
|
|
88
|
-
const openaiModel = {
|
|
89
|
-
...mockModel,
|
|
90
|
-
providerID: "openai",
|
|
91
|
-
api: {
|
|
92
|
-
id: "gpt-4",
|
|
93
|
-
url: "https://api.openai.com",
|
|
94
|
-
npm: "@ai-sdk/openai",
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
const result = ProviderTransform.options({
|
|
98
|
-
model: openaiModel,
|
|
99
|
-
sessionID,
|
|
100
|
-
providerOptions: {},
|
|
101
|
-
})
|
|
102
|
-
expect(result.store).toBe(false)
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
describe("ProviderTransform.maxOutputTokens", () => {
|
|
107
|
-
test("returns 32k when modelLimit > 32k", () => {
|
|
108
|
-
const modelLimit = 100000
|
|
109
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
110
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test("returns modelLimit when modelLimit < 32k", () => {
|
|
114
|
-
const modelLimit = 16000
|
|
115
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
116
|
-
expect(result).toBe(16000)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
describe("azure", () => {
|
|
120
|
-
test("returns 32k when modelLimit > 32k", () => {
|
|
121
|
-
const modelLimit = 100000
|
|
122
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
123
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test("returns modelLimit when modelLimit < 32k", () => {
|
|
127
|
-
const modelLimit = 16000
|
|
128
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
129
|
-
expect(result).toBe(16000)
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
describe("bedrock", () => {
|
|
134
|
-
test("returns 32k when modelLimit > 32k", () => {
|
|
135
|
-
const modelLimit = 100000
|
|
136
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
137
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test("returns modelLimit when modelLimit < 32k", () => {
|
|
141
|
-
const modelLimit = 16000
|
|
142
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
143
|
-
expect(result).toBe(16000)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
describe("anthropic without thinking options", () => {
|
|
148
|
-
test("returns 32k when modelLimit > 32k", () => {
|
|
149
|
-
const modelLimit = 100000
|
|
150
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
151
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test("returns modelLimit when modelLimit < 32k", () => {
|
|
155
|
-
const modelLimit = 16000
|
|
156
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
|
|
157
|
-
expect(result).toBe(16000)
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
describe("anthropic with thinking options", () => {
|
|
162
|
-
test("returns 32k when budgetTokens + 32k <= modelLimit", () => {
|
|
163
|
-
const modelLimit = 100000
|
|
164
|
-
const options = {
|
|
165
|
-
thinking: {
|
|
166
|
-
type: "enabled",
|
|
167
|
-
budgetTokens: 10000,
|
|
168
|
-
},
|
|
169
|
-
}
|
|
170
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
|
|
171
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
test("returns modelLimit - budgetTokens when budgetTokens + 32k > modelLimit", () => {
|
|
175
|
-
const modelLimit = 50000
|
|
176
|
-
const options = {
|
|
177
|
-
thinking: {
|
|
178
|
-
type: "enabled",
|
|
179
|
-
budgetTokens: 30000,
|
|
180
|
-
},
|
|
181
|
-
}
|
|
182
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
|
|
183
|
-
expect(result).toBe(20000)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
test("returns 32k when thinking type is not enabled", () => {
|
|
187
|
-
const modelLimit = 100000
|
|
188
|
-
const options = {
|
|
189
|
-
thinking: {
|
|
190
|
-
type: "disabled",
|
|
191
|
-
budgetTokens: 10000,
|
|
192
|
-
},
|
|
193
|
-
}
|
|
194
|
-
const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
|
|
195
|
-
expect(result).toBe(OUTPUT_TOKEN_MAX)
|
|
196
|
-
})
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
describe("ProviderTransform.schema - gemini array items", () => {
|
|
201
|
-
test("adds missing items for array properties", () => {
|
|
202
|
-
const geminiModel = {
|
|
203
|
-
providerID: "google",
|
|
204
|
-
api: {
|
|
205
|
-
id: "gemini-3-pro",
|
|
206
|
-
},
|
|
207
|
-
} as any
|
|
208
|
-
|
|
209
|
-
const schema = {
|
|
210
|
-
type: "object",
|
|
211
|
-
properties: {
|
|
212
|
-
nodes: { type: "array" },
|
|
213
|
-
edges: { type: "array", items: { type: "string" } },
|
|
214
|
-
},
|
|
215
|
-
} as any
|
|
216
|
-
|
|
217
|
-
const result = ProviderTransform.schema(geminiModel, schema) as any
|
|
218
|
-
|
|
219
|
-
expect(result.properties.nodes.items).toBeDefined()
|
|
220
|
-
expect(result.properties.edges.items.type).toBe("string")
|
|
221
|
-
})
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
describe("ProviderTransform.message - DeepSeek reasoning content", () => {
|
|
225
|
-
test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
|
|
226
|
-
const msgs = [
|
|
227
|
-
{
|
|
228
|
-
role: "assistant",
|
|
229
|
-
content: [
|
|
230
|
-
{ type: "reasoning", text: "Let me think about this..." },
|
|
231
|
-
{
|
|
232
|
-
type: "tool-call",
|
|
233
|
-
toolCallId: "test",
|
|
234
|
-
toolName: "bash",
|
|
235
|
-
input: { command: "echo hello" },
|
|
236
|
-
},
|
|
237
|
-
],
|
|
238
|
-
},
|
|
239
|
-
] as any[]
|
|
240
|
-
|
|
241
|
-
const result = ProviderTransform.message(
|
|
242
|
-
msgs,
|
|
243
|
-
{
|
|
244
|
-
id: "deepseek/deepseek-chat",
|
|
245
|
-
providerID: "deepseek",
|
|
246
|
-
api: {
|
|
247
|
-
id: "deepseek-chat",
|
|
248
|
-
url: "https://api.deepseek.com",
|
|
249
|
-
npm: "@ai-sdk/openai-compatible",
|
|
250
|
-
},
|
|
251
|
-
name: "DeepSeek Chat",
|
|
252
|
-
capabilities: {
|
|
253
|
-
temperature: true,
|
|
254
|
-
reasoning: true,
|
|
255
|
-
attachment: false,
|
|
256
|
-
toolcall: true,
|
|
257
|
-
input: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
258
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
259
|
-
interleaved: {
|
|
260
|
-
field: "reasoning_content",
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
cost: {
|
|
264
|
-
input: 0.001,
|
|
265
|
-
output: 0.002,
|
|
266
|
-
cache: { read: 0.0001, write: 0.0002 },
|
|
267
|
-
},
|
|
268
|
-
limit: {
|
|
269
|
-
context: 128000,
|
|
270
|
-
output: 8192,
|
|
271
|
-
},
|
|
272
|
-
status: "active",
|
|
273
|
-
options: {},
|
|
274
|
-
headers: {},
|
|
275
|
-
release_date: "2023-04-01",
|
|
276
|
-
},
|
|
277
|
-
{},
|
|
278
|
-
)
|
|
279
|
-
|
|
280
|
-
expect(result).toHaveLength(1)
|
|
281
|
-
expect(result[0].content).toEqual([
|
|
282
|
-
{
|
|
283
|
-
type: "tool-call",
|
|
284
|
-
toolCallId: "test",
|
|
285
|
-
toolName: "bash",
|
|
286
|
-
input: { command: "echo hello" },
|
|
287
|
-
},
|
|
288
|
-
])
|
|
289
|
-
expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBe("Let me think about this...")
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
test("Non-DeepSeek providers leave reasoning content unchanged", () => {
|
|
293
|
-
const msgs = [
|
|
294
|
-
{
|
|
295
|
-
role: "assistant",
|
|
296
|
-
content: [
|
|
297
|
-
{ type: "reasoning", text: "Should not be processed" },
|
|
298
|
-
{ type: "text", text: "Answer" },
|
|
299
|
-
],
|
|
300
|
-
},
|
|
301
|
-
] as any[]
|
|
302
|
-
|
|
303
|
-
const result = ProviderTransform.message(
|
|
304
|
-
msgs,
|
|
305
|
-
{
|
|
306
|
-
id: "openai/gpt-4",
|
|
307
|
-
providerID: "openai",
|
|
308
|
-
api: {
|
|
309
|
-
id: "gpt-4",
|
|
310
|
-
url: "https://api.openai.com",
|
|
311
|
-
npm: "@ai-sdk/openai",
|
|
312
|
-
},
|
|
313
|
-
name: "GPT-4",
|
|
314
|
-
capabilities: {
|
|
315
|
-
temperature: true,
|
|
316
|
-
reasoning: false,
|
|
317
|
-
attachment: true,
|
|
318
|
-
toolcall: true,
|
|
319
|
-
input: { text: true, audio: false, image: true, video: false, pdf: false },
|
|
320
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
321
|
-
interleaved: false,
|
|
322
|
-
},
|
|
323
|
-
cost: {
|
|
324
|
-
input: 0.03,
|
|
325
|
-
output: 0.06,
|
|
326
|
-
cache: { read: 0.001, write: 0.002 },
|
|
327
|
-
},
|
|
328
|
-
limit: {
|
|
329
|
-
context: 128000,
|
|
330
|
-
output: 4096,
|
|
331
|
-
},
|
|
332
|
-
status: "active",
|
|
333
|
-
options: {},
|
|
334
|
-
headers: {},
|
|
335
|
-
release_date: "2023-04-01",
|
|
336
|
-
},
|
|
337
|
-
{},
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
expect(result[0].content).toEqual([
|
|
341
|
-
{ type: "reasoning", text: "Should not be processed" },
|
|
342
|
-
{ type: "text", text: "Answer" },
|
|
343
|
-
])
|
|
344
|
-
expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
|
|
345
|
-
})
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
describe("ProviderTransform.message - empty image handling", () => {
|
|
349
|
-
const mockModel = {
|
|
350
|
-
id: "anthropic/claude-3-5-sonnet",
|
|
351
|
-
providerID: "anthropic",
|
|
352
|
-
api: {
|
|
353
|
-
id: "claude-3-5-sonnet-20241022",
|
|
354
|
-
url: "https://api.anthropic.com",
|
|
355
|
-
npm: "@ai-sdk/anthropic",
|
|
356
|
-
},
|
|
357
|
-
name: "Claude 3.5 Sonnet",
|
|
358
|
-
capabilities: {
|
|
359
|
-
temperature: true,
|
|
360
|
-
reasoning: false,
|
|
361
|
-
attachment: true,
|
|
362
|
-
toolcall: true,
|
|
363
|
-
input: { text: true, audio: false, image: true, video: false, pdf: true },
|
|
364
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
365
|
-
interleaved: false,
|
|
366
|
-
},
|
|
367
|
-
cost: {
|
|
368
|
-
input: 0.003,
|
|
369
|
-
output: 0.015,
|
|
370
|
-
cache: { read: 0.0003, write: 0.00375 },
|
|
371
|
-
},
|
|
372
|
-
limit: {
|
|
373
|
-
context: 200000,
|
|
374
|
-
output: 8192,
|
|
375
|
-
},
|
|
376
|
-
status: "active",
|
|
377
|
-
options: {},
|
|
378
|
-
headers: {},
|
|
379
|
-
} as any
|
|
380
|
-
|
|
381
|
-
test("should replace empty base64 image with error text", () => {
|
|
382
|
-
const msgs = [
|
|
383
|
-
{
|
|
384
|
-
role: "user",
|
|
385
|
-
content: [
|
|
386
|
-
{ type: "text", text: "What is in this image?" },
|
|
387
|
-
{ type: "image", image: "data:image/png;base64," },
|
|
388
|
-
],
|
|
389
|
-
},
|
|
390
|
-
] as any[]
|
|
391
|
-
|
|
392
|
-
const result = ProviderTransform.message(msgs, mockModel, {})
|
|
393
|
-
|
|
394
|
-
expect(result).toHaveLength(1)
|
|
395
|
-
expect(result[0].content).toHaveLength(2)
|
|
396
|
-
expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
|
|
397
|
-
expect(result[0].content[1]).toEqual({
|
|
398
|
-
type: "text",
|
|
399
|
-
text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
|
|
400
|
-
})
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
test("should keep valid base64 images unchanged", () => {
|
|
404
|
-
const validBase64 =
|
|
405
|
-
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
|
|
406
|
-
const msgs = [
|
|
407
|
-
{
|
|
408
|
-
role: "user",
|
|
409
|
-
content: [
|
|
410
|
-
{ type: "text", text: "What is in this image?" },
|
|
411
|
-
{ type: "image", image: `data:image/png;base64,${validBase64}` },
|
|
412
|
-
],
|
|
413
|
-
},
|
|
414
|
-
] as any[]
|
|
415
|
-
|
|
416
|
-
const result = ProviderTransform.message(msgs, mockModel, {})
|
|
417
|
-
|
|
418
|
-
expect(result).toHaveLength(1)
|
|
419
|
-
expect(result[0].content).toHaveLength(2)
|
|
420
|
-
expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
|
|
421
|
-
expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
test("should handle mixed valid and empty images", () => {
|
|
425
|
-
const validBase64 =
|
|
426
|
-
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
|
|
427
|
-
const msgs = [
|
|
428
|
-
{
|
|
429
|
-
role: "user",
|
|
430
|
-
content: [
|
|
431
|
-
{ type: "text", text: "Compare these images" },
|
|
432
|
-
{ type: "image", image: `data:image/png;base64,${validBase64}` },
|
|
433
|
-
{ type: "image", image: "data:image/jpeg;base64," },
|
|
434
|
-
],
|
|
435
|
-
},
|
|
436
|
-
] as any[]
|
|
437
|
-
|
|
438
|
-
const result = ProviderTransform.message(msgs, mockModel, {})
|
|
439
|
-
|
|
440
|
-
expect(result).toHaveLength(1)
|
|
441
|
-
expect(result[0].content).toHaveLength(3)
|
|
442
|
-
expect(result[0].content[0]).toEqual({ type: "text", text: "Compare these images" })
|
|
443
|
-
expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
|
|
444
|
-
expect(result[0].content[2]).toEqual({
|
|
445
|
-
type: "text",
|
|
446
|
-
text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
|
|
447
|
-
})
|
|
448
|
-
})
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
describe("ProviderTransform.message - anthropic empty content filtering", () => {
|
|
452
|
-
const anthropicModel = {
|
|
453
|
-
id: "anthropic/claude-3-5-sonnet",
|
|
454
|
-
providerID: "anthropic",
|
|
455
|
-
api: {
|
|
456
|
-
id: "claude-3-5-sonnet-20241022",
|
|
457
|
-
url: "https://api.anthropic.com",
|
|
458
|
-
npm: "@ai-sdk/anthropic",
|
|
459
|
-
},
|
|
460
|
-
name: "Claude 3.5 Sonnet",
|
|
461
|
-
capabilities: {
|
|
462
|
-
temperature: true,
|
|
463
|
-
reasoning: false,
|
|
464
|
-
attachment: true,
|
|
465
|
-
toolcall: true,
|
|
466
|
-
input: { text: true, audio: false, image: true, video: false, pdf: true },
|
|
467
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
468
|
-
interleaved: false,
|
|
469
|
-
},
|
|
470
|
-
cost: {
|
|
471
|
-
input: 0.003,
|
|
472
|
-
output: 0.015,
|
|
473
|
-
cache: { read: 0.0003, write: 0.00375 },
|
|
474
|
-
},
|
|
475
|
-
limit: {
|
|
476
|
-
context: 200000,
|
|
477
|
-
output: 8192,
|
|
478
|
-
},
|
|
479
|
-
status: "active",
|
|
480
|
-
options: {},
|
|
481
|
-
headers: {},
|
|
482
|
-
} as any
|
|
483
|
-
|
|
484
|
-
test("filters out messages with empty string content", () => {
|
|
485
|
-
const msgs = [
|
|
486
|
-
{ role: "user", content: "Hello" },
|
|
487
|
-
{ role: "assistant", content: "" },
|
|
488
|
-
{ role: "user", content: "World" },
|
|
489
|
-
] as any[]
|
|
490
|
-
|
|
491
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
492
|
-
|
|
493
|
-
expect(result).toHaveLength(2)
|
|
494
|
-
expect(result[0].content).toBe("Hello")
|
|
495
|
-
expect(result[1].content).toBe("World")
|
|
496
|
-
})
|
|
497
|
-
|
|
498
|
-
test("filters out empty text parts from array content", () => {
|
|
499
|
-
const msgs = [
|
|
500
|
-
{
|
|
501
|
-
role: "assistant",
|
|
502
|
-
content: [
|
|
503
|
-
{ type: "text", text: "" },
|
|
504
|
-
{ type: "text", text: "Hello" },
|
|
505
|
-
{ type: "text", text: "" },
|
|
506
|
-
],
|
|
507
|
-
},
|
|
508
|
-
] as any[]
|
|
509
|
-
|
|
510
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
511
|
-
|
|
512
|
-
expect(result).toHaveLength(1)
|
|
513
|
-
expect(result[0].content).toHaveLength(1)
|
|
514
|
-
expect(result[0].content[0]).toEqual({ type: "text", text: "Hello" })
|
|
515
|
-
})
|
|
516
|
-
|
|
517
|
-
test("filters out empty reasoning parts from array content", () => {
|
|
518
|
-
const msgs = [
|
|
519
|
-
{
|
|
520
|
-
role: "assistant",
|
|
521
|
-
content: [
|
|
522
|
-
{ type: "reasoning", text: "" },
|
|
523
|
-
{ type: "text", text: "Answer" },
|
|
524
|
-
{ type: "reasoning", text: "" },
|
|
525
|
-
],
|
|
526
|
-
},
|
|
527
|
-
] as any[]
|
|
528
|
-
|
|
529
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
530
|
-
|
|
531
|
-
expect(result).toHaveLength(1)
|
|
532
|
-
expect(result[0].content).toHaveLength(1)
|
|
533
|
-
expect(result[0].content[0]).toEqual({ type: "text", text: "Answer" })
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
test("removes entire message when all parts are empty", () => {
|
|
537
|
-
const msgs = [
|
|
538
|
-
{ role: "user", content: "Hello" },
|
|
539
|
-
{
|
|
540
|
-
role: "assistant",
|
|
541
|
-
content: [
|
|
542
|
-
{ type: "text", text: "" },
|
|
543
|
-
{ type: "reasoning", text: "" },
|
|
544
|
-
],
|
|
545
|
-
},
|
|
546
|
-
{ role: "user", content: "World" },
|
|
547
|
-
] as any[]
|
|
548
|
-
|
|
549
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
550
|
-
|
|
551
|
-
expect(result).toHaveLength(2)
|
|
552
|
-
expect(result[0].content).toBe("Hello")
|
|
553
|
-
expect(result[1].content).toBe("World")
|
|
554
|
-
})
|
|
555
|
-
|
|
556
|
-
test("keeps non-text/reasoning parts even if text parts are empty", () => {
|
|
557
|
-
const msgs = [
|
|
558
|
-
{
|
|
559
|
-
role: "assistant",
|
|
560
|
-
content: [
|
|
561
|
-
{ type: "text", text: "" },
|
|
562
|
-
{ type: "tool-call", toolCallId: "123", toolName: "bash", input: { command: "ls" } },
|
|
563
|
-
],
|
|
564
|
-
},
|
|
565
|
-
] as any[]
|
|
566
|
-
|
|
567
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
568
|
-
|
|
569
|
-
expect(result).toHaveLength(1)
|
|
570
|
-
expect(result[0].content).toHaveLength(1)
|
|
571
|
-
expect(result[0].content[0]).toEqual({
|
|
572
|
-
type: "tool-call",
|
|
573
|
-
toolCallId: "123",
|
|
574
|
-
toolName: "bash",
|
|
575
|
-
input: { command: "ls" },
|
|
576
|
-
})
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
test("keeps messages with valid text alongside empty parts", () => {
|
|
580
|
-
const msgs = [
|
|
581
|
-
{
|
|
582
|
-
role: "assistant",
|
|
583
|
-
content: [
|
|
584
|
-
{ type: "reasoning", text: "Thinking..." },
|
|
585
|
-
{ type: "text", text: "" },
|
|
586
|
-
{ type: "text", text: "Result" },
|
|
587
|
-
],
|
|
588
|
-
},
|
|
589
|
-
] as any[]
|
|
590
|
-
|
|
591
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {})
|
|
592
|
-
|
|
593
|
-
expect(result).toHaveLength(1)
|
|
594
|
-
expect(result[0].content).toHaveLength(2)
|
|
595
|
-
expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
|
|
596
|
-
expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
|
|
597
|
-
})
|
|
598
|
-
|
|
599
|
-
test("does not filter for non-anthropic providers", () => {
|
|
600
|
-
const openaiModel = {
|
|
601
|
-
...anthropicModel,
|
|
602
|
-
providerID: "openai",
|
|
603
|
-
api: {
|
|
604
|
-
id: "gpt-4",
|
|
605
|
-
url: "https://api.openai.com",
|
|
606
|
-
npm: "@ai-sdk/openai",
|
|
607
|
-
},
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
const msgs = [
|
|
611
|
-
{ role: "assistant", content: "" },
|
|
612
|
-
{
|
|
613
|
-
role: "assistant",
|
|
614
|
-
content: [{ type: "text", text: "" }],
|
|
615
|
-
},
|
|
616
|
-
] as any[]
|
|
617
|
-
|
|
618
|
-
const result = ProviderTransform.message(msgs, openaiModel, {})
|
|
619
|
-
|
|
620
|
-
expect(result).toHaveLength(2)
|
|
621
|
-
expect(result[0].content).toBe("")
|
|
622
|
-
expect(result[1].content).toHaveLength(1)
|
|
623
|
-
})
|
|
624
|
-
})
|
|
625
|
-
|
|
626
|
-
describe("ProviderTransform.message - strip openai metadata when store=false", () => {
|
|
627
|
-
const openaiModel = {
|
|
628
|
-
id: "openai/gpt-5",
|
|
629
|
-
providerID: "openai",
|
|
630
|
-
api: {
|
|
631
|
-
id: "gpt-5",
|
|
632
|
-
url: "https://api.openai.com",
|
|
633
|
-
npm: "@ai-sdk/openai",
|
|
634
|
-
},
|
|
635
|
-
name: "GPT-5",
|
|
636
|
-
capabilities: {
|
|
637
|
-
temperature: true,
|
|
638
|
-
reasoning: true,
|
|
639
|
-
attachment: true,
|
|
640
|
-
toolcall: true,
|
|
641
|
-
input: { text: true, audio: false, image: true, video: false, pdf: false },
|
|
642
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
643
|
-
interleaved: false,
|
|
644
|
-
},
|
|
645
|
-
cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
|
|
646
|
-
limit: { context: 128000, output: 4096 },
|
|
647
|
-
status: "active",
|
|
648
|
-
options: {},
|
|
649
|
-
headers: {},
|
|
650
|
-
} as any
|
|
651
|
-
|
|
652
|
-
test("preserves itemId and reasoningEncryptedContent when store=false", () => {
|
|
653
|
-
const msgs = [
|
|
654
|
-
{
|
|
655
|
-
role: "assistant",
|
|
656
|
-
content: [
|
|
657
|
-
{
|
|
658
|
-
type: "reasoning",
|
|
659
|
-
text: "thinking...",
|
|
660
|
-
providerOptions: {
|
|
661
|
-
openai: {
|
|
662
|
-
itemId: "rs_123",
|
|
663
|
-
reasoningEncryptedContent: "encrypted",
|
|
664
|
-
},
|
|
665
|
-
},
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
type: "text",
|
|
669
|
-
text: "Hello",
|
|
670
|
-
providerOptions: {
|
|
671
|
-
openai: {
|
|
672
|
-
itemId: "msg_456",
|
|
673
|
-
},
|
|
674
|
-
},
|
|
675
|
-
},
|
|
676
|
-
],
|
|
677
|
-
},
|
|
678
|
-
] as any[]
|
|
679
|
-
|
|
680
|
-
const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
|
|
681
|
-
|
|
682
|
-
expect(result).toHaveLength(1)
|
|
683
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
|
|
684
|
-
expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
|
|
685
|
-
})
|
|
686
|
-
|
|
687
|
-
test("preserves itemId and reasoningEncryptedContent when store=false even when not openai", () => {
|
|
688
|
-
const zenModel = {
|
|
689
|
-
...openaiModel,
|
|
690
|
-
providerID: "zen",
|
|
691
|
-
}
|
|
692
|
-
const msgs = [
|
|
693
|
-
{
|
|
694
|
-
role: "assistant",
|
|
695
|
-
content: [
|
|
696
|
-
{
|
|
697
|
-
type: "reasoning",
|
|
698
|
-
text: "thinking...",
|
|
699
|
-
providerOptions: {
|
|
700
|
-
openai: {
|
|
701
|
-
itemId: "rs_123",
|
|
702
|
-
reasoningEncryptedContent: "encrypted",
|
|
703
|
-
},
|
|
704
|
-
},
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
type: "text",
|
|
708
|
-
text: "Hello",
|
|
709
|
-
providerOptions: {
|
|
710
|
-
openai: {
|
|
711
|
-
itemId: "msg_456",
|
|
712
|
-
},
|
|
713
|
-
},
|
|
714
|
-
},
|
|
715
|
-
],
|
|
716
|
-
},
|
|
717
|
-
] as any[]
|
|
718
|
-
|
|
719
|
-
const result = ProviderTransform.message(msgs, zenModel, { store: false }) as any[]
|
|
720
|
-
|
|
721
|
-
expect(result).toHaveLength(1)
|
|
722
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
|
|
723
|
-
expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
|
|
724
|
-
})
|
|
725
|
-
|
|
726
|
-
test("preserves other openai options including itemId", () => {
|
|
727
|
-
const msgs = [
|
|
728
|
-
{
|
|
729
|
-
role: "assistant",
|
|
730
|
-
content: [
|
|
731
|
-
{
|
|
732
|
-
type: "text",
|
|
733
|
-
text: "Hello",
|
|
734
|
-
providerOptions: {
|
|
735
|
-
openai: {
|
|
736
|
-
itemId: "msg_123",
|
|
737
|
-
otherOption: "value",
|
|
738
|
-
},
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
],
|
|
742
|
-
},
|
|
743
|
-
] as any[]
|
|
744
|
-
|
|
745
|
-
const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
|
|
746
|
-
|
|
747
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
|
|
748
|
-
expect(result[0].content[0].providerOptions?.openai?.otherOption).toBe("value")
|
|
749
|
-
})
|
|
750
|
-
|
|
751
|
-
test("preserves metadata for openai package when store is true", () => {
|
|
752
|
-
const msgs = [
|
|
753
|
-
{
|
|
754
|
-
role: "assistant",
|
|
755
|
-
content: [
|
|
756
|
-
{
|
|
757
|
-
type: "text",
|
|
758
|
-
text: "Hello",
|
|
759
|
-
providerOptions: {
|
|
760
|
-
openai: {
|
|
761
|
-
itemId: "msg_123",
|
|
762
|
-
},
|
|
763
|
-
},
|
|
764
|
-
},
|
|
765
|
-
],
|
|
766
|
-
},
|
|
767
|
-
] as any[]
|
|
768
|
-
|
|
769
|
-
// openai package preserves itemId regardless of store value
|
|
770
|
-
const result = ProviderTransform.message(msgs, openaiModel, { store: true }) as any[]
|
|
771
|
-
|
|
772
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
|
|
773
|
-
})
|
|
774
|
-
|
|
775
|
-
test("preserves metadata for non-openai packages when store is false", () => {
|
|
776
|
-
const anthropicModel = {
|
|
777
|
-
...openaiModel,
|
|
778
|
-
providerID: "anthropic",
|
|
779
|
-
api: {
|
|
780
|
-
id: "claude-3",
|
|
781
|
-
url: "https://api.anthropic.com",
|
|
782
|
-
npm: "@ai-sdk/anthropic",
|
|
783
|
-
},
|
|
784
|
-
}
|
|
785
|
-
const msgs = [
|
|
786
|
-
{
|
|
787
|
-
role: "assistant",
|
|
788
|
-
content: [
|
|
789
|
-
{
|
|
790
|
-
type: "text",
|
|
791
|
-
text: "Hello",
|
|
792
|
-
providerOptions: {
|
|
793
|
-
openai: {
|
|
794
|
-
itemId: "msg_123",
|
|
795
|
-
},
|
|
796
|
-
},
|
|
797
|
-
},
|
|
798
|
-
],
|
|
799
|
-
},
|
|
800
|
-
] as any[]
|
|
801
|
-
|
|
802
|
-
// store=false preserves metadata for non-openai packages
|
|
803
|
-
const result = ProviderTransform.message(msgs, anthropicModel, { store: false }) as any[]
|
|
804
|
-
|
|
805
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
|
|
806
|
-
})
|
|
807
|
-
|
|
808
|
-
test("preserves metadata using providerID key when store is false", () => {
|
|
809
|
-
const opencodeModel = {
|
|
810
|
-
...openaiModel,
|
|
811
|
-
providerID: "opencode",
|
|
812
|
-
api: {
|
|
813
|
-
id: "opencode-test",
|
|
814
|
-
url: "https://api.opencode.ai",
|
|
815
|
-
npm: "@ai-sdk/openai-compatible",
|
|
816
|
-
},
|
|
817
|
-
}
|
|
818
|
-
const msgs = [
|
|
819
|
-
{
|
|
820
|
-
role: "assistant",
|
|
821
|
-
content: [
|
|
822
|
-
{
|
|
823
|
-
type: "text",
|
|
824
|
-
text: "Hello",
|
|
825
|
-
providerOptions: {
|
|
826
|
-
opencode: {
|
|
827
|
-
itemId: "msg_123",
|
|
828
|
-
otherOption: "value",
|
|
829
|
-
},
|
|
830
|
-
},
|
|
831
|
-
},
|
|
832
|
-
],
|
|
833
|
-
},
|
|
834
|
-
] as any[]
|
|
835
|
-
|
|
836
|
-
const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
|
|
837
|
-
|
|
838
|
-
expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_123")
|
|
839
|
-
expect(result[0].content[0].providerOptions?.opencode?.otherOption).toBe("value")
|
|
840
|
-
})
|
|
841
|
-
|
|
842
|
-
test("preserves itemId across all providerOptions keys", () => {
|
|
843
|
-
const opencodeModel = {
|
|
844
|
-
...openaiModel,
|
|
845
|
-
providerID: "opencode",
|
|
846
|
-
api: {
|
|
847
|
-
id: "opencode-test",
|
|
848
|
-
url: "https://api.opencode.ai",
|
|
849
|
-
npm: "@ai-sdk/openai-compatible",
|
|
850
|
-
},
|
|
851
|
-
}
|
|
852
|
-
const msgs = [
|
|
853
|
-
{
|
|
854
|
-
role: "assistant",
|
|
855
|
-
providerOptions: {
|
|
856
|
-
openai: { itemId: "msg_root" },
|
|
857
|
-
opencode: { itemId: "msg_opencode" },
|
|
858
|
-
extra: { itemId: "msg_extra" },
|
|
859
|
-
},
|
|
860
|
-
content: [
|
|
861
|
-
{
|
|
862
|
-
type: "text",
|
|
863
|
-
text: "Hello",
|
|
864
|
-
providerOptions: {
|
|
865
|
-
openai: { itemId: "msg_openai_part" },
|
|
866
|
-
opencode: { itemId: "msg_opencode_part" },
|
|
867
|
-
extra: { itemId: "msg_extra_part" },
|
|
868
|
-
},
|
|
869
|
-
},
|
|
870
|
-
],
|
|
871
|
-
},
|
|
872
|
-
] as any[]
|
|
873
|
-
|
|
874
|
-
const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
|
|
875
|
-
|
|
876
|
-
expect(result[0].providerOptions?.openai?.itemId).toBe("msg_root")
|
|
877
|
-
expect(result[0].providerOptions?.opencode?.itemId).toBe("msg_opencode")
|
|
878
|
-
expect(result[0].providerOptions?.extra?.itemId).toBe("msg_extra")
|
|
879
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_openai_part")
|
|
880
|
-
expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_opencode_part")
|
|
881
|
-
expect(result[0].content[0].providerOptions?.extra?.itemId).toBe("msg_extra_part")
|
|
882
|
-
})
|
|
883
|
-
|
|
884
|
-
test("does not strip metadata for non-openai packages when store is not false", () => {
|
|
885
|
-
const anthropicModel = {
|
|
886
|
-
...openaiModel,
|
|
887
|
-
providerID: "anthropic",
|
|
888
|
-
api: {
|
|
889
|
-
id: "claude-3",
|
|
890
|
-
url: "https://api.anthropic.com",
|
|
891
|
-
npm: "@ai-sdk/anthropic",
|
|
892
|
-
},
|
|
893
|
-
}
|
|
894
|
-
const msgs = [
|
|
895
|
-
{
|
|
896
|
-
role: "assistant",
|
|
897
|
-
content: [
|
|
898
|
-
{
|
|
899
|
-
type: "text",
|
|
900
|
-
text: "Hello",
|
|
901
|
-
providerOptions: {
|
|
902
|
-
openai: {
|
|
903
|
-
itemId: "msg_123",
|
|
904
|
-
},
|
|
905
|
-
},
|
|
906
|
-
},
|
|
907
|
-
],
|
|
908
|
-
},
|
|
909
|
-
] as any[]
|
|
910
|
-
|
|
911
|
-
const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
|
|
912
|
-
|
|
913
|
-
expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
|
|
914
|
-
})
|
|
915
|
-
})
|
|
916
|
-
|
|
917
|
-
describe("ProviderTransform.message - providerOptions key remapping", () => {
|
|
918
|
-
const createModel = (providerID: string, npm: string) =>
|
|
919
|
-
({
|
|
920
|
-
id: `${providerID}/test-model`,
|
|
921
|
-
providerID,
|
|
922
|
-
api: {
|
|
923
|
-
id: "test-model",
|
|
924
|
-
url: "https://api.test.com",
|
|
925
|
-
npm,
|
|
926
|
-
},
|
|
927
|
-
name: "Test Model",
|
|
928
|
-
capabilities: {
|
|
929
|
-
temperature: true,
|
|
930
|
-
reasoning: false,
|
|
931
|
-
attachment: true,
|
|
932
|
-
toolcall: true,
|
|
933
|
-
input: { text: true, audio: false, image: true, video: false, pdf: true },
|
|
934
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
935
|
-
interleaved: false,
|
|
936
|
-
},
|
|
937
|
-
cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
|
|
938
|
-
limit: { context: 128000, output: 8192 },
|
|
939
|
-
status: "active",
|
|
940
|
-
options: {},
|
|
941
|
-
headers: {},
|
|
942
|
-
}) as any
|
|
943
|
-
|
|
944
|
-
test("azure keeps 'azure' key and does not remap to 'openai'", () => {
|
|
945
|
-
const model = createModel("azure", "@ai-sdk/azure")
|
|
946
|
-
const msgs = [
|
|
947
|
-
{
|
|
948
|
-
role: "user",
|
|
949
|
-
content: "Hello",
|
|
950
|
-
providerOptions: {
|
|
951
|
-
azure: { someOption: "value" },
|
|
952
|
-
},
|
|
953
|
-
},
|
|
954
|
-
] as any[]
|
|
955
|
-
|
|
956
|
-
const result = ProviderTransform.message(msgs, model, {})
|
|
957
|
-
|
|
958
|
-
expect(result[0].providerOptions?.azure).toEqual({ someOption: "value" })
|
|
959
|
-
expect(result[0].providerOptions?.openai).toBeUndefined()
|
|
960
|
-
})
|
|
961
|
-
|
|
962
|
-
test("openai with github-copilot npm remaps providerID to 'openai'", () => {
|
|
963
|
-
const model = createModel("github-copilot", "@ai-sdk/github-copilot")
|
|
964
|
-
const msgs = [
|
|
965
|
-
{
|
|
966
|
-
role: "user",
|
|
967
|
-
content: "Hello",
|
|
968
|
-
providerOptions: {
|
|
969
|
-
"github-copilot": { someOption: "value" },
|
|
970
|
-
},
|
|
971
|
-
},
|
|
972
|
-
] as any[]
|
|
973
|
-
|
|
974
|
-
const result = ProviderTransform.message(msgs, model, {})
|
|
975
|
-
|
|
976
|
-
expect(result[0].providerOptions?.openai).toEqual({ someOption: "value" })
|
|
977
|
-
expect(result[0].providerOptions?.["github-copilot"]).toBeUndefined()
|
|
978
|
-
})
|
|
979
|
-
|
|
980
|
-
test("bedrock remaps providerID to 'bedrock' key", () => {
|
|
981
|
-
const model = createModel("my-bedrock", "@ai-sdk/amazon-bedrock")
|
|
982
|
-
const msgs = [
|
|
983
|
-
{
|
|
984
|
-
role: "user",
|
|
985
|
-
content: "Hello",
|
|
986
|
-
providerOptions: {
|
|
987
|
-
"my-bedrock": { someOption: "value" },
|
|
988
|
-
},
|
|
989
|
-
},
|
|
990
|
-
] as any[]
|
|
991
|
-
|
|
992
|
-
const result = ProviderTransform.message(msgs, model, {})
|
|
993
|
-
|
|
994
|
-
expect(result[0].providerOptions?.bedrock).toEqual({ someOption: "value" })
|
|
995
|
-
expect(result[0].providerOptions?.["my-bedrock"]).toBeUndefined()
|
|
996
|
-
})
|
|
997
|
-
})
|
|
998
|
-
|
|
999
|
-
describe("ProviderTransform.variants", () => {
|
|
1000
|
-
const createMockModel = (overrides: Partial<any> = {}): any => ({
|
|
1001
|
-
id: "test/test-model",
|
|
1002
|
-
providerID: "test",
|
|
1003
|
-
api: {
|
|
1004
|
-
id: "test-model",
|
|
1005
|
-
url: "https://api.test.com",
|
|
1006
|
-
npm: "@ai-sdk/openai",
|
|
1007
|
-
},
|
|
1008
|
-
name: "Test Model",
|
|
1009
|
-
capabilities: {
|
|
1010
|
-
temperature: true,
|
|
1011
|
-
reasoning: true,
|
|
1012
|
-
attachment: true,
|
|
1013
|
-
toolcall: true,
|
|
1014
|
-
input: { text: true, audio: false, image: true, video: false, pdf: false },
|
|
1015
|
-
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
|
1016
|
-
interleaved: false,
|
|
1017
|
-
},
|
|
1018
|
-
cost: {
|
|
1019
|
-
input: 0.001,
|
|
1020
|
-
output: 0.002,
|
|
1021
|
-
cache: { read: 0.0001, write: 0.0002 },
|
|
1022
|
-
},
|
|
1023
|
-
limit: {
|
|
1024
|
-
context: 128000,
|
|
1025
|
-
output: 8192,
|
|
1026
|
-
},
|
|
1027
|
-
status: "active",
|
|
1028
|
-
options: {},
|
|
1029
|
-
headers: {},
|
|
1030
|
-
release_date: "2024-01-01",
|
|
1031
|
-
...overrides,
|
|
1032
|
-
})
|
|
1033
|
-
|
|
1034
|
-
test("returns empty object when model has no reasoning capabilities", () => {
|
|
1035
|
-
const model = createMockModel({
|
|
1036
|
-
capabilities: { reasoning: false },
|
|
1037
|
-
})
|
|
1038
|
-
const result = ProviderTransform.variants(model)
|
|
1039
|
-
expect(result).toEqual({})
|
|
1040
|
-
})
|
|
1041
|
-
|
|
1042
|
-
test("deepseek returns empty object", () => {
|
|
1043
|
-
const model = createMockModel({
|
|
1044
|
-
id: "deepseek/deepseek-chat",
|
|
1045
|
-
providerID: "deepseek",
|
|
1046
|
-
api: {
|
|
1047
|
-
id: "deepseek-chat",
|
|
1048
|
-
url: "https://api.deepseek.com",
|
|
1049
|
-
npm: "@ai-sdk/openai-compatible",
|
|
1050
|
-
},
|
|
1051
|
-
})
|
|
1052
|
-
const result = ProviderTransform.variants(model)
|
|
1053
|
-
expect(result).toEqual({})
|
|
1054
|
-
})
|
|
1055
|
-
|
|
1056
|
-
test("minimax returns empty object", () => {
|
|
1057
|
-
const model = createMockModel({
|
|
1058
|
-
id: "minimax/minimax-model",
|
|
1059
|
-
providerID: "minimax",
|
|
1060
|
-
api: {
|
|
1061
|
-
id: "minimax-model",
|
|
1062
|
-
url: "https://api.minimax.com",
|
|
1063
|
-
npm: "@ai-sdk/openai-compatible",
|
|
1064
|
-
},
|
|
1065
|
-
})
|
|
1066
|
-
const result = ProviderTransform.variants(model)
|
|
1067
|
-
expect(result).toEqual({})
|
|
1068
|
-
})
|
|
1069
|
-
|
|
1070
|
-
test("glm returns empty object", () => {
|
|
1071
|
-
const model = createMockModel({
|
|
1072
|
-
id: "glm/glm-4",
|
|
1073
|
-
providerID: "glm",
|
|
1074
|
-
api: {
|
|
1075
|
-
id: "glm-4",
|
|
1076
|
-
url: "https://api.glm.com",
|
|
1077
|
-
npm: "@ai-sdk/openai-compatible",
|
|
1078
|
-
},
|
|
1079
|
-
})
|
|
1080
|
-
const result = ProviderTransform.variants(model)
|
|
1081
|
-
expect(result).toEqual({})
|
|
1082
|
-
})
|
|
1083
|
-
|
|
1084
|
-
test("mistral returns empty object", () => {
|
|
1085
|
-
const model = createMockModel({
|
|
1086
|
-
id: "mistral/mistral-large",
|
|
1087
|
-
providerID: "mistral",
|
|
1088
|
-
api: {
|
|
1089
|
-
id: "mistral-large-latest",
|
|
1090
|
-
url: "https://api.mistral.com",
|
|
1091
|
-
npm: "@ai-sdk/mistral",
|
|
1092
|
-
},
|
|
1093
|
-
})
|
|
1094
|
-
const result = ProviderTransform.variants(model)
|
|
1095
|
-
expect(result).toEqual({})
|
|
1096
|
-
})
|
|
1097
|
-
|
|
1098
|
-
describe("@openrouter/ai-sdk-provider", () => {
|
|
1099
|
-
test("returns empty object for non-qualifying models", () => {
|
|
1100
|
-
const model = createMockModel({
|
|
1101
|
-
id: "openrouter/test-model",
|
|
1102
|
-
providerID: "openrouter",
|
|
1103
|
-
api: {
|
|
1104
|
-
id: "test-model",
|
|
1105
|
-
url: "https://openrouter.ai",
|
|
1106
|
-
npm: "@openrouter/ai-sdk-provider",
|
|
1107
|
-
},
|
|
1108
|
-
})
|
|
1109
|
-
const result = ProviderTransform.variants(model)
|
|
1110
|
-
expect(result).toEqual({})
|
|
1111
|
-
})
|
|
1112
|
-
|
|
1113
|
-
test("gpt models return OPENAI_EFFORTS with reasoning", () => {
|
|
1114
|
-
const model = createMockModel({
|
|
1115
|
-
id: "openrouter/gpt-4",
|
|
1116
|
-
providerID: "openrouter",
|
|
1117
|
-
api: {
|
|
1118
|
-
id: "gpt-4",
|
|
1119
|
-
url: "https://openrouter.ai",
|
|
1120
|
-
npm: "@openrouter/ai-sdk-provider",
|
|
1121
|
-
},
|
|
1122
|
-
})
|
|
1123
|
-
const result = ProviderTransform.variants(model)
|
|
1124
|
-
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
|
1125
|
-
expect(result.low).toEqual({ reasoning: { effort: "low" } })
|
|
1126
|
-
expect(result.high).toEqual({ reasoning: { effort: "high" } })
|
|
1127
|
-
})
|
|
1128
|
-
|
|
1129
|
-
test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
|
|
1130
|
-
const model = createMockModel({
|
|
1131
|
-
id: "openrouter/gemini-3-5-pro",
|
|
1132
|
-
providerID: "openrouter",
|
|
1133
|
-
api: {
|
|
1134
|
-
id: "gemini-3-5-pro",
|
|
1135
|
-
url: "https://openrouter.ai",
|
|
1136
|
-
npm: "@openrouter/ai-sdk-provider",
|
|
1137
|
-
},
|
|
1138
|
-
})
|
|
1139
|
-
const result = ProviderTransform.variants(model)
|
|
1140
|
-
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
|
1141
|
-
})
|
|
1142
|
-
|
|
1143
|
-
test("grok-4 returns empty object", () => {
|
|
1144
|
-
const model = createMockModel({
|
|
1145
|
-
id: "openrouter/grok-4",
|
|
1146
|
-
providerID: "openrouter",
|
|
1147
|
-
api: {
|
|
1148
|
-
id: "grok-4",
|
|
1149
|
-
url: "https://openrouter.ai",
|
|
1150
|
-
npm: "@openrouter/ai-sdk-provider",
|
|
1151
|
-
},
|
|
1152
|
-
})
|
|
1153
|
-
const result = ProviderTransform.variants(model)
|
|
1154
|
-
expect(result).toEqual({})
|
|
1155
|
-
})
|
|
1156
|
-
|
|
1157
|
-
test("grok-3-mini returns low and high with reasoning", () => {
|
|
1158
|
-
const model = createMockModel({
|
|
1159
|
-
id: "openrouter/grok-3-mini",
|
|
1160
|
-
providerID: "openrouter",
|
|
1161
|
-
api: {
|
|
1162
|
-
id: "grok-3-mini",
|
|
1163
|
-
url: "https://openrouter.ai",
|
|
1164
|
-
npm: "@openrouter/ai-sdk-provider",
|
|
1165
|
-
},
|
|
1166
|
-
})
|
|
1167
|
-
const result = ProviderTransform.variants(model)
|
|
1168
|
-
expect(Object.keys(result)).toEqual(["low", "high"])
|
|
1169
|
-
expect(result.low).toEqual({ reasoning: { effort: "low" } })
|
|
1170
|
-
expect(result.high).toEqual({ reasoning: { effort: "high" } })
|
|
1171
|
-
})
|
|
1172
|
-
})
|
|
1173
|
-
|
|
1174
|
-
describe("@ai-sdk/gateway", () => {
|
|
1175
|
-
test("returns OPENAI_EFFORTS with reasoningEffort", () => {
|
|
1176
|
-
const model = createMockModel({
|
|
1177
|
-
id: "gateway/gateway-model",
|
|
1178
|
-
providerID: "gateway",
|
|
1179
|
-
api: {
|
|
1180
|
-
id: "gateway-model",
|
|
1181
|
-
url: "https://gateway.ai",
|
|
1182
|
-
npm: "@ai-sdk/gateway",
|
|
1183
|
-
},
|
|
1184
|
-
})
|
|
1185
|
-
const result = ProviderTransform.variants(model)
|
|
1186
|
-
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
|
1187
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1188
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1189
|
-
})
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
-
describe("@ai-sdk/cerebras", () => {
|
|
1193
|
-
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
|
|
1194
|
-
const model = createMockModel({
|
|
1195
|
-
id: "cerebras/llama-4",
|
|
1196
|
-
providerID: "cerebras",
|
|
1197
|
-
api: {
|
|
1198
|
-
id: "llama-4-sc",
|
|
1199
|
-
url: "https://api.cerebras.ai",
|
|
1200
|
-
npm: "@ai-sdk/cerebras",
|
|
1201
|
-
},
|
|
1202
|
-
})
|
|
1203
|
-
const result = ProviderTransform.variants(model)
|
|
1204
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1205
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1206
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1207
|
-
})
|
|
1208
|
-
})
|
|
1209
|
-
|
|
1210
|
-
describe("@ai-sdk/togetherai", () => {
|
|
1211
|
-
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
|
|
1212
|
-
const model = createMockModel({
|
|
1213
|
-
id: "togetherai/llama-4",
|
|
1214
|
-
providerID: "togetherai",
|
|
1215
|
-
api: {
|
|
1216
|
-
id: "llama-4-sc",
|
|
1217
|
-
url: "https://api.togetherai.com",
|
|
1218
|
-
npm: "@ai-sdk/togetherai",
|
|
1219
|
-
},
|
|
1220
|
-
})
|
|
1221
|
-
const result = ProviderTransform.variants(model)
|
|
1222
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1223
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1224
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1225
|
-
})
|
|
1226
|
-
})
|
|
1227
|
-
|
|
1228
|
-
describe("@ai-sdk/xai", () => {
|
|
1229
|
-
test("grok-3 returns empty object", () => {
|
|
1230
|
-
const model = createMockModel({
|
|
1231
|
-
id: "xai/grok-3",
|
|
1232
|
-
providerID: "xai",
|
|
1233
|
-
api: {
|
|
1234
|
-
id: "grok-3",
|
|
1235
|
-
url: "https://api.x.ai",
|
|
1236
|
-
npm: "@ai-sdk/xai",
|
|
1237
|
-
},
|
|
1238
|
-
})
|
|
1239
|
-
const result = ProviderTransform.variants(model)
|
|
1240
|
-
expect(result).toEqual({})
|
|
1241
|
-
})
|
|
1242
|
-
|
|
1243
|
-
test("grok-3-mini returns low and high with reasoningEffort", () => {
|
|
1244
|
-
const model = createMockModel({
|
|
1245
|
-
id: "xai/grok-3-mini",
|
|
1246
|
-
providerID: "xai",
|
|
1247
|
-
api: {
|
|
1248
|
-
id: "grok-3-mini",
|
|
1249
|
-
url: "https://api.x.ai",
|
|
1250
|
-
npm: "@ai-sdk/xai",
|
|
1251
|
-
},
|
|
1252
|
-
})
|
|
1253
|
-
const result = ProviderTransform.variants(model)
|
|
1254
|
-
expect(Object.keys(result)).toEqual(["low", "high"])
|
|
1255
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1256
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1257
|
-
})
|
|
1258
|
-
})
|
|
1259
|
-
|
|
1260
|
-
describe("@ai-sdk/deepinfra", () => {
|
|
1261
|
-
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
|
|
1262
|
-
const model = createMockModel({
|
|
1263
|
-
id: "deepinfra/llama-4",
|
|
1264
|
-
providerID: "deepinfra",
|
|
1265
|
-
api: {
|
|
1266
|
-
id: "llama-4-sc",
|
|
1267
|
-
url: "https://api.deepinfra.com",
|
|
1268
|
-
npm: "@ai-sdk/deepinfra",
|
|
1269
|
-
},
|
|
1270
|
-
})
|
|
1271
|
-
const result = ProviderTransform.variants(model)
|
|
1272
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1273
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1274
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1275
|
-
})
|
|
1276
|
-
})
|
|
1277
|
-
|
|
1278
|
-
describe("@ai-sdk/openai-compatible", () => {
|
|
1279
|
-
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
|
|
1280
|
-
const model = createMockModel({
|
|
1281
|
-
id: "custom-provider/custom-model",
|
|
1282
|
-
providerID: "custom-provider",
|
|
1283
|
-
api: {
|
|
1284
|
-
id: "custom-model",
|
|
1285
|
-
url: "https://api.custom.com",
|
|
1286
|
-
npm: "@ai-sdk/openai-compatible",
|
|
1287
|
-
},
|
|
1288
|
-
})
|
|
1289
|
-
const result = ProviderTransform.variants(model)
|
|
1290
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1291
|
-
expect(result.low).toEqual({ reasoningEffort: "low" })
|
|
1292
|
-
expect(result.high).toEqual({ reasoningEffort: "high" })
|
|
1293
|
-
})
|
|
1294
|
-
})
|
|
1295
|
-
|
|
1296
|
-
describe("@ai-sdk/azure", () => {
|
|
1297
|
-
test("o1-mini returns empty object", () => {
|
|
1298
|
-
const model = createMockModel({
|
|
1299
|
-
id: "o1-mini",
|
|
1300
|
-
providerID: "azure",
|
|
1301
|
-
api: {
|
|
1302
|
-
id: "o1-mini",
|
|
1303
|
-
url: "https://azure.com",
|
|
1304
|
-
npm: "@ai-sdk/azure",
|
|
1305
|
-
},
|
|
1306
|
-
})
|
|
1307
|
-
const result = ProviderTransform.variants(model)
|
|
1308
|
-
expect(result).toEqual({})
|
|
1309
|
-
})
|
|
1310
|
-
|
|
1311
|
-
test("standard azure models return custom efforts with reasoningSummary", () => {
|
|
1312
|
-
const model = createMockModel({
|
|
1313
|
-
id: "o1",
|
|
1314
|
-
providerID: "azure",
|
|
1315
|
-
api: {
|
|
1316
|
-
id: "o1",
|
|
1317
|
-
url: "https://azure.com",
|
|
1318
|
-
npm: "@ai-sdk/azure",
|
|
1319
|
-
},
|
|
1320
|
-
})
|
|
1321
|
-
const result = ProviderTransform.variants(model)
|
|
1322
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1323
|
-
expect(result.low).toEqual({
|
|
1324
|
-
reasoningEffort: "low",
|
|
1325
|
-
reasoningSummary: "auto",
|
|
1326
|
-
include: ["reasoning.encrypted_content"],
|
|
1327
|
-
})
|
|
1328
|
-
})
|
|
1329
|
-
|
|
1330
|
-
test("gpt-5 adds minimal effort", () => {
|
|
1331
|
-
const model = createMockModel({
|
|
1332
|
-
id: "gpt-5",
|
|
1333
|
-
providerID: "azure",
|
|
1334
|
-
api: {
|
|
1335
|
-
id: "gpt-5",
|
|
1336
|
-
url: "https://azure.com",
|
|
1337
|
-
npm: "@ai-sdk/azure",
|
|
1338
|
-
},
|
|
1339
|
-
})
|
|
1340
|
-
const result = ProviderTransform.variants(model)
|
|
1341
|
-
expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
|
|
1342
|
-
})
|
|
1343
|
-
})
|
|
1344
|
-
|
|
1345
|
-
describe("@ai-sdk/openai", () => {
|
|
1346
|
-
test("gpt-5-pro returns empty object", () => {
|
|
1347
|
-
const model = createMockModel({
|
|
1348
|
-
id: "gpt-5-pro",
|
|
1349
|
-
providerID: "openai",
|
|
1350
|
-
api: {
|
|
1351
|
-
id: "gpt-5-pro",
|
|
1352
|
-
url: "https://api.openai.com",
|
|
1353
|
-
npm: "@ai-sdk/openai",
|
|
1354
|
-
},
|
|
1355
|
-
})
|
|
1356
|
-
const result = ProviderTransform.variants(model)
|
|
1357
|
-
expect(result).toEqual({})
|
|
1358
|
-
})
|
|
1359
|
-
|
|
1360
|
-
test("standard openai models return custom efforts with reasoningSummary", () => {
|
|
1361
|
-
const model = createMockModel({
|
|
1362
|
-
id: "gpt-5",
|
|
1363
|
-
providerID: "openai",
|
|
1364
|
-
api: {
|
|
1365
|
-
id: "gpt-5",
|
|
1366
|
-
url: "https://api.openai.com",
|
|
1367
|
-
npm: "@ai-sdk/openai",
|
|
1368
|
-
},
|
|
1369
|
-
release_date: "2024-06-01",
|
|
1370
|
-
})
|
|
1371
|
-
const result = ProviderTransform.variants(model)
|
|
1372
|
-
expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
|
|
1373
|
-
expect(result.low).toEqual({
|
|
1374
|
-
reasoningEffort: "low",
|
|
1375
|
-
reasoningSummary: "auto",
|
|
1376
|
-
include: ["reasoning.encrypted_content"],
|
|
1377
|
-
})
|
|
1378
|
-
})
|
|
1379
|
-
|
|
1380
|
-
test("models after 2025-11-13 include 'none' effort", () => {
|
|
1381
|
-
const model = createMockModel({
|
|
1382
|
-
id: "gpt-5-nano",
|
|
1383
|
-
providerID: "openai",
|
|
1384
|
-
api: {
|
|
1385
|
-
id: "gpt-5-nano",
|
|
1386
|
-
url: "https://api.openai.com",
|
|
1387
|
-
npm: "@ai-sdk/openai",
|
|
1388
|
-
},
|
|
1389
|
-
release_date: "2025-11-14",
|
|
1390
|
-
})
|
|
1391
|
-
const result = ProviderTransform.variants(model)
|
|
1392
|
-
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high"])
|
|
1393
|
-
})
|
|
1394
|
-
|
|
1395
|
-
test("models after 2025-12-04 include 'xhigh' effort", () => {
|
|
1396
|
-
const model = createMockModel({
|
|
1397
|
-
id: "openai/gpt-5-chat",
|
|
1398
|
-
providerID: "openai",
|
|
1399
|
-
api: {
|
|
1400
|
-
id: "gpt-5-chat",
|
|
1401
|
-
url: "https://api.openai.com",
|
|
1402
|
-
npm: "@ai-sdk/openai",
|
|
1403
|
-
},
|
|
1404
|
-
release_date: "2025-12-05",
|
|
1405
|
-
})
|
|
1406
|
-
const result = ProviderTransform.variants(model)
|
|
1407
|
-
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
|
1408
|
-
})
|
|
1409
|
-
})
|
|
1410
|
-
|
|
1411
|
-
describe("@ai-sdk/anthropic", () => {
|
|
1412
|
-
test("returns high and max with thinking config", () => {
|
|
1413
|
-
const model = createMockModel({
|
|
1414
|
-
id: "anthropic/claude-4",
|
|
1415
|
-
providerID: "anthropic",
|
|
1416
|
-
api: {
|
|
1417
|
-
id: "claude-4",
|
|
1418
|
-
url: "https://api.anthropic.com",
|
|
1419
|
-
npm: "@ai-sdk/anthropic",
|
|
1420
|
-
},
|
|
1421
|
-
})
|
|
1422
|
-
const result = ProviderTransform.variants(model)
|
|
1423
|
-
expect(Object.keys(result)).toEqual(["high", "max"])
|
|
1424
|
-
expect(result.high).toEqual({
|
|
1425
|
-
thinking: {
|
|
1426
|
-
type: "enabled",
|
|
1427
|
-
budgetTokens: 16000,
|
|
1428
|
-
},
|
|
1429
|
-
})
|
|
1430
|
-
expect(result.max).toEqual({
|
|
1431
|
-
thinking: {
|
|
1432
|
-
type: "enabled",
|
|
1433
|
-
budgetTokens: 31999,
|
|
1434
|
-
},
|
|
1435
|
-
})
|
|
1436
|
-
})
|
|
1437
|
-
})
|
|
1438
|
-
|
|
1439
|
-
describe("@ai-sdk/amazon-bedrock", () => {
|
|
1440
|
-
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
|
|
1441
|
-
const model = createMockModel({
|
|
1442
|
-
id: "bedrock/llama-4",
|
|
1443
|
-
providerID: "bedrock",
|
|
1444
|
-
api: {
|
|
1445
|
-
id: "llama-4-sc",
|
|
1446
|
-
url: "https://bedrock.amazonaws.com",
|
|
1447
|
-
npm: "@ai-sdk/amazon-bedrock",
|
|
1448
|
-
},
|
|
1449
|
-
})
|
|
1450
|
-
const result = ProviderTransform.variants(model)
|
|
1451
|
-
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
|
1452
|
-
expect(result.low).toEqual({
|
|
1453
|
-
reasoningConfig: {
|
|
1454
|
-
type: "enabled",
|
|
1455
|
-
maxReasoningEffort: "low",
|
|
1456
|
-
},
|
|
1457
|
-
})
|
|
1458
|
-
})
|
|
1459
|
-
})
|
|
1460
|
-
|
|
1461
|
-
describe("@ai-sdk/google", () => {
|
|
1462
|
-
test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
|
|
1463
|
-
const model = createMockModel({
|
|
1464
|
-
id: "google/gemini-2.5-pro",
|
|
1465
|
-
providerID: "google",
|
|
1466
|
-
api: {
|
|
1467
|
-
id: "gemini-2.5-pro",
|
|
1468
|
-
url: "https://generativelanguage.googleapis.com",
|
|
1469
|
-
npm: "@ai-sdk/google",
|
|
1470
|
-
},
|
|
1471
|
-
})
|
|
1472
|
-
const result = ProviderTransform.variants(model)
|
|
1473
|
-
expect(Object.keys(result)).toEqual(["high", "max"])
|
|
1474
|
-
expect(result.high).toEqual({
|
|
1475
|
-
thinkingConfig: {
|
|
1476
|
-
includeThoughts: true,
|
|
1477
|
-
thinkingBudget: 16000,
|
|
1478
|
-
},
|
|
1479
|
-
})
|
|
1480
|
-
expect(result.max).toEqual({
|
|
1481
|
-
thinkingConfig: {
|
|
1482
|
-
includeThoughts: true,
|
|
1483
|
-
thinkingBudget: 24576,
|
|
1484
|
-
},
|
|
1485
|
-
})
|
|
1486
|
-
})
|
|
1487
|
-
|
|
1488
|
-
test("other gemini models return low and high with thinkingLevel", () => {
|
|
1489
|
-
const model = createMockModel({
|
|
1490
|
-
id: "google/gemini-2.0-pro",
|
|
1491
|
-
providerID: "google",
|
|
1492
|
-
api: {
|
|
1493
|
-
id: "gemini-2.0-pro",
|
|
1494
|
-
url: "https://generativelanguage.googleapis.com",
|
|
1495
|
-
npm: "@ai-sdk/google",
|
|
1496
|
-
},
|
|
1497
|
-
})
|
|
1498
|
-
const result = ProviderTransform.variants(model)
|
|
1499
|
-
expect(Object.keys(result)).toEqual(["low", "high"])
|
|
1500
|
-
expect(result.low).toEqual({
|
|
1501
|
-
includeThoughts: true,
|
|
1502
|
-
thinkingLevel: "low",
|
|
1503
|
-
})
|
|
1504
|
-
expect(result.high).toEqual({
|
|
1505
|
-
includeThoughts: true,
|
|
1506
|
-
thinkingLevel: "high",
|
|
1507
|
-
})
|
|
1508
|
-
})
|
|
1509
|
-
})
|
|
1510
|
-
|
|
1511
|
-
describe("@ai-sdk/google-vertex", () => {
|
|
1512
|
-
test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
|
|
1513
|
-
const model = createMockModel({
|
|
1514
|
-
id: "google-vertex/gemini-2.5-pro",
|
|
1515
|
-
providerID: "google-vertex",
|
|
1516
|
-
api: {
|
|
1517
|
-
id: "gemini-2.5-pro",
|
|
1518
|
-
url: "https://vertexai.googleapis.com",
|
|
1519
|
-
npm: "@ai-sdk/google-vertex",
|
|
1520
|
-
},
|
|
1521
|
-
})
|
|
1522
|
-
const result = ProviderTransform.variants(model)
|
|
1523
|
-
expect(Object.keys(result)).toEqual(["high", "max"])
|
|
1524
|
-
})
|
|
1525
|
-
|
|
1526
|
-
test("other vertex models return low and high with thinkingLevel", () => {
|
|
1527
|
-
const model = createMockModel({
|
|
1528
|
-
id: "google-vertex/gemini-2.0-pro",
|
|
1529
|
-
providerID: "google-vertex",
|
|
1530
|
-
api: {
|
|
1531
|
-
id: "gemini-2.0-pro",
|
|
1532
|
-
url: "https://vertexai.googleapis.com",
|
|
1533
|
-
npm: "@ai-sdk/google-vertex",
|
|
1534
|
-
},
|
|
1535
|
-
})
|
|
1536
|
-
const result = ProviderTransform.variants(model)
|
|
1537
|
-
expect(Object.keys(result)).toEqual(["low", "high"])
|
|
1538
|
-
})
|
|
1539
|
-
})
|
|
1540
|
-
|
|
1541
|
-
describe("@ai-sdk/cohere", () => {
|
|
1542
|
-
test("returns empty object", () => {
|
|
1543
|
-
const model = createMockModel({
|
|
1544
|
-
id: "cohere/command-r",
|
|
1545
|
-
providerID: "cohere",
|
|
1546
|
-
api: {
|
|
1547
|
-
id: "command-r",
|
|
1548
|
-
url: "https://api.cohere.com",
|
|
1549
|
-
npm: "@ai-sdk/cohere",
|
|
1550
|
-
},
|
|
1551
|
-
})
|
|
1552
|
-
const result = ProviderTransform.variants(model)
|
|
1553
|
-
expect(result).toEqual({})
|
|
1554
|
-
})
|
|
1555
|
-
})
|
|
1556
|
-
|
|
1557
|
-
describe("@ai-sdk/groq", () => {
|
|
1558
|
-
test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
|
|
1559
|
-
const model = createMockModel({
|
|
1560
|
-
id: "groq/llama-4",
|
|
1561
|
-
providerID: "groq",
|
|
1562
|
-
api: {
|
|
1563
|
-
id: "llama-4-sc",
|
|
1564
|
-
url: "https://api.groq.com",
|
|
1565
|
-
npm: "@ai-sdk/groq",
|
|
1566
|
-
},
|
|
1567
|
-
})
|
|
1568
|
-
const result = ProviderTransform.variants(model)
|
|
1569
|
-
expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
|
|
1570
|
-
expect(result.none).toEqual({
|
|
1571
|
-
includeThoughts: true,
|
|
1572
|
-
thinkingLevel: "none",
|
|
1573
|
-
})
|
|
1574
|
-
expect(result.low).toEqual({
|
|
1575
|
-
includeThoughts: true,
|
|
1576
|
-
thinkingLevel: "low",
|
|
1577
|
-
})
|
|
1578
|
-
})
|
|
1579
|
-
})
|
|
1580
|
-
|
|
1581
|
-
describe("@ai-sdk/perplexity", () => {
|
|
1582
|
-
test("returns empty object", () => {
|
|
1583
|
-
const model = createMockModel({
|
|
1584
|
-
id: "perplexity/sonar-plus",
|
|
1585
|
-
providerID: "perplexity",
|
|
1586
|
-
api: {
|
|
1587
|
-
id: "sonar-plus",
|
|
1588
|
-
url: "https://api.perplexity.ai",
|
|
1589
|
-
npm: "@ai-sdk/perplexity",
|
|
1590
|
-
},
|
|
1591
|
-
})
|
|
1592
|
-
const result = ProviderTransform.variants(model)
|
|
1593
|
-
expect(result).toEqual({})
|
|
1594
|
-
})
|
|
1595
|
-
})
|
|
1596
|
-
})
|