diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb6d130..b5765619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Changed +- **provider**: Refresh models for individual AI providers in Settings and choose which models to add. Use Add Provider to set up a new provider. + ## [0.7.2] - 2026-11-27 ### Added diff --git a/apps/web/e2e/README.md b/apps/web/e2e/README.md index 8016c859..b5c37cb7 100644 --- a/apps/web/e2e/README.md +++ b/apps/web/e2e/README.md @@ -68,6 +68,7 @@ apps/web/e2e/ | Owner manages resource quotas in settings and resets usage from the dashboard | `tests/team/quotas-settings.spec.ts` | | Owner creates an API token that is shown once, listed by hint, and authenticates API calls | `tests/team/api-tokens.spec.ts` | | Session logs stay within the dialog and scroll through long messages and expanded records on desktop and narrow screens | `tests/team/agent-session-logs.spec.ts` | +| Provider cards show credential status, and the selected provider's model preview scrolls on desktop and mobile | `tests/team/provider-model-refresh.spec.ts` | ### project | Test | File | diff --git a/apps/web/e2e/tests/team/provider-model-refresh.spec.ts b/apps/web/e2e/tests/team/provider-model-refresh.spec.ts new file mode 100644 index 00000000..70355f78 --- /dev/null +++ b/apps/web/e2e/tests/team/provider-model-refresh.spec.ts @@ -0,0 +1,104 @@ +import type { RefreshedProviderModel } from '@shumai/dtos' +import { expect, test } from '../../fixtures' + +test('provider cards show credential status and open a scrollable preview for the selected provider', async ({ + owner, + prisma, +}) => { + const { page, teamId } = owner + const provider = await prisma.provider.create({ + data: { + teamId, + name: 'OpenAI production', + config: { + api: 'openai-responses', + baseUrl: 'https://api.openai.com/v1', + apiKey: 'saved-test-key', + }, + }, + }) + const missing = await prisma.provider.create({ + data: { + teamId, + name: 'Anthropic staging', + config: { + api: 'anthropic-messages', + baseUrl: 'https://api.anthropic.com', + apiKey: 'UNSET_E2E_ANTHROPIC_KEY', + }, + }, + }) + const models = Array.from({ length: 48 }, (_, index): RefreshedProviderModel => ({ + modelId: `test-model-${index + 1}`, + name: `Test Model ${index + 1}`, + config: { + reasoning: false, + input: ['text'], + contextWindow: 128000, + maxTokens: 4096, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + }, + })) + + const releasePreview = Promise.withResolvers() + await page.route( + `**/api/teams/${teamId}/providers/${provider.id}/models/refresh`, + async (route) => { + await releasePreview.promise + await route.fulfill({ + json: { status: 'ready', providerUpdatedAt: provider.updatedAt.toISOString(), models }, + }) + }, + ) + await page.goto(`/teams/${teamId}/settings#providers`) + + const cards = page.locator('main [data-slot="card"]') + const openai = cards.filter({ hasText: provider.name }) + const anthropic = cards.filter({ hasText: missing.name }) + const refresh = openai.getByRole('button', { name: /Refresh models for OpenAI production/ }) + await expect(cards.first()).toContainText(provider.name) + await expect(openai.getByText('Configured', { exact: true })).toBeVisible() + await expect(anthropic.getByText('Configured', { exact: true })).toHaveCount(0) + await expect(anthropic.getByRole('button', { name: /Refresh models/ })).toBeEnabled() + + await refresh.focus() + await page.keyboard.press('Enter') + await expect(refresh).toHaveAttribute('aria-busy', 'true') + await expect(anthropic.getByRole('button', { name: /Refresh models/ })).toHaveAttribute( + 'aria-busy', + 'false', + ) + releasePreview.resolve() + + const dialog = page.getByRole('dialog', { name: 'New models for OpenAI production' }) + await expect(dialog).toBeVisible() + await expect(dialog.getByRole('checkbox', { name: 'Test Model 1 test-model-1' })).toBeVisible() + + for (const viewport of [ + { width: 1280, height: 800 }, + { width: 390, height: 640 }, + ]) { + await page.setViewportSize(viewport) + await expect + .poll(() => + dialog.locator('[data-slot="scroll-area-viewport"]').evaluate((element) => { + const scrollAreaBounds = element.getBoundingClientRect() + const dialogBounds = element.closest('[role="dialog"]')?.getBoundingClientRect() + return ( + dialogBounds !== undefined && + dialogBounds.left >= 0 && + dialogBounds.right <= window.innerWidth && + dialogBounds.top >= 0 && + dialogBounds.bottom <= window.innerHeight && + scrollAreaBounds.bottom < dialogBounds.bottom && + element.scrollHeight > element.clientHeight + ) + }), + ) + .toBe(true) + } + + await dialog.getByRole('button', { name: 'Cancel' }).click() + await expect(dialog).toBeHidden() + await expect(refresh).toBeFocused() +}) diff --git a/bun.lock b/bun.lock index 99a1da2d..64d2f1d3 100644 --- a/bun.lock +++ b/bun.lock @@ -147,9 +147,9 @@ "name": "@shumai/agent", "version": "0.7.2", "dependencies": { - "@earendil-works/chord": "1.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/chord": "1.7.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", @@ -172,7 +172,7 @@ "version": "0.7.2", "dependencies": { "@better-auth/mcp": "1.7.12", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-durable": "1.7.0", "@hono/zod-validator": "0.7.6", "@modelcontextprotocol/server": "2.0.0", "@shumai/core": "workspace:*", @@ -214,9 +214,9 @@ "@aws-sdk/s3-request-presigner": "3.1121.0", "@better-auth/mcp": "1.7.12", "@better-auth/oauth-provider": "1.7.12", - "@earendil-works/chord": "1.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/chord": "1.7.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@modelcontextprotocol/client": "2.0.0", "@shumai/db": "workspace:*", @@ -271,8 +271,8 @@ "name": "@shumai/dtos", "version": "0.7.2", "dependencies": { - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "zod": "4.5.4", }, }, @@ -280,8 +280,8 @@ "name": "@shumai/e2e", "version": "0.7.2", "dependencies": { - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@shumai/agent": "workspace:*", "@shumai/core": "workspace:*", @@ -323,8 +323,8 @@ "@dnd-kit/abstract": "0.5.0", "@dnd-kit/dom": "0.5.0", "@dnd-kit/react": "0.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@ferrucc-io/emoji-picker": "0.1.2", "@hookform/resolvers": "5.9.1", "@lexical/code": "0.49.0", @@ -496,21 +496,21 @@ "@aws-sdk/core": ["@aws-sdk/core@3.977.9", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@aws-sdk/xml-builder": "^3.972.40", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.33.3", "@smithy/signature-v4": "^5.6.12", "@smithy/types": "^4.17.2", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-reqPFEQrZxDZpeGj4PFMepBeR5LGYHRqq/L0motTzgFkCRBA4rFdaVXDSLYyGHhxVz7sT2PDnPN9CluGSfgyJA=="], - "@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-H404B7dJl2mCrBqahDEYsanB0xhdDp6tXnXcTUnXmmpy2Q3J0Ho0bUajZ2jr/RdwzCyS59Gi8xXIFwPLGBl6Uw=="], + "@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-uO5TiSvb6j1w9RTe5z28OaOmsrOxVQUPaC5+wZl50RfOXcrYD/KgnS8I9lfyGXc7sGbkCopK6VnhNIAoLqfewQ=="], - "@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.72", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/fetch-http-handler": "^5.7.2", "@smithy/node-http-handler": "^4.11.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-X98zYOrVOeuosCX+6ktf29FC2N2GHPLia7qv6mzPzTc+RPAuHWCDS++Z6JK7eGYqb/v6uaW7bAXaOvDBfol+0w=="], + "@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.82", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-vQzlDHlC24Yz42p+rT4NBoP/5VdetkBoujbOLq9h6QYWC8THuZSPYnXIR9OP3XcOrdMgPBBipOrdssfxnIiWUg=="], - "@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.15", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-login": "^3.972.77", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rykg6s5ceBuynMOGWgoowO4N+27JfnqXAnVaSunZl0hOO1XodSrxGNz6sCEbnmS0lAfQZDKyb3fbr46gSuv6Sg=="], + "@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.25", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/credential-provider-env": "^3.972.80", "@aws-sdk/credential-provider-http": "^3.972.82", "@aws-sdk/credential-provider-login": "^3.972.87", "@aws-sdk/credential-provider-process": "^3.972.80", "@aws-sdk/credential-provider-sso": "^3.973.24", "@aws-sdk/credential-provider-web-identity": "^3.972.86", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/credential-provider-imds": "^4.5.2", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-b5xl71uCRdWsu7P1VeGpiGuCf6zfYETsSNOv8AmYVTrsgbvTJRXdmmOPVfxkvGGVNsiKkGctClQW3jAn0SZLug=="], - "@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.77", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Jb59xfEISoN5mmbnA+HYqdtrSX3CgCtJoof+V5D8/TgUI56W63GEEd5Y58WijU3Ou6+WEgaLD1feVzaRXV5IDQ=="], + "@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.87", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-C4ZFmcwM+Zj14Z8huVUk54Gv4uzT1ZdzG9cY3Gdh8FePakq7Bss1OFsgZjAhWFOkFOGpBvFBeu0OWjWf8HNKRQ=="], - "@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.81", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rml+WitoFvXmv6JZ18U/xGdGDGGvB/mOin0ya0lTnTrdC0Z1lrVxTYh7iNklZBcvcRMrs4DoEf6xy1KWyrLQQw=="], + "@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.82", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-znDkEOGXB8W3kG1LJUKP3foBZY/9qLM0eil/DxWXSp37XsdsRLQHE/d/OaCGGVgKpA6znR38h/+INk8do1FjiA=="], - "@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2ry03fGRJr4sV3jI+ocjj5JqALnFD6ymM5KiNCDZMvq8bX2GSbE0vji4aM43TVCl2nXqqLRZaUxdq/KeWRAY4Q=="], + "@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-xqfixO5aclje7tbQJDias+iNND5wp/3QZixCdZcVQpgWPTZ0V5DfTW9A804A5Z7ezu7sH3WRO+vzUjtiJBA8yg=="], - "@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.14", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/token-providers": "3.1116.0", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-jkhg/8ocAAoc0RFyLMhCw+/zZh7gystQgd4F4hznNa8P4Cc501PQmxd+jGLiMHodPJ+7Zv/3znM62gZojyasmA=="], + "@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.24", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/token-providers": "3.1161.0", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-nlg3BKG03Cgzvv/dMnhxvDJPhAhQSpaN0RUdwgU7ziwkasoev7iI8el8Xy4Rd5sqzgaDUbV269fOXck5SargqA=="], - "@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.76", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-d3AGyVu759PGr35mEB2s22xxlNEA5rpdxtSPJthfPFJvoQ8dt357iVPECqWfUxXp1toJAvKmbtcIYVGigaGsCA=="], + "@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.86", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-zKTyLJBEyfQBVlYqT6Jt+mYV4r8kGbWM7dn6v4Y4MRARizhYafjDXP/iMu76UMRhToSPNmIKX1XAb24gtpBFIA=="], "@aws-sdk/eventstream-handler-node": ["@aws-sdk/eventstream-handler-node@3.972.34", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-cTeVzpu1xEAkryTZBYhGwnQ6gOGyp8ZYZvmn0Sg/nI/ABmy/CRHHxPDJDUi9PxwxUtGGaatvfRUB3FCgT/rSWw=="], @@ -618,17 +618,17 @@ "@dnd-kit/state": ["@dnd-kit/state@0.5.0", "", { "dependencies": { "@preact/signals-core": "^1.10.0", "tslib": "^2.6.2" } }, "sha512-y7XbabQqjF58Lk8YmDQuR8l6QjN+Kh4qlGEjUvHuIeasLk1QP+9L5diXS98VMxQIivyMmUtX2//f+3N7qPJX4w=="], - "@earendil-works/chord": ["@earendil-works/chord@1.5.0", "", { "dependencies": { "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0" }, "peerDependencies": { "esbuild": "0.28.2", "ws": "8.21.0" }, "optionalPeers": ["esbuild", "ws"] }, "sha512-jf555zbCM21E03DVBDPD/Tuae0lz64YjaHx/athUxNZ/H7phVVb0dWfZsaYnxaXPQ1odW8iHEoVLOlE/prvUPg=="], + "@earendil-works/chord": ["@earendil-works/chord@1.7.0", "", { "dependencies": { "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0" }, "peerDependencies": { "esbuild": "^0.28.2", "react": "^19.3.0", "ws": "^8.21.0" }, "optionalPeers": ["esbuild", "react", "ws"] }, "sha512-/zBlRrJkNbw0dJ4OrUzk08PC48mzOIFZQKTUE1qxQUWoPlf/xms95lEigzC30MllS+k5qqih7Clg0cTzYgPs1w=="], - "@earendil-works/pi-ai": ["@earendil-works/pi-ai@1.5.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.129.0", "@aws-sdk/client-bedrock-runtime": "3.1127.0", "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0", "@google/genai": "2.21.0", "@smithy/node-http-handler": "4.12.1", "http-proxy-agent": "9.1.0", "https-proxy-agent": "9.1.0", "openai": "7.19.0", "partial-json": "0.1.7" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-VeWxNqTHSqRCf8AcY/6kvNwh+neRL6MPxZPePVztIQy6qqK9MR/YoCSN/ZgDnIyCD3pqEXgRyQbzk4KV4uvjbg=="], + "@earendil-works/pi-ai": ["@earendil-works/pi-ai@1.7.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.129.0", "@aws-sdk/client-bedrock-runtime": "3.1127.0", "@aws-sdk/credential-provider-node": "3.972.82", "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0", "@google/genai": "3.6.1", "@smithy/node-http-handler": "4.12.1", "http-proxy-agent": "9.1.0", "https-proxy-agent": "9.1.0", "openai": "7.59.0", "partial-json": "0.1.7" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-iKryMlUYniwWbU7YU0uS7W0+cGd9c6oJ6PzRLOn8j4+1njG4c+BQq1cNawctx/npDqGeOx8ME7Gkgl6K6arPuw=="], - "@earendil-works/pi-codemode": ["@earendil-works/pi-codemode@1.5.0", "", { "dependencies": { "quickjs-wasi": "3.6.2" } }, "sha512-PLBJZ17AEWGzOlAAcFuOkw3PxkOti0JlFuZQyeF2GRTqbpuYo4k9t8YqUV2uOQVzrUnKdxahwaFUqc1eNS1WAg=="], + "@earendil-works/pi-codemode": ["@earendil-works/pi-codemode@1.7.0", "", { "dependencies": { "quickjs-wasi": "3.6.2" } }, "sha512-fhCoh8TLxhdRTOWSEplwp39Uv+JTsu9pCqtgu9gorO8zcaw92vsbVI/G89yFs92csTo2+yB7EsJq/+725Vj+eA=="], - "@earendil-works/pi-durable": ["@earendil-works/pi-durable@1.5.0", "", { "dependencies": { "@earendil-works/chord": "1.5.0", "@earendil-works/pi-ai": "1.5.0", "@earendil-works/pi-codemode": "1.5.0", "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0", "@silvia-odwyer/photon": "0.3.3", "diff": "8.0.4" } }, "sha512-xeBP2vIo5NvsCMQ4Y/V+Z164xQEi9JWiBWHdjn4Z15EnFqV3c0FxJAX26FqyyyintrYyk+Enre94GNcvRlBA5g=="], + "@earendil-works/pi-durable": ["@earendil-works/pi-durable@1.7.0", "", { "dependencies": { "@earendil-works/chord": "1.7.0", "@earendil-works/pi-ai": "1.7.0", "@earendil-works/pi-codemode": "1.7.0", "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0", "@silvia-odwyer/photon": "0.3.3", "diff": "8.0.4" } }, "sha512-qL9PlFfXrirBNt7QR2bjZfviN6ZVcsGTHEqaj6U4Lxqqx9Vtth7LyIuGNlG2chDKMr3/ABamH8qZ9ggMgTGDOQ=="], - "@earendil-works/pi-schema": ["@earendil-works/pi-schema@1.5.0", "", {}, "sha512-RW0MbT2tR65OY6xMsgB/yVBb7m/RTNwA+9hurSN1vVXfHZRVmVnXbruBPrx/PzbrQnW5yLVlMRWxErGDQtF1Hg=="], + "@earendil-works/pi-schema": ["@earendil-works/pi-schema@1.7.0", "", {}, "sha512-skji4McLg9jum3NFWzFa/4QRGEZhMGnSi3QL8b9VljJkc/QopH2/BFuGKI+VcEwYzKGwsd0I8RzvXGnZGfGltQ=="], - "@earendil-works/pi-telemetry": ["@earendil-works/pi-telemetry@1.5.0", "", {}, "sha512-VW3tcVdnNfl/Vk8wHPTzZdKkxcsCOM12ppiO4DXnd9wMxUCmOfLt/wvUnWeKWbTVlVSRg0uqKtnnhE2UCsG2Bw=="], + "@earendil-works/pi-telemetry": ["@earendil-works/pi-telemetry@1.7.0", "", {}, "sha512-QZkngqktohuFZ2TZuJSXDuUntld4sCMW1tkUPaD4moMEX/z1lwcjycXnd9ChO9HNxm/Jfo+UTiC+N2hkAF9b0w=="], "@electric-sql/pglite": ["@electric-sql/pglite@0.4.3", "", {}, "sha512-ichuWTgtd4mOM1G4SpyGJa5trT03lWbMypDV0fUXUCXg5hiHqVAz/bZyV68NqmkLB7WcYmj1RMJVSp8HV/v/ZQ=="], @@ -2498,7 +2498,7 @@ "once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="], - "openai": ["openai@7.19.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "undici", "ws", "zod"] }, "sha512-MX2s3u2L5racTO0CC/SWpCOasJQBCJrqLKXK+l82cAhdeF8mPMBEe/gxMm0ZFa2xpKpOFLRjxv5afYEZbBXmbQ=="], + "openai": ["openai@7.59.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "google-auth-library": ">=9.15.1 <12", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "google-auth-library", "undici", "ws", "zod"] }, "sha512-wPYKJkLPFEdNJ2tThSg4jE1Ptsv4X3u8g8LIvu0Qz/UIhsKeCzl73rl48PtQsDVrJL/ku0liXOsbyd2TsRsPJw=="], "optionator": ["optionator@0.9.4", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="], @@ -3046,11 +3046,85 @@ "@aws-sdk/client-bedrock-runtime/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="], + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.81", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rml+WitoFvXmv6JZ18U/xGdGDGGvB/mOin0ya0lTnTrdC0Z1lrVxTYh7iNklZBcvcRMrs4DoEf6xy1KWyrLQQw=="], + "@aws-sdk/client-s3/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="], - "@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="], + "@aws-sdk/credential-provider-env/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], - "@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1116.0", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-ygIivKqh8aHzNkucOCXHyIBgBpLPfrSI0mCqXF+vLBsPTUKqj0VSqAY0GFPe7lQl4HntjOcQ+KSyS7oUV2C54Q=="], + "@aws-sdk/credential-provider-env/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-env/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-env/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-http/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-http/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-http/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-http/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + + "@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + + "@aws-sdk/credential-provider-http/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-ini/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-ini/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-login/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-login/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-node/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-node/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-process/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-process/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-process/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-process/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1161.0", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-ypbXSofNcSHwf/KA40bFCXJb0MLaAKrfT7sot4dFaA+2lsuXNah4zLRJIAU7Qmvs9PFJ6rnY0bZFEC+mE7attA=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-sso/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-sso/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], + + "@aws-sdk/credential-provider-web-identity/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], + + "@aws-sdk/credential-provider-web-identity/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], "@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="], @@ -3060,9 +3134,7 @@ "@dbos-inc/dbos-sdk/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], - "@earendil-works/chord/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], - - "@earendil-works/pi-ai/@google/genai": ["@google/genai@2.21.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"], "hasInstallScript": true }, "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q=="], + "@earendil-works/pi-ai/@google/genai": ["@google/genai@3.6.1", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.6.5", "ws": "^8.21.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-DQIkZkl+VoZc+RUSaJ41vRuywjQDpP0t/oUf5/ddQhNW6JsPjVULW2EgHmuJ1mrr6ACtrmUdPlqtNXF1yfKySg=="], "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], @@ -3320,25 +3392,77 @@ "wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-uO5TiSvb6j1w9RTe5z28OaOmsrOxVQUPaC5+wZl50RfOXcrYD/KgnS8I9lfyGXc7sGbkCopK6VnhNIAoLqfewQ=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.82", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-vQzlDHlC24Yz42p+rT4NBoP/5VdetkBoujbOLq9h6QYWC8THuZSPYnXIR9OP3XcOrdMgPBBipOrdssfxnIiWUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.25", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/credential-provider-env": "^3.972.80", "@aws-sdk/credential-provider-http": "^3.972.82", "@aws-sdk/credential-provider-login": "^3.972.87", "@aws-sdk/credential-provider-process": "^3.972.80", "@aws-sdk/credential-provider-sso": "^3.973.24", "@aws-sdk/credential-provider-web-identity": "^3.972.86", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/credential-provider-imds": "^4.5.2", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-b5xl71uCRdWsu7P1VeGpiGuCf6zfYETsSNOv8AmYVTrsgbvTJRXdmmOPVfxkvGGVNsiKkGctClQW3jAn0SZLug=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-xqfixO5aclje7tbQJDias+iNND5wp/3QZixCdZcVQpgWPTZ0V5DfTW9A804A5Z7ezu7sH3WRO+vzUjtiJBA8yg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.24", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/token-providers": "3.1161.0", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-nlg3BKG03Cgzvv/dMnhxvDJPhAhQSpaN0RUdwgU7ziwkasoev7iI8el8Xy4Rd5sqzgaDUbV269fOXck5SargqA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.86", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-zKTyLJBEyfQBVlYqT6Jt+mYV4r8kGbWM7dn6v4Y4MRARizhYafjDXP/iMu76UMRhToSPNmIKX1XAb24gtpBFIA=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="], "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="], "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], - "@earendil-works/pi-ai/@google/genai/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-H404B7dJl2mCrBqahDEYsanB0xhdDp6tXnXcTUnXmmpy2Q3J0Ho0bUajZ2jr/RdwzCyS59Gi8xXIFwPLGBl6Uw=="], + + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.72", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/fetch-http-handler": "^5.7.2", "@smithy/node-http-handler": "^4.11.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-X98zYOrVOeuosCX+6ktf29FC2N2GHPLia7qv6mzPzTc+RPAuHWCDS++Z6JK7eGYqb/v6uaW7bAXaOvDBfol+0w=="], + + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.15", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-login": "^3.972.77", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rykg6s5ceBuynMOGWgoowO4N+27JfnqXAnVaSunZl0hOO1XodSrxGNz6sCEbnmS0lAfQZDKyb3fbr46gSuv6Sg=="], + + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2ry03fGRJr4sV3jI+ocjj5JqALnFD6ymM5KiNCDZMvq8bX2GSbE0vji4aM43TVCl2nXqqLRZaUxdq/KeWRAY4Q=="], + + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.14", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/token-providers": "3.1116.0", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-jkhg/8ocAAoc0RFyLMhCw+/zZh7gystQgd4F4hznNa8P4Cc501PQmxd+jGLiMHodPJ+7Zv/3znM62gZojyasmA=="], + + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.76", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-d3AGyVu759PGr35mEB2s22xxlNEA5rpdxtSPJthfPFJvoQ8dt357iVPECqWfUxXp1toJAvKmbtcIYVGigaGsCA=="], + + "@aws-sdk/credential-provider-env/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-env/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-http/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-http/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + + "@aws-sdk/credential-provider-process/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-process/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], "@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], @@ -3456,31 +3580,27 @@ "readdir-glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.77", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Jb59xfEISoN5mmbnA+HYqdtrSX3CgCtJoof+V5D8/TgUI56W63GEEd5Y58WijU3Ou6+WEgaLD1feVzaRXV5IDQ=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + "@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1116.0", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-ygIivKqh8aHzNkucOCXHyIBgBpLPfrSI0mCqXF+vLBsPTUKqj0VSqAY0GFPe7lQl4HntjOcQ+KSyS7oUV2C54Q=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], + "@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.87", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-C4ZFmcwM+Zj14Z8huVUk54Gv4uzT1ZdzG9cY3Gdh8FePakq7Bss1OFsgZjAhWFOkFOGpBvFBeu0OWjWf8HNKRQ=="], + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1161.0", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-ypbXSofNcSHwf/KA40bFCXJb0MLaAKrfT7sot4dFaA+2lsuXNah4zLRJIAU7Qmvs9PFJ6rnY0bZFEC+mE7attA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="], + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], "@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="], @@ -3508,70 +3628,14 @@ "readdir-glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + "@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], + "@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], + "@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="], + "@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], "@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], - - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="], } } diff --git a/docs/using-shumai/agent-providers.mdx b/docs/using-shumai/agent-providers.mdx index 07f5e38f..23f62b2c 100644 --- a/docs/using-shumai/agent-providers.mdx +++ b/docs/using-shumai/agent-providers.mdx @@ -11,7 +11,7 @@ When creating agents for chat or metadata autofill, you must select an underlyin ## Built-In Providers -Shumai ships with pre-configured configurations for major LLM providers. Because Shumai uses [Pi](https://github.com/earendil-works/pi) as its core agent framework, the supported provider and model configurations are automatically synchronized with Pi's capabilities. +Shumai seeds new teams with provider and model configurations bundled with [Pi](https://github.com/earendil-works/pi). In **Settings → Providers**, choose **Refresh models** on a provider card, select compatible models, then choose **Add selected**. Refresh looks up the public catalog and preserves your saved settings and models. Use **Add Provider** to set up another provider. Team Owner can freely edit, delete, or add new providers. All configured provider and model settings are injected directly into the Pi framework at runtime. diff --git a/docs/zh/using-shumai/agent-providers.mdx b/docs/zh/using-shumai/agent-providers.mdx index c2501386..432b3fe9 100644 --- a/docs/zh/using-shumai/agent-providers.mdx +++ b/docs/zh/using-shumai/agent-providers.mdx @@ -11,7 +11,7 @@ description: 将 Shumai 连接至 OpenAI、Anthropic、Gemini 或自定义 LLM ## 内置模型服务商 -Shumai 预置了主流 LLM 服务商的配置。由于 Shumai 采用 [Pi](https://github.com/earendil-works/pi) 作为底层核心智能体框架,系统支持的服务商与模型配置会自动与 Pi 的功能生态保持同步。 +Shumai 使用 [Pi](https://github.com/earendil-works/pi) 随附的服务商与模型配置初始化新团队。在**设置 → 服务商**中,点击服务商卡片上的**刷新模型**,选择兼容的模型,然后点击**添加所选**。刷新会查询公开模型目录,并保留现有设置和模型。若要设置其他服务商,请点击**添加服务商**。 团队所有者可自由编辑、删除或添加新服务商。所有已配置的服务商与模型参数均会在运行时直接注入 Pi 框架。 diff --git a/packages/agent/package.json b/packages/agent/package.json index 7dcad8b9..7c1f27f2 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -6,9 +6,9 @@ "main": "./src/index.ts", "types": "./src/index.ts", "dependencies": { - "@earendil-works/chord": "1.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/chord": "1.7.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", diff --git a/packages/api/package.json b/packages/api/package.json index 4bcef0ca..b81253d7 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -7,7 +7,7 @@ "types": "./src/index.ts", "dependencies": { "@better-auth/mcp": "1.7.12", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-durable": "1.7.0", "@hono/zod-validator": "0.7.6", "@modelcontextprotocol/server": "2.0.0", "@shumai/core": "workspace:*", diff --git a/packages/api/src/provider.test.ts b/packages/api/src/provider.test.ts index 4874fc37..dad8f0fc 100644 --- a/packages/api/src/provider.test.ts +++ b/packages/api/src/provider.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi, beforeEach } from 'vitest' import { Hono, type Context, type Next } from 'hono' +import { HTTPException } from 'hono/http-exception' import providerRoute from './provider' import { providerService } from '@shumai/core/src/provider/provider' import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz' @@ -34,6 +35,7 @@ describe('provider api', () => { beforeEach(() => { vi.restoreAllMocks() + vi.clearAllMocks() vi.mocked(authzService.hasPermission).mockResolvedValue(undefined) }) @@ -320,78 +322,57 @@ describe('provider api', () => { }) }) - it('POST /teams/:teamId/providers/sync-check checks for updates', async () => { - vi.mocked(providerService.checkUpdates).mockResolvedValue({ - providers: [ - { - name: 'deepseek', - isNewProvider: true, - config: { api: 'openai-responses', apiKey: 'DEEPSEEK_API_KEY' }, - models: [], - }, - ], - totalNewProviders: 1, - totalNewModels: 0, - }) + const modelsPath = '/teams/t1/providers/p1/models' + const providerUpdatedAt = '2026-11-29T09:15:00.000Z' + const selection = { + providerUpdatedAt, + modelIds: ['test-model'], + } + const importRequest = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(selection), + } - const res = await app.request('/teams/t1/providers/sync-check', { - method: 'POST', + it('previews refresh results for the requested provider as a team admin', async () => { + vi.mocked(providerService.refreshModels).mockResolvedValue({ + status: 'ready', + providerUpdatedAt, + models: [], }) + const res = await app.request(modelsPath + '/refresh', { method: 'POST' }) expect(res.status).toBe(200) - const data = await res.json() - expect(data.totalNewProviders).toBe(1) - expect(data.providers).toHaveLength(1) - expect(providerService.checkUpdates).toHaveBeenCalledWith('t1') + expect(res.headers.get('Cache-Control')).toBe('no-store') + expect(await res.json()).toEqual({ status: 'ready', providerUpdatedAt, models: [] }) + expect(providerService.refreshModels).toHaveBeenCalledWith('t1', 'p1') expect(authzService.hasPermission).toHaveBeenCalledWith({ user: expect.anything(), permission: Permission.Admin, type: ResourceType.Team, id: 't1', }) + expect(auditLogService.logAction).not.toHaveBeenCalled() }) - it('POST /teams/:teamId/providers/sync-apply applies sync selection', async () => { - vi.mocked(providerService.applySync).mockResolvedValue({ - addedProviders: 1, - addedModels: 3, - }) - - const payload = { - providers: [ - { - name: 'deepseek', - isNewProvider: true, - config: { api: 'openai-responses', apiKey: 'KEY' }, - models: [ - { - modelId: 'deepseek-v4-flash', - name: 'DeepSeek V4 Flash', - config: { - api: 'openai-responses', - reasoning: true, - input: ['text'], - contextWindow: 128000, - maxTokens: 4096, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - }, - }, - ], - }, - ], - } - - const res = await app.request('/teams/t1/providers/sync-apply', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload), + it('returns the server reason for an unavailable refresh', async () => { + vi.mocked(providerService.refreshModels).mockResolvedValue({ + status: 'unavailable', + reason: 'catalog_unavailable', }) + const res = await app.request(modelsPath + '/refresh', { method: 'POST' }) expect(res.status).toBe(200) - const data = await res.json() - expect(data.addedProviders).toBe(1) - expect(data.addedModels).toBe(3) - expect(providerService.applySync).toHaveBeenCalledWith('t1', payload) + expect(await res.json()).toEqual({ status: 'unavailable', reason: 'catalog_unavailable' }) + }) + + it('imports the selection into the scoped provider and records its audit entry', async () => { + vi.mocked(providerService.importModels).mockResolvedValue({ addedModels: 1 }) + + const res = await app.request(modelsPath + '/import', importRequest) + expect(res.status).toBe(200) + expect(await res.json()).toEqual({ addedModels: 1 }) + expect(providerService.importModels).toHaveBeenCalledWith('t1', 'p1', selection) expect(authzService.hasPermission).toHaveBeenCalledWith({ user: expect.anything(), permission: Permission.Admin, @@ -402,6 +383,36 @@ describe('provider api', () => { action: 'provider_update', teamId: 't1', userId: 'user1', + itemId: 'p1', }) }) + + it('skips the audit entry when the selected models already exist', async () => { + vi.mocked(providerService.importModels).mockResolvedValue({ addedModels: 0 }) + const res = await app.request(modelsPath + '/import', importRequest) + expect(res.status).toBe(200) + expect(await res.json()).toEqual({ addedModels: 0 }) + expect(auditLogService.logAction).not.toHaveBeenCalled() + }) + + it('rejects requests without team-admin permission before looking up the provider', async () => { + vi.mocked(authzService.hasPermission).mockRejectedValue(new HTTPException(403)) + const refresh = await app.request(modelsPath + '/refresh', { method: 'POST' }) + const apply = await app.request(modelsPath + '/import', importRequest) + expect(refresh.status).toBe(403) + expect(apply.status).toBe(403) + expect(providerService.refreshModels).not.toHaveBeenCalled() + expect(providerService.importModels).not.toHaveBeenCalled() + expect(auditLogService.logAction).not.toHaveBeenCalled() + }) + + it('rejects an empty import selection before performing a write', async () => { + const res = await app.request(modelsPath + '/import', { + ...importRequest, + body: JSON.stringify({ providerUpdatedAt, modelIds: [] }), + }) + + expect(res.status).toBe(400) + expect(providerService.importModels).not.toHaveBeenCalled() + }) }) diff --git a/packages/api/src/provider.ts b/packages/api/src/provider.ts index 6f1e7c28..312c4849 100644 --- a/packages/api/src/provider.ts +++ b/packages/api/src/provider.ts @@ -5,7 +5,7 @@ import { providerService } from '@shumai/core/src/provider/provider' import { createModelRequestSchema, createProviderRequestSchema, - syncApplyRequestSchema, + importProviderModelsRequestSchema, updateModelRequestSchema, updateProviderRequestSchema, AuditAction, @@ -31,8 +31,8 @@ const route = new Hono<{ Variables: { user: User } }>() return c.json(providers) }) - .post('/teams/:teamId/providers/sync-check', async (c) => { - const teamId = c.req.param('teamId') + .post('/teams/:teamId/providers/:providerId/models/refresh', async (c) => { + const { teamId, providerId } = c.req.param() const user = c.get('user') await authzService.hasPermission({ @@ -42,15 +42,16 @@ const route = new Hono<{ Variables: { user: User } }>() id: teamId, }) - const result = await providerService.checkUpdates(teamId) + const result = await providerService.refreshModels(teamId, providerId) + c.header('Cache-Control', 'no-store') return c.json(result) }) .post( - '/teams/:teamId/providers/sync-apply', - zValidator('json', syncApplyRequestSchema), + '/teams/:teamId/providers/:providerId/models/import', + zValidator('json', importProviderModelsRequestSchema), async (c) => { - const teamId = c.req.param('teamId') + const { teamId, providerId } = c.req.param() const user = c.get('user') const body = c.req.valid('json') @@ -61,12 +62,15 @@ const route = new Hono<{ Variables: { user: User } }>() id: teamId, }) - const result = await providerService.applySync(teamId, body) - await auditLogService.logAction({ - action: AuditAction.provider_update, - teamId, - userId: user?.id, - }) + const result = await providerService.importModels(teamId, providerId, body) + if (result.addedModels > 0) { + await auditLogService.logAction({ + action: AuditAction.provider_update, + teamId, + userId: user?.id, + itemId: providerId, + }) + } return c.json(result) }, ) diff --git a/packages/core/package.json b/packages/core/package.json index a560275e..0e91d431 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -28,9 +28,9 @@ "@aws-sdk/s3-request-presigner": "3.1121.0", "@better-auth/mcp": "1.7.12", "@better-auth/oauth-provider": "1.7.12", - "@earendil-works/chord": "1.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/chord": "1.7.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@modelcontextprotocol/client": "2.0.0", "@shumai/db": "workspace:*", diff --git a/packages/core/src/agent/session-cache.ts b/packages/core/src/agent/session-cache.ts index 171303a5..d4b0f50d 100644 --- a/packages/core/src/agent/session-cache.ts +++ b/packages/core/src/agent/session-cache.ts @@ -92,8 +92,10 @@ export async function openSessionCache(sessionId: string) { throw new Error('Session commit sequence mismatch') seq = receipt.seq } - if (result.stored !== commits.length) + if (result.kind === 'refused') { throw result.refused ?? new Error('Session restoration refused') + } + if (result.stored !== commits.length) throw new Error('Session restoration was incomplete') } await save(true) } catch (error) { diff --git a/packages/core/src/provider/builtin.ts b/packages/core/src/provider/builtin.ts index 2f7c277a..bf6b5a11 100644 --- a/packages/core/src/provider/builtin.ts +++ b/packages/core/src/provider/builtin.ts @@ -19,7 +19,7 @@ export const ENV_MAP: Record = { openai: 'OPENAI_API_KEY', anthropic: 'ANTHROPIC_API_KEY', 'github-copilot': 'COPILOT_GITHUB_TOKEN', - 'azure-openai-responses': 'AZURE_OPENAI_API_KEY', + azure: 'AZURE_OPENAI_API_KEY', deepseek: 'DEEPSEEK_API_KEY', google: 'GEMINI_API_KEY', 'google-vertex': 'GOOGLE_CLOUD_API_KEY', diff --git a/packages/core/src/provider/fixtures/models-dev.json b/packages/core/src/provider/fixtures/models-dev.json deleted file mode 100644 index 4d4341f2..00000000 --- a/packages/core/src/provider/fixtures/models-dev.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "anthropic": { - "models": { - "claude-3-5-sonnet-20241022": { - "id": "claude-3-5-sonnet-20241022", - "name": "Claude 3.5 Sonnet", - "tool_call": true, - "reasoning": false, - "limit": { - "context": 200000, - "output": 8192 - }, - "cost": { - "input": 3, - "output": 15, - "cache_read": 0.3, - "cache_write": 3.75 - } - } - } - }, - "openai": { - "models": { - "gpt-4o": { - "id": "gpt-4o", - "name": "GPT-4o", - "tool_call": true, - "reasoning": false, - "limit": { - "context": 128000, - "output": 4096 - }, - "cost": { - "input": 2.5, - "output": 10 - } - }, - "gpt-4o-extra-new": { - "id": "gpt-4o-extra-new", - "name": "GPT-4o Extra New", - "tool_call": true, - "reasoning": false, - "limit": { - "context": 128000, - "output": 4096 - }, - "cost": { - "input": 2.5, - "output": 10 - } - } - } - } -} diff --git a/packages/core/src/provider/fixtures/nvidia.json b/packages/core/src/provider/fixtures/nvidia.json deleted file mode 100644 index 6476828b..00000000 --- a/packages/core/src/provider/fixtures/nvidia.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "data": [ - { - "id": "meta/llama-3.1-70b-instruct" - } - ] -} diff --git a/packages/core/src/provider/fixtures/openrouter.json b/packages/core/src/provider/fixtures/openrouter.json deleted file mode 100644 index 52c53ca8..00000000 --- a/packages/core/src/provider/fixtures/openrouter.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "data": [ - { - "id": "meta-llama/llama-3.1-8b-instruct", - "name": "Meta: Llama 3.1 8B Instruct", - "context_length": 131072, - "pricing": { - "prompt": "0.00000005", - "completion": "0.00000008" - }, - "top_provider": { - "max_completion_tokens": 8192 - }, - "supported_parameters": ["tools"] - } - ] -} diff --git a/packages/core/src/provider/generator/generate-models.ts b/packages/core/src/provider/generator/generate-models.ts deleted file mode 100644 index 55c5e161..00000000 --- a/packages/core/src/provider/generator/generate-models.ts +++ /dev/null @@ -1,2703 +0,0 @@ -import type { - AnthropicMessagesCompat, - Api, - KnownProvider, - Model, - ModelCost, - OpenAICompletionsCompat, - OpenAIResponsesCompat, -} from '@earendil-works/pi-ai' -import { - CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL, - CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL, - CLOUDFLARE_AI_GATEWAY_OPENAI_BASE_URL, - CLOUDFLARE_WORKERS_AI_BASE_URL, -} from '@earendil-works/pi-ai/api/cloudflare' -import { - getEffortThinkingLevelMap, - type ModelsDevReasoningOption, -} from './models-dev-reasoning-options.ts' - -export interface GeneratorOptions { - strict?: boolean - jsonOnly?: boolean - timeoutMs?: number -} - -export const DEFAULT_CATALOG_TIMEOUT_MS = 30000 - -let generatorOptions: GeneratorOptions = { - strict: true, - timeoutMs: DEFAULT_CATALOG_TIMEOUT_MS, -} - -interface ModelsDevModel { - id: string - name: string - tool_call?: boolean - structured_output?: boolean - reasoning?: boolean - reasoning_options?: ModelsDevReasoningOption[] - limit?: { - context?: number - output?: number - } - cost?: { - input?: number - output?: number - cache_read?: number - cache_write?: number - tiers?: { - input?: number - output?: number - cache_read?: number - cache_write?: number - tier?: { - type?: string - size?: number - } - }[] - } - modalities?: { - input?: string[] - output?: string[] - } - provider?: { - npm?: string - } -} - -interface ModelsDevProvider { - models?: Record -} - -type ModelsDevCatalog = Record - -interface NvidiaNimModelListItem { - id: string -} - -interface AiGatewayModel { - id: string - name?: string - context_window?: number - max_tokens?: number - tags?: string[] - pricing?: { - input?: string | number - output?: string | number - input_cache_read?: string | number - input_cache_write?: string | number - } -} - -const COPILOT_STATIC_HEADERS = { - 'User-Agent': 'GitHubCopilotChat/0.35.0', - 'Editor-Version': 'vscode/1.107.0', - 'Editor-Plugin-Version': 'copilot-chat/0.35.0', - 'Copilot-Integration-Id': 'vscode-chat', -} as const - -const KIMI_STATIC_HEADERS = { - 'User-Agent': 'KimiCLI/1.5', -} as const - -const TOGETHER_BASE_URL = 'https://api.together.ai/v1' -const TOGETHER_BASE_COMPAT: OpenAICompletionsCompat = { - supportsStore: false, - supportsDeveloperRole: false, - supportsReasoningEffort: false, - maxTokensField: 'max_tokens', - supportsStrictMode: false, - supportsLongCacheRetention: false, -} -const TOGETHER_TOGGLE_REASONING_COMPAT: OpenAICompletionsCompat = { - ...TOGETHER_BASE_COMPAT, - thinkingFormat: 'together', -} -const TOGETHER_REASONING_EFFORT_COMPAT: OpenAICompletionsCompat = { - ...TOGETHER_BASE_COMPAT, - supportsReasoningEffort: true, - thinkingFormat: 'openai', -} -const TOGETHER_TOGGLE_REASONING_EFFORT_COMPAT: OpenAICompletionsCompat = { - ...TOGETHER_TOGGLE_REASONING_COMPAT, - supportsReasoningEffort: true, -} -const TOGETHER_REASONING_ONLY_MODELS = new Set([ - 'deepseek-ai/DeepSeek-R1', - 'MiniMaxAI/MiniMax-M2.7', -]) -const TOGETHER_REASONING_EFFORT_MODELS = new Set(['openai/gpt-oss-20b', 'openai/gpt-oss-120b']) -const TOGETHER_TOGGLE_REASONING_EFFORT_MODELS = new Set(['deepseek-ai/DeepSeek-V4-Pro']) -const TOGETHER_FIXED_REASONING_LEVEL_MAP = { - off: null, - minimal: null, - low: null, - medium: null, -} as const -const TOGETHER_REASONING_EFFORT_LEVEL_MAP = { - off: null, - minimal: null, -} as const -const TOGETHER_DEEPSEEK_V4_THINKING_LEVEL_MAP = { - minimal: null, - low: null, - medium: null, - high: 'high', - xhigh: null, -} as const -const TOGETHER_TOGGLE_REASONING_LEVEL_MAP = { - minimal: null, - low: null, - medium: null, -} as const - -const AI_GATEWAY_MODELS_URL = 'https://ai-gateway.vercel.sh/v1' -const AI_GATEWAY_BASE_URL = 'https://ai-gateway.vercel.sh' -const VERTEX_BASE_URL = 'https://{location}-aiplatform.googleapis.com' -const NVIDIA_BASE_URL = 'https://integrate.api.nvidia.com/v1' -const NVIDIA_HEADERS = { - 'NVCF-POLL-SECONDS': '3600', -} as const -const NVIDIA_OPENAI_COMPAT: OpenAICompletionsCompat = { - supportsStore: false, - supportsDeveloperRole: false, - supportsReasoningEffort: false, - maxTokensField: 'max_tokens', - supportsStrictMode: false, - supportsLongCacheRetention: false, -} -const NVIDIA_NIM_UNSUPPORTED_MODELS = new Set([ - 'abacusai/dracarys-llama-3.1-70b-instruct', - 'bytedance/seed-oss-36b-instruct', - 'deepseek-ai/deepseek-v4-flash', - 'deepseek-ai/deepseek-v4-pro', - 'google/gemma-2-2b-it', - 'google/gemma-3n-e2b-it', - 'google/gemma-3n-e4b-it', - 'google/gemma-4-31b-it', - 'meta/llama-3.2-1b-instruct', - 'meta/llama-4-maverick-17b-128e-instruct', - 'microsoft/phi-4-mini-instruct', - 'minimaxai/minimax-m2.7', - 'mistralai/mistral-nemotron', - 'nvidia/nemotron-mini-4b-instruct', - 'qwen/qwen3-next-80b-a3b-instruct', - 'qwen/qwen3.5-397b-a17b', - 'sarvamai/sarvam-m', - 'upstage/solar-10.7b-instruct', -]) -const ZAI_TOOL_STREAM_UNSUPPORTED_MODELS = new Set([ - 'glm-4.5', - 'glm-4.5-air', - 'glm-4.5-flash', - 'glm-4.5v', -]) -const ZAI_GLM52_THINKING_LEVEL_MAP = { - minimal: null, - low: 'high', - medium: 'high', - high: 'high', - max: 'max', -} as const -const OPENCODE_GO_GLM52_THINKING_LEVEL_MAP = { - off: null, - minimal: null, - low: null, - medium: null, - high: 'high', - max: 'max', -} as const -const EAGER_TOOL_INPUT_STREAMING_UNSUPPORTED_ANTHROPIC_MODELS = new Set([ - 'github-copilot:claude-haiku-4.5', - 'github-copilot:claude-sonnet-4', - 'github-copilot:claude-sonnet-4.5', -]) - -const DEEPSEEK_V4_THINKING_LEVEL_MAP = { - minimal: null, - low: null, - medium: null, - high: 'high', - max: 'max', -} as const - -const KIMI_K3_MAX_TOKENS = 131072 -const KIMI_K3_COST = { - input: 3, - output: 15, - cacheRead: 0.3, - cacheWrite: 0, -} as const -// Kimi Coding is subscription-backed, so models.dev reports zero cost. Use the -// equivalent Moonshot API rates to estimate the value of subscription usage. -const KIMI_CODING_IMPLIED_COSTS: Record['cost']> = { - k3: KIMI_K3_COST, - 'kimi-for-coding': { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, - 'kimi-for-coding-highspeed': { input: 1.9, output: 8, cacheRead: 0.38, cacheWrite: 0 }, - 'kimi-k2-thinking': { input: 0.6, output: 2.5, cacheRead: 0.15, cacheWrite: 0 }, -} -const OPENROUTER_KIMI_K3_MODEL_IDS = new Set(['moonshotai/kimi-k3', '~moonshotai/kimi-latest']) - -const ANT_LING_RING_THINKING_LEVEL_MAP = { - off: null, - minimal: null, - low: null, - medium: null, - high: 'high', - xhigh: 'xhigh', -} as const - -const BEDROCK_INFERENCE_PROFILE_ONLY_MODEL_IDS = new Set(['anthropic.claude-opus-5']) -const MODELS_DEV_OPENAI_UNSUPPORTED_MODEL_IDS = new Set(['gpt-5.6']) -const OPENAI_TOOL_SEARCH_MODEL_IDS = new Set([ - 'gpt-5.4', - 'gpt-5.4-mini', - 'gpt-5.4-pro', - 'gpt-5.5', - 'gpt-5.6-sol', - 'gpt-5.6-terra', - 'gpt-5.6-luna', -]) -const OPENAI_LONG_CONTEXT_INPUT_THRESHOLD = 272000 -const OPENAI_SHORT_CONTEXT_CAPPED_MODEL_IDS = new Set([ - 'gpt-5.4', - 'gpt-5.5', - 'gpt-5.6-sol', - 'gpt-5.6-terra', - 'gpt-5.6-luna', -]) -const OPENAI_LONG_CONTEXT_PRICING_MODEL_IDS = new Set([ - 'gpt-5.4', - 'gpt-5.4-pro', - 'gpt-5.5', - 'gpt-5.5-pro', - 'gpt-5.6-sol', - 'gpt-5.6-terra', - 'gpt-5.6-luna', -]) - -function withOpenAiLongContextPricing(cost: Model['cost']): Model['cost'] { - return { - ...cost, - tiers: [ - { - inputTokensAbove: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD, - input: cost.input * 2, - output: cost.output * 1.5, - cacheRead: cost.cacheRead * 2, - cacheWrite: cost.cacheWrite * 2, - }, - ], - } -} - -const OPENAI_RESPONSES_NONE_REASONING_MODELS = new Set([ - 'gpt-5.1', - 'gpt-5.2', - 'gpt-5.3-codex', - 'gpt-5.4', - 'gpt-5.4-mini', - 'gpt-5.4-nano', - 'gpt-5.5', - 'gpt-5.6-sol', - 'gpt-5.6-terra', - 'gpt-5.6-luna', -]) -const XAI_RESPONSES_MODEL_ID = 'grok-4.5' -const XAI_BUILTIN_EXCLUDED_MODEL_IDS = new Set([ - 'grok-3', - 'grok-3-fast', - 'grok-4.20-0309-non-reasoning', - 'grok-4.20-0309-reasoning', - 'grok-code-fast-1', -]) -const XAI_RESPONSES_EFFORT_LEVEL_MAP = { - off: null, - minimal: null, -} as const -const XAI_RESPONSES_COMPAT: OpenAIResponsesCompat = { - supportsLongCacheRetention: false, -} - -const OPENCODE_OPENAI_COMPLETIONS_LONG_CACHE_RETENTION_UNSUPPORTED_MODELS = new Set([ - 'opencode:deepseek-v4-flash', - 'opencode:deepseek-v4-pro', - 'opencode:kimi-k2.5', - 'opencode:kimi-k2.6', - 'opencode:minimax-m2.7', - 'opencode-go:kimi-k2.6', -]) - -// GitHub's "Models with extended capabilities" table lists these Copilot models as supporting -// the extended 1 million token context window. -const GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS = new Set([ - 'claude-fable-5', - 'claude-opus-4.6', - 'claude-opus-4.7', - 'claude-opus-4.8', - 'claude-sonnet-4.6', - 'claude-sonnet-5', - 'gpt-5.3-codex', - 'gpt-5.4', - 'gpt-5.5', -]) - -// Checked manually against the authenticated GitHub Copilot /models endpoint on 2026-06-15. -// Keep this to narrow corrections over models.dev metadata instead of snapshotting Copilot's catalog. -const GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES: Record< - string, - NonNullable['thinkingLevelMap']> -> = { - 'claude-opus-4.7': { minimal: 'low' }, - 'claude-opus-4.8': { minimal: 'low' }, - 'claude-sonnet-4.6': { minimal: 'low', max: 'max' }, -} - -function mergeThinkingLevelMap( - model: Model, - map: NonNullable['thinkingLevelMap']>, -): void { - model.thinkingLevelMap = { ...model.thinkingLevelMap, ...map } -} - -const modelsDevReasoningOptions = new Map() - -function getModelKey(model: Pick, 'provider' | 'id'>): string { - return `${model.provider}:${model.id}` -} - -function recordModelsDevReasoningOptions( - provider: string, - id: string, - sourceModel: ModelsDevModel, -): void { - if (sourceModel.reasoning_options !== undefined) { - modelsDevReasoningOptions.set(`${provider}:${id}`, sourceModel.reasoning_options) - } -} - -function supportsDirectReasoningEffort(model: Model): boolean { - if (model.api === 'anthropic-messages') - return (model as Model<'anthropic-messages'>).compat?.forceAdaptiveThinking === true - if ( - model.api === 'openai-responses' || - model.api === 'azure-openai-responses' || - model.api === 'openai-codex-responses' - ) { - return true - } - if (model.api !== 'openai-completions') return false - - const compat = { - ...detectOpenAICompletionsCompat(model as Model<'openai-completions'>), - ...(model.compat as OpenAICompletionsCompat | undefined), - } - return compat.thinkingFormat === 'openai' && compat.supportsReasoningEffort === true -} - -function applyModelsDevReasoningOptionMetadata(model: Model): void { - const reasoningOptions = modelsDevReasoningOptions.get(getModelKey(model)) - if (!reasoningOptions || !supportsDirectReasoningEffort(model)) return - const thinkingLevelMap = getEffortThinkingLevelMap(reasoningOptions) - if (thinkingLevelMap) mergeThinkingLevelMap(model, thinkingLevelMap) -} - -function getTogetherCompat(modelId: string, reasoning: boolean): OpenAICompletionsCompat { - if (!reasoning) return TOGETHER_BASE_COMPAT - if (TOGETHER_REASONING_EFFORT_MODELS.has(modelId)) return TOGETHER_REASONING_EFFORT_COMPAT - if (TOGETHER_TOGGLE_REASONING_EFFORT_MODELS.has(modelId)) - return TOGETHER_TOGGLE_REASONING_EFFORT_COMPAT - if (TOGETHER_REASONING_ONLY_MODELS.has(modelId)) return TOGETHER_BASE_COMPAT - return TOGETHER_TOGGLE_REASONING_COMPAT -} - -function getTogetherThinkingLevelMap( - modelId: string, - reasoning: boolean, -): NonNullable['thinkingLevelMap']> | undefined { - if (!reasoning) return undefined - if (TOGETHER_REASONING_EFFORT_MODELS.has(modelId)) - return { ...TOGETHER_REASONING_EFFORT_LEVEL_MAP } - if (TOGETHER_TOGGLE_REASONING_EFFORT_MODELS.has(modelId)) - return { ...TOGETHER_DEEPSEEK_V4_THINKING_LEVEL_MAP } - if (TOGETHER_REASONING_ONLY_MODELS.has(modelId)) return { ...TOGETHER_FIXED_REASONING_LEVEL_MAP } - return { ...TOGETHER_TOGGLE_REASONING_LEVEL_MAP } -} - -function supportsOpenAiXhigh(modelId: string): boolean { - return ( - modelId.includes('gpt-5.2') || - modelId.includes('gpt-5.3') || - modelId.includes('gpt-5.4') || - modelId.includes('gpt-5.5') || - modelId.includes('gpt-5.6') - ) -} - -function supportsOpenAiMax(model: Model): boolean { - return ( - model.id.includes('gpt-5.6') && - (model.api === 'openai-responses' || - model.api === 'azure-openai-responses' || - model.api === 'openai-codex-responses' || - model.api === 'openai-completions') - ) -} - -function isGoogleThinkingApi(model: Model): boolean { - return model.api === 'google-generative-ai' || model.api === 'google-vertex' -} - -function isAnthropicAdaptiveThinkingModel(modelId: string): boolean { - return ( - modelId.includes('opus-4-6') || - modelId.includes('opus-4.6') || - modelId.includes('opus-4-7') || - modelId.includes('opus-4.7') || - modelId.includes('opus-4-8') || - modelId.includes('opus-4.8') || - modelId.includes('opus-5') || - modelId.includes('opus.5') || - modelId.includes('sonnet-4-6') || - modelId.includes('sonnet-4.6') || - modelId.includes('sonnet-5') || - modelId.includes('sonnet.5') || - modelId.includes('fable-5') - ) -} - -function isAnthropicTemperatureUnsupportedModel(modelId: string): boolean { - const id = modelId.toLowerCase() - return ( - id.includes('opus-4-7') || - id.includes('opus-4.7') || - id.includes('opus-4-8') || - id.includes('opus-4.8') || - id.includes('opus-5') || - id.includes('opus.5') - ) -} - -const OPENAI_COMPLETIONS_DEFAULT_COMPAT = { - supportsStore: true, - supportsDeveloperRole: true, - supportsReasoningEffort: true, - supportsUsageInStreaming: true, - maxTokensField: 'max_completion_tokens', - requiresToolResultName: false, - requiresAssistantAfterToolResult: false, - requiresThinkingAsText: false, - requiresReasoningContentOnAssistantMessages: false, - thinkingFormat: 'openai', - openRouterRouting: {}, - vercelGatewayRouting: {}, - chatTemplateKwargs: {}, - zaiToolStream: false, - supportsStrictMode: true, - supportsOpenAIGrammarTools: false, - sendSessionAffinityHeaders: false, - supportsLongCacheRetention: true, -} as OpenAICompletionsCompat - -type OpenAICompletionsResolvedCompat = OpenAICompletionsCompat - -function mergeAnthropicMessagesCompat(model: Model, compat: AnthropicMessagesCompat): void { - model.compat = { ...(model.compat as AnthropicMessagesCompat | undefined), ...compat } -} - -function detectOpenAICompletionsCompat( - model: Model<'openai-completions'>, -): OpenAICompletionsResolvedCompat { - const provider = model.provider - const baseUrl = model.baseUrl - - const isZai = - provider === 'zai' || - provider === 'zai-coding-cn' || - baseUrl.includes('api.z.ai') || - baseUrl.includes('open.bigmodel.cn') - const isTogether = - provider === 'together' || - baseUrl.includes('api.together.ai') || - baseUrl.includes('api.together.xyz') - const isMoonshot = - provider === 'moonshotai' || provider === 'moonshotai-cn' || baseUrl.includes('api.moonshot.') - const isOpenRouter = provider === 'openrouter' || baseUrl.includes('openrouter.ai') - const isCloudflareWorkersAI = - provider === 'cloudflare-workers-ai' || baseUrl.includes('api.cloudflare.com') - const isCloudflareAiGateway = - provider === 'cloudflare-ai-gateway' || baseUrl.includes('gateway.ai.cloudflare.com') - const isNvidia = provider === 'nvidia' || baseUrl.includes('integrate.api.nvidia.com') - const isAntLing = provider === 'ant-ling' || baseUrl.includes('api.ant-ling.com') - const isTogetherReasoningOnly = isTogether && TOGETHER_REASONING_ONLY_MODELS.has(model.id) - - const isNonStandard = - isNvidia || - provider === 'cerebras' || - baseUrl.includes('cerebras.ai') || - provider === 'xai' || - baseUrl.includes('api.x.ai') || - isTogether || - baseUrl.includes('chutes.ai') || - baseUrl.includes('deepseek.com') || - isZai || - isMoonshot || - provider === 'opencode' || - baseUrl.includes('opencode.ai') || - isCloudflareWorkersAI || - isCloudflareAiGateway || - isAntLing - - const useMaxTokens = - baseUrl.includes('chutes.ai') || - isMoonshot || - isCloudflareAiGateway || - isTogether || - isNvidia || - isAntLing - - const isGrok = provider === 'xai' || baseUrl.includes('api.x.ai') - const isDeepSeek = provider === 'deepseek' || baseUrl.includes('deepseek.com') - const isOpenRouterDeveloperRoleModel = - isOpenRouter && (model.id.startsWith('anthropic/') || model.id.startsWith('openai/')) - const cacheControlFormat = - provider === 'openrouter' && /^~?anthropic\//.test(model.id) ? 'anthropic' : undefined - - return { - supportsStore: !isNonStandard, - supportsDeveloperRole: isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter), - supportsReasoningEffort: - !isGrok && - !isZai && - !isMoonshot && - !isTogether && - !isCloudflareAiGateway && - !isNvidia && - !isAntLing, - supportsUsageInStreaming: true, - maxTokensField: useMaxTokens ? 'max_tokens' : 'max_completion_tokens', - requiresToolResultName: false, - requiresAssistantAfterToolResult: false, - requiresThinkingAsText: false, - requiresReasoningContentOnAssistantMessages: isDeepSeek, - thinkingFormat: isDeepSeek - ? 'deepseek' - : isZai - ? 'zai' - : isTogether && !isTogetherReasoningOnly - ? 'together' - : isAntLing - ? 'ant-ling' - : isOpenRouter - ? 'openrouter' - : 'openai', - openRouterRouting: {}, - vercelGatewayRouting: {}, - chatTemplateKwargs: {}, - zaiToolStream: false, - supportsStrictMode: !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia, - supportsOpenAIGrammarTools: false, - ...(cacheControlFormat ? { cacheControlFormat } : {}), - sendSessionAffinityHeaders: false, - supportsLongCacheRetention: !( - isTogether || - isCloudflareWorkersAI || - isCloudflareAiGateway || - isNvidia || - isAntLing - ), - } -} - -function isPlainEmptyObject(value: unknown): boolean { - return ( - typeof value === 'object' && - value !== null && - !Array.isArray(value) && - Object.keys(value).length === 0 - ) -} - -function openAICompletionsCompatDelta( - compat: OpenAICompletionsResolvedCompat, -): OpenAICompletionsCompat { - const delta: OpenAICompletionsCompat = {} - for (const [key, value] of Object.entries(compat)) { - const defaultValue = - OPENAI_COMPLETIONS_DEFAULT_COMPAT[key as keyof typeof OPENAI_COMPLETIONS_DEFAULT_COMPAT] - if (isPlainEmptyObject(value) && isPlainEmptyObject(defaultValue)) continue - if (value !== defaultValue) { - ;(delta as Record)[key] = value - } - } - return delta -} - -function mergeOpenAICompletionsCompat(model: Model, compat: OpenAICompletionsCompat): void { - model.compat = { ...(model.compat as OpenAICompletionsCompat | undefined), ...compat } -} - -function applyOpenAICompletionsCompatMetadata(model: Model): void { - if (model.api !== 'openai-completions') return - const detected = openAICompletionsCompatDelta( - detectOpenAICompletionsCompat(model as Model<'openai-completions'>), - ) - model.compat = { ...detected, ...(model.compat as OpenAICompletionsCompat | undefined) } - if (Object.keys(model.compat).length === 0) { - delete model.compat - } -} - -function applyStrictToolCompatMetadata(model: Model): void { - if (model.provider === 'openai' && model.api === 'openai-responses') { - model.compat = { - ...(model.compat as OpenAIResponsesCompat | undefined), - supportsStrictMode: true, - } - } else if (model.provider === 'anthropic' && model.api === 'anthropic-messages') { - mergeAnthropicMessagesCompat(model, { supportsStrictTools: true }) - } -} - -// Responses endpoints verified (OpenAI, ChatGPT Codex backend, GitHub Copilot, -// opencode zen) or documented (Azure OpenAI, Cloudflare AI Gateway) to pass -// OpenAI custom grammar tools through. OpenAI rejects `type: "custom"` tools -// for pre-GPT-5 models (gpt-4.x, gpt-4o, o-series). -const OPENAI_GRAMMAR_TOOL_PROVIDERS = new Set([ - 'openai', - 'openai-codex', - 'azure-openai-responses', - 'github-copilot', - 'opencode', - 'cloudflare-ai-gateway', -]) -const OPENAI_GRAMMAR_TOOL_APIS = new Set([ - 'openai-responses', - 'azure-openai-responses', - 'openai-codex-responses', -]) - -function applyOpenAIGrammarToolCompatMetadata(model: Model): void { - if ( - !OPENAI_GRAMMAR_TOOL_APIS.has(model.api) || - !OPENAI_GRAMMAR_TOOL_PROVIDERS.has(model.provider) - ) - return - const match = /^gpt-(\d+)/.exec(model.id) - if (!match || Number(match[1]) < 5) return - model.compat = { - ...(model.compat as OpenAIResponsesCompat | undefined), - supportsOpenAIGrammarTools: true, - } -} - -function applyOpenAIToolSearchMetadata(model: Model): void { - const isOpenAIResponses = model.provider === 'openai' && model.api === 'openai-responses' - const isOpenAICodex = model.provider === 'openai-codex' && model.api === 'openai-codex-responses' - if (!(isOpenAIResponses || isOpenAICodex) || !OPENAI_TOOL_SEARCH_MODEL_IDS.has(model.id)) return - model.compat = { - ...(model.compat as OpenAIResponsesCompat | undefined), - supportsToolSearch: true, - } -} - -// OpenAI charges prompt-cache writes starting with the GPT-5.6 family, and exactly -// those models accept `prompt_cache_options`; older models reject the parameter. -// https://developers.openai.com/api/docs/guides/prompt-caching -function applyOpenAIExplicitPromptCacheMetadata(model: Model): void { - if (model.provider !== 'openai' || model.api !== 'openai-responses') return - if (!(model.cost.cacheWrite > 0)) return - model.compat = { - ...(model.compat as OpenAIResponsesCompat | undefined), - supportsExplicitPromptCacheMode: true, - } -} - -function isGemini3ProModel(modelId: string): boolean { - return /gemini-3(?:\.\d+)?-pro/.test(modelId.toLowerCase()) -} - -function isGemini3FlashModel(modelId: string): boolean { - const id = modelId.toLowerCase() - return ( - /gemini-3(?:\.\d+)?-flash/.test(id) || - id === 'gemini-flash-latest' || - id === 'gemini-flash-lite-latest' - ) -} - -function isGemma4Model(modelId: string): boolean { - return /gemma-?4/.test(modelId.toLowerCase()) -} - -function applyThinkingLevelMetadata(model: Model): void { - if ( - (model.api === 'openai-responses' || model.api === 'azure-openai-responses') && - model.id.startsWith('gpt-5') - ) { - mergeThinkingLevelMap(model, { off: null }) - } - if (model.provider === 'github-copilot' && model.id.startsWith('gpt-5')) { - mergeThinkingLevelMap(model, { minimal: 'low' }) - } - if ( - model.api === 'openai-responses' && - model.provider === 'openai' && - OPENAI_RESPONSES_NONE_REASONING_MODELS.has(model.id) - ) { - mergeThinkingLevelMap(model, { off: 'none' }) - } - if ( - model.provider === 'xai' && - model.api === 'openai-responses' && - model.id === XAI_RESPONSES_MODEL_ID - ) { - mergeThinkingLevelMap(model, XAI_RESPONSES_EFFORT_LEVEL_MAP) - } - if (supportsOpenAiXhigh(model.id)) { - mergeThinkingLevelMap(model, { xhigh: 'xhigh' }) - } - if (supportsOpenAiMax(model)) { - mergeThinkingLevelMap(model, { max: 'max' }) - } - if (model.provider === 'openai' && model.id === 'gpt-5.5') { - mergeThinkingLevelMap(model, { minimal: null }) - } - if (model.id.endsWith('gpt-5.5-pro')) { - mergeThinkingLevelMap(model, { off: null, minimal: null, low: null }) - } - // Anthropic adaptive-thinking effort support (per Anthropic adaptive thinking docs): - // - "max" is available on all adaptive-thinking Claude models. - // - "xhigh" is only available on Opus 4.7/4.8/5, Sonnet 5, and Fable 5. - if ( - model.id.includes('opus-4-6') || - model.id.includes('opus-4.6') || - model.id.includes('sonnet-4-6') || - model.id.includes('sonnet-4.6') - ) { - mergeThinkingLevelMap(model, { max: 'max' }) - } - if ( - model.id.includes('opus-4-7') || - model.id.includes('opus-4.7') || - model.id.includes('opus-4-8') || - model.id.includes('opus-4.8') || - model.id.includes('opus-5') || - model.id.includes('opus.5') || - model.id.includes('sonnet-5') || - model.id.includes('sonnet.5') - ) { - mergeThinkingLevelMap(model, { xhigh: 'xhigh', max: 'max' }) - } - if (model.id.includes('fable-5')) { - mergeThinkingLevelMap(model, { off: null, xhigh: 'xhigh', max: 'max' }) - } - if (model.api === 'anthropic-messages' && isAnthropicAdaptiveThinkingModel(model.id)) { - mergeAnthropicMessagesCompat(model, { forceAdaptiveThinking: true }) - } - if (model.api === 'anthropic-messages' && isAnthropicTemperatureUnsupportedModel(model.id)) { - mergeAnthropicMessagesCompat(model, { supportsTemperature: false }) - } - if (model.api === 'openai-completions' && model.id.includes('deepseek-v4')) { - mergeThinkingLevelMap( - model, - model.provider === 'openrouter' - ? { ...DEEPSEEK_V4_THINKING_LEVEL_MAP, xhigh: 'xhigh', max: null } - : DEEPSEEK_V4_THINKING_LEVEL_MAP, - ) - } - if (isGoogleThinkingApi(model) && isGemini3ProModel(model.id)) { - mergeThinkingLevelMap(model, { - off: null, - minimal: null, - low: 'LOW', - medium: null, - high: 'HIGH', - }) - } - if (isGoogleThinkingApi(model) && isGemini3FlashModel(model.id)) { - mergeThinkingLevelMap(model, { off: null }) - } - if (isGoogleThinkingApi(model) && isGemma4Model(model.id)) { - mergeThinkingLevelMap(model, { - off: null, - minimal: 'MINIMAL', - low: null, - medium: null, - high: 'HIGH', - }) - } - if (model.provider === 'groq' && model.id === 'qwen/qwen3-32b') { - mergeThinkingLevelMap(model, { minimal: null, low: null, medium: null, high: 'default' }) - } - if (model.provider === 'openai-codex' && supportsOpenAiXhigh(model.id)) { - mergeThinkingLevelMap(model, { minimal: 'low' }) - } - if ( - (model.provider === 'moonshotai' || model.provider === 'moonshotai-cn') && - (model.id === 'kimi-k2.7-code' || model.id === 'kimi-k2.7-code-highspeed') - ) { - // Kimi K2.7 Code is always-thinking. Official docs say - // `thinking: { type: "disabled" }` is rejected, and callers can omit - // the thinking parameter to use the enabled default. - mergeThinkingLevelMap(model, { off: null }) - } - if (model.provider === 'openrouter' && model.id.startsWith('inception/mercury-2')) { - // Mercury 2 in instant mode (reasoning_effort: "none") disables tool calling. - // Mark "off" unsupported so the openai-completions provider omits the reasoning param - // instead of defaulting to {reasoning:{effort:"none"}} (see openai-completions.ts:575). - // Pi's low/medium/high pass through verbatim; OpenRouter normalizes to Mercury's vocabulary. - mergeThinkingLevelMap(model, { off: null }) - } - if (model.provider === 'openrouter' && model.id === 'z-ai/glm-5.2') { - mergeThinkingLevelMap(model, { xhigh: 'xhigh' }) - } - if (model.provider === 'fireworks' && model.id.includes('glm-5p2')) { - mergeThinkingLevelMap(model, { - off: 'none', - minimal: null, - low: 'high', - medium: 'high', - max: 'max', - }) - } - if (model.provider === 'opencode-go' && model.id === 'glm-5.2') { - mergeThinkingLevelMap(model, OPENCODE_GO_GLM52_THINKING_LEVEL_MAP) - } - if (model.provider === 'opencode-go' && model.id === 'kimi-k2.6') { - // OpenCode Go exposes Kimi K2.6 thinking as on/off, not distinct effort tiers. - mergeThinkingLevelMap(model, { minimal: null, low: null, medium: null }) - } - if (model.provider === 'opencode' && model.id === 'grok-build-0.1') { - // OpenCode Zen Grok Build reasons by default but rejects explicit reasoningEffort. - mergeThinkingLevelMap(model, { off: null, minimal: null, low: null, medium: null }) - } - if (model.provider === 'ant-ling' && model.reasoning) { - // Ring reasons by default. Only high/xhigh have documented explicit effort controls. - mergeThinkingLevelMap(model, ANT_LING_RING_THINKING_LEVEL_MAP) - } - if (model.provider === 'github-copilot') { - const override = GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES[model.id] - if (override) { - mergeThinkingLevelMap(model, override) - } - } -} - -function getAnthropicMessagesCompat( - provider: string, - modelId: string, -): AnthropicMessagesCompat | undefined { - const compat: AnthropicMessagesCompat = {} - if (EAGER_TOOL_INPUT_STREAMING_UNSUPPORTED_ANTHROPIC_MODELS.has(`${provider}:${modelId}`)) { - compat.supportsEagerToolInputStreaming = false - } - if (provider === 'xiaomi' || provider.startsWith('xiaomi-token-plan-')) { - compat.allowEmptySignature = true - } - return Object.keys(compat).length > 0 ? compat : undefined -} - -function getBedrockBaseUrl(modelId: string): string { - return modelId.startsWith('eu.') - ? 'https://bedrock-runtime.eu-central-1.amazonaws.com' - : 'https://bedrock-runtime.us-east-1.amazonaws.com' -} - -function normalizeNvidiaModelId(modelId: string): string { - return modelId.toLowerCase().replaceAll('_', '.') -} - -function roundCost(value: number): number { - return Number(value.toFixed(6)) -} - -function getModelsDevCost(cost: ModelsDevModel['cost']): ModelCost { - const tiers = cost?.tiers?.flatMap((tier) => { - const context = tier.tier - if (context?.type !== 'context' || context.size === undefined) return [] - return [ - { - inputTokensAbove: context.size, - input: tier.input || 0, - output: tier.output || 0, - cacheRead: tier.cache_read || 0, - cacheWrite: tier.cache_write || 0, - }, - ] - }) - - return { - input: cost?.input || 0, - output: cost?.output || 0, - cacheRead: cost?.cache_read || 0, - cacheWrite: cost?.cache_write || 0, - ...(tiers && tiers.length > 0 ? { tiers } : {}), - } -} - -async function fetchNvidiaNimModelIds(): Promise> { - const timeout = generatorOptions.timeoutMs ?? DEFAULT_CATALOG_TIMEOUT_MS - try { - console.log('Fetching models from NVIDIA NIM API...') - const response = await fetch(`${NVIDIA_BASE_URL}/models`, { - signal: AbortSignal.timeout(timeout), - }) - if (!response.ok) throw new Error(`NVIDIA NIM API returned ${response.status}`) - const data = (await response.json()) as { data?: NvidiaNimModelListItem[] } - const modelIds = new Map() - - for (const model of data.data ?? []) { - modelIds.set(model.id, model.id) - modelIds.set(normalizeNvidiaModelId(model.id), model.id) - } - - console.log(`Fetched ${data.data?.length ?? 0} model IDs from NVIDIA NIM`) - return modelIds - } catch (error) { - console.error('Failed to fetch NVIDIA NIM models:', error) - if (generatorOptions.strict) throw error - return new Map() - } -} - -async function fetchOpenRouterModels(): Promise[]> { - const timeout = generatorOptions.timeoutMs ?? DEFAULT_CATALOG_TIMEOUT_MS - try { - console.log('Fetching models from OpenRouter API...') - const response = await fetch('https://openrouter.ai/api/v1/models', { - signal: AbortSignal.timeout(timeout), - }) - if (!response.ok) throw new Error(`OpenRouter API returned ${response.status}`) - const data = await response.json() - - const models: Model[] = [] - - for (const model of data.data) { - // Only include models that support tools - if (!model.supported_parameters?.includes('tools')) continue - - // Parse provider from model ID - let provider: KnownProvider = 'openrouter' - let modelKey = model.id - - modelKey = model.id // Keep full ID for OpenRouter - - // Parse input modalities - const input: ('text' | 'image')[] = ['text'] - if (model.architecture?.modality?.includes('image')) { - input.push('image') - } - - // Convert pricing from $/token to $/million tokens - const inputCost = roundCost(parseFloat(model.pricing?.prompt || '0') * 1_000_000) - const outputCost = roundCost(parseFloat(model.pricing?.completion || '0') * 1_000_000) - const cacheReadCost = roundCost( - parseFloat(model.pricing?.input_cache_read || '0') * 1_000_000, - ) - const cacheWriteCost = roundCost( - parseFloat(model.pricing?.input_cache_write || '0') * 1_000_000, - ) - - const contextWindow = model.top_provider?.context_length || model.context_length || 4096 - - const normalizedModel: Model = { - id: modelKey, - name: model.name, - api: 'openai-completions', - baseUrl: 'https://openrouter.ai/api/v1', - provider, - reasoning: model.supported_parameters?.includes('reasoning') || false, - input, - cost: { - input: inputCost, - output: outputCost, - cacheRead: cacheReadCost, - cacheWrite: cacheWriteCost, - }, - contextWindow, - maxTokens: model.top_provider?.max_completion_tokens || 4096, - } - models.push(normalizedModel) - } - - console.log(`Fetched ${models.length} tool-capable models from OpenRouter`) - return models - } catch (error) { - console.error('Failed to fetch OpenRouter models:', error) - if (generatorOptions.strict) { - throw new Error(`Failed to fetch OpenRouter models: ${(error as Error).message}`) - } - return [] - } -} - -async function fetchAiGatewayModels(): Promise[]> { - const timeout = generatorOptions.timeoutMs ?? DEFAULT_CATALOG_TIMEOUT_MS - try { - console.log('Fetching models from Vercel AI Gateway API...') - const response = await fetch(`${AI_GATEWAY_MODELS_URL}/models`, { - signal: AbortSignal.timeout(timeout), - }) - if (!response.ok) throw new Error(`Vercel AI Gateway API returned ${response.status}`) - const data = await response.json() - const models: Model[] = [] - - const toNumber = (value: string | number | undefined): number => { - if (typeof value === 'number') { - return Number.isFinite(value) ? value : 0 - } - const parsed = parseFloat(value ?? '0') - return Number.isFinite(parsed) ? parsed : 0 - } - - const items = Array.isArray(data.data) ? (data.data as AiGatewayModel[]) : [] - for (const model of items) { - const tags = Array.isArray(model.tags) ? model.tags : [] - // Only include models that support tools - if (!tags.includes('tool-use')) continue - - const input: ('text' | 'image')[] = ['text'] - if (tags.includes('vision')) { - input.push('image') - } - - const inputCost = roundCost(toNumber(model.pricing?.input) * 1_000_000) - const outputCost = roundCost(toNumber(model.pricing?.output) * 1_000_000) - const cacheReadCost = roundCost(toNumber(model.pricing?.input_cache_read) * 1_000_000) - const cacheWriteCost = roundCost(toNumber(model.pricing?.input_cache_write) * 1_000_000) - - models.push({ - id: model.id, - name: model.name || model.id, - api: 'anthropic-messages', - baseUrl: AI_GATEWAY_BASE_URL, - provider: 'vercel-ai-gateway', - reasoning: tags.includes('reasoning'), - input, - cost: { - input: inputCost, - output: outputCost, - cacheRead: cacheReadCost, - cacheWrite: cacheWriteCost, - }, - contextWindow: model.context_window || 4096, - maxTokens: model.max_tokens || 4096, - }) - } - - console.log(`Fetched ${models.length} tool-capable models from Vercel AI Gateway`) - return models - } catch (error) { - console.error('Failed to fetch Vercel AI Gateway models:', error) - if (generatorOptions.strict) { - throw new Error(`Failed to fetch Vercel AI Gateway models: ${(error as Error).message}`) - } - return [] - } -} - -async function loadModelsDevData(): Promise[]> { - const timeout = generatorOptions.timeoutMs ?? DEFAULT_CATALOG_TIMEOUT_MS - try { - console.log('Fetching models from models.dev API...') - const response = await fetch('https://models.dev/api.json', { - signal: AbortSignal.timeout(timeout), - }) - if (!response.ok) throw new Error(`models.dev API returned ${response.status}`) - const data = (await response.json()) as ModelsDevCatalog - - const models: Model[] = [] - const nvidiaNimModelIds = data.nvidia?.models - ? await fetchNvidiaNimModelIds() - : new Map() - - // Process Amazon Bedrock models - if (data['amazon-bedrock']?.models) { - for (const [modelId, model] of Object.entries(data['amazon-bedrock'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - if (BEDROCK_INFERENCE_PROFILE_ONLY_MODEL_IDS.has(modelId)) continue - - let id = modelId - - if (id.startsWith('ai21.jamba')) { - // These models doesn't support tool use in streaming mode - continue - } - - if (id.startsWith('mistral.mistral-7b-instruct-v0')) { - // These models doesn't support system messages - continue - } - - models.push({ - id, - name: m.name || id, - api: 'bedrock-converse-stream' as const, - provider: 'amazon-bedrock' as const, - baseUrl: getBedrockBaseUrl(id), - reasoning: m.reasoning === true, - input: (m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text']) as ( - 'text' | 'image' - )[], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - ...(m.structured_output === true && { compat: { supportsStrictMode: true } }), - }) - recordModelsDevReasoningOptions('amazon-bedrock' as const, id, m) - } - } - - // Process Anthropic models - if (data.anthropic?.models) { - for (const [modelId, model] of Object.entries(data.anthropic.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'anthropic-messages', - provider: 'anthropic', - baseUrl: 'https://api.anthropic.com', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('anthropic', modelId, m) - } - } - - // Process Google models - if (data.google?.models) { - for (const [modelId, model] of Object.entries(data.google.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - let source = m - if (modelId === 'gemini-flash-latest') { - source = (data.google.models['gemini-3.5-flash'] as ModelsDevModel | undefined) ?? m - } - if (modelId === 'gemini-flash-lite-latest') { - source = (data.google.models['gemini-3.1-flash-lite'] as ModelsDevModel | undefined) ?? m - } - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'google-generative-ai', - provider: 'google', - baseUrl: 'https://generativelanguage.googleapis.com/v1beta', - reasoning: source.reasoning === true, - input: source.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: source.cost?.input || 0, - output: source.cost?.output || 0, - cacheRead: source.cost?.cache_read || 0, - cacheWrite: source.cost?.cache_write || 0, - }, - contextWindow: source.limit?.context || 4096, - maxTokens: source.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('google', modelId, source) - } - } - - // Process Google Vertex Gemini models. The google-vertex models.dev catalog also includes - // Claude, OpenAI, and other MaaS models that do not use the @google/genai Gemini streaming - // path implemented by our google-vertex provider. - if (data['google-vertex']?.models) { - for (const [modelId, model] of Object.entries(data['google-vertex'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - if (!modelId.startsWith('gemini-')) continue - if (modelId === 'gemini-3.1-flash-lite-preview') continue - let source = m - if (modelId === 'gemini-flash-latest') { - source = - (data['google-vertex'].models['gemini-3.5-flash'] as ModelsDevModel | undefined) ?? m - } - if (modelId === 'gemini-flash-lite-latest') { - source = - (data['google-vertex'].models['gemini-3.1-flash-lite'] as ModelsDevModel | undefined) ?? - m - } - - // models.dev reports Vertex cache_read/cache_write values for Gemini 2.5 Flash that - // do not match the official Gemini API standard pricing table. pi only accounts - // cachedContentTokenCount as cacheRead. - const cacheRead = modelId === 'gemini-2.5-flash' ? 0.03 : source.cost?.cache_read || 0 - models.push({ - id: modelId, - name: m.name || modelId, - api: 'google-vertex', - provider: 'google-vertex', - baseUrl: VERTEX_BASE_URL, - reasoning: source.reasoning === true, - input: source.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: source.cost?.input || 0, - output: source.cost?.output || 0, - cacheRead, - cacheWrite: 0, - }, - contextWindow: source.limit?.context || 4096, - maxTokens: source.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('google-vertex', modelId, source) - } - } - - // Process OpenAI models - if (data.openai?.models) { - for (const [modelId, model] of Object.entries(data.openai.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - // models.dev lists this alias, but it is not accepted by OpenAI APIs. - if (MODELS_DEV_OPENAI_UNSUPPORTED_MODEL_IDS.has(modelId)) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-responses', - provider: 'openai', - baseUrl: 'https://api.openai.com/v1', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('openai', modelId, m) - } - } - - // Process Groq models - if (data.groq?.models) { - for (const [modelId, model] of Object.entries(data.groq.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider: 'groq', - baseUrl: 'https://api.groq.com/openai/v1', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('groq', modelId, m) - } - } - - // Process Cerebras models - if (data.cerebras?.models) { - for (const [modelId, model] of Object.entries(data.cerebras.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider: 'cerebras', - baseUrl: 'https://api.cerebras.ai/v1', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('cerebras', modelId, m) - } - } - - // Process Cloudflare Workers AI models - if (data['cloudflare-workers-ai']?.models) { - for (const [modelId, model] of Object.entries(data['cloudflare-workers-ai'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider: 'cloudflare-workers-ai', - baseUrl: CLOUDFLARE_WORKERS_AI_BASE_URL, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - compat: { sendSessionAffinityHeaders: true }, - }) - recordModelsDevReasoningOptions('cloudflare-workers-ai', modelId, m) - } - } - - // Process Cloudflare AI Gateway models - if (data['cloudflare-ai-gateway']?.models) { - for (const [prefixedId, model] of Object.entries(data['cloudflare-ai-gateway'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - const slashIdx = prefixedId.indexOf('/') - if (slashIdx === -1) continue - const upstream = prefixedId.slice(0, slashIdx) - const nativeId = prefixedId.slice(slashIdx + 1) - - let api: 'anthropic-messages' | 'openai-completions' | 'openai-responses' - let baseUrl: string - let id: string - if (upstream === 'openai') { - api = 'openai-responses' - baseUrl = CLOUDFLARE_AI_GATEWAY_OPENAI_BASE_URL - id = nativeId - } else if (upstream === 'anthropic') { - api = 'anthropic-messages' - baseUrl = CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL - id = nativeId - } else if (upstream === 'workers-ai') { - api = 'openai-completions' - baseUrl = CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL - id = prefixedId - } else { - continue - } - - // Gateway passthroughs forward session affinity headers to upstreams that - // use them for cache/routing affinity. - const compat = - upstream === 'anthropic' || upstream === 'workers-ai' - ? { sendSessionAffinityHeaders: true } - : undefined - - models.push({ - id, - name: m.name || id, - api, - provider: 'cloudflare-ai-gateway', - baseUrl, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - ...(compat ? { compat } : {}), - }) - recordModelsDevReasoningOptions('cloudflare-ai-gateway', id, m) - } - } - - // Process xAi models - if (data.xai?.models) { - for (const [modelId, model] of Object.entries(data.xai.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - const useResponsesApi = modelId === XAI_RESPONSES_MODEL_ID - - models.push({ - id: modelId, - name: m.name || modelId, - api: useResponsesApi ? 'openai-responses' : 'openai-completions', - provider: 'xai', - baseUrl: 'https://api.x.ai/v1', - ...(useResponsesApi ? { compat: { ...XAI_RESPONSES_COMPAT } } : {}), - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('xai', modelId, m) - } - } - - // Process zAi models - const zaiCodingPlanVariants = [ - { provider: 'zai', baseUrl: 'https://api.z.ai/api/coding/paas/v4' }, - { provider: 'zai-coding-cn', baseUrl: 'https://open.bigmodel.cn/api/coding/paas/v4' }, - ] as const - - if (data['zai-coding-plan']?.models) { - for (const { provider, baseUrl } of zaiCodingPlanVariants) { - for (const [modelId, model] of Object.entries(data['zai-coding-plan'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - const supportsImage = m.modalities?.input?.includes('image') - - const isGlm52 = modelId === 'glm-5.2' - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider, - baseUrl, - reasoning: m.reasoning === true, - ...(isGlm52 ? { thinkingLevelMap: ZAI_GLM52_THINKING_LEVEL_MAP } : {}), - input: supportsImage ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - compat: { - supportsDeveloperRole: false, - thinkingFormat: 'zai', - ...(isGlm52 ? { supportsReasoningEffort: true } : {}), - ...(!ZAI_TOOL_STREAM_UNSUPPORTED_MODELS.has(modelId) ? { zaiToolStream: true } : {}), - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions(provider, modelId, m) - } - } - } - - // Process Mistral models - if (data.mistral?.models) { - for (const [modelId, model] of Object.entries(data.mistral.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'mistral-conversations', - provider: 'mistral', - baseUrl: 'https://api.mistral.ai', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read ?? (m.cost?.input ? roundCost(m.cost.input * 0.1) : 0), - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('mistral', modelId, m) - } - } - - // Process Hugging Face models - if (data.huggingface?.models) { - for (const [modelId, model] of Object.entries(data.huggingface.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider: 'huggingface', - baseUrl: 'https://router.huggingface.co/v1', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - compat: { - supportsDeveloperRole: false, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('huggingface', modelId, m) - } - } - - // Process Fireworks models - if (data['fireworks-ai']?.models) { - for (const [modelId, model] of Object.entries(data['fireworks-ai'].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'anthropic-messages', - provider: 'fireworks', - // Fireworks Anthropic-compatible API - SDK appends /v1/messages - baseUrl: 'https://api.fireworks.ai/inference', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - // Fireworks prompt caching uses automatic prefix matching + session affinity. - // x-session-affinity routes requests to the same replica for cache hits. - // cache_control on tools and eager_input_streaming are not supported. - // See: https://docs.fireworks.ai/tools-sdks/anthropic-compatibility - compat: { - sendSessionAffinityHeaders: true, - supportsEagerToolInputStreaming: false, - supportsCacheControlOnTools: false, - supportsLongCacheRetention: false, - }, - }) - recordModelsDevReasoningOptions('fireworks', modelId, m) - } - } - - // Process NVIDIA NIM models - if (data.nvidia?.models) { - for (const [modelId, model] of Object.entries(data.nvidia.models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - if (!m.modalities?.input?.includes('text')) continue - if (!m.modalities?.output?.includes('text')) continue - - const liveModelId = - nvidiaNimModelIds.get(modelId) ?? nvidiaNimModelIds.get(normalizeNvidiaModelId(modelId)) - if (!liveModelId) continue - if (NVIDIA_NIM_UNSUPPORTED_MODELS.has(liveModelId)) continue - - models.push({ - id: liveModelId, - name: m.name || liveModelId, - api: 'openai-completions', - provider: 'nvidia', - baseUrl: NVIDIA_BASE_URL, - headers: { ...NVIDIA_HEADERS }, - reasoning: m.reasoning === true, - input: m.modalities.input.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - compat: NVIDIA_OPENAI_COMPAT, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('nvidia', liveModelId, m) - } - } - - // Process Together AI models - const togetherProvider = data.together ?? data.togetherai ?? data['together-ai'] - if (togetherProvider?.models) { - for (const [modelId, model] of Object.entries(togetherProvider.models)) { - const m = model as ModelsDevModel & { status?: string } - if (m.tool_call !== true) continue - if (m.status === 'deprecated') continue - - const reasoning = m.reasoning === true - const thinkingLevelMap = getTogetherThinkingLevelMap(modelId, reasoning) - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider: 'together', - baseUrl: TOGETHER_BASE_URL, - reasoning, - ...(thinkingLevelMap ? { thinkingLevelMap } : {}), - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - compat: getTogetherCompat(modelId, reasoning), - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('together', modelId, m) - } - } - - // Process OpenCode models (Zen and Go) - // API mapping based on provider.npm field: - // - @ai-sdk/openai → openai-responses - // - @ai-sdk/anthropic → anthropic-messages - // - @ai-sdk/google → google-generative-ai - // - null/undefined/@ai-sdk/openai-compatible → openai-completions - const opencodeVariants = [ - { key: 'opencode', provider: 'opencode', basePath: 'https://opencode.ai/zen' }, - { key: 'opencode-go', provider: 'opencode-go', basePath: 'https://opencode.ai/zen/go' }, - ] as const - - for (const variant of opencodeVariants) { - const variantModels = data[variant.key]?.models - if (!variantModels) continue - - for (const [modelId, model] of Object.entries(variantModels)) { - const m = model as ModelsDevModel & { status?: string } - if (m.tool_call !== true) continue - if (m.status === 'deprecated') continue - - const npm = m.provider?.npm - let api: Api - let baseUrl: string - let compat: OpenAICompletionsCompat | OpenAIResponsesCompat | undefined - - if (npm === '@ai-sdk/openai') { - api = 'openai-responses' - baseUrl = `${variant.basePath}/v1` - compat = { sessionAffinityFormat: 'openai-nosession' } - } else if (npm === '@ai-sdk/anthropic') { - api = 'anthropic-messages' - // Anthropic SDK appends /v1/messages to baseURL - baseUrl = variant.basePath - } else if (npm === '@ai-sdk/google') { - api = 'google-generative-ai' - baseUrl = `${variant.basePath}/v1` - } else if (npm === '@ai-sdk/alibaba') { - api = 'openai-completions' - baseUrl = `${variant.basePath}/v1` - compat = { cacheControlFormat: 'anthropic' } - } else { - // null, undefined, or @ai-sdk/openai-compatible - api = 'openai-completions' - baseUrl = `${variant.basePath}/v1` - } - - if (variant.provider === 'opencode' && modelId === 'grok-build-0.1') { - compat = { ...(compat ?? {}), supportsReasoningEffort: false } - } - - if ( - (variant.provider === 'opencode' || variant.provider === 'opencode-go') && - modelId === 'kimi-k2.6' - ) { - // OpenCode Kimi K2.6 accepts Anthropic-style thinking objects - // and rejects string thinking values or combined reasoning_effort. - compat = { ...(compat ?? {}), thinkingFormat: 'deepseek', supportsReasoningEffort: false } - } - - // Fix known mismatches between models.dev npm data and actual - // OpenCode Go endpoint behaviour. models.dev reports these models - // as @ai-sdk/anthropic, but the OpenCode Go endpoints either don't - // accept Anthropic SDK auth (MiniMax M2.7) or are served through - // the OpenAI-compatible /v1/chat/completions path (Qwen 3.5/3.6). - // Switch them to openai-completions so requests use Bearer auth - // and the standard /v1/chat/completions endpoint. - if (variant.provider === 'opencode-go') { - if (modelId === 'minimax-m2.7') { - api = 'openai-completions' - baseUrl = `${variant.basePath}/v1` - } - if (modelId === 'qwen3.5-plus' || modelId === 'qwen3.6-plus') { - api = 'openai-completions' - baseUrl = `${variant.basePath}/v1` - // Qwen/DashScope uses enable_thinking at the top level. - compat = { ...(compat ?? {}), thinkingFormat: 'qwen' } - } - } - - if (api === 'openai-completions') { - compat = { ...(compat ?? {}), maxTokensField: 'max_tokens' } - if ( - OPENCODE_OPENAI_COMPLETIONS_LONG_CACHE_RETENTION_UNSUPPORTED_MODELS.has( - `${variant.provider}:${modelId}`, - ) - ) { - compat = { ...compat, supportsLongCacheRetention: false } - } - } - - models.push({ - id: modelId, - name: m.name || modelId, - api, - provider: variant.provider, - baseUrl, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - ...(compat ? { compat } : {}), - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions(variant.provider, modelId, m) - } - } - - // Process GitHub Copilot models - if (data['github-copilot']?.models) { - for (const [modelId, model] of Object.entries(data['github-copilot'].models)) { - const m = model as ModelsDevModel & { status?: string } - if (m.tool_call !== true) continue - if (m.status === 'deprecated') continue - - // Claude 4.x and 5.x models route to Anthropic Messages API - const isCopilotClaude = /^claude-(haiku|sonnet|opus)-[45]([.\-]|$)/.test(modelId) - // gpt-5, oswe, and MAI-Code models are only served through the - // Copilot /responses endpoint. - const needsResponsesApi = - modelId.startsWith('gpt-5') || modelId.startsWith('oswe') || modelId.startsWith('mai-') - - const api: Api = isCopilotClaude - ? 'anthropic-messages' - : needsResponsesApi - ? 'openai-responses' - : 'openai-completions' - - const anthropicCompat = - api === 'anthropic-messages' - ? getAnthropicMessagesCompat('github-copilot', modelId) - : undefined - - const copilotModel: Model = { - id: modelId, - name: m.name || modelId, - api, - provider: 'github-copilot', - baseUrl: 'https://api.individual.githubcopilot.com', - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: getModelsDevCost(m.cost), - contextWindow: m.limit?.context || 128000, - maxTokens: m.limit?.output || 8192, - headers: { ...COPILOT_STATIC_HEADERS }, - ...(anthropicCompat ? { compat: anthropicCompat } : {}), - // compat only applies to openai-completions - ...(api === 'openai-completions' - ? { - compat: { - supportsStore: false, - supportsDeveloperRole: false, - supportsReasoningEffort: false, - }, - } - : {}), - } - - models.push(copilotModel) - recordModelsDevReasoningOptions('github-copilot', modelId, m) - } - } - - // Process MiniMax models - const minimaxVariants = [ - { key: 'minimax', provider: 'minimax', baseUrl: 'https://api.minimax.io/anthropic' }, - { key: 'minimax-cn', provider: 'minimax-cn', baseUrl: 'https://api.minimaxi.com/anthropic' }, - ] as const - - for (const { key, provider, baseUrl } of minimaxVariants) { - if (data[key]?.models) { - for (const [modelId, model] of Object.entries(data[key].models)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'anthropic-messages', - provider, - // MiniMax's Anthropic-compatible API - SDK appends /v1/messages - baseUrl, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions(provider, modelId, m) - } - } - } - - // Process Kimi For Coding models - if (data['kimi-for-coding']?.models) { - const kimiModels = data['kimi-for-coding'].models as Record - const hasCanonicalModel = Object.prototype.hasOwnProperty.call(kimiModels, 'kimi-for-coding') - - const kimiAliases = new Set(['k2p5', 'k2p6', 'k2p7']) - - for (const [modelId, model] of Object.entries(kimiModels)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - // models.dev may expose versioned aliases (e.g. k2p5/k2p6/k2p7). - // Normalize aliases to the canonical model id and drop duplicates when canonical exists. - if (kimiAliases.has(modelId) && hasCanonicalModel) continue - - const normalizedId = kimiAliases.has(modelId) ? 'kimi-for-coding' : modelId - const normalizedName = kimiAliases.has(modelId) ? 'Kimi For Coding' : m.name || normalizedId - const isKimiK3 = normalizedId === 'k3' - const allowEmptySignature = isKimiK3 || normalizedId === 'kimi-for-coding' - const impliedCost = KIMI_CODING_IMPLIED_COSTS[normalizedId] - - models.push({ - id: normalizedId, - name: normalizedName, - api: 'anthropic-messages', - provider: 'kimi-coding', - // Kimi For Coding's Anthropic-compatible API - SDK appends /v1/messages - baseUrl: 'https://api.kimi.com/coding', - headers: { ...KIMI_STATIC_HEADERS }, - compat: { - ...(allowEmptySignature ? { allowEmptySignature: true } : {}), - forceAdaptiveThinking: true, - }, - reasoning: isKimiK3 || m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || impliedCost?.input || 0, - output: m.cost?.output || impliedCost?.output || 0, - cacheRead: m.cost?.cache_read || impliedCost?.cacheRead || 0, - cacheWrite: m.cost?.cache_write || impliedCost?.cacheWrite || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions('kimi-coding', normalizedId, m) - } - } - - // Process Moonshot AI models - const moonshotVariants = [ - { key: 'moonshotai', provider: 'moonshotai', baseUrl: 'https://api.moonshot.ai/v1' }, - { key: 'moonshotai-cn', provider: 'moonshotai-cn', baseUrl: 'https://api.moonshot.cn/v1' }, - ] as const - const moonshotCompat: OpenAICompletionsCompat = { - supportsStore: false, - supportsDeveloperRole: false, - supportsReasoningEffort: false, - maxTokensField: 'max_tokens', - supportsStrictMode: false, - thinkingFormat: 'deepseek', - } - const getMoonshotProviderModels = ( - key: 'moonshotai' | 'moonshotai-cn', - ): Record => { - const providerModels = data[key]?.models as Record | undefined - return providerModels ? { ...providerModels } : {} - } - const moonshotModels = { - moonshotai: getMoonshotProviderModels('moonshotai'), - 'moonshotai-cn': getMoonshotProviderModels('moonshotai-cn'), - } - - for (const { key, provider, baseUrl } of moonshotVariants) { - for (const [modelId, m] of Object.entries(moonshotModels[key])) { - if (m.tool_call !== true) continue - - const isKimiK3 = modelId === 'kimi-k3' - const compat = isKimiK3 ? { ...moonshotCompat } : moonshotCompat - if (isKimiK3) { - compat.requiresReasoningContentOnAssistantMessages = true - compat.thinkingFormat = 'openai' - compat.supportsReasoningEffort = true - } - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider, - baseUrl, - reasoning: isKimiK3 || m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || (isKimiK3 ? KIMI_K3_COST.input : 0), - output: m.cost?.output || (isKimiK3 ? KIMI_K3_COST.output : 0), - cacheRead: m.cost?.cache_read || (isKimiK3 ? KIMI_K3_COST.cacheRead : 0), - cacheWrite: m.cost?.cache_write || (isKimiK3 ? KIMI_K3_COST.cacheWrite : 0), - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - compat, - }) - recordModelsDevReasoningOptions(provider, modelId, m) - } - } - - // Process Xiaomi MiMo models - // Built-in `xiaomi` targets the API billing endpoint (single stable URL, - // keys from platform.xiaomimimo.com). The three `xiaomi-token-plan-*` - // providers cover prepaid Token Plan endpoints in cn / ams / sgp. - const xiaomiCompat: OpenAICompletionsCompat = { - requiresReasoningContentOnAssistantMessages: true, - thinkingFormat: 'deepseek', - } - const xiaomiVariants = [ - { source: 'xiaomi', provider: 'xiaomi', baseUrl: 'https://api.xiaomimimo.com/v1' }, - { - source: 'xiaomi-token-plan-cn', - provider: 'xiaomi-token-plan-cn', - baseUrl: 'https://token-plan-cn.xiaomimimo.com/v1', - }, - { - source: 'xiaomi-token-plan-ams', - provider: 'xiaomi-token-plan-ams', - baseUrl: 'https://token-plan-ams.xiaomimimo.com/v1', - }, - { - source: 'xiaomi-token-plan-sgp', - provider: 'xiaomi-token-plan-sgp', - baseUrl: 'https://token-plan-sgp.xiaomimimo.com/v1', - }, - ] as const - - for (const { source, provider, baseUrl } of xiaomiVariants) { - const providerModels = data[source]?.models - if (!providerModels) continue - - for (const [modelId, model] of Object.entries(providerModels)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider, - baseUrl, - compat: xiaomiCompat, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions(provider, modelId, m) - } - } - - // Process Alibaba Cloud Model Studio Token Plan models - // Two regions (international / cn) with identical catalogs, separate - // endpoints and API keys (sk-sp- prefix). models.dev keys are - // "alibaba-token-plan[-cn]"; pi exposes them as "qwen-token-plan[-cn]". - const qwenTokenPlanCompat: OpenAICompletionsCompat = { - thinkingFormat: 'qwen', - supportsDeveloperRole: false, - supportsStore: false, - } - const qwenTokenPlanVariants = [ - { - source: 'alibaba-token-plan', - provider: 'qwen-token-plan', - baseUrl: 'https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1', - }, - { - source: 'alibaba-token-plan-cn', - provider: 'qwen-token-plan-cn', - baseUrl: 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1', - }, - ] as const - - for (const { source, provider, baseUrl } of qwenTokenPlanVariants) { - const providerModels = data[source]?.models - if (!providerModels) continue - - for (const [modelId, model] of Object.entries(providerModels)) { - const m = model as ModelsDevModel - if (m.tool_call !== true) continue - - models.push({ - id: modelId, - name: m.name || modelId, - api: 'openai-completions', - provider, - baseUrl, - compat: qwenTokenPlanCompat, - reasoning: m.reasoning === true, - input: m.modalities?.input?.includes('image') ? ['text', 'image'] : ['text'], - cost: { - input: m.cost?.input || 0, - output: m.cost?.output || 0, - cacheRead: m.cost?.cache_read || 0, - cacheWrite: m.cost?.cache_write || 0, - }, - contextWindow: m.limit?.context || 4096, - maxTokens: m.limit?.output || 4096, - }) - recordModelsDevReasoningOptions(provider, modelId, m) - } - } - - console.log(`Loaded ${models.length} tool-capable models from models.dev`) - return models - } catch (error) { - console.error('Failed to load models.dev data:', error) - if (generatorOptions.strict) { - throw new Error(`Failed to load models.dev catalog: ${(error as Error).message}`) - } - return [] - } -} -export interface GenerateModelsResult { - providers: Record>> - groupedProviders?: Record>>> - sortedProviderIds: string[] -} - -export async function generateModels( - options?: Partial, -): Promise { - if (options) { - generatorOptions = { ...generatorOptions, ...options } - } - // Fetch models from both sources - // models.dev: Anthropic, Google, OpenAI, Groq, Cerebras - // OpenRouter: xAI and other providers (excluding Anthropic, Google, OpenAI) - // AI Gateway: OpenAI-compatible catalog with tool-capable models - const modelsDevModels = await loadModelsDevData() - const openRouterModels = await fetchOpenRouterModels() - const aiGatewayModels = await fetchAiGatewayModels() - - // Combine models (models.dev has priority) - const allModels = [...modelsDevModels, ...openRouterModels, ...aiGatewayModels].filter( - (model) => - !(model.provider === 'xai' && XAI_BUILTIN_EXCLUDED_MODEL_IDS.has(model.id)) && - !( - (model.provider === 'opencode' || model.provider === 'opencode-go') && - model.id === 'gpt-5.3-codex-spark' - ), - ) - - if (allModels.length === 0) { - throw new Error('Failed to retrieve any models from upstream catalogs') - } - - // Temporary overrides until upstream model metadata is corrected. - for (const candidate of allModels) { - if ( - candidate.provider === 'github-copilot' && - GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS.has(candidate.id) - ) { - candidate.contextWindow = 1000000 - } - - if ( - (candidate.provider === 'anthropic' || - candidate.provider === 'opencode' || - candidate.provider === 'opencode-go') && - (candidate.id === 'claude-opus-4-6' || - candidate.id === 'claude-sonnet-4-6' || - candidate.id === 'claude-opus-4.6' || - candidate.id === 'claude-sonnet-4.6') - ) { - candidate.contextWindow = 1000000 - } - - // OpenCode variants list Claude Sonnet 4/4.5 with 1M context, actual limit is 200K - if ( - (candidate.provider === 'opencode' || candidate.provider === 'opencode-go') && - (candidate.id === 'claude-sonnet-4-5' || candidate.id === 'claude-sonnet-4') - ) { - candidate.contextWindow = 200000 - } - if ( - (candidate.provider === 'opencode' || candidate.provider === 'opencode-go') && - candidate.id === 'gpt-5.4' - ) { - candidate.contextWindow = 272000 - candidate.maxTokens = 128000 - } - // Keep direct OpenAI requests in the short-context pricing tier by default. Users can opt into the - // larger context through model overrides, so retain long-context cost metadata on the capped models. - if ( - candidate.provider === 'openai' && - OPENAI_SHORT_CONTEXT_CAPPED_MODEL_IDS.has(candidate.id) - ) { - candidate.contextWindow = OPENAI_LONG_CONTEXT_INPUT_THRESHOLD - candidate.maxTokens = 128000 - } - if ( - candidate.provider === 'openai' && - OPENAI_LONG_CONTEXT_PRICING_MODEL_IDS.has(candidate.id) - ) { - candidate.cost = withOpenAiLongContextPricing(candidate.cost) - } - // models.dev reports gpt-5-pro output as 272000 (a duplicate of the input sub-limit); - // the actual max output is 128000. Also propagates to the derived Azure clone. - if (candidate.provider === 'openai' && candidate.id === 'gpt-5-pro') { - candidate.maxTokens = 128000 - } - // Keep Kimi K3's canonical output limit when gateway metadata is missing or incorrect. - if ( - (candidate.provider === 'openrouter' && OPENROUTER_KIMI_K3_MODEL_IDS.has(candidate.id)) || - (candidate.provider === 'vercel-ai-gateway' && candidate.id === 'moonshotai/kimi-k3') - ) { - candidate.maxTokens = KIMI_K3_MAX_TOKENS - } - // Keep selected OpenRouter model metadata stable until upstream settles. - if (candidate.provider === 'openrouter' && candidate.id === 'moonshotai/kimi-k2.5') { - candidate.cost.input = 0.41 - candidate.cost.output = 2.06 - candidate.cost.cacheRead = 0.07 - candidate.maxTokens = 4096 - } - if (candidate.provider === 'openrouter' && candidate.id.startsWith('moonshotai/kimi-k2.6')) { - candidate.compat = { - ...candidate.compat, - supportsDeveloperRole: false, - requiresReasoningContentOnAssistantMessages: true, - } - } - if (candidate.provider === 'openrouter' && candidate.id === 'z-ai/glm-5') { - candidate.cost.input = 0.6 - candidate.cost.output = 1.9 - candidate.cost.cacheRead = 0.119 - } - if (candidate.provider === 'fireworks' && candidate.id.includes('glm-5p2')) { - candidate.api = 'openai-completions' - candidate.baseUrl = 'https://api.fireworks.ai/inference/v1' - candidate.compat = { supportsStore: false, supportsDeveloperRole: false } - } - } - - // Add missing gpt models - const missingOpenAiModels: Model<'openai-responses'>[] = [ - { - id: 'gpt-5.6-sol', - name: 'GPT-5.6 Sol', - api: 'openai-responses', - baseUrl: 'https://api.openai.com/v1', - provider: 'openai', - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ - input: 5, - output: 30, - cacheRead: 0.5, - cacheWrite: 6.25, - }), - contextWindow: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD, - maxTokens: 128000, - }, - { - id: 'gpt-5.6-terra', - name: 'GPT-5.6 Terra', - api: 'openai-responses', - baseUrl: 'https://api.openai.com/v1', - provider: 'openai', - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ - input: 2.5, - output: 15, - cacheRead: 0.25, - cacheWrite: 3.125, - }), - contextWindow: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD, - maxTokens: 128000, - }, - { - id: 'gpt-5.6-luna', - name: 'GPT-5.6 Luna', - api: 'openai-responses', - baseUrl: 'https://api.openai.com/v1', - provider: 'openai', - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ input: 1, output: 6, cacheRead: 0.1, cacheWrite: 1.25 }), - contextWindow: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD, - maxTokens: 128000, - }, - { - id: 'gpt-5-chat-latest', - name: 'GPT-5 Chat Latest', - api: 'openai-responses', - baseUrl: 'https://api.openai.com/v1', - provider: 'openai', - reasoning: false, - input: ['text', 'image'], - cost: { - input: 1.25, - output: 10, - cacheRead: 0.125, - cacheWrite: 0, - }, - contextWindow: 128000, - maxTokens: 16384, - }, - ] - for (const model of missingOpenAiModels) { - if (!allModels.some((m) => m.provider === model.provider && m.id === model.id)) { - allModels.push(model) - } - } - - const deepseekCompat: OpenAICompletionsCompat = { - requiresReasoningContentOnAssistantMessages: true, - thinkingFormat: 'deepseek', - } - const deepseekV4Models: Model<'openai-completions'>[] = [ - { - id: 'deepseek-v4-flash', - name: 'DeepSeek V4 Flash', - api: 'openai-completions', - baseUrl: 'https://api.deepseek.com', - provider: 'deepseek', - reasoning: true, - input: ['text'], - cost: { - input: 0.14, - output: 0.28, - cacheRead: 0.0028, - cacheWrite: 0, - }, - contextWindow: 1000000, - maxTokens: 384000, - compat: deepseekCompat, - }, - { - id: 'deepseek-v4-pro', - name: 'DeepSeek V4 Pro', - api: 'openai-completions', - baseUrl: 'https://api.deepseek.com', - provider: 'deepseek', - reasoning: true, - input: ['text'], - cost: { - input: 0.435, - output: 0.87, - cacheRead: 0.003625, - cacheWrite: 0, - }, - contextWindow: 1000000, - maxTokens: 384000, - compat: deepseekCompat, - }, - ] - allModels.push(...deepseekV4Models) - - const antLingCompat: OpenAICompletionsCompat = { - supportsStore: false, - supportsDeveloperRole: false, - supportsReasoningEffort: false, - maxTokensField: 'max_tokens', - supportsLongCacheRetention: false, - } - const antLingModels: Model<'openai-completions'>[] = [ - { - id: 'Ling-2.6-flash', - name: 'Ling 2.6 Flash', - api: 'openai-completions', - baseUrl: 'https://api.ant-ling.com/v1', - provider: 'ant-ling', - reasoning: false, - input: ['text'], - cost: { input: 0.01, output: 0.02, cacheRead: 0, cacheWrite: 0 }, - contextWindow: 262144, - maxTokens: 65536, - compat: antLingCompat, - }, - { - id: 'Ling-2.6-1T', - name: 'Ling 2.6 1T', - api: 'openai-completions', - baseUrl: 'https://api.ant-ling.com/v1', - provider: 'ant-ling', - reasoning: false, - input: ['text'], - cost: { input: 0.06, output: 0.25, cacheRead: 0, cacheWrite: 0 }, - contextWindow: 262144, - maxTokens: 65536, - compat: antLingCompat, - }, - { - id: 'Ring-2.6-1T', - name: 'Ring 2.6 1T', - api: 'openai-completions', - baseUrl: 'https://api.ant-ling.com/v1', - provider: 'ant-ling', - reasoning: true, - input: ['text'], - cost: { input: 0.06, output: 0.25, cacheRead: 0, cacheWrite: 0 }, - contextWindow: 262144, - maxTokens: 65536, - compat: { ...antLingCompat, thinkingFormat: 'ant-ling' }, - }, - ] - allModels.push(...antLingModels) - - for (const candidate of allModels) { - if (candidate.api === 'openai-completions' && candidate.id.includes('deepseek-v4')) { - const preservesNativeReasoningEffort = - candidate.provider === 'openrouter' || candidate.provider === 'opencode' - candidate.compat = { - ...candidate.compat, - ...(preservesNativeReasoningEffort - ? { - requiresReasoningContentOnAssistantMessages: - deepseekCompat.requiresReasoningContentOnAssistantMessages, - } - : deepseekCompat), - } - } - } - - const minimaxDirectSupportedIds = new Set([ - 'MiniMax-M2.7', - 'MiniMax-M2.7-highspeed', - 'MiniMax-M3', - ]) - - for (let i = allModels.length - 1; i >= 0; i--) { - const candidate = allModels[i] - if ( - (candidate.provider === 'minimax' || candidate.provider === 'minimax-cn') && - !minimaxDirectSupportedIds.has(candidate.id) - ) { - allModels.splice(i, 1) - } - } - - // OpenAI Codex (ChatGPT OAuth) models - // NOTE: These are not fetched from models.dev; we keep a small, explicit list to avoid aliases. - // Older model limits are based on observed server behavior; GPT-5.6 follows Codex's 272k catalog limit (formerly 372k). - const CODEX_BASE_URL = 'https://chatgpt.com/backend-api' - const CODEX_CONTEXT = 272000 - const CODEX_GPT_56_CONTEXT = 272000 - const CODEX_SPARK_CONTEXT = 128000 - const CODEX_MAX_TOKENS = 128000 - const codexModels: Model<'openai-codex-responses'>[] = [ - { - id: 'gpt-5.3-codex-spark', - name: 'GPT-5.3 Codex Spark', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text'], - cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, - contextWindow: CODEX_SPARK_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.4', - name: 'GPT-5.4', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ - input: 2.5, - output: 15, - cacheRead: 0.25, - cacheWrite: 0, - }), - contextWindow: CODEX_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.4-mini', - name: 'GPT-5.4 mini', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, - contextWindow: CODEX_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.5', - name: 'GPT-5.5', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 }), - contextWindow: CODEX_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.6-luna', - name: 'GPT-5.6 Luna', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ input: 1, output: 6, cacheRead: 0.1, cacheWrite: 1.25 }), - contextWindow: CODEX_GPT_56_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.6-sol', - name: 'GPT-5.6 Sol', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ - input: 5, - output: 30, - cacheRead: 0.5, - cacheWrite: 6.25, - }), - contextWindow: CODEX_GPT_56_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - { - id: 'gpt-5.6-terra', - name: 'GPT-5.6 Terra', - api: 'openai-codex-responses', - provider: 'openai-codex', - baseUrl: CODEX_BASE_URL, - reasoning: true, - input: ['text', 'image'], - cost: withOpenAiLongContextPricing({ - input: 2.5, - output: 15, - cacheRead: 0.25, - cacheWrite: 3.125, - }), - contextWindow: CODEX_GPT_56_CONTEXT, - maxTokens: CODEX_MAX_TOKENS, - }, - ] - allModels.push(...codexModels) - - // Add missing Mistral Medium 3.5 model until models.dev includes it - if (!allModels.some((m) => m.provider === 'mistral' && m.id === 'mistral-medium-3.5')) { - allModels.push({ - id: 'mistral-medium-3.5', - name: 'Mistral Medium 3.5', - api: 'mistral-conversations', - provider: 'mistral', - baseUrl: 'https://api.mistral.ai', - reasoning: true, - input: ['text', 'image'], - cost: { - input: 1.5, - output: 7.5, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 262144, // 256k tokens - maxTokens: 262144, - }) - } - - // Add qwen3.8-max-preview to Qwen Token Plan providers until models.dev includes it - for (const qwenTpProvider of ['qwen-token-plan', 'qwen-token-plan-cn'] as const) { - if (!allModels.some((m) => m.provider === qwenTpProvider && m.id === 'qwen3.8-max-preview')) { - const baseUrl = - qwenTpProvider === 'qwen-token-plan' - ? 'https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1' - : 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1' - allModels.push({ - id: 'qwen3.8-max-preview', - name: 'Qwen3.8 Max Preview', - api: 'openai-completions', - provider: qwenTpProvider, - baseUrl, - compat: { - thinkingFormat: 'qwen', - supportsDeveloperRole: false, - supportsStore: false, - } satisfies OpenAICompletionsCompat, - reasoning: true, - input: ['text', 'image'], - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - contextWindow: 1000000, - maxTokens: 65536, - }) - } - } - - // Add "auto" alias for openrouter/auto - if (!allModels.some((m) => m.provider === 'openrouter' && m.id === 'auto')) { - allModels.push({ - id: 'auto', - name: 'Auto', - api: 'openai-completions', - provider: 'openrouter', - baseUrl: 'https://openrouter.ai/api/v1', - reasoning: true, - input: ['text', 'image'], - cost: { - // we dont know about the costs because OpenRouter auto routes to different models - // and then charges you for the underlying used model - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 2000000, - maxTokens: 30000, - }) - } - - // Add "fusion" alias for openrouter/fusion. OpenRouter exposes Fusion as a - // router alias/plugin entry point; its model metadata does not advertise - // tools, but the alias resolves to a concrete model that can invoke caller - // tools and has the openrouter:fusion server tool auto-injected. - if (!allModels.some((m) => m.provider === 'openrouter' && m.id === 'openrouter/fusion')) { - allModels.push({ - id: 'openrouter/fusion', - name: 'OpenRouter: Fusion', - api: 'openai-completions', - provider: 'openrouter', - baseUrl: 'https://openrouter.ai/api/v1', - reasoning: true, - input: ['text'], - cost: { - // we dont know about the costs because Fusion routes to multiple models - // and then charges you for the underlying used models - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, - }, - contextWindow: 1000000, - maxTokens: 30000, - }) - } - - // Azure Foundry deploys these with larger context windows than OpenAI's own short-tier defaults. - // See models-sold-directly-by-azure docs. - const AZURE_CONTEXT_WINDOW_OVERRIDES: Record = { - 'gpt-5.4': 1050000, - 'gpt-5.5': 1050000, - 'gpt-5.6-luna': 1050000, - 'gpt-5.6-sol': 1050000, - 'gpt-5.6-terra': 1050000, - } - const azureOpenAiModels: Model[] = allModels - .filter((model) => model.provider === 'openai' && model.api === 'openai-responses') - .map((model) => ({ - ...model, - api: 'azure-openai-responses', - provider: 'azure-openai-responses', - baseUrl: '', - cost: { - input: model.cost.input, - output: model.cost.output, - cacheRead: model.cost.cacheRead, - cacheWrite: model.cost.cacheWrite, - }, - contextWindow: AZURE_CONTEXT_WINDOW_OVERRIDES[model.id] ?? model.contextWindow, - })) - allModels.push(...azureOpenAiModels) - - for (const model of allModels) { - applyOpenAICompletionsCompatMetadata(model) - applyModelsDevReasoningOptionMetadata(model) - applyThinkingLevelMetadata(model) - applyStrictToolCompatMetadata(model) - applyOpenAIGrammarToolCompatMetadata(model) - applyOpenAIToolSearchMetadata(model) - applyOpenAIExplicitPromptCacheMetadata(model) - } - - // Group by provider and deduplicate by model ID - const providers: Record>> = {} - for (const model of allModels) { - if (!providers[model.provider]) { - providers[model.provider] = {} - } - // Use model ID as key to automatically deduplicate - // Only add if not already present (models.dev takes priority over OpenRouter) - if (!providers[model.provider][model.id]) { - providers[model.provider][model.id] = model - } - } - - const sortedProviderIds = Object.keys(providers).sort() - const jsonProviders: Record>> = {} - for (const providerId of sortedProviderIds) { - jsonProviders[providerId] = {} - for (const modelId of Object.keys(providers[providerId]).sort()) { - jsonProviders[providerId][modelId] = providers[providerId][modelId] - } - } - - const generatedDataProviders: Record>>> = {} - for (const providerId of sortedProviderIds) { - const models = jsonProviders[providerId] - generatedDataProviders[providerId] = {} - const apiIds = Array.from(new Set(Object.values(models).map((model) => model.api))).sort() - for (const api of apiIds) { - generatedDataProviders[providerId][api] = {} - for (const [modelId, model] of Object.entries(models)) { - if (model.api !== api) continue - generatedDataProviders[providerId][api][modelId] = model - } - } - } - - return { - providers: jsonProviders, - groupedProviders: generatedDataProviders, - sortedProviderIds, - } -} diff --git a/packages/core/src/provider/generator/models-dev-reasoning-options.ts b/packages/core/src/provider/generator/models-dev-reasoning-options.ts deleted file mode 100644 index 1a98c788..00000000 --- a/packages/core/src/provider/generator/models-dev-reasoning-options.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { ThinkingLevel, ThinkingLevelMap } from '@earendil-works/pi-ai' - -export type ModelsDevReasoningOption = - | { type: 'toggle' } - | { - type: 'effort' - values: Array< - 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'default' | null - > - } - | { type: 'budget_tokens'; min?: number; max?: number } - -const THINKING_LEVELS: readonly ThinkingLevel[] = [ - 'minimal', - 'low', - 'medium', - 'high', - 'xhigh', - 'max', -] - -/** - * Converts models.dev verified effort values into Pi's selectable thinking levels. - * Values without a Pi equivalent (`default` and JSON `null`) are intentionally - * omitted. - */ -export function getEffortThinkingLevelMap( - options: readonly ModelsDevReasoningOption[], -): ThinkingLevelMap | undefined { - const effortValues = options.flatMap((option) => (option.type === 'effort' ? option.values : [])) - if (effortValues.length === 0) return undefined - - const supported = new Set(effortValues) - if (!THINKING_LEVELS.some((level) => supported.has(level)) && !supported.has('none')) - return undefined - - const map: ThinkingLevelMap = { off: supported.has('none') ? 'none' : null } - for (const level of THINKING_LEVELS) { - map[level] = supported.has(level) ? level : null - } - return map -} diff --git a/packages/core/src/provider/model-refresh.ts b/packages/core/src/provider/model-refresh.ts new file mode 100644 index 00000000..bd6f4d03 --- /dev/null +++ b/packages/core/src/provider/model-refresh.ts @@ -0,0 +1,197 @@ +import { PI_AI_VERSION } from '@earendil-works/pi-ai' +import { getBuiltinModels, getBuiltinProviders } from '@earendil-works/pi-ai/providers/all' +import { CompatSchemasByApi } from '@earendil-works/pi-ai/providers/compat-schema' +import { ThinkingLevelMapSchema } from '@earendil-works/pi-ai/providers/model-schema' +import { + providerModelConfigSchema, + type ProviderConfigSerializable, + type ProviderRefreshUnavailableReason, + type RefreshedProviderModel, +} from '@shumai/dtos' +import { HTTPException } from 'hono/http-exception' +import { z } from 'zod' +import { ENV_MAP } from './builtin' + +type RefreshConnection = + | { unavailableReason: ProviderRefreshUnavailableReason } + | { unavailableReason: null; piProviderId: string } + +type CatalogResult = + | { status: 'unavailable'; reason: 'catalog_unavailable' } + | { status: 'ready'; models: RefreshedProviderModel[] } + +const REFRESH_TIMEOUT_MS = 10_000 +const builtinConnections = new Map>( + getBuiltinProviders().map((id) => [ + id, + new Set(getBuiltinModels(id).map(({ api, baseUrl }) => connectionKey(api, baseUrl))), + ]), +) +const catalogSchema = z.record( + z.string(), + z.looseObject({ + id: z.string().min(1), + provider: z.string(), + api: z.string(), + baseUrl: z.string(), + type: z.string().optional(), + }), +) +const compatSchemas = new Map( + Object.entries(CompatSchemasByApi).map(([api, schema]) => [api, z.fromJSONSchema(schema)]), +) +const thinkingLevelMapSchema = z.fromJSONSchema(ThinkingLevelMapSchema) +const catalogHeaderNames = new Set([ + 'user-agent', + 'editor-version', + 'editor-plugin-version', + 'copilot-integration-id', + 'nvcf-poll-seconds', +]) +const catalogHeadersSchema = z.record( + z.string().refine((name) => catalogHeaderNames.has(name.toLowerCase())), + z.string().regex(/^[\t\x20-\x7E]*$/), +) + +function normalizeBaseUrl(baseUrl?: string): string { + return baseUrl?.trim().replace(/\/+$/, '') ?? '' +} + +function connectionKey(api: string, baseUrl?: string): string { + return JSON.stringify([api, normalizeBaseUrl(baseUrl)]) +} + +function piProviderName(name: string): string { + return name === 'azure-openai-responses' ? 'azure' : name +} + +export function isProviderConfigured(name: string, config: ProviderConfigSerializable): boolean { + const key = config.apiKey?.trim() + if (key) { + const envValue = process.env[key] + if (envValue !== undefined) return Boolean(envValue.trim()) + // Existing forms accept literal keys and names such as OPENAI_API_KEY in the same field. + return !/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/.test(key) + } + + const envName = ENV_MAP[piProviderName(name)] + if (envName && process.env[envName]?.trim()) return true + if (name === 'amazon-bedrock' && config.api === 'bedrock-converse-stream') { + return Boolean( + process.env.AWS_BEARER_TOKEN_BEDROCK || + process.env.AWS_PROFILE || + (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) || + process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || + process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI || + process.env.AWS_WEB_IDENTITY_TOKEN_FILE, + ) + } + + const url = URL.parse(config.baseUrl ?? '') + return Boolean( + url && + config.api === 'openai-completions' && + (config.authHeader === false || + /^(?:localhost|127\.\d+\.\d+\.\d+|\[::1\])$/.test(url.hostname)), + ) +} + +function azureDeploymentIds(): Set { + // Pi uses model-id=deployment-name mappings for Azure's deployment-specific API. + const entries = process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP?.split(',') ?? [] + return new Set( + entries.flatMap((entry) => { + const [modelId, deployment] = entry.split('=', 2).map((value) => value.trim()) + return modelId && deployment ? [modelId] : [] + }), + ) +} + +export function getRefreshConnection( + name: string, + config: ProviderConfigSerializable, +): RefreshConnection { + const providerId = piProviderName(name) + if (providerId === 'azure' && config.api === 'azure-openai-responses') { + const endpoint = + config.baseUrl || process.env.AZURE_OPENAI_BASE_URL || process.env.AZURE_OPENAI_RESOURCE_NAME + return endpoint && azureDeploymentIds().size > 0 + ? { unavailableReason: null, piProviderId: providerId } + : { unavailableReason: 'azure_deployment_required' } + } + if ( + providerId === 'kimi-coding' && + config.api === 'anthropic-messages' && + normalizeBaseUrl(config.baseUrl) === 'https://api.kimi.com/coding' + ) { + return { unavailableReason: 'legacy_kimi_connection' } + } + + const key = connectionKey(config.api, config.baseUrl) + const namedConnections = builtinConnections.get(providerId) + if (namedConnections?.has(key)) return { unavailableReason: null, piProviderId: providerId } + // A renamed provider can still be resolved if its protocol and endpoint identify one catalog. + if (!namedConnections && config.baseUrl) { + const matches = [...builtinConnections].filter(([, connections]) => connections.has(key)) + if (matches.length === 1) return { unavailableReason: null, piProviderId: matches[0][0] } + } + return { unavailableReason: 'unsupported_connection' } +} + +export async function discoverProviderModels( + piProviderId: string, + config: ProviderConfigSerializable, +): Promise { + const url = new URL(`/api/models/providers/${encodeURIComponent(piProviderId)}`, 'https://pi.dev') + url.searchParams.set('pi-version', PI_AI_VERSION) + let catalog: z.infer + try { + const response = await fetch(url, { + headers: { Accept: 'application/json' }, + redirect: 'error', + signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS), + }) + if (response.status === 404 || response.status === 501) { + return { status: 'unavailable', reason: 'catalog_unavailable' } + } + if (!response.ok) throw new Error(`Pi catalog returned HTTP ${response.status}`) + catalog = catalogSchema.parse(await response.json()) + } catch (cause) { + throw new HTTPException(502, { message: 'Could not refresh provider models', cause }) + } + + const key = connectionKey(config.api, config.baseUrl) + const azureDeployments = piProviderId === 'azure' ? azureDeploymentIds() : undefined + const models = Object.entries(catalog).flatMap(([id, model]) => { + if ( + model.id !== id || + model.provider !== piProviderId || + (model.type && model.type !== 'chat') + ) { + return [] + } + const matches = azureDeployments + ? model.api === config.api && model.baseUrl === '' && azureDeployments.has(id) + : connectionKey(model.api, model.baseUrl) === key + if (!matches) return [] + if ( + model.compat !== undefined && + !compatSchemas.get(model.api)?.safeParse(model.compat).success + ) + return [] + if ( + model.thinkingLevelMap !== undefined && + !thinkingLevelMapSchema.safeParse(model.thinkingLevelMap).success + ) + return [] + if (model.headers !== undefined && !catalogHeadersSchema.safeParse(model.headers).success) + return [] + + // Keep omitted flags absent so Pi can apply model- and endpoint-specific defaults. + const modelConfig = providerModelConfigSchema.safeParse(model) + if (!modelConfig.success) return [] + const name = typeof model.name === 'string' && model.name ? model.name : id + return [{ modelId: id, name, config: modelConfig.data }] + }) + return { status: 'ready', models } +} diff --git a/packages/core/src/provider/provider.test.ts b/packages/core/src/provider/provider.test.ts index 35aec4eb..88c31090 100644 --- a/packages/core/src/provider/provider.test.ts +++ b/packages/core/src/provider/provider.test.ts @@ -3,46 +3,53 @@ import { setupTestDbHooks } from '@shumai/db/test' import { teamService } from '@shumai/core/src/team/team' import { agentService } from '@shumai/core/src/agent/agent' import { providerService } from './provider' -import { describe, expect, it, vi } from 'vitest' -import * as generateModelsModule from './generator/generate-models' +import { afterEach, describe, expect, it, vi } from 'vitest' import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos' import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin' import { z } from 'zod' -import modelsDevFixture from './fixtures/models-dev.json' -import openRouterFixture from './fixtures/openrouter.json' -import nvidiaFixture from './fixtures/nvidia.json' -const originalFetch = globalThis.fetch +const openaiConfig = { + api: 'openai-responses', + baseUrl: 'https://api.openai.com/v1', + apiKey: 'saved-test-key', +} satisfies ProviderConfigSerializable -function setupCatalogFetchMock() { - return vi.spyOn(globalThis, 'fetch').mockImplementation(async (input: RequestInfo | URL) => { - const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url - if (url.includes('models.dev')) { - return new Response(JSON.stringify(modelsDevFixture), { - status: 200, - headers: { 'Content-Type': 'application/json' }, - }) +const candidateConfig = { + api: openaiConfig.api, + reasoning: true, + input: ['text'], + contextWindow: 256000, + maxTokens: 16000, + cost: { input: 1, output: 2, cacheRead: 0, cacheWrite: 0 }, +} satisfies ProviderModel['config'] + +function catalogModel(id: string, options?: Record) { + return { + ...candidateConfig, + provider: 'openai', + baseUrl: openaiConfig.baseUrl, + id, + name: id, + ...options, + } +} + +function mockCatalog(models: ReturnType[]) { + const requests: Request[] = [] + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => { + const request = new Request(input, init) + requests.push(request) + if (new URL(request.url).origin !== 'https://pi.dev') { + throw new Error('Unexpected catalog host') } - if (url.includes('openrouter.ai')) { - return new Response(JSON.stringify(openRouterFixture), { - status: 200, - headers: { 'Content-Type': 'application/json' }, - }) - } - if (url.includes('nvidia')) { - return new Response(JSON.stringify(nvidiaFixture), { - status: 200, - headers: { 'Content-Type': 'application/json' }, - }) - } - if (url.includes('ai-gateway')) { - return new Response(JSON.stringify({ data: [] }), { - status: 200, - headers: { 'Content-Type': 'application/json' }, - }) - } - return originalFetch(input) + return Response.json(Object.fromEntries(models.map((model) => [model.id, model]))) }) + return requests +} + +function readyPreview(result: Awaited>) { + if (result.status !== 'ready') throw new Error('Expected refreshed models') + return result } type ProviderModel = z.infer @@ -385,182 +392,270 @@ describe('ProviderService', () => { expect((modelsAfterUpdate[1].config as { api: string }).api).toBe('anthropic-messages') }) - it('should check for updates and correctly segregate new vs existing providers', async () => { - const fetchSpy = setupCatalogFetchMock() - try { - // 1. Check updates with empty team: all discovered providers are new - const emptyTeam = await prisma.team.create({ - data: { name: 'Empty Provider Team' }, + describe('model refresh', () => { + afterEach(() => { + vi.restoreAllMocks() + vi.unstubAllEnvs() + }) + + it('reports resolved credentials and eligibility separately and preserves legacy Kimi', async () => { + vi.stubEnv('CUSTOM_OPENAI_KEY', 'a-resolved-test-key') + vi.stubEnv('UNSET_ANTHROPIC_KEY', undefined) + const team = await prisma.team.create({ data: { name: 'Providers' } }) + const configured = await providerService.create(team.id, 'OpenAI production', { + ...openaiConfig, + apiKey: 'CUSTOM_OPENAI_KEY', }) - const initialCheck = await providerService.checkUpdates(emptyTeam.id) - expect(initialCheck.totalNewProviders).toBeGreaterThan(0) - expect(initialCheck.totalNewModels).toBeGreaterThan(0) - expect(initialCheck.providers.every((p) => p.isNewProvider)).toBe(true) + const unconfigured = await providerService.create(team.id, 'anthropic', { + api: 'anthropic-messages', + baseUrl: 'https://api.anthropic.com', + apiKey: 'UNSET_ANTHROPIC_KEY', + }) + const legacyConfig = { + api: 'anthropic-messages', + baseUrl: 'https://api.kimi.com/coding', + apiKey: 'literal-kimi-key', + } satisfies ProviderConfigSerializable + const legacy = await providerService.create(team.id, 'kimi-coding', legacyConfig) + const local = await providerService.create(team.id, 'Local Ollama', { + api: 'openai-completions', + baseUrl: 'http://localhost:11434/v1', + }) + vi.stubEnv('AWS_PROFILE', 'test-profile') + const bedrock = await providerService.create(team.id, 'amazon-bedrock', { + api: 'bedrock-converse-stream', + }) + const providers = await providerService.listByTeam(team.id) + expect(providers).toHaveLength(5) + expect(providers).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + id: configured.id, + configured: true, + refreshUnavailableReason: null, + config: { ...openaiConfig, apiKey: 'CUSTOM_OPENAI_KEY' }, + }), + expect.objectContaining({ + id: unconfigured.id, + configured: false, + refreshUnavailableReason: null, + }), + expect.objectContaining({ + id: legacy.id, + configured: true, + refreshUnavailableReason: 'legacy_kimi_connection', + }), + expect.objectContaining({ + id: local.id, + configured: true, + refreshUnavailableReason: 'unsupported_connection', + }), + expect.objectContaining({ id: bedrock.id, configured: true }), + ]), + ) - // 2. With default team (which has builtin providers initialized) - const teamWithBuiltins = await teamService.ensureDefaultTeam() - - // 3. Check updates after init: existing providers should have isNewProvider: false - const afterInitCheck = await providerService.checkUpdates(teamWithBuiltins.id) - const existing = afterInitCheck.providers.find((p) => !p.isNewProvider) - expect(existing).toBeDefined() - if (existing) { - expect(existing.isNewProvider).toBe(false) - const dbModels = await providerService.listModelsByProvider( - teamWithBuiltins.id, - (await providerService.listByTeam(teamWithBuiltins.id)).find( - (p) => p.name === existing.name, - )!.id, - ) - const dbModelIds = new Set(dbModels.map((m) => m.modelId)) - for (const m of existing.models) { - expect(dbModelIds.has(m.modelId)).toBe(false) - } - } - } finally { - fetchSpy.mockRestore() - } - }) - - it('should throw an error when upstream catalog fetch fails in checkUpdates', async () => { - const team = await teamService.ensureDefaultTeam() - const spy = vi - .spyOn(generateModelsModule, 'generateModels') - .mockRejectedValueOnce(new Error('Failed to load models.dev catalog: 502 Bad Gateway')) - - await expect(providerService.checkUpdates(team.id)).rejects.toThrow( - 'Failed to load models.dev catalog: 502 Bad Gateway', - ) - spy.mockRestore() - }) - - it('should throw an error when upstream catalog is empty in checkUpdates', async () => { - const team = await teamService.ensureDefaultTeam() - const spy = vi.spyOn(generateModelsModule, 'generateModels').mockResolvedValueOnce({ - providers: {}, - groupedProviders: {}, - sortedProviderIds: [], + const requests = mockCatalog([]) + await expect(providerService.refreshModels(team.id, unconfigured.id)).resolves.toMatchObject({ + status: 'ready', + models: [], + }) + await expect(providerService.refreshModels(team.id, legacy.id)).resolves.toEqual({ + status: 'unavailable', + reason: 'legacy_kimi_connection', + }) + expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([ + '/api/models/providers/anthropic', + ]) + expect(await providerService.getById(legacy.id)).toMatchObject({ config: legacyConfig }) }) - await expect(providerService.checkUpdates(team.id)).rejects.toThrow( - 'Failed to retrieve model catalog from upstream services', - ) - spy.mockRestore() - }) + it('refreshes only the requested provider and filters existing and incompatible models', async () => { + vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey) + const team = await teamService.ensureDefaultTeam() + const providers = await providerService.listByTeam(team.id) + const openai = providers.find(({ name }) => name === 'openai')! + const existingModels = await providerService.listModelsByProvider(team.id, openai.id) + const requests = mockCatalog([ + catalogModel(existingModels[0].modelId), + catalogModel('new-model', { + compat: { supportsStrictMode: true }, + thinkingLevelMap: { low: 'low' }, + }), + catalogModel('wrong-api', { api: 'openai-completions' }), + catalogModel('wrong-url', { baseUrl: 'https://other.example/v1' }), + catalogModel('wrong-provider', { provider: 'anthropic' }), + catalogModel('not-chat', { type: 'image' }), + catalogModel('invalid-compat', { compat: { supportsStrictMode: 'yes' } }), + ]) - it('should apply sync by adding selected providers and models without modifying existing ones', async () => { - const team = await teamService.ensureDefaultTeam() - - // Create an existing provider with 1 model and a custom apiKey - const existingProvider = await providerService.create( - team.id, - 'test-existing-provider', - { api: 'openai-responses', apiKey: 'custom-api-key', baseUrl: 'https://example.com' }, - [ - { - modelId: 'existing-m1', - name: 'Existing Model 1', - config: { - api: 'openai-responses', - reasoning: false, - input: ['text'], - contextWindow: 128000, - maxTokens: 4096, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + const result = await providerService.refreshModels(team.id, openai.id) + expect(result).toMatchObject({ + status: 'ready', + models: [ + { + modelId: 'new-model', + name: 'new-model', + config: { + ...candidateConfig, + compat: { supportsStrictMode: true }, + thinkingLevelMap: { low: 'low' }, + }, }, - }, - ], - ) - - // Apply sync with 1 new provider and 1 new model on the existing provider - const syncResult = await providerService.applySync(team.id, { - providers: [ - { - name: 'test-new-synced-provider', - isNewProvider: true, - config: { - api: 'anthropic-messages', - apiKey: 'ENV_SYNC_KEY', - baseUrl: 'https://api.anthropic.com', - }, - models: [ - { - modelId: 'new-p-m1', - name: 'New Provider Model 1', - config: { - api: 'anthropic-messages', - reasoning: false, - input: ['text'], - contextWindow: 200000, - maxTokens: 8192, - cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, - }, - }, - ], - }, - { - name: 'test-existing-provider', - isNewProvider: false, - config: { api: 'openai-responses', apiKey: 'should-not-override' }, - models: [ - { - modelId: 'existing-m2', - name: 'Newly Added Model 2', - config: { - api: 'openai-responses', - reasoning: true, - input: ['text'], - contextWindow: 128000, - maxTokens: 4096, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - }, - }, - // Duplicate model that already exists: should be ignored - { - modelId: 'existing-m1', - name: 'Existing Model 1 Overwrite Attempt', - config: { - api: 'openai-responses', - reasoning: false, - input: ['text'], - contextWindow: 999999, - maxTokens: 999999, - cost: { input: 9, output: 9, cacheRead: 9, cacheWrite: 9 }, - }, - }, - ], - }, - ], + ], + }) + expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([ + '/api/models/providers/openai', + ]) + expect(requests[0].headers.has('Authorization')).toBe(false) + expect(JSON.stringify(result)).not.toContain(openaiConfig.apiKey) + expect(await providerService.listModelsByProvider(team.id, openai.id)).toEqual(existingModels) + expect(await providerService.listByTeam(team.id)).toEqual(providers) }) - expect(syncResult.addedProviders).toBe(1) - expect(syncResult.addedModels).toBe(2) + it('uses the versioned public OpenRouter catalog without sending saved credentials', async () => { + const openRouterKey = 'saved-openrouter-test-key' + vi.stubEnv('SHUMAI_TEST_OPENROUTER_KEY', openRouterKey) + const team = await prisma.team.create({ data: { name: 'OpenRouter' } }) + const baseUrl = 'https://openrouter.ai/api/v1' + const api = 'openai-completions' as const + const provider = await providerService.create(team.id, 'openrouter', { + api, + baseUrl: baseUrl + '/', + apiKey: 'SHUMAI_TEST_OPENROUTER_KEY', + }) + const modelId = 'org/new-openrouter-model' + const requests: Request[] = [] + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => { + const request = new Request(input, init) + requests.push(request) + return Response.json({ + [modelId]: { ...catalogModel(modelId, { api, baseUrl }), provider: 'openrouter' }, + }) + }) - // Verify existing provider config was NOT modified - const reloadedExisting = await providerService.getById(existingProvider.id) - expect((reloadedExisting?.config as { apiKey: string }).apiKey).toBe('custom-api-key') + const { models } = readyPreview(await providerService.refreshModels(team.id, provider.id)) + expect(models.map(({ modelId }) => modelId)).toEqual([modelId]) + expect(requests.map(({ url }) => url)).toEqual([ + 'https://pi.dev/api/models/providers/openrouter?pi-version=1.7.0', + ]) + expect(requests[0].headers.has('Authorization')).toBe(false) - // Verify existing model was NOT modified - const existingModels = await providerService.listModelsByProvider(team.id, existingProvider.id) - expect(existingModels).toHaveLength(2) - const m1 = existingModels.find((m) => m.modelId === 'existing-m1') - expect(m1?.name).toBe('Existing Model 1') - expect((m1?.config as { contextWindow: number }).contextWindow).toBe(128000) + const customProvider = await providerService.update(team.id, provider.id, { + ...provider.config, + baseUrl: 'https://openrouter-proxy.example/api/v1', + }) + await expect(providerService.refreshModels(team.id, customProvider.id)).resolves.toEqual({ + status: 'unavailable', + reason: 'unsupported_connection', + }) + expect(requests).toHaveLength(1) + }) - // Verify newly added model on existing provider - const m2 = existingModels.find((m) => m.modelId === 'existing-m2') - expect(m2).toBeDefined() - expect(m2?.name).toBe('Newly Added Model 2') + it('distinguishes a successful empty preview from an upstream error', async () => { + vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey) + const team = await teamService.ensureDefaultTeam() + const provider = (await providerService.listByTeam(team.id)).find( + ({ name }) => name === 'openai', + )! + mockCatalog([]) + await expect(providerService.refreshModels(team.id, provider.id)).resolves.toMatchObject({ + status: 'ready', + models: [], + }) + vi.restoreAllMocks() + const fetchMock = vi.spyOn(globalThis, 'fetch') + fetchMock.mockResolvedValueOnce(new Response(null, { status: 404 })) + await expect(providerService.refreshModels(team.id, provider.id)).resolves.toEqual({ + status: 'unavailable', + reason: 'catalog_unavailable', + }) + fetchMock.mockResolvedValueOnce(Response.json({ error: 'malformed catalog' })) + await expect(providerService.refreshModels(team.id, provider.id)).rejects.toMatchObject({ + status: 502, + }) + fetchMock.mockRejectedValueOnce(new DOMException('Timed out', 'TimeoutError')) - // Verify newly added provider - const providers = await providerService.listByTeam(team.id) - const newProvider = providers.find((p) => p.name === 'test-new-synced-provider') - expect(newProvider).toBeDefined() - expect(newProvider?.isBuiltin).toBe(true) - expect((newProvider?.config as { apiKey: string }).apiKey).toBe('ENV_SYNC_KEY') + await expect(providerService.refreshModels(team.id, provider.id)).rejects.toMatchObject({ + status: 502, + }) + }) - const newProviderModels = await providerService.listModelsByProvider(team.id, newProvider!.id) - expect(newProviderModels).toHaveLength(1) - expect(newProviderModels[0].modelId).toBe('new-p-m1') + it('imports only the selected models once and preserves existing models and settings', async () => { + vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey) + const team = await teamService.ensureDefaultTeam() + const provider = (await providerService.listByTeam(team.id)).find( + ({ name }) => name === 'openai', + )! + const original = await providerService.getById(provider.id) + const existing = await providerService.listModelsByProvider(team.id, provider.id) + mockCatalog([catalogModel('new-model'), catalogModel('unselected-model')]) + const preview = readyPreview(await providerService.refreshModels(team.id, provider.id)) + const selection = { providerUpdatedAt: preview.providerUpdatedAt, modelIds: ['new-model'] } + + await expect(providerService.importModels(team.id, provider.id, selection)).resolves.toEqual({ + addedModels: 1, + }) + await expect(providerService.importModels(team.id, provider.id, selection)).resolves.toEqual({ + addedModels: 0, + }) + expect(await providerService.listModelsByProvider(team.id, provider.id)).toEqual([ + expect.objectContaining({ modelId: 'new-model', config: candidateConfig }), + ...existing, + ]) + expect(await providerService.getById(provider.id)).toEqual(original) + }) + + it('rejects out-of-team, unknown, and stale selections without adding models', async () => { + const team = await prisma.team.create({ data: { name: 'Refresh Team' } }) + const otherTeam = await prisma.team.create({ data: { name: 'Other Team' } }) + const provider = await providerService.create(team.id, 'openai', openaiConfig) + const requests = mockCatalog([catalogModel('new-model')]) + await expect(providerService.refreshModels(otherTeam.id, provider.id)).rejects.toMatchObject({ + status: 404, + }) + expect(requests).toHaveLength(0) + + const preview = readyPreview(await providerService.refreshModels(team.id, provider.id)) + const selection = { providerUpdatedAt: preview.providerUpdatedAt, modelIds: ['new-model'] } + await expect( + providerService.importModels(otherTeam.id, provider.id, selection), + ).rejects.toMatchObject({ status: 404 }) + await expect( + providerService.importModels(team.id, provider.id, { + ...selection, + modelIds: ['new-model', 'unknown'], + }), + ).rejects.toMatchObject({ status: 409 }) + + await providerService.update(team.id, provider.id, { ...openaiConfig, apiKey: 'changed-key' }) + await expect( + providerService.importModels(team.id, provider.id, selection), + ).rejects.toMatchObject({ status: 409 }) + expect(await providerService.listModelsByProvider(team.id, provider.id)).toEqual([]) + }) + + it('refreshes legacy Azure connections using only configured deployment mappings', async () => { + vi.stubEnv('AZURE_OPENAI_DEPLOYMENT_NAME_MAP', undefined) + const team = await prisma.team.create({ data: { name: 'Azure models' } }) + const provider = await providerService.create(team.id, 'azure-openai-responses', { + api: 'azure-openai-responses', + baseUrl: 'https://example.openai.azure.com/openai/v1', + }) + const azure = { provider: 'azure', api: 'azure-openai-responses', baseUrl: '' } + const requests = mockCatalog([ + catalogModel('gpt-deployed', azure), + catalogModel('gpt-unmapped', azure), + ]) + await expect(providerService.refreshModels(team.id, provider.id)).resolves.toEqual({ + status: 'unavailable', + reason: 'azure_deployment_required', + }) + vi.stubEnv('AZURE_OPENAI_DEPLOYMENT_NAME_MAP', 'gpt-deployed=team-deployment') + const preview = readyPreview(await providerService.refreshModels(team.id, provider.id)) + expect(preview.models.map(({ modelId }) => modelId)).toEqual(['gpt-deployed']) + expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([ + '/api/models/providers/azure', + ]) + }) }) }) diff --git a/packages/core/src/provider/provider.ts b/packages/core/src/provider/provider.ts index e942e574..9390b7b2 100644 --- a/packages/core/src/provider/provider.ts +++ b/packages/core/src/provider/provider.ts @@ -1,22 +1,16 @@ import { prisma } from '@shumai/db' import { CreateModelRequest, + ImportProviderModelsRequest, ProviderConfigSerializable, + ProviderModelRefreshResponse, providerModelSchema, - SyncApplyRequest, - SyncApplyResponse, - SyncCheckResponse, - SyncModelItem, - SyncProviderItem, UpdateModelRequest, } from '@shumai/dtos' -import { - ENV_MAP, - getBuiltinProvidersMap, - PRIORITY_PROVIDERS, -} from '@shumai/core/src/provider/builtin' -import { generateModels } from '@shumai/core/src/provider/generator/generate-models' +import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin' +import { HTTPException } from 'hono/http-exception' import { z } from 'zod' +import { discoverProviderModels, getRefreshConnection, isProviderConfigured } from './model-refresh' type ProviderModel = z.infer @@ -70,11 +64,23 @@ export class ProviderService { orderBy: { id: 'desc' }, }) - return providers.map((p) => ({ - ...p, - modelsCount: p._count.models, - _count: undefined, - })) + return providers.map( + ({ _count, id, teamId, name, config, isBuiltin, createdAt, updatedAt }) => { + const connection = getRefreshConnection(name, config) + return { + id, + teamId, + name, + config, + isBuiltin, + createdAt, + updatedAt, + modelsCount: _count.models, + configured: isProviderConfigured(name, config), + refreshUnavailableReason: connection.unavailableReason, + } + }, + ) } async getById(id: string) { @@ -124,6 +130,11 @@ export class ProviderService { name?: string, ) { return this.prismaClient.$transaction(async (tx) => { + const provider = await tx.provider.update({ + where: { id, teamId }, + data: { config, ...(name ? { name } : {}) }, + }) + if (models !== undefined) { const existingModels = await tx.model.findMany({ where: { providerId: id }, @@ -189,15 +200,7 @@ export class ProviderService { } } - // Update provider config and optional name - return tx.provider.update({ - where: { id, teamId }, - data: { - config, - ...(name ? { name } : {}), - }, - include: { models: true }, - }) + return { ...provider, models: await tx.model.findMany({ where: { providerId: id } }) } }) } @@ -305,179 +308,66 @@ export class ProviderService { }) } - async checkUpdates(teamId: string): Promise { - const catalog = await generateModels({ strict: true, timeoutMs: 30000 }) - - if (!catalog || catalog.sortedProviderIds.length === 0) { - throw new Error('Failed to retrieve model catalog from upstream services') - } - - const existingProviders = await this.prismaClient.provider.findMany({ - where: { teamId }, - include: { models: true }, + async refreshModels(teamId: string, providerId: string): Promise { + const provider = await this.prismaClient.provider.findUnique({ + where: { id: providerId, teamId }, + include: { models: { select: { modelId: true } } }, }) + if (!provider) throw new HTTPException(404, { message: 'Provider not found' }) - const existingProviderMap = new Map() - for (const p of existingProviders) { - existingProviderMap.set(p.name, p) + const connection = getRefreshConnection(provider.name, provider.config) + if (connection.unavailableReason) { + return { status: 'unavailable', reason: connection.unavailableReason } } - - const items: SyncProviderItem[] = [] - let totalNewProviders = 0 - let totalNewModels = 0 - - for (const providerId of catalog.sortedProviderIds) { - const modelsMap = catalog.providers[providerId] - if (!modelsMap) continue - const modelList = Object.values(modelsMap) - if (modelList.length === 0) continue - - const existingProvider = existingProviderMap.get(providerId) - - if (!existingProvider) { - const firstModel = modelList[0] - const newModels: SyncModelItem[] = modelList.map((m) => ({ - modelId: m.id, - name: m.name || m.id, - config: { - api: m.api as ProviderConfigSerializable['api'], - reasoning: m.reasoning ?? false, - input: (m.input ?? ['text']) as ('text' | 'image')[], - contextWindow: m.contextWindow, - maxTokens: m.maxTokens, - cost: { - input: m.cost?.input ?? 0, - output: m.cost?.output ?? 0, - cacheRead: m.cost?.cacheRead ?? 0, - cacheWrite: m.cost?.cacheWrite ?? 0, - }, - }, - })) - - items.push({ - name: providerId, - isNewProvider: true, - config: { - api: firstModel.api as ProviderConfigSerializable['api'], - baseUrl: firstModel.baseUrl, - apiKey: ENV_MAP[providerId] || '', - }, - models: newModels, - }) - - totalNewProviders++ - totalNewModels += newModels.length - } else { - const existingModelIds = new Set(existingProvider.models.map((m) => m.modelId)) - const newModels: SyncModelItem[] = [] - - for (const m of modelList) { - if (!existingModelIds.has(m.id)) { - newModels.push({ - modelId: m.id, - name: m.name || m.id, - config: { - api: m.api as ProviderConfigSerializable['api'], - reasoning: m.reasoning ?? false, - input: (m.input ?? ['text']) as ('text' | 'image')[], - contextWindow: m.contextWindow, - maxTokens: m.maxTokens, - cost: { - input: m.cost?.input ?? 0, - output: m.cost?.output ?? 0, - cacheRead: m.cost?.cacheRead ?? 0, - cacheWrite: m.cost?.cacheWrite ?? 0, - }, - }, - }) - } - } - - if (newModels.length > 0) { - items.push({ - name: providerId, - isNewProvider: false, - config: existingProvider.config as ProviderConfigSerializable, - models: newModels, - }) - totalNewModels += newModels.length - } - } - } - - items.sort((a, b) => { - const indexA = PRIORITY_PROVIDERS.indexOf(a.name) - const indexB = PRIORITY_PROVIDERS.indexOf(b.name) - if (indexA !== -1 && indexB !== -1) return indexA - indexB - if (indexA !== -1) return -1 - if (indexB !== -1) return 1 - return a.name.localeCompare(b.name) - }) - + const catalog = await discoverProviderModels(connection.piProviderId, provider.config) + if (catalog.status === 'unavailable') return catalog + const existingIds = new Set(provider.models.map(({ modelId }) => modelId)) return { - providers: items, - totalNewProviders, - totalNewModels, + status: 'ready', + providerUpdatedAt: provider.updatedAt.toISOString(), + models: catalog.models.filter(({ modelId }) => !existingIds.has(modelId)), } } - async applySync(teamId: string, payload: SyncApplyRequest): Promise { - let addedProviders = 0 - let addedModels = 0 - - await this.prismaClient.$transaction(async (tx) => { - for (const providerItem of payload.providers) { - let providerId: string - - if (providerItem.isNewProvider) { - const existing = await tx.provider.findFirst({ - where: { teamId, name: providerItem.name }, - }) - if (!existing) { - const created = await tx.provider.create({ - data: { - teamId, - name: providerItem.name, - isBuiltin: true, - config: providerItem.config, - }, - }) - providerId = created.id - addedProviders++ - } else { - providerId = existing.id - } - } else { - const existing = await tx.provider.findFirst({ - where: { teamId, name: providerItem.name }, - }) - if (!existing) continue - providerId = existing.id - } - - for (const modelItem of providerItem.models) { - const existingModel = await tx.model.findFirst({ - where: { - providerId, - modelId: modelItem.modelId, - }, - }) - if (!existingModel) { - await tx.model.create({ - data: { - providerId, - modelId: modelItem.modelId, - name: modelItem.name || modelItem.modelId, - config: modelItem.config, - }, - }) - addedModels++ - } - } - } + async importModels( + teamId: string, + providerId: string, + { modelIds, providerUpdatedAt }: ImportProviderModelsRequest, + ) { + const provider = await this.prismaClient.provider.findUnique({ + where: { id: providerId, teamId }, + include: { models: { where: { modelId: { in: modelIds } }, select: { modelId: true } } }, }) + if (!provider) throw new HTTPException(404, { message: 'Provider not found' }) + const staleSelection = () => + new HTTPException(409, { message: 'Refresh the model list before importing' }) + if (provider.updatedAt.toISOString() !== providerUpdatedAt) throw staleSelection() + const existingIds = new Set(provider.models.map(({ modelId }) => modelId)) + const newIds = new Set(modelIds.filter((modelId) => !existingIds.has(modelId))) + if (newIds.size === 0) return { addedModels: 0 } - return { addedProviders, addedModels } + const connection = getRefreshConnection(provider.name, provider.config) + if (connection.unavailableReason) throw staleSelection() + const catalog = await discoverProviderModels(connection.piProviderId, provider.config) + if (catalog.status === 'unavailable') throw staleSelection() + const models = catalog.models.filter(({ modelId }) => newIds.has(modelId)) + if (models.length !== newIds.size) throw staleSelection() + + return this.prismaClient.$transaction(async (tx) => { + // The network request finishes before we lock the connection for the insert. + const [locked] = await tx.$queryRaw<{ updatedAt: Date }[]>` + SELECT updated_at AS "updatedAt" FROM providers + WHERE id = ${providerId} AND team_id = ${teamId} FOR NO KEY UPDATE + ` + if (!locked) throw new HTTPException(404, { message: 'Provider not found' }) + if (locked.updatedAt.toISOString() !== providerUpdatedAt) throw staleSelection() + + const { count } = await tx.model.createMany({ + data: models.map(({ modelId, name, config }) => ({ providerId, modelId, name, config })), + skipDuplicates: true, + }) + return { addedModels: count } + }) } } diff --git a/packages/dtos/package.json b/packages/dtos/package.json index 5500fc52..6028d9af 100644 --- a/packages/dtos/package.json +++ b/packages/dtos/package.json @@ -6,8 +6,8 @@ "main": "./src/index.ts", "types": "./src/index.ts", "dependencies": { - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "zod": "4.5.4" } } diff --git a/packages/dtos/src/provider.ts b/packages/dtos/src/provider.ts index 3c964de3..c0dedfd0 100644 --- a/packages/dtos/src/provider.ts +++ b/packages/dtos/src/provider.ts @@ -13,6 +13,10 @@ export const KNOWN_APIS = [ 'google-vertex', ] as const +const jsonObjectSchema = z + .record(z.string(), z.unknown()) + .refine((value) => z.json().safeParse(value).success) + // We define a serializable version of ProviderConfig for our API and DB // as the original ProviderConfig interface includes non-serializable fields (functions) export const providerModelConfigSchema = z.object({ @@ -21,6 +25,9 @@ export const providerModelConfigSchema = z.object({ input: z.array(z.enum(['text', 'image'])).default(['text']), contextWindow: z.number().int().positive().default(128000), maxTokens: z.number().int().positive().default(4096), + compat: jsonObjectSchema.optional(), + thinkingLevelMap: jsonObjectSchema.optional(), + headers: z.record(z.string(), z.string()).optional(), cost: z.object({ input: z.number().nonnegative().default(0), output: z.number().nonnegative().default(0), @@ -78,60 +85,58 @@ export const updateModelRequestSchema = z.object({ export type UpdateModelRequest = z.infer +export const providerRefreshUnavailableReasonSchema = z.enum([ + 'unsupported_connection', + 'legacy_kimi_connection', + 'azure_deployment_required', + 'catalog_unavailable', +]) + +export type ProviderRefreshUnavailableReason = z.infer< + typeof providerRefreshUnavailableReasonSchema +> + export const providerResponseSchema = z.object({ id: z.string(), + teamId: z.string(), name: z.string(), isBuiltin: z.boolean(), config: providerConfigSchema, models: z.array(providerModelSchema).optional(), modelsCount: z.number().optional(), + configured: z.boolean(), + refreshUnavailableReason: providerRefreshUnavailableReasonSchema.nullable(), createdAt: z.date(), updatedAt: z.date(), }) export type ProviderResponse = z.infer -export const syncModelItemSchema = z.object({ - modelId: z.string().min(1), - name: z.string().default(''), - config: providerModelConfigSchema, +export const refreshedProviderModelSchema = createModelRequestSchema.pick({ + modelId: true, + name: true, + config: true, }) -export type SyncModelItem = z.infer +export type RefreshedProviderModel = z.infer -export const syncProviderItemSchema = z.object({ - name: z.string(), - isNewProvider: z.boolean(), - config: providerConfigSchema, - models: z.array(syncModelItemSchema), +export const providerModelRefreshResponseSchema = z.discriminatedUnion('status', [ + z.object({ + status: z.literal('ready'), + providerUpdatedAt: z.iso.datetime(), + models: z.array(refreshedProviderModelSchema), + }), + z.object({ + status: z.literal('unavailable'), + reason: providerRefreshUnavailableReasonSchema, + }), +]) + +export type ProviderModelRefreshResponse = z.infer + +export const importProviderModelsRequestSchema = z.object({ + providerUpdatedAt: z.iso.datetime(), + modelIds: z.array(z.string().min(1)).min(1), }) -export type SyncProviderItem = z.infer - -export const syncCheckResponseSchema = z.object({ - providers: z.array(syncProviderItemSchema), - totalNewProviders: z.number(), - totalNewModels: z.number(), -}) - -export type SyncCheckResponse = z.infer - -export const syncApplyRequestSchema = z.object({ - providers: z.array( - z.object({ - name: z.string(), - isNewProvider: z.boolean(), - config: providerConfigSchema, - models: z.array(syncModelItemSchema), - }), - ), -}) - -export type SyncApplyRequest = z.infer - -export const syncApplyResponseSchema = z.object({ - addedProviders: z.number(), - addedModels: z.number(), -}) - -export type SyncApplyResponse = z.infer +export type ImportProviderModelsRequest = z.infer diff --git a/packages/e2e/package.json b/packages/e2e/package.json index 1ea1bf24..7811dff9 100644 --- a/packages/e2e/package.json +++ b/packages/e2e/package.json @@ -4,8 +4,8 @@ "private": true, "type": "module", "dependencies": { - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@google/genai": "2.28.0", "@shumai/agent": "workspace:*", "@shumai/core": "workspace:*", diff --git a/packages/webui/components/settings/ProvidersSettings.tsx b/packages/webui/components/settings/ProvidersSettings.tsx index 3f2f3671..693bb7e5 100644 --- a/packages/webui/components/settings/ProvidersSettings.tsx +++ b/packages/webui/components/settings/ProvidersSettings.tsx @@ -38,17 +38,19 @@ import { SelectValue, } from '@/ui/components/ui/select' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/ui/components/ui/tabs' -import { providerConfigSchema, KNOWN_APIS, type SyncCheckResponse } from '@shumai/dtos' +import { + providerConfigSchema, + KNOWN_APIS, + type ProviderRefreshUnavailableReason, + type RefreshedProviderModel, +} from '@shumai/dtos' import { useForm } from '@tanstack/react-form' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { InferResponseType } from 'hono/client' import { - ChevronRight, Cpu, Globe, - Info, Loader2, - Maximize2, MoreVertical, Plus, RefreshCw, @@ -61,7 +63,7 @@ import { toast } from 'sonner' import { z } from 'zod' import { m } from '@/ui/paraglide/messages.js' import { ModelFormDialog, ModelFormValues } from './ModelFormDialog' -import { SyncProvidersDialog } from './SyncProvidersDialog' +import { RefreshProviderModelsDialog } from './RefreshProviderModelsDialog' const API_PROTOCOL_LABELS: Record<(typeof KNOWN_APIS)[number], string> = { 'openai-completions': 'OpenAI Completions', @@ -87,6 +89,19 @@ interface ProvidersSettingsProps { teamId: string } +function refreshUnavailableText(reason: ProviderRefreshUnavailableReason) { + switch (reason) { + case 'legacy_kimi_connection': + return m.provider_refresh_legacy_kimi_connection() + case 'azure_deployment_required': + return m.provider_refresh_azure_deployment_required() + case 'catalog_unavailable': + return m.provider_refresh_catalog_unavailable() + case 'unsupported_connection': + return m.provider_refresh_unsupported_connection() + } +} + export function ProvidersSettings({ teamId }: ProvidersSettingsProps) { const queryClient = useQueryClient() const [editingProviderId, setEditingProviderId] = useState(null) @@ -94,31 +109,40 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) { const [searchQuery, setSearchQuery] = useState('') const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false) const [providerToDelete, setProviderToDelete] = useState(null) - const [isSyncDialogOpen, setIsSyncDialogOpen] = useState(false) - const [syncData, setSyncData] = useState(null) + const [preview, setPreview] = useState<{ + provider: Provider + providerUpdatedAt: string + models: RefreshedProviderModel[] + trigger: HTMLButtonElement + } | null>(null) - // Check updates mutation - const syncCheckMutation = useMutation({ - mutationFn: async () => { - const res = await client.api.teams[':teamId'].providers['sync-check'].$post({ - param: { teamId }, + const refreshMutation = useMutation({ + mutationFn: async ({ provider }: { provider: Provider; trigger: HTMLButtonElement }) => { + const res = await client.api.teams[':teamId'].providers[':providerId'].models.refresh.$post({ + param: { teamId, providerId: provider.id }, }) - if (!res.ok) { - const err = await res.json().catch(() => ({ message: 'Failed to check updates' })) - throw new Error((err as { message?: string }).message || 'Failed to check updates') - } - return await res.json() + if (!res.ok) throw new Error(m.provider_refresh_failed()) + return res.json() }, - onSuccess: (data) => { - if (data.totalNewModels === 0 && data.totalNewProviders === 0) { - toast.info(m.sync_providers_up_to_date()) + onSuccess: (data, { provider, trigger }) => { + if (data.status === 'unavailable') { + toast.info(refreshUnavailableText(data.reason)) + void queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] }) return } - setSyncData(data) - setIsSyncDialogOpen(true) + if (data.models.length === 0) { + toast.info(m.provider_refresh_no_new_models({ name: provider.name })) + return + } + setPreview({ + provider, + providerUpdatedAt: data.providerUpdatedAt, + models: data.models, + trigger, + }) }, - onError: (error: Error) => { - toast.error(error.message) + onError: () => { + toast.error(m.provider_refresh_failed()) }, }) @@ -143,9 +167,10 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) { const filteredProviders = useMemo(() => { if (!providers) return [] - if (!searchQuery.trim()) return providers - const query = searchQuery.toLowerCase() - return providers.filter((p) => p.name.toLowerCase().includes(query)) + const query = searchQuery.trim().toLowerCase() + return providers + .filter((p) => p.name.toLowerCase().includes(query)) + .sort((a, b) => Number(b.configured) - Number(a.configured)) }, [providers, searchQuery]) // Create Mutation @@ -207,120 +232,40 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) { return (
-
-
-

- - {m.configured_ai_providers()} -

-
- - -
-
- -
+
+
setSearchQuery(e.target.value)} className="pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0" />
+
{filteredProviders.map((provider) => ( - setEditingProviderId(provider.id)} - > - -
-
- -
-
-
- {provider.name} -
-
- - - {provider.config.api} - - {provider.config.baseUrl && ( - - - - - {provider.config.baseUrl} - - - )} - - - - {m.n_models_count({ count: provider.modelsCount })} - -
-
-
- -
- - e.stopPropagation()}> - - - - { - e.stopPropagation() - setProviderToDelete(provider) - setIsDeleteDialogOpen(true) - }} - className="text-destructive focus:text-destructive gap-2 cursor-pointer" - > - {m.delete()} - - - - -
-
-
+ provider={provider} + isRefreshing={ + refreshMutation.isPending && refreshMutation.variables?.provider.id === provider.id + } + refreshInProgress={refreshMutation.isPending} + onEdit={() => setEditingProviderId(provider.id)} + onRefresh={(trigger) => refreshMutation.mutate({ provider, trigger })} + onDelete={() => { + setProviderToDelete(provider) + setIsDeleteDialogOpen(true) + }} + /> ))} {providers?.length === 0 && ( @@ -400,19 +345,123 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) { - setIsSyncDialogOpen(false)} - teamId={teamId} - syncData={syncData} - onSuccess={() => { - queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] }) - }} - /> + {preview && ( + setPreview(null)} + onCloseAutoFocus={() => preview.trigger.focus()} + onImported={() => { + void queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] }) + }} + /> + )}
) } +function ProviderCard({ + provider, + isRefreshing, + refreshInProgress, + onEdit, + onRefresh, + onDelete, +}: { + provider: Provider + isRefreshing: boolean + refreshInProgress: boolean + onEdit: () => void + onRefresh: (button: HTMLButtonElement) => void + onDelete: () => void +}) { + const unavailable = provider.refreshUnavailableReason + const reasonId = `provider-refresh-reason-${provider.id}` + const displayUrl = provider.config.baseUrl?.replace(/^https?:\/\//, '') + return ( + + + + +
+
+ + {provider.configured && ( + + {m.provider_configured_badge()} + + )} +
+
+ {API_PROTOCOL_LABELS[provider.config.api] ?? provider.config.api} + + {m.n_models_count({ count: provider.modelsCount })} +
+ {unavailable ? ( +

+ {refreshUnavailableText(unavailable)} +

+ ) : displayUrl ? ( +

+ {displayUrl} +

+ ) : null} +
+
+ + + + + + + {m.edit()} + + {m.delete()} + + + +
+
+
+ ) +} + // --------------------------------------------------------------------------- // Create Provider Dialog // --------------------------------------------------------------------------- diff --git a/packages/webui/components/settings/RefreshProviderModelsDialog.test.tsx b/packages/webui/components/settings/RefreshProviderModelsDialog.test.tsx new file mode 100644 index 00000000..a60a9e4d --- /dev/null +++ b/packages/webui/components/settings/RefreshProviderModelsDialog.test.tsx @@ -0,0 +1,107 @@ +// @vitest-environment happy-dom +import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import type { RefreshedProviderModel } from '@shumai/dtos' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { RefreshProviderModelsDialog } from './RefreshProviderModelsDialog' + +const { importModels } = vi.hoisted(() => ({ importModels: vi.fn() })) + +vi.mock('@/ui/api/client', () => ({ + client: { + api: { + teams: { + ':teamId': { + providers: { ':providerId': { models: { import: { $post: importModels } } } }, + }, + }, + }, + }, +})) + +const models = Array.from({ length: 6 }, (_, index): RefreshedProviderModel => ({ + modelId: `model-${index + 1}`, + name: `Model ${index + 1}`, + config: { + api: 'openai-responses', + reasoning: false, + input: ['text'], + contextWindow: 128000, + maxTokens: 4096, + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + }, +})) + +function renderDialog() { + const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }) + const onClose = vi.fn() + const onImported = vi.fn() + render( + + + , + ) + return { onClose, onImported } +} + +describe('RefreshProviderModelsDialog', () => { + afterEach(() => { + cleanup() + importModels.mockReset() + }) + + it('opens a single-provider preview with selectable models and an empty selection', () => { + renderDialog() + expect(screen.getByRole('heading', { name: 'New models for OpenAI' })).toBeTruthy() + expect(screen.getByText('Select the models you want to add.')).toBeTruthy() + expect(screen.getAllByRole('checkbox')).toHaveLength(models.length) + expect(screen.getByRole('button', { name: 'Add selected' }).hasAttribute('disabled')).toBe(true) + }) + + it('filters models and selects or deselects the visible results', () => { + renderDialog() + const search = screen.getByRole('textbox') + fireEvent.change(search, { target: { value: 'model-2' } }) + expect(screen.queryByText('Model 1')).toBeNull() + expect(screen.getAllByRole('checkbox')).toHaveLength(1) + + fireEvent.click(screen.getByRole('button', { name: 'Select visible' })) + expect(screen.getByRole('checkbox').getAttribute('aria-checked')).toBe('true') + expect(screen.getByRole('button', { name: 'Add selected (1)' })).toBeTruthy() + fireEvent.click(screen.getByRole('button', { name: 'Deselect visible' })) + expect(screen.getByRole('checkbox').getAttribute('aria-checked')).toBe('false') + expect(screen.getByRole('button', { name: 'Add selected' }).hasAttribute('disabled')).toBe(true) + }) + + it('imports only the selected models into the previewed provider', async () => { + importModels.mockResolvedValueOnce(Response.json({ addedModels: 1 })) + const { onClose, onImported } = renderDialog() + fireEvent.click(screen.getAllByRole('checkbox')[1]) + fireEvent.click(screen.getByRole('button', { name: 'Add selected (1)' })) + + await waitFor(() => expect(onClose).toHaveBeenCalledOnce()) + expect(onImported).toHaveBeenCalledOnce() + expect(importModels).toHaveBeenCalledWith({ + param: { teamId: 'team-1', providerId: 'provider-1' }, + json: { providerUpdatedAt: '2026-11-29T09:15:00.000Z', modelIds: ['model-2'] }, + }) + }) + + it('shows an actionable error when the preview becomes stale', async () => { + importModels.mockResolvedValueOnce(new Response(null, { status: 409 })) + const { onImported } = renderDialog() + fireEvent.click(screen.getAllByRole('checkbox')[0]) + fireEvent.click(screen.getByRole('button', { name: 'Add selected (1)' })) + expect((await screen.findByRole('alert')).textContent).toContain('Refresh models again.') + expect(onImported).not.toHaveBeenCalled() + }) +}) diff --git a/packages/webui/components/settings/RefreshProviderModelsDialog.tsx b/packages/webui/components/settings/RefreshProviderModelsDialog.tsx new file mode 100644 index 00000000..6702f0e2 --- /dev/null +++ b/packages/webui/components/settings/RefreshProviderModelsDialog.tsx @@ -0,0 +1,187 @@ +import { useState } from 'react' +import { useMutation } from '@tanstack/react-query' +import { Loader2 } from 'lucide-react' +import { toast } from 'sonner' +import type { RefreshedProviderModel } from '@shumai/dtos' +import { client } from '@/ui/api/client' +import { Badge } from '@/ui/components/ui/badge' +import { Button } from '@/ui/components/ui/button' +import { Checkbox } from '@/ui/components/ui/checkbox' +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@/ui/components/ui/dialog' +import { Input } from '@/ui/components/ui/input' +import { ScrollArea } from '@/ui/components/ui/scroll-area' +import { m } from '@/ui/paraglide/messages.js' + +interface RefreshProviderModelsDialogProps { + teamId: string + providerId: string + providerUpdatedAt: string + providerName: string + models: RefreshedProviderModel[] + onClose: () => void + onCloseAutoFocus: () => void + onImported: () => void +} + +export function RefreshProviderModelsDialog({ + teamId, + providerId, + providerUpdatedAt, + providerName, + models, + onClose, + onCloseAutoFocus, + onImported, +}: RefreshProviderModelsDialogProps) { + const [selectedIds, setSelectedIds] = useState(() => new Set()) + const [search, setSearch] = useState('') + const query = search.trim().toLowerCase() + const filteredModels = models.filter( + ({ name, modelId }) => + name.toLowerCase().includes(query) || modelId.toLowerCase().includes(query), + ) + const allVisibleSelected = + filteredModels.length > 0 && filteredModels.every(({ modelId }) => selectedIds.has(modelId)) + + const importMutation = useMutation({ + mutationFn: async () => { + const res = await client.api.teams[':teamId'].providers[':providerId'].models.import.$post({ + param: { teamId, providerId }, + json: { providerUpdatedAt, modelIds: [...selectedIds] }, + }) + if (res.status === 409) throw new Error(m.provider_refresh_stale()) + if (!res.ok) throw new Error(m.provider_refresh_import_failed()) + return res.json() + }, + onSuccess: ({ addedModels }) => { + if (addedModels > 0) { + toast.success(m.provider_refresh_imported({ count: addedModels, name: providerName })) + } else { + toast.info(m.provider_refresh_no_new_models({ name: providerName })) + } + onImported() + onClose() + }, + }) + + function selectModels(modelIds: string[], selected: boolean) { + setSelectedIds((previous) => { + const next = new Set(previous) + for (const modelId of modelIds) { + if (selected) next.add(modelId) + else next.delete(modelId) + } + return next + }) + } + + return ( + !open && !importMutation.isPending && onClose()}> + { + event.preventDefault() + onCloseAutoFocus() + }} + > + + {m.provider_refresh_dialog_title({ name: providerName })} + {m.provider_refresh_dialog_description()} + + {models.length > 5 && ( +
+ setSearch(event.target.value)} + /> + +
+ )} + +
    + {filteredModels.map(({ name, modelId, config }) => ( +
  • + +
  • + ))} +
+ {filteredModels.length === 0 && ( +

{m.no_matches_found()}

+ )} +
+ {importMutation.error && ( +

+ {importMutation.error.message} +

+ )} + + + + +
+
+ ) +} diff --git a/packages/webui/components/settings/SyncProvidersDialog.test.tsx b/packages/webui/components/settings/SyncProvidersDialog.test.tsx deleted file mode 100644 index 69676b9e..00000000 --- a/packages/webui/components/settings/SyncProvidersDialog.test.tsx +++ /dev/null @@ -1,275 +0,0 @@ -// @vitest-environment happy-dom -import { cleanup, render, screen, fireEvent } from '@testing-library/react' -import React from 'react' -import { afterEach, describe, expect, it, vi } from 'vitest' -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { SyncProvidersDialog } from './SyncProvidersDialog' -import type { SyncCheckResponse } from '@shumai/dtos' - -describe('SyncProvidersDialog', () => { - afterEach(() => { - cleanup() - }) - - const mockSyncData: SyncCheckResponse = { - totalNewProviders: 1, - totalNewModels: 3, - providers: [ - { - name: 'test-new-provider', - isNewProvider: true, - config: { api: 'openai-responses', apiKey: 'NEW_KEY' }, - models: [ - { - modelId: 'm-new-1', - name: 'New Model 1', - config: { - api: 'openai-responses', - reasoning: true, - input: ['text'], - contextWindow: 128000, - maxTokens: 4096, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - }, - }, - { - modelId: 'm-new-2', - name: 'New Model 2', - config: { - api: 'openai-responses', - reasoning: false, - input: ['text'], - contextWindow: 64000, - maxTokens: 2048, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - }, - }, - ], - }, - { - name: 'test-existing-provider', - isNewProvider: false, - config: { api: 'anthropic-messages', apiKey: 'EXISTING_KEY' }, - models: [ - { - modelId: 'm-existing-add-1', - name: 'Existing Provider New Model 1', - config: { - api: 'anthropic-messages', - reasoning: false, - input: ['text'], - contextWindow: 200000, - maxTokens: 8192, - cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, - }, - }, - ], - }, - ], - } - - function renderDialog(props?: Partial>) { - const queryClient = new QueryClient({ - defaultOptions: { queries: { retry: false } }, - }) - - return render( - - - , - ) - } - - it('renders the dialog with description, providers and models pre-selected by default', () => { - renderDialog() - - // Title and description - expect(screen.getByRole('heading', { name: /sync providers & models/i })).toBeDefined() - expect( - screen.getAllByText( - /existing providers, custom endpoints, api keys, and model configurations will never be deleted or modified/i, - ).length, - ).toBeGreaterThan(0) - - // Check provider names - expect(screen.getByText('test-new-provider')).toBeDefined() - expect(screen.getByText('test-existing-provider')).toBeDefined() - - // Badges - expect(screen.getByText(/^new provider$/i)).toBeDefined() - expect(screen.getByText(/^existing provider$/i)).toBeDefined() - - // Check that both new and existing providers have checkboxes - const newProviderCheckbox = document.getElementById('provider-check-test-new-provider') - expect(newProviderCheckbox).toBeDefined() - expect(newProviderCheckbox?.getAttribute('data-state')).toBe('checked') - - const existingProviderCheckbox = document.getElementById( - 'provider-check-test-existing-provider', - ) - expect(existingProviderCheckbox).toBeDefined() - expect(existingProviderCheckbox?.getAttribute('data-state')).toBe('checked') - - // Model checkboxes are checked by default - const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1') - expect(mNew1Check).toBeDefined() - expect(mNew1Check?.getAttribute('data-state')).toBe('checked') - }) - - it('toggles all models for an existing provider when its checkbox is clicked', () => { - renderDialog() - - const existingProviderCheckbox = document.getElementById( - 'provider-check-test-existing-provider', - )! - const existingModelCheck = document.getElementById( - 'model-check-test-existing-provider-m-existing-add-1', - )! - - expect(existingModelCheck.getAttribute('data-state')).toBe('checked') - - // Click to uncheck all - fireEvent.click(existingProviderCheckbox) - expect(existingModelCheck.getAttribute('data-state')).toBe('unchecked') - expect(existingProviderCheckbox.getAttribute('data-state')).toBe('unchecked') - - // Click to check all - fireEvent.click(existingProviderCheckbox) - expect(existingModelCheck.getAttribute('data-state')).toBe('checked') - expect(existingProviderCheckbox.getAttribute('data-state')).toBe('checked') - }) - - it('supports select all and deselect all buttons', () => { - renderDialog() - - const deselectAllBtn = screen.getByRole('button', { name: /^deselect all$/i }) - fireEvent.click(deselectAllBtn) - - const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1') - expect(mNew1Check?.getAttribute('data-state')).toBe('unchecked') - - const selectAllBtn = screen.getByRole('button', { name: /^select all$/i }) - fireEvent.click(selectAllBtn) - expect(mNew1Check?.getAttribute('data-state')).toBe('checked') - }) - - it('unchecks new provider when all its models are unchecked', () => { - renderDialog() - - const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1')! - const mNew2Check = document.getElementById('model-check-test-new-provider-m-new-2')! - const newProviderCheckbox = document.getElementById('provider-check-test-new-provider')! - - // Uncheck both models - fireEvent.click(mNew1Check) - expect(newProviderCheckbox.getAttribute('data-state')).toBe('indeterminate') - - fireEvent.click(mNew2Check) - expect(newProviderCheckbox.getAttribute('data-state')).toBe('unchecked') - - // Re-check one model -> provider should automatically check - fireEvent.click(mNew1Check) - expect(newProviderCheckbox.getAttribute('data-state')).not.toBe('unchecked') - }) - - it('filters models when user types in search input', () => { - renderDialog() - - const searchInput = screen.getByPlaceholderText(/filter new providers or models/i) - fireEvent.change(searchInput, { target: { value: 'm-existing-add-1' } }) - - // Only existing provider model should be visible - expect(screen.queryByText('m-new-1')).toBeNull() - expect(screen.getByText('Existing Provider New Model 1')).toBeDefined() - }) - - it('supports expand all and collapse all buttons', () => { - renderDialog() - - // Models should be visible initially (all expanded) - expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeDefined() - - // Click Collapse All - const collapseAllBtn = screen.getByRole('button', { name: /^collapse all$/i }) - fireEvent.click(collapseAllBtn) - - // Child models should be collapsed (not in DOM) - expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeNull() - - // Click Expand All - const expandAllBtn = screen.getByRole('button', { name: /^expand all$/i }) - fireEvent.click(expandAllBtn) - - // Child models should be visible again - expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeDefined() - }) - - it('updates selection and expansion state when syncData prop changes while mounted', () => { - const { rerender } = renderDialog() - - // Initially, test-new-provider is present - expect(screen.getByText('test-new-provider')).toBeDefined() - - // Deselect all models to change internal state - const deselectAllBtn = screen.getByRole('button', { name: /^deselect all$/i }) - fireEvent.click(deselectAllBtn) - const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1') - expect(mNew1Check?.getAttribute('data-state')).toBe('unchecked') - - // Now supply new syncData prop with different providers and models - const updatedSyncData: SyncCheckResponse = { - totalNewProviders: 1, - totalNewModels: 1, - providers: [ - { - name: 'updated-provider', - isNewProvider: true, - config: { api: 'openai-responses' }, - models: [ - { - modelId: 'm-updated-1', - name: 'Updated Model 1', - config: { - api: 'openai-responses', - reasoning: false, - input: ['text'], - contextWindow: 32000, - maxTokens: 1024, - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - }, - }, - ], - }, - ], - } - - const queryClient = new QueryClient({ - defaultOptions: { queries: { retry: false } }, - }) - - rerender( - - - , - ) - - // New provider should be rendered, expanded by default, and model should be pre-selected - expect(screen.getByText('updated-provider')).toBeDefined() - const updatedModelCheck = document.getElementById('model-check-updated-provider-m-updated-1') - expect(updatedModelCheck).toBeDefined() - expect(updatedModelCheck?.getAttribute('data-state')).toBe('checked') - }) -}) diff --git a/packages/webui/components/settings/SyncProvidersDialog.tsx b/packages/webui/components/settings/SyncProvidersDialog.tsx deleted file mode 100644 index 2e2bba67..00000000 --- a/packages/webui/components/settings/SyncProvidersDialog.tsx +++ /dev/null @@ -1,474 +0,0 @@ -import { useState, useMemo, useEffect } from 'react' -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from '@/ui/components/ui/dialog' -import { Button } from '@/ui/components/ui/button' -import { Checkbox } from '@/ui/components/ui/checkbox' -import { Badge } from '@/ui/components/ui/badge' -import { Input } from '@/ui/components/ui/input' -import { ScrollArea } from '@/ui/components/ui/scroll-area' -import { ChevronDown, ChevronRight, Cpu, Loader2, Search, Sparkles } from 'lucide-react' -import { useMutation } from '@tanstack/react-query' -import { client } from '@/ui/api/client' -import { toast } from 'sonner' -import { m } from '@/ui/paraglide/messages.js' -import type { SyncCheckResponse, SyncApplyRequest } from '@shumai/dtos' - -interface SyncProvidersDialogProps { - isOpen: boolean - onClose: () => void - teamId: string - syncData: SyncCheckResponse | null - onSuccess: () => void -} - -export function SyncProvidersDialog({ - isOpen, - onClose, - teamId, - syncData, - onSuccess, -}: SyncProvidersDialogProps) { - const [filterQuery, setFilterQuery] = useState('') - const [expandedProviders, setExpandedProviders] = useState>(() => { - return new Set(syncData?.providers.map((p) => p.name) || []) - }) - - // Pre-selected by default (opt-out) - const [selectedModels, setSelectedModels] = useState>(() => { - const set = new Set() - syncData?.providers.forEach((p) => { - p.models.forEach((mItem) => { - set.add(`${p.name}:${mItem.modelId}`) - }) - }) - return set - }) - - // Sync state if syncData changes - useEffect(() => { - if (syncData) { - setExpandedProviders(new Set(syncData.providers.map((p) => p.name))) - const modelSet = new Set() - syncData.providers.forEach((p) => { - p.models.forEach((mItem) => { - modelSet.add(`${p.name}:${mItem.modelId}`) - }) - }) - setSelectedModels(modelSet) - } - }, [syncData]) - - // Filtered tree data based on filterQuery - const filteredTree = useMemo(() => { - if (!syncData) return [] - const q = filterQuery.trim().toLowerCase() - if (!q) return syncData.providers - - return syncData.providers - .map((p) => { - const matchesProvider = p.name.toLowerCase().includes(q) - const matchingModels = p.models.filter( - (mItem) => - matchesProvider || - mItem.modelId.toLowerCase().includes(q) || - mItem.name.toLowerCase().includes(q), - ) - if (matchingModels.length > 0) { - return { ...p, models: matchingModels } - } - return null - }) - .filter((p): p is NonNullable => p !== null) - }, [syncData, filterQuery]) - - // Total selected models & providers - const totalSelectedModelsCount = selectedModels.size - const totalSelectedProvidersCount = useMemo(() => { - if (!syncData) return 0 - let count = 0 - for (const p of syncData.providers) { - const hasSelectedModel = p.models.some((mItem) => - selectedModels.has(`${p.name}:${mItem.modelId}`), - ) - if (hasSelectedModel) count++ - } - return count - }, [syncData, selectedModels]) - - const toggleExpand = (providerName: string) => { - setExpandedProviders((prev) => { - const next = new Set(prev) - if (next.has(providerName)) { - next.delete(providerName) - } else { - next.add(providerName) - } - return next - }) - } - - const handleExpandAll = () => { - if (!syncData) return - setExpandedProviders(new Set(syncData.providers.map((p) => p.name))) - } - - const handleCollapseAll = () => { - setExpandedProviders(new Set()) - } - - const toggleModel = (providerName: string, modelId: string) => { - const key = `${providerName}:${modelId}` - setSelectedModels((prevModels) => { - const nextModels = new Set(prevModels) - if (nextModels.has(key)) { - nextModels.delete(key) - } else { - nextModels.add(key) - } - return nextModels - }) - } - - const toggleProvider = (providerName: string) => { - const providerData = syncData?.providers.find((p) => p.name === providerName) - if (!providerData || providerData.models.length === 0) return - - const allModelsChecked = providerData.models.every((mItem) => - selectedModels.has(`${providerName}:${mItem.modelId}`), - ) - - setSelectedModels((prev) => { - const next = new Set(prev) - providerData.models.forEach((mItem) => { - const key = `${providerName}:${mItem.modelId}` - if (allModelsChecked) { - next.delete(key) - } else { - next.add(key) - } - }) - return next - }) - } - - const handleSelectAll = () => { - if (!syncData) return - const modelSet = new Set() - syncData.providers.forEach((p) => { - p.models.forEach((mItem) => { - modelSet.add(`${p.name}:${mItem.modelId}`) - }) - }) - setSelectedModels(modelSet) - } - - const handleDeselectAll = () => { - setSelectedModels(new Set()) - } - - // Apply mutation - const applyMutation = useMutation({ - mutationFn: async (payload: SyncApplyRequest) => { - const res = await client.api.teams[':teamId'].providers['sync-apply'].$post({ - param: { teamId }, - json: payload, - }) - if (!res.ok) { - const err = await res.json().catch(() => ({ message: 'Failed to apply sync' })) - throw new Error((err as { message?: string }).message || 'Failed to apply sync') - } - return await res.json() - }, - onSuccess: (data) => { - toast.success( - m.sync_providers_success({ - modelCount: data.addedModels, - providerCount: data.addedProviders, - }), - ) - onSuccess() - onClose() - }, - onError: (error: Error) => { - toast.error(error.message) - }, - }) - - const handleConfirm = async () => { - if (!syncData || totalSelectedModelsCount === 0) return - - const providersToSync: SyncApplyRequest['providers'] = [] - - for (const p of syncData.providers) { - const selectedModelsForProvider = p.models.filter((mItem) => - selectedModels.has(`${p.name}:${mItem.modelId}`), - ) - - if (selectedModelsForProvider.length > 0) { - providersToSync.push({ - name: p.name, - isNewProvider: p.isNewProvider, - config: p.config, - models: selectedModelsForProvider, - }) - } - } - - if (providersToSync.length === 0) return - - await applyMutation.mutateAsync({ - providers: providersToSync, - }) - } - - return ( - !open && onClose()}> - - - - - {m.sync_providers_dialog_title()} - - - {m.sync_providers_dialog_description()} - - - - {/* Controls Toolbar */} -
-
-
- - setFilterQuery(e.target.value)} - placeholder={m.sync_providers_search_placeholder()} - className="pl-8 h-8 text-xs bg-background" - /> -
-
- - -
- - -
-
-
- - {/* Tree List Container */} -
- -
- {filteredTree.length === 0 ? ( -
- {m.no_matches_found()} -
- ) : ( - filteredTree.map((provider) => { - const isExpanded = expandedProviders.has(provider.name) - const isNew = provider.isNewProvider - - // Determine provider check state - const checkedCount = provider.models.filter((mItem) => - selectedModels.has(`${provider.name}:${mItem.modelId}`), - ).length - const allChecked = checkedCount === provider.models.length - const someChecked = checkedCount > 0 && !allChecked - - return ( -
- {/* Provider Header Row */} -
-
- - - toggleProvider(provider.name)} - id={`provider-check-${provider.name}`} - /> - - -
- -
- {isNew ? ( - - {m.sync_providers_new_provider()} - - ) : ( - - {m.sync_providers_existing_provider()} - - )} - - {m.sync_providers_new_models_count({ - count: provider.models.length, - })} - -
-
- - {/* Model Children Rows */} - {isExpanded && ( -
- {provider.models.map((model) => { - const isModelChecked = selectedModels.has( - `${provider.name}:${model.modelId}`, - ) - return ( -
-
- - toggleModel(provider.name, model.modelId) - } - id={`model-check-${provider.name}-${model.modelId}`} - /> - -
- -
- {model.config.reasoning && ( - - {m.sync_providers_reasoning()} - - )} - - {m.sync_providers_context_window({ - count: Math.round(model.config.contextWindow / 1000), - })} - -
-
- ) - })} -
- )} -
- ) - }) - )} -
-
-
- - {/* Selected Count & Footer */} - -
- {m.sync_providers_selected_count({ - modelCount: totalSelectedModelsCount, - providerCount: totalSelectedProvidersCount, - })} -
-
- - -
-
- -
- ) -} diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index 17b7fec2..602b1a52 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -459,27 +459,27 @@ "ai": "AI", "providers": "Providers", "providers_description": "Configure AI providers and their models for this team.", - "configured_ai_providers": "Configured AI Providers", + "provider_configured_badge": "Configured", + "provider_options": "Options for {name}", + "provider_refresh_models": "Refresh models", + "provider_refresh_action": "Refresh models for {name}", + "provider_refresh_loading": "Refreshing…", + "provider_refresh_legacy_kimi_connection": "The public Kimi catalog uses Chat Completions. You can still add models manually to this Anthropic Messages connection.", + "provider_refresh_azure_deployment_required": "Set an Azure endpoint and map deployed model IDs to refresh models.", + "provider_refresh_catalog_unavailable": "Pi does not publish a model catalog for this provider.", + "provider_refresh_unsupported_connection": "Refresh is unavailable for this endpoint or API.", + "provider_refresh_failed": "Could not refresh models. Try again.", + "provider_refresh_no_new_models": "No new models for {name}.", + "provider_refresh_dialog_title": "New models for {name}", + "provider_refresh_dialog_description": "Select the models you want to add.", + "provider_refresh_select_visible": "Select visible", + "provider_refresh_deselect_visible": "Deselect visible", + "provider_refresh_add_selected": "Add selected", + "provider_refresh_add_selection": "Add selected ({count})", + "provider_refresh_imported": "Added {count} models to {name}.", + "provider_refresh_import_failed": "Could not add the selected models. Try again.", + "provider_refresh_stale": "This preview has expired or the connection changed. Refresh models again.", "add_provider": "Add Provider", - "sync_providers": "Sync Providers", - "sync_providers_checking": "Checking for updates...", - "sync_providers_dialog_title": "Sync Providers & Models", - "sync_providers_dialog_description": "Select the new providers and models you want to add. Existing providers, custom endpoints, API keys, and model configurations will never be deleted or modified.", - "sync_providers_up_to_date": "All providers and models are already up to date.", - "sync_providers_select_all": "Select All", - "sync_providers_deselect_all": "Deselect All", - "sync_providers_expand_all": "Expand All", - "sync_providers_collapse_all": "Collapse All", - "sync_providers_search_placeholder": "Filter new providers or models...", - "sync_providers_new_provider": "New Provider", - "sync_providers_existing_provider": "Existing Provider", - "sync_providers_new_models_count": "{count} new models", - "sync_providers_selected_count": "{modelCount} models selected across {providerCount} providers", - "sync_providers_reasoning": "reasoning", - "sync_providers_context_window": "{count}k ctx", - "sync_providers_add_selected": "Add Selected ({count})", - "sync_providers_adding": "Adding...", - "sync_providers_success": "Successfully added {modelCount} models across {providerCount} providers.", "search_providers_placeholder": "Search providers...", "no_providers_found": "No providers found", "built_in": "Built-in", diff --git a/packages/webui/messages/ko.json b/packages/webui/messages/ko.json index e34556aa..894539f7 100644 --- a/packages/webui/messages/ko.json +++ b/packages/webui/messages/ko.json @@ -444,27 +444,27 @@ "ai": "AI", "providers": "프로바이더", "providers_description": "이 팀의 AI 프로바이더와 모델을 설정합니다.", - "configured_ai_providers": "설정된 AI 프로바이더", + "provider_configured_badge": "설정됨", + "provider_options": "{name} 옵션", + "provider_refresh_models": "모델 새로 고침", + "provider_refresh_action": "{name}의 모델 새로 고침", + "provider_refresh_loading": "새로 고치는 중…", + "provider_refresh_legacy_kimi_connection": "Kimi 공개 카탈로그는 Chat Completions를 사용합니다. 이 Anthropic Messages 연결에 모델을 직접 추가할 수 있습니다.", + "provider_refresh_azure_deployment_required": "모델을 새로 고치려면 Azure 엔드포인트를 설정하고 배포된 모델 ID를 매핑하세요.", + "provider_refresh_catalog_unavailable": "Pi에서 이 제공업체의 모델 카탈로그를 제공하지 않습니다.", + "provider_refresh_unsupported_connection": "이 엔드포인트 또는 API에서는 모델을 새로 고칠 수 없습니다.", + "provider_refresh_failed": "모델을 새로 고침할 수 없습니다. 다시 시도하세요.", + "provider_refresh_no_new_models": "{name}에 새 모델이 없습니다.", + "provider_refresh_dialog_title": "{name}의 새 모델", + "provider_refresh_dialog_description": "추가할 모델을 선택하세요.", + "provider_refresh_select_visible": "표시된 모델 선택", + "provider_refresh_deselect_visible": "표시된 모델 선택 해제", + "provider_refresh_add_selected": "선택한 모델 추가", + "provider_refresh_add_selection": "선택한 모델 추가({count}개)", + "provider_refresh_imported": "{name}에 모델 {count}개를 추가했습니다.", + "provider_refresh_import_failed": "선택한 모델을 추가할 수 없습니다. 다시 시도하세요.", + "provider_refresh_stale": "미리 보기가 만료되었거나 연결이 변경되었습니다. 모델을 다시 새로 고치세요.", "add_provider": "프로바이더 추가", - "sync_providers": "프로바이더 동기화", - "sync_providers_checking": "업데이트 확인 중...", - "sync_providers_dialog_title": "프로바이더 및 모델 동기화", - "sync_providers_dialog_description": "추가할 새 프로바이더와 모델을 선택하세요. 기존 프로바이더, 사용자 지정 엔드포인트, API 키, 모델 설정은 삭제되거나 변경되지 않습니다.", - "sync_providers_up_to_date": "모든 프로바이더와 모델이 최신 상태입니다.", - "sync_providers_select_all": "모두 선택", - "sync_providers_deselect_all": "모두 선택 해제", - "sync_providers_expand_all": "모두 펼치기", - "sync_providers_collapse_all": "모두 접기", - "sync_providers_search_placeholder": "새 프로바이더 또는 모델 필터...", - "sync_providers_new_provider": "새 프로바이더", - "sync_providers_existing_provider": "기존 프로바이더", - "sync_providers_new_models_count": "새 모델 {count}개", - "sync_providers_selected_count": "프로바이더 {providerCount}개에서 모델 {modelCount}개 선택됨", - "sync_providers_reasoning": "추론", - "sync_providers_context_window": "컨텍스트 {count}k", - "sync_providers_add_selected": "선택 항목 추가({count})", - "sync_providers_adding": "추가 중...", - "sync_providers_success": "프로바이더 {providerCount}개에 모델 {modelCount}개를 추가했습니다.", "search_providers_placeholder": "프로바이더 검색...", "no_providers_found": "프로바이더를 찾을 수 없습니다", "built_in": "기본 제공", diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index c624cea1..e9844192 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -459,27 +459,27 @@ "ai": "AI", "providers": "提供商", "providers_description": "为此团队配置 AI 提供商及其模型。", - "configured_ai_providers": "已配置的 AI 提供商", + "provider_configured_badge": "已配置", + "provider_options": "{name} 的选项", + "provider_refresh_models": "刷新模型", + "provider_refresh_action": "刷新 {name} 的模型", + "provider_refresh_loading": "正在刷新…", + "provider_refresh_legacy_kimi_connection": "Kimi 的公开目录使用 Chat Completions。你仍然可以为此 Anthropic Messages 连接手动添加模型。", + "provider_refresh_azure_deployment_required": "设置 Azure 端点和已部署模型的 ID 映射后,即可刷新模型。", + "provider_refresh_catalog_unavailable": "Pi 未发布此提供商的模型目录。", + "provider_refresh_unsupported_connection": "此端点或 API 不支持刷新模型。", + "provider_refresh_failed": "无法刷新模型,请重试。", + "provider_refresh_no_new_models": "{name} 暂无新模型。", + "provider_refresh_dialog_title": "{name} 的新模型", + "provider_refresh_dialog_description": "请选择要添加的模型。", + "provider_refresh_select_visible": "选中当前结果", + "provider_refresh_deselect_visible": "取消选中当前结果", + "provider_refresh_add_selected": "添加所选模型", + "provider_refresh_add_selection": "添加所选模型({count} 个)", + "provider_refresh_imported": "已向 {name} 添加 {count} 个模型。", + "provider_refresh_import_failed": "无法添加所选模型,请重试。", + "provider_refresh_stale": "预览已过期或连接已更改,请重新刷新模型。", "add_provider": "添加提供商", - "sync_providers": "同步提供商", - "sync_providers_checking": "正在检查更新...", - "sync_providers_dialog_title": "同步提供商与模型", - "sync_providers_dialog_description": "选择您希望添加的新提供商和模型。现有的提供商、自定义端点、API 密钥和模型配置绝不会被删除或修改。", - "sync_providers_up_to_date": "所有提供商和模型均已是最新状态。", - "sync_providers_select_all": "全选", - "sync_providers_deselect_all": "取消全选", - "sync_providers_expand_all": "全部展开", - "sync_providers_collapse_all": "全部折叠", - "sync_providers_search_placeholder": "筛选新提供商或模型...", - "sync_providers_new_provider": "新提供商", - "sync_providers_existing_provider": "现有提供商", - "sync_providers_new_models_count": "{count} 个新模型", - "sync_providers_selected_count": "已选 {modelCount} 个模型,分布在 {providerCount} 个提供商中", - "sync_providers_reasoning": "深度思考", - "sync_providers_context_window": "{count}k 上下文", - "sync_providers_add_selected": "添加所选 ({count})", - "sync_providers_adding": "正在添加...", - "sync_providers_success": "已成功添加 {providerCount} 个提供商中的 {modelCount} 个模型。", "search_providers_placeholder": "搜索提供商...", "no_providers_found": "未找到提供商", "built_in": "内置", diff --git a/packages/webui/package.json b/packages/webui/package.json index 6420600f..24670f49 100644 --- a/packages/webui/package.json +++ b/packages/webui/package.json @@ -10,8 +10,8 @@ "@dnd-kit/abstract": "0.5.0", "@dnd-kit/dom": "0.5.0", "@dnd-kit/react": "0.5.0", - "@earendil-works/pi-ai": "1.5.0", - "@earendil-works/pi-durable": "1.5.0", + "@earendil-works/pi-ai": "1.7.0", + "@earendil-works/pi-durable": "1.7.0", "@ferrucc-io/emoji-picker": "0.1.2", "@hookform/resolvers": "5.9.1", "@lexical/code": "0.49.0", diff --git a/packages/webui/routes/teams/$teamId/settings.lazy.tsx b/packages/webui/routes/teams/$teamId/settings.lazy.tsx index ec96cd91..45d3a11f 100644 --- a/packages/webui/routes/teams/$teamId/settings.lazy.tsx +++ b/packages/webui/routes/teams/$teamId/settings.lazy.tsx @@ -533,7 +533,12 @@ export function TeamSettingsPage() {
{/* Sidebar */} -
+