kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: relax tool name validation a bit
rodzic
28940bc91e
commit
5cdf5962ff
|
@ -3,9 +3,11 @@
|
|||
import useInfiniteScroll from 'react-infinite-scroll-hook'
|
||||
|
||||
import { useAgentic } from '@/components/agentic-provider'
|
||||
import { DotsSection } from '@/components/dots-section'
|
||||
import { LoadingIndicator } from '@/components/loading-indicator'
|
||||
import { PageContainer } from '@/components/page-container'
|
||||
import { PublicProject } from '@/components/public-project'
|
||||
import { SupplySideCTA } from '@/components/supply-side-cta'
|
||||
import { useInfiniteQuery } from '@/lib/query-client'
|
||||
|
||||
export function MarketplaceIndex() {
|
||||
|
@ -90,6 +92,21 @@ export function MarketplaceIndex() {
|
|||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* CTA section */}
|
||||
<DotsSection className='flex flex-col gap-12 mb-16'>
|
||||
<h2 className='text-center text-balance leading-snug md:leading-none text-3xl font-heading'>
|
||||
Your API → Paid MCP, Instantly
|
||||
</h2>
|
||||
|
||||
<h5 className='text-center max-w-2xl'>
|
||||
Run one command to turn any MCP server or OpenAPI service into a paid
|
||||
MCP product. With built-in support for every major LLM SDK and MCP
|
||||
client.
|
||||
</h5>
|
||||
|
||||
<SupplySideCTA variant='docs' />
|
||||
</DotsSection>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { isToolNameAllowed, toolNameRe } from '@agentic/platform-validators'
|
||||
import {
|
||||
isToolNameAllowed,
|
||||
isValidToolName,
|
||||
toolNameRe
|
||||
} from '@agentic/platform-validators'
|
||||
import { z } from '@hono/zod-openapi'
|
||||
|
||||
import { pricingPlanSlugSchema } from './pricing'
|
||||
|
@ -17,6 +21,12 @@ export const toolNameSchema = z
|
|||
.string()
|
||||
.nonempty()
|
||||
.regex(toolNameRe)
|
||||
.refine(
|
||||
(name) => isValidToolName(name),
|
||||
(name) => ({
|
||||
message: `Tool name "${name}" is invalid; must match /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/.`
|
||||
})
|
||||
)
|
||||
.refine(
|
||||
(name) => isToolNameAllowed(name),
|
||||
(name) => ({
|
||||
|
|
|
@ -4,13 +4,13 @@ import type { ParsedToolIdentifier, ParseIdentifierOptions } from './types'
|
|||
import { coerceIdentifier } from './utils'
|
||||
|
||||
const toolIdentifierImplicitRe =
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})\/([a-zA-Z_][a-zA-Z0-9_]{0,63})$/
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})\/([a-zA-Z_][a-zA-Z0-9_-]{0,63})$/
|
||||
|
||||
const toolIdentifierHashRe =
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})@([a-z0-9]{8})\/([a-zA-Z_][a-zA-Z0-9_]{0,63})$/
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})@([a-z0-9]{8})\/([a-zA-Z_][a-zA-Z0-9_-]{0,63})$/
|
||||
|
||||
const toolIdentifierVersionRe =
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})@([\d.a-z-@]+)\/([a-zA-Z_][a-zA-Z0-9_]{0,63})$/
|
||||
/^@([a-z0-9-]{1,256})\/([a-z0-9-]{1,256})@([\d.a-z-@]+)\/([a-zA-Z_][a-zA-Z0-9_-]{0,63})$/
|
||||
|
||||
export function parseToolIdentifier(
|
||||
identifier?: string,
|
||||
|
|
|
@ -163,14 +163,15 @@ test('isValidToolName success', () => {
|
|||
expect(isValidToolName('searchGoogle')).toBe(true)
|
||||
expect(isValidToolName('searchGoogle2')).toBe(true)
|
||||
expect(isValidToolName('_searchGoogle')).toBe(true)
|
||||
expect(isValidToolName('tool-name')).toBe(true)
|
||||
})
|
||||
|
||||
test('isValidToolName failure', () => {
|
||||
expect(isValidToolName('ab1.2')).toBe(false)
|
||||
expect(isValidToolName('foo-bar')).toBe(false)
|
||||
expect(isValidToolName('-foo-bar')).toBe(false)
|
||||
expect(isValidToolName('abc/123')).toBe(false)
|
||||
expect(isValidToolName('search_google ')).toBe(false)
|
||||
expect(isValidToolName('search-google')).toBe(false)
|
||||
expect(isValidToolName('-search_google')).toBe(false)
|
||||
expect(
|
||||
isValidToolName(
|
||||
'too_long_too_long_too_long_too_long_too_long_too_long_too_long_to'
|
||||
|
|
|
@ -13,7 +13,7 @@ export const passwordRe = /^.{3,1024}$/
|
|||
export const projectSlugRe = /^[a-z0-9-]{1,256}$/
|
||||
export const deploymentHashRe = /^[a-z0-9]{8}$/
|
||||
|
||||
export const toolNameRe = /^[a-zA-Z_][a-zA-Z0-9_]{0,63}$/
|
||||
export const toolNameRe = /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/
|
||||
|
||||
export function isValidEmail(value: string): boolean {
|
||||
return emailValidator.validate(value)
|
||||
|
|
|
@ -964,6 +964,12 @@ importers:
|
|||
specifier: 'catalog:'
|
||||
version: 4.1.97(@types/node@24.0.7)(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
|
||||
|
||||
examples/mcp-servers/context7:
|
||||
dependencies:
|
||||
'@agentic/platform':
|
||||
specifier: workspace:*
|
||||
version: link:../../../packages/platform
|
||||
|
||||
examples/mcp-servers/search:
|
||||
dependencies:
|
||||
'@agentic/platform':
|
||||
|
|
Ładowanie…
Reference in New Issue