feat: improvements to openai-to-ts

pull/701/head
Travis Fischer 2025-03-25 21:50:43 +08:00
rodzic 6e03cf975e
commit 0d8f59eef8
29 zmienionych plików z 51428 dodań i 50207 usunięć

Wyświetl plik

@ -58,6 +58,7 @@
"tools/apollo",
"tools/arxiv",
"tools/bing",
"tools/brave-search",
"tools/calculator",
"tools/clearbit",
"tools/dexa",

Wyświetl plik

@ -1,4 +1,5 @@
import type * as types from './types.ts'
import type { AIFunction } from './types.ts'
import { AIFunctionsProvider } from './fns'
import { isAIFunction } from './utils'
@ -132,6 +133,25 @@ export class AIFunctionSet implements Iterable<types.AIFunction> {
return [...this.entries].map(fn)
}
/**
* Returns a new AIFunctionSet containing only the AIFunctions in this set
* matching the given tags.
*/
getFilteredByTags(...tags: string[]): AIFunctionSet {
const tagsSet = new Set(tags)
return this.getFilteredBy((fn) => fn.tags?.some((t) => tagsSet.has(t)))
}
/**
* Returns a new AIFunctionSet containing only the AIFunctions in this set
* matching a custom filter function.
*/
getFilteredBy(
filterFn: (fn: AIFunction) => boolean | undefined
): AIFunctionSet {
return new AIFunctionSet(Array.from(this).filter((fn) => filterFn(fn)))
}
/**
* Returns the functions in this set as an array compatible with OpenAI's
* chat completions `functions`.

Wyświetl plik

@ -3,13 +3,13 @@ import { asAgenticSchema } from './schema'
import { assert } from './utils'
export type CreateAIFunctionArgs<
InputSchema extends types.AIFunctionInputSchema
InputSchema extends types.AIFunctionInputSchema = types.AIFunctionInputSchema
> = {
/** Name of the function. */
name: string
/** Description of the function. */
description?: string
description: string
/**
* Zod schema or AgenticSchema for the function parameters.
@ -26,6 +26,11 @@ export type CreateAIFunctionArgs<
* Defaults to `true`.
*/
strict?: boolean
/**
* Optional tags to help organize functions.
*/
tags?: string[]
}
export type AIFunctionImplementation<
@ -65,9 +70,10 @@ export function createAIFunction<
>(
{
name,
description = '',
description,
inputSchema,
strict = true,
tags,
execute
}: CreateAIFunctionArgs<InputSchema> & {
/** Underlying function implementation. */
@ -132,6 +138,7 @@ export function createAIFunction<
aiFunction.inputSchema = inputSchema
aiFunction.parseInput = parseInput
aiFunction.execute = execute
aiFunction.tags = tags
aiFunction.spec = {
name,
description,

Wyświetl plik

@ -1,14 +1,14 @@
import type * as types from './types'
import type { AIFunction } from './types'
import { AIFunctionSet } from './ai-function-set'
import { createAIFunction } from './create-ai-function'
import {
createAIFunction,
type CreateAIFunctionArgs
} from './create-ai-function'
import { assert } from './utils'
export interface PrivateAIFunctionMetadata {
name: string
description: string
inputSchema: types.AIFunctionInputSchema
export type PrivateAIFunctionMetadata = CreateAIFunctionArgs & {
methodName: string
strict?: boolean
}
// Polyfill for `Symbol.metadata`
@ -64,6 +64,23 @@ export abstract class AIFunctionsProvider {
return this._functions
}
/**
* Returns the AIFunctions provided by this class filtered by the given tags.
*/
getFunctionsFilteredByTags(...tags: string[]): AIFunctionSet {
return this.functions.getFilteredByTags(...tags)
}
/**
* Returns the AIFunctions provided by this class which match a custom filter
* function.
*/
getFunctionsFilteredBy(
filterFn: (fn: AIFunction) => boolean | undefined
): AIFunctionSet {
return this.functions.getFilteredBy(filterFn)
}
}
export function aiFunction<
@ -71,17 +88,7 @@ export function aiFunction<
InputSchema extends types.AIFunctionInputSchema,
OptionalArgs extends Array<undefined>,
Return extends types.MaybePromise<any>
>({
name,
description,
inputSchema,
strict
}: {
name?: string
description: string
inputSchema: InputSchema
strict?: boolean
}) {
>(args: CreateAIFunctionArgs<InputSchema>) {
return (
_targetMethod: (
this: This,
@ -102,12 +109,10 @@ export function aiFunction<
context.metadata.invocables = []
}
assert(args.name, 'aiFunction requires a non-empty "name" argument')
;(context.metadata.invocables as PrivateAIFunctionMetadata[]).push({
name: name ?? methodName,
description,
inputSchema,
methodName,
strict
...args,
methodName
})
context.addInitializer(function () {

Wyświetl plik

@ -114,6 +114,9 @@ export interface AIFunction<
*/
// TODO: this `any` shouldn't be necessary, but it is for `createAIFunction` results to be assignable to `AIFunctionLike`
execute: (params: inferInput<InputSchema> | any) => MaybePromise<Output>
/** Optional tags to help organize functions. */
tags?: string[]
}
export type SafeParseResult<TData> =

Wyświetl plik

@ -40,7 +40,7 @@ export namespace github {
}
/**
* Basic GitHub API wrapper.
* Agentic GitHub client.
*/
export class GitHubClient extends AIFunctionsProvider {
protected readonly apiKey: string

Wyświetl plik

@ -96,7 +96,7 @@ export class McpTools extends AIFunctionsProvider {
return createAIFunction(
{
name: `${this.name}_${tool.name}`,
description: tool.description,
description: tool.description ?? `${this.name} ${tool.name}`,
inputSchema: createJsonSchema(tool.inputSchema),
strict: true
},

Wyświetl plik

@ -37,7 +37,7 @@ async function main() {
description: 'Disables eslint formatting',
default: false
},
noZodSchemaJsDocs: {
noZodJsDocs: {
type: Boolean,
description: 'Disables js docs for zod schemas',
default: false
@ -57,13 +57,24 @@ async function main() {
return
}
if (Object.keys(args.unknownFlags).length) {
console.error(
'Unknown flags:',
Object.keys(args.unknownFlags).join(', '),
'\n'
)
args.showHelp()
gracefulExit(1)
return
}
const output = await generateTSFromOpenAPI({
openapiFilePath,
outputDir: args.flags.outputDir || process.cwd(),
dryRun: args.flags.dryRun,
prettier: !args.flags.noPrettier,
eslint: !args.flags.noEslint,
zodSchemaJsDocs: !args.flags.noZodSchemaJsDocs
zodSchemaJsDocs: !args.flags.noZodJsDocs
})
if (args.flags.dryRun) {

Wyświetl plik

@ -1,6 +1,3 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
@ -13,476 +10,8 @@ import {
pick
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace firecrawl {
export const apiBaseUrl = 'https://api.firecrawl.dev/v0'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const ScrapeResponseSchema = z.object({
success: z.boolean().optional(),
/** Warning message to let you know of any issues. */
warning: z
.string()
.describe('Warning message to let you know of any issues.')
.optional(),
data: z
.object({
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
.optional(),
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
.optional(),
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
.optional(),
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
.optional(),
metadata: z
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
statusCode: z
.number()
.int()
.describe('The status code of the page')
.optional(),
/** The error message of the page */
error: z
.string()
.describe('The error message of the page')
.optional()
})
.optional()
})
.optional()
})
export type ScrapeResponse = z.infer<typeof ScrapeResponseSchema>
export const CrawlResponseSchema = z.object({
success: z.boolean().optional(),
id: z.string().optional(),
url: z.string().url().optional()
})
export type CrawlResponse = z.infer<typeof CrawlResponseSchema>
export const SearchResponseSchema = z.object({
success: z.boolean().optional(),
data: z.array(z.any()).optional()
})
export type SearchResponse = z.infer<typeof SearchResponseSchema>
export const CrawlStatusResponseObjSchema = z.object({
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
.optional(),
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
.optional(),
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
.optional(),
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
.optional(),
metadata: z
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
statusCode: z
.number()
.int()
.describe('The status code of the page')
.optional(),
/** The error message of the page */
error: z.string().describe('The error message of the page').optional()
})
.optional()
})
export type CrawlStatusResponseObj = z.infer<
typeof CrawlStatusResponseObjSchema
>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const ScrapeParamsSchema = z.object({
/** The URL to scrape */
url: z.string().url().describe('The URL to scrape'),
/**
* Specific formats to return.
*
* - markdown: The page in Markdown format.
* - html: The page's HTML, trimmed to include only meaningful content.
* - rawHtml: The page's original HTML.
* - links: The links on the page.
* - screenshot: A screenshot of the top of the page.
* - screenshot@fullPage: A screenshot of the full page. (overridden by screenshot if present)
*/
formats: z
.array(
z.enum([
'markdown',
'html',
'rawHtml',
'links',
'screenshot',
'screenshot@fullPage'
])
)
.describe(
"Specific formats to return.\n\n - markdown: The page in Markdown format.\n - html: The page's HTML, trimmed to include only meaningful content.\n - rawHtml: The page's original HTML.\n - links: The links on the page.\n - screenshot: A screenshot of the top of the page.\n - screenshot@fullPage: A screenshot of the full page. (overridden by screenshot if present)"
)
.default(['markdown']),
/** Headers to send with the request. Can be used to send cookies, user-agent, etc. */
headers: z
.record(z.any())
.describe(
'Headers to send with the request. Can be used to send cookies, user-agent, etc.'
)
.optional(),
/** Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer' */
includeTags: z
.array(z.string())
.describe(
"Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer' */
excludeTags: z
.array(z.string())
.describe(
"Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(true),
/** Timeout in milliseconds for the request */
timeout: z
.number()
.int()
.describe('Timeout in milliseconds for the request')
.default(30_000),
/** Wait x amount of milliseconds for the page to load to fetch content */
waitFor: z
.number()
.int()
.describe(
'Wait x amount of milliseconds for the page to load to fetch content'
)
.default(0)
})
export type ScrapeParams = z.infer<typeof ScrapeParamsSchema>
export const CrawlUrlsParamsSchema = z.object({
/** The base URL to start crawling from */
url: z.string().url().describe('The base URL to start crawling from'),
crawlerOptions: z
.object({
/** URL patterns to include */
includes: z
.array(z.string())
.describe('URL patterns to include')
.optional(),
/** URL patterns to exclude */
excludes: z
.array(z.string())
.describe('URL patterns to exclude')
.optional(),
/** Generate alt text for images using LLMs (must have a paid plan) */
generateImgAltText: z
.boolean()
.describe(
'Generate alt text for images using LLMs (must have a paid plan)'
)
.default(false),
/** If true, returns only the URLs as a list on the crawl status. Attention: the return response will be a list of URLs inside the data, not a list of documents. */
returnOnlyUrls: z
.boolean()
.describe(
'If true, returns only the URLs as a list on the crawl status. Attention: the return response will be a list of URLs inside the data, not a list of documents.'
)
.default(false),
/** Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern. */
maxDepth: z
.number()
.int()
.describe(
'Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern.'
)
.optional(),
/** The crawling mode to use. Fast mode crawls 4x faster websites without sitemap, but may not be as accurate and shouldn't be used in heavy js-rendered websites. */
mode: z
.enum(['default', 'fast'])
.describe(
"The crawling mode to use. Fast mode crawls 4x faster websites without sitemap, but may not be as accurate and shouldn't be used in heavy js-rendered websites."
)
.default('default'),
/** Ignore the website sitemap when crawling */
ignoreSitemap: z
.boolean()
.describe('Ignore the website sitemap when crawling')
.default(false),
/** Maximum number of pages to crawl */
limit: z
.number()
.int()
.describe('Maximum number of pages to crawl')
.default(10_000),
/** Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product' */
allowBackwardCrawling: z
.boolean()
.describe(
"Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product'"
)
.default(false),
/** Allows the crawler to follow links to external websites. */
allowExternalContentLinks: z
.boolean()
.describe('Allows the crawler to follow links to external websites.')
.default(false)
})
.optional(),
pageOptions: z
.object({
/** Headers to send with the request. Can be used to send cookies, user-agent, etc. */
headers: z
.record(z.any())
.describe(
'Headers to send with the request. Can be used to send cookies, user-agent, etc.'
)
.optional(),
/** Include the HTML version of the content on page. Will output a html key in the response. */
includeHtml: z
.boolean()
.describe(
'Include the HTML version of the content on page. Will output a html key in the response.'
)
.default(false),
/** Include the raw HTML content of the page. Will output a rawHtml key in the response. */
includeRawHtml: z
.boolean()
.describe(
'Include the raw HTML content of the page. Will output a rawHtml key in the response.'
)
.default(false),
/** Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer' */
onlyIncludeTags: z
.array(z.string())
.describe(
"Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(false),
/** Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer' */
removeTags: z
.array(z.string())
.describe(
"Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Replace all relative paths with absolute paths for images and links */
replaceAllPathsWithAbsolutePaths: z
.boolean()
.describe(
'Replace all relative paths with absolute paths for images and links'
)
.default(false),
/** Include a screenshot of the top of the page that you are scraping. */
screenshot: z
.boolean()
.describe(
'Include a screenshot of the top of the page that you are scraping.'
)
.default(false),
/** Include a full page screenshot of the page that you are scraping. */
fullPageScreenshot: z
.boolean()
.describe(
'Include a full page screenshot of the page that you are scraping.'
)
.default(false),
/** Wait x amount of milliseconds for the page to load to fetch content */
waitFor: z
.number()
.int()
.describe(
'Wait x amount of milliseconds for the page to load to fetch content'
)
.default(0)
})
.optional()
})
export type CrawlUrlsParams = z.infer<typeof CrawlUrlsParamsSchema>
export const CrawlUrlsResponseSchema = CrawlResponseSchema
export type CrawlUrlsResponse = z.infer<typeof CrawlUrlsResponseSchema>
export const SearchGoogleParamsSchema = z.object({
/** The query to search for */
query: z.string().url().describe('The query to search for'),
pageOptions: z
.object({
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(false),
/** Fetch the content of each page. If false, defaults to a basic fast serp API. */
fetchPageContent: z
.boolean()
.describe(
'Fetch the content of each page. If false, defaults to a basic fast serp API.'
)
.default(true),
/** Include the HTML version of the content on page. Will output a html key in the response. */
includeHtml: z
.boolean()
.describe(
'Include the HTML version of the content on page. Will output a html key in the response.'
)
.default(false),
/** Include the raw HTML content of the page. Will output a rawHtml key in the response. */
includeRawHtml: z
.boolean()
.describe(
'Include the raw HTML content of the page. Will output a rawHtml key in the response.'
)
.default(false)
})
.optional(),
searchOptions: z
.object({
/** Maximum number of results. Max is 20 during beta. */
limit: z
.number()
.int()
.describe('Maximum number of results. Max is 20 during beta.')
.optional()
})
.optional()
})
export type SearchGoogleParams = z.infer<typeof SearchGoogleParamsSchema>
export const SearchGoogleResponseSchema = SearchResponseSchema
export type SearchGoogleResponse = z.infer<typeof SearchGoogleResponseSchema>
export const GetCrawlStatusParamsSchema = z.object({
/** ID of the crawl job */
jobId: z.string().describe('ID of the crawl job')
})
export type GetCrawlStatusParams = z.infer<typeof GetCrawlStatusParamsSchema>
export const GetCrawlStatusResponseSchema = z.object({
/** Status of the job (completed, active, failed, paused) */
status: z
.string()
.describe('Status of the job (completed, active, failed, paused)')
.optional(),
/** Current page number */
current: z.number().int().describe('Current page number').optional(),
/** Total number of pages */
total: z.number().int().describe('Total number of pages').optional(),
/** Data returned from the job (null when it is in progress) */
data: z
.array(CrawlStatusResponseObjSchema)
.describe('Data returned from the job (null when it is in progress)')
.optional(),
/** Partial documents returned as it is being crawled (streaming). **This feature is currently in alpha - expect breaking changes** When a page is ready, it will append to the partial_data array, so there is no need to wait for the entire website to be crawled. When the crawl is done, partial_data will become empty and the result will be available in `data`. There is a max of 50 items in the array response. The oldest item (top of the array) will be removed when the new item is added to the array. */
partial_data: z
.array(CrawlStatusResponseObjSchema)
.describe(
'Partial documents returned as it is being crawled (streaming). **This feature is currently in alpha - expect breaking changes** When a page is ready, it will append to the partial_data array, so there is no need to wait for the entire website to be crawled. When the crawl is done, partial_data will become empty and the result will be available in `data`. There is a max of 50 items in the array response. The oldest item (top of the array) will be removed when the new item is added to the array.'
)
.optional()
})
export type GetCrawlStatusResponse = z.infer<
typeof GetCrawlStatusResponseSchema
>
export const CancelCrawlJobParamsSchema = z.object({
/** ID of the crawl job */
jobId: z.string().describe('ID of the crawl job')
})
export type CancelCrawlJobParams = z.infer<typeof CancelCrawlJobParamsSchema>
export const CancelCrawlJobResponseSchema = z.object({
/** Returns cancelled. */
status: z.string().describe('Returns cancelled.').optional()
})
export type CancelCrawlJobResponse = z.infer<
typeof CancelCrawlJobResponseSchema
>
}
import { firecrawl } from './firecrawl'
/**
* Agentic Firecrawl client.
@ -526,7 +55,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_scrape',
description: `Scrape a single URL.`,
inputSchema: firecrawl.ScrapeParamsSchema
inputSchema: firecrawl.ScrapeParamsSchema,
tags: ['Scraping']
})
async scrape(
params: firecrawl.ScrapeParams
@ -554,7 +84,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_crawl_urls',
description: `Crawl multiple URLs based on options.`,
inputSchema: firecrawl.CrawlUrlsParamsSchema
inputSchema: firecrawl.CrawlUrlsParamsSchema,
tags: ['Crawling']
})
async crawlUrls(
params: firecrawl.CrawlUrlsParams
@ -572,7 +103,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_search_google',
description: `Search for a keyword in Google, returns top page results with markdown content for each page.`,
inputSchema: firecrawl.SearchGoogleParamsSchema
inputSchema: firecrawl.SearchGoogleParamsSchema,
tags: ['Search']
})
async searchGoogle(
params: firecrawl.SearchGoogleParams
@ -590,7 +122,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_get_crawl_status',
description: `Get the status of a crawl job.`,
inputSchema: firecrawl.GetCrawlStatusParamsSchema
inputSchema: firecrawl.GetCrawlStatusParamsSchema,
tags: ['Crawl']
})
async getCrawlStatus(
params: firecrawl.GetCrawlStatusParams
@ -606,7 +139,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_cancel_crawl_job',
description: `Cancel a crawl job.`,
inputSchema: firecrawl.CancelCrawlJobParamsSchema
inputSchema: firecrawl.CancelCrawlJobParamsSchema,
tags: ['Crawl']
})
async cancelCrawlJob(
params: firecrawl.CancelCrawlJobParams

Wyświetl plik

@ -0,0 +1,474 @@
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'
export namespace firecrawl {
export const apiBaseUrl = 'https://api.firecrawl.dev/v0'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const ScrapeResponseSchema = z.object({
success: z.boolean().optional(),
/** Warning message to let you know of any issues. */
warning: z
.string()
.describe('Warning message to let you know of any issues.')
.optional(),
data: z
.object({
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
.optional(),
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
.optional(),
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
.optional(),
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
.optional(),
metadata: z
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
statusCode: z
.number()
.int()
.describe('The status code of the page')
.optional(),
/** The error message of the page */
error: z
.string()
.describe('The error message of the page')
.optional()
})
.optional()
})
.optional()
})
export type ScrapeResponse = z.infer<typeof ScrapeResponseSchema>
export const CrawlResponseSchema = z.object({
success: z.boolean().optional(),
id: z.string().optional(),
url: z.string().url().optional()
})
export type CrawlResponse = z.infer<typeof CrawlResponseSchema>
export const SearchResponseSchema = z.object({
success: z.boolean().optional(),
data: z.array(z.any()).optional()
})
export type SearchResponse = z.infer<typeof SearchResponseSchema>
export const CrawlStatusResponseObjSchema = z.object({
/** Markdown content of the page if the `markdown` format was specified (default) */
markdown: z
.string()
.describe(
'Markdown content of the page if the `markdown` format was specified (default)'
)
.optional(),
/** HTML version of the content on page if the `html` format was specified */
html: z
.string()
.describe(
'HTML version of the content on page if the `html` format was specified'
)
.optional(),
/** Raw HTML content of the page if the `rawHtml` format was specified */
rawHtml: z
.string()
.describe(
'Raw HTML content of the page if the `rawHtml` format was specified'
)
.optional(),
/** Links on the page if the `links` format was specified */
links: z
.array(z.string().url())
.describe('Links on the page if the `links` format was specified')
.optional(),
/** URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified */
screenshot: z
.string()
.describe(
'URL of the screenshot of the page if the `screenshot` or `screenshot@fullSize` format was specified'
)
.optional(),
metadata: z
.object({
title: z.string().optional(),
description: z.string().optional(),
language: z.string().optional(),
sourceURL: z.string().url().optional(),
'<any other metadata> ': z.string().optional(),
/** The status code of the page */
statusCode: z
.number()
.int()
.describe('The status code of the page')
.optional(),
/** The error message of the page */
error: z.string().describe('The error message of the page').optional()
})
.optional()
})
export type CrawlStatusResponseObj = z.infer<
typeof CrawlStatusResponseObjSchema
>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const ScrapeParamsSchema = z.object({
/** The URL to scrape */
url: z.string().url().describe('The URL to scrape'),
/**
* Specific formats to return.
*
* - markdown: The page in Markdown format.
* - html: The page's HTML, trimmed to include only meaningful content.
* - rawHtml: The page's original HTML.
* - links: The links on the page.
* - screenshot: A screenshot of the top of the page.
* - screenshot@fullPage: A screenshot of the full page. (overridden by screenshot if present)
*/
formats: z
.array(
z.enum([
'markdown',
'html',
'rawHtml',
'links',
'screenshot',
'screenshot@fullPage'
])
)
.describe(
"Specific formats to return.\n\n - markdown: The page in Markdown format.\n - html: The page's HTML, trimmed to include only meaningful content.\n - rawHtml: The page's original HTML.\n - links: The links on the page.\n - screenshot: A screenshot of the top of the page.\n - screenshot@fullPage: A screenshot of the full page. (overridden by screenshot if present)"
)
.default(['markdown']),
/** Headers to send with the request. Can be used to send cookies, user-agent, etc. */
headers: z
.record(z.any())
.describe(
'Headers to send with the request. Can be used to send cookies, user-agent, etc.'
)
.optional(),
/** Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer' */
includeTags: z
.array(z.string())
.describe(
"Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer' */
excludeTags: z
.array(z.string())
.describe(
"Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(true),
/** Timeout in milliseconds for the request */
timeout: z
.number()
.int()
.describe('Timeout in milliseconds for the request')
.default(30_000),
/** Wait x amount of milliseconds for the page to load to fetch content */
waitFor: z
.number()
.int()
.describe(
'Wait x amount of milliseconds for the page to load to fetch content'
)
.default(0)
})
export type ScrapeParams = z.infer<typeof ScrapeParamsSchema>
export const CrawlUrlsParamsSchema = z.object({
/** The base URL to start crawling from */
url: z.string().url().describe('The base URL to start crawling from'),
crawlerOptions: z
.object({
/** URL patterns to include */
includes: z
.array(z.string())
.describe('URL patterns to include')
.optional(),
/** URL patterns to exclude */
excludes: z
.array(z.string())
.describe('URL patterns to exclude')
.optional(),
/** Generate alt text for images using LLMs (must have a paid plan) */
generateImgAltText: z
.boolean()
.describe(
'Generate alt text for images using LLMs (must have a paid plan)'
)
.default(false),
/** If true, returns only the URLs as a list on the crawl status. Attention: the return response will be a list of URLs inside the data, not a list of documents. */
returnOnlyUrls: z
.boolean()
.describe(
'If true, returns only the URLs as a list on the crawl status. Attention: the return response will be a list of URLs inside the data, not a list of documents.'
)
.default(false),
/** Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern. */
maxDepth: z
.number()
.int()
.describe(
'Maximum depth to crawl relative to the entered URL. A maxDepth of 0 scrapes only the entered URL. A maxDepth of 1 scrapes the entered URL and all pages one level deep. A maxDepth of 2 scrapes the entered URL and all pages up to two levels deep. Higher values follow the same pattern.'
)
.optional(),
/** The crawling mode to use. Fast mode crawls 4x faster websites without sitemap, but may not be as accurate and shouldn't be used in heavy js-rendered websites. */
mode: z
.enum(['default', 'fast'])
.describe(
"The crawling mode to use. Fast mode crawls 4x faster websites without sitemap, but may not be as accurate and shouldn't be used in heavy js-rendered websites."
)
.default('default'),
/** Ignore the website sitemap when crawling */
ignoreSitemap: z
.boolean()
.describe('Ignore the website sitemap when crawling')
.default(false),
/** Maximum number of pages to crawl */
limit: z
.number()
.int()
.describe('Maximum number of pages to crawl')
.default(10_000),
/** Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product' */
allowBackwardCrawling: z
.boolean()
.describe(
"Enables the crawler to navigate from a specific URL to previously linked pages. For instance, from 'example.com/product/123' back to 'example.com/product'"
)
.default(false),
/** Allows the crawler to follow links to external websites. */
allowExternalContentLinks: z
.boolean()
.describe('Allows the crawler to follow links to external websites.')
.default(false)
})
.optional(),
pageOptions: z
.object({
/** Headers to send with the request. Can be used to send cookies, user-agent, etc. */
headers: z
.record(z.any())
.describe(
'Headers to send with the request. Can be used to send cookies, user-agent, etc.'
)
.optional(),
/** Include the HTML version of the content on page. Will output a html key in the response. */
includeHtml: z
.boolean()
.describe(
'Include the HTML version of the content on page. Will output a html key in the response.'
)
.default(false),
/** Include the raw HTML content of the page. Will output a rawHtml key in the response. */
includeRawHtml: z
.boolean()
.describe(
'Include the raw HTML content of the page. Will output a rawHtml key in the response.'
)
.default(false),
/** Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer' */
onlyIncludeTags: z
.array(z.string())
.describe(
"Only include tags, classes and ids from the page in the final output. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(false),
/** Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer' */
removeTags: z
.array(z.string())
.describe(
"Tags, classes and ids to remove from the page. Use comma separated values. Example: 'script, .ad, #footer'"
)
.optional(),
/** Replace all relative paths with absolute paths for images and links */
replaceAllPathsWithAbsolutePaths: z
.boolean()
.describe(
'Replace all relative paths with absolute paths for images and links'
)
.default(false),
/** Include a screenshot of the top of the page that you are scraping. */
screenshot: z
.boolean()
.describe(
'Include a screenshot of the top of the page that you are scraping.'
)
.default(false),
/** Include a full page screenshot of the page that you are scraping. */
fullPageScreenshot: z
.boolean()
.describe(
'Include a full page screenshot of the page that you are scraping.'
)
.default(false),
/** Wait x amount of milliseconds for the page to load to fetch content */
waitFor: z
.number()
.int()
.describe(
'Wait x amount of milliseconds for the page to load to fetch content'
)
.default(0)
})
.optional()
})
export type CrawlUrlsParams = z.infer<typeof CrawlUrlsParamsSchema>
export const CrawlUrlsResponseSchema = CrawlResponseSchema
export type CrawlUrlsResponse = z.infer<typeof CrawlUrlsResponseSchema>
export const SearchGoogleParamsSchema = z.object({
/** The query to search for */
query: z.string().url().describe('The query to search for'),
pageOptions: z
.object({
/** Only return the main content of the page excluding headers, navs, footers, etc. */
onlyMainContent: z
.boolean()
.describe(
'Only return the main content of the page excluding headers, navs, footers, etc.'
)
.default(false),
/** Fetch the content of each page. If false, defaults to a basic fast serp API. */
fetchPageContent: z
.boolean()
.describe(
'Fetch the content of each page. If false, defaults to a basic fast serp API.'
)
.default(true),
/** Include the HTML version of the content on page. Will output a html key in the response. */
includeHtml: z
.boolean()
.describe(
'Include the HTML version of the content on page. Will output a html key in the response.'
)
.default(false),
/** Include the raw HTML content of the page. Will output a rawHtml key in the response. */
includeRawHtml: z
.boolean()
.describe(
'Include the raw HTML content of the page. Will output a rawHtml key in the response.'
)
.default(false)
})
.optional(),
searchOptions: z
.object({
/** Maximum number of results. Max is 20 during beta. */
limit: z
.number()
.int()
.describe('Maximum number of results. Max is 20 during beta.')
.optional()
})
.optional()
})
export type SearchGoogleParams = z.infer<typeof SearchGoogleParamsSchema>
export const SearchGoogleResponseSchema = SearchResponseSchema
export type SearchGoogleResponse = z.infer<typeof SearchGoogleResponseSchema>
export const GetCrawlStatusParamsSchema = z.object({
/** ID of the crawl job */
jobId: z.string().describe('ID of the crawl job')
})
export type GetCrawlStatusParams = z.infer<typeof GetCrawlStatusParamsSchema>
export const GetCrawlStatusResponseSchema = z.object({
/** Status of the job (completed, active, failed, paused) */
status: z
.string()
.describe('Status of the job (completed, active, failed, paused)')
.optional(),
/** Current page number */
current: z.number().int().describe('Current page number').optional(),
/** Total number of pages */
total: z.number().int().describe('Total number of pages').optional(),
/** Data returned from the job (null when it is in progress) */
data: z
.array(CrawlStatusResponseObjSchema)
.describe('Data returned from the job (null when it is in progress)')
.optional(),
/** Partial documents returned as it is being crawled (streaming). **This feature is currently in alpha - expect breaking changes** When a page is ready, it will append to the partial_data array, so there is no need to wait for the entire website to be crawled. When the crawl is done, partial_data will become empty and the result will be available in `data`. There is a max of 50 items in the array response. The oldest item (top of the array) will be removed when the new item is added to the array. */
partial_data: z
.array(CrawlStatusResponseObjSchema)
.describe(
'Partial documents returned as it is being crawled (streaming). **This feature is currently in alpha - expect breaking changes** When a page is ready, it will append to the partial_data array, so there is no need to wait for the entire website to be crawled. When the crawl is done, partial_data will become empty and the result will be available in `data`. There is a max of 50 items in the array response. The oldest item (top of the array) will be removed when the new item is added to the array.'
)
.optional()
})
export type GetCrawlStatusResponse = z.infer<
typeof GetCrawlStatusResponseSchema
>
export const CancelCrawlJobParamsSchema = z.object({
/** ID of the crawl job */
jobId: z.string().describe('ID of the crawl job')
})
export type CancelCrawlJobParams = z.infer<typeof CancelCrawlJobParamsSchema>
export const CancelCrawlJobResponseSchema = z.object({
/** Returns cancelled. */
status: z.string().describe('Returns cancelled.').optional()
})
export type CancelCrawlJobResponse = z.infer<
typeof CancelCrawlJobResponseSchema
>
}

Wyświetl plik

@ -1,6 +1,3 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
@ -12,57 +9,8 @@ import {
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace petstore {
export const apiBaseUrl = 'http://petstore.swagger.io/v1'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const PetSchema = z.object({
id: z.number().int(),
name: z.string(),
tag: z.string().optional()
})
export type Pet = z.infer<typeof PetSchema>
export const PetsSchema = z.array(PetSchema).max(100)
export type Pets = z.infer<typeof PetsSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const ListPetsParamsSchema = z.object({
/** How many items to return at one time (max 100) */
limit: z
.number()
.int()
.lte(100)
.describe('How many items to return at one time (max 100)')
.optional()
})
export type ListPetsParams = z.infer<typeof ListPetsParamsSchema>
export const ListPetsResponseSchema = PetsSchema
export type ListPetsResponse = z.infer<typeof ListPetsResponseSchema>
export const CreatePetsParamsSchema = PetSchema
export type CreatePetsParams = z.infer<typeof CreatePetsParamsSchema>
export type CreatePetsResponse = undefined
export const ShowPetByIdParamsSchema = z.object({
/** The id of the pet to retrieve */
petId: z.string().describe('The id of the pet to retrieve')
})
export type ShowPetByIdParams = z.infer<typeof ShowPetByIdParamsSchema>
export const ShowPetByIdResponseSchema = PetSchema
export type ShowPetByIdResponse = z.infer<typeof ShowPetByIdResponseSchema>
}
import { petstore } from './pet-store'
/**
* Agentic PetStore client.
@ -95,7 +43,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_list_pets',
description: `List all pets.`,
inputSchema: petstore.ListPetsParamsSchema
inputSchema: petstore.ListPetsParamsSchema,
tags: ['pets']
})
async listPets(
params: petstore.ListPetsParams
@ -113,7 +62,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_create_pets',
description: `Create a pet.`,
inputSchema: petstore.CreatePetsParamsSchema
inputSchema: petstore.CreatePetsParamsSchema,
tags: ['pets']
})
async createPets(
params: petstore.CreatePetsParams
@ -131,7 +81,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_show_pet_by_id',
description: `Info for a specific pet.`,
inputSchema: petstore.ShowPetByIdParamsSchema
inputSchema: petstore.ShowPetByIdParamsSchema,
tags: ['pets']
})
async showPetById(
params: petstore.ShowPetByIdParams

Wyświetl plik

@ -0,0 +1,55 @@
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'
export namespace petstore {
export const apiBaseUrl = 'http://petstore.swagger.io/v1'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const PetSchema = z.object({
id: z.number().int(),
name: z.string(),
tag: z.string().optional()
})
export type Pet = z.infer<typeof PetSchema>
export const PetsSchema = z.array(PetSchema).max(100)
export type Pets = z.infer<typeof PetsSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const ListPetsParamsSchema = z.object({
/** How many items to return at one time (max 100) */
limit: z
.number()
.int()
.lte(100)
.describe('How many items to return at one time (max 100)')
.optional()
})
export type ListPetsParams = z.infer<typeof ListPetsParamsSchema>
export const ListPetsResponseSchema = PetsSchema
export type ListPetsResponse = z.infer<typeof ListPetsResponseSchema>
export const CreatePetsParamsSchema = PetSchema
export type CreatePetsParams = z.infer<typeof CreatePetsParamsSchema>
export type CreatePetsResponse = undefined
export const ShowPetByIdParamsSchema = z.object({
/** The id of the pet to retrieve */
petId: z.string().describe('The id of the pet to retrieve')
})
export type ShowPetByIdParams = z.infer<typeof ShowPetByIdParamsSchema>
export const ShowPetByIdResponseSchema = PetSchema
export type ShowPetByIdResponse = z.infer<typeof ShowPetByIdResponseSchema>
}

Wyświetl plik

@ -1,6 +1,3 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
@ -12,69 +9,8 @@ import {
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace petstoreexpanded {
export const apiBaseUrl = 'http://petstore.swagger.io/api'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const NewPetSchema = z.object({
name: z.string(),
tag: z.string().optional()
})
export type NewPet = z.infer<typeof NewPetSchema>
export const PetSchema = z.intersection(
NewPetSchema,
z.object({ id: z.number().int() })
)
export type Pet = z.infer<typeof PetSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const FindPetsParamsSchema = z.object({
/** tags to filter by */
tags: z.array(z.string()).describe('tags to filter by').optional(),
/** maximum number of results to return */
limit: z
.number()
.int()
.describe('maximum number of results to return')
.optional()
})
export type FindPetsParams = z.infer<typeof FindPetsParamsSchema>
export const FindPetsResponseSchema = z.array(PetSchema)
export type FindPetsResponse = z.infer<typeof FindPetsResponseSchema>
export const AddPetParamsSchema = NewPetSchema
export type AddPetParams = z.infer<typeof AddPetParamsSchema>
export const AddPetResponseSchema = PetSchema
export type AddPetResponse = z.infer<typeof AddPetResponseSchema>
export const FindPetByIdParamsSchema = z.object({
/** ID of pet to fetch */
id: z.number().int().describe('ID of pet to fetch')
})
export type FindPetByIdParams = z.infer<typeof FindPetByIdParamsSchema>
export const FindPetByIdResponseSchema = PetSchema
export type FindPetByIdResponse = z.infer<typeof FindPetByIdResponseSchema>
export const DeletePetParamsSchema = z.object({
/** ID of pet to delete */
id: z.number().int().describe('ID of pet to delete')
})
export type DeletePetParams = z.infer<typeof DeletePetParamsSchema>
export type DeletePetResponse = undefined
}
import { petstoreexpanded } from './petstore-expanded'
/**
* Agentic PetstoreExpanded client.

Wyświetl plik

@ -0,0 +1,67 @@
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'
export namespace petstoreexpanded {
export const apiBaseUrl = 'http://petstore.swagger.io/api'
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
export const NewPetSchema = z.object({
name: z.string(),
tag: z.string().optional()
})
export type NewPet = z.infer<typeof NewPetSchema>
export const PetSchema = z.intersection(
NewPetSchema,
z.object({ id: z.number().int() })
)
export type Pet = z.infer<typeof PetSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const FindPetsParamsSchema = z.object({
/** tags to filter by */
tags: z.array(z.string()).describe('tags to filter by').optional(),
/** maximum number of results to return */
limit: z
.number()
.int()
.describe('maximum number of results to return')
.optional()
})
export type FindPetsParams = z.infer<typeof FindPetsParamsSchema>
export const FindPetsResponseSchema = z.array(PetSchema)
export type FindPetsResponse = z.infer<typeof FindPetsResponseSchema>
export const AddPetParamsSchema = NewPetSchema
export type AddPetParams = z.infer<typeof AddPetParamsSchema>
export const AddPetResponseSchema = PetSchema
export type AddPetResponse = z.infer<typeof AddPetResponseSchema>
export const FindPetByIdParamsSchema = z.object({
/** ID of pet to fetch */
id: z.number().int().describe('ID of pet to fetch')
})
export type FindPetByIdParams = z.infer<typeof FindPetByIdParamsSchema>
export const FindPetByIdResponseSchema = PetSchema
export type FindPetByIdResponse = z.infer<typeof FindPetByIdResponseSchema>
export const DeletePetParamsSchema = z.object({
/** ID of pet to delete */
id: z.number().int().describe('ID of pet to delete')
})
export type DeletePetParams = z.infer<typeof DeletePetParamsSchema>
export type DeletePetResponse = undefined
}

Wyświetl plik

@ -1,124 +1,11 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace security {
export const apiBaseUrl = 'https://httpbin.org'
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetAnythingApiKeyParamsSchema = z.object({})
export type GetAnythingApiKeyParams = z.infer<
typeof GetAnythingApiKeyParamsSchema
>
export type GetAnythingApiKeyResponse = undefined
export const PostAnythingApiKeyParamsSchema = z.object({})
export type PostAnythingApiKeyParams = z.infer<
typeof PostAnythingApiKeyParamsSchema
>
export type PostAnythingApiKeyResponse = undefined
export const PutAnythingApiKeyParamsSchema = z.object({})
export type PutAnythingApiKeyParams = z.infer<
typeof PutAnythingApiKeyParamsSchema
>
export type PutAnythingApiKeyResponse = undefined
export const PostAnythingBasicParamsSchema = z.object({})
export type PostAnythingBasicParams = z.infer<
typeof PostAnythingBasicParamsSchema
>
export type PostAnythingBasicResponse = undefined
export const PostAnythingBearerParamsSchema = z.object({})
export type PostAnythingBearerParams = z.infer<
typeof PostAnythingBearerParamsSchema
>
export type PostAnythingBearerResponse = undefined
export const PutAnythingBearerParamsSchema = z.object({})
export type PutAnythingBearerParams = z.infer<
typeof PutAnythingBearerParamsSchema
>
export type PutAnythingBearerResponse = undefined
export const GetAnythingOauth2ParamsSchema = z.object({})
export type GetAnythingOauth2Params = z.infer<
typeof GetAnythingOauth2ParamsSchema
>
export type GetAnythingOauth2Response = undefined
export const PostAnythingOauth2ParamsSchema = z.object({})
export type PostAnythingOauth2Params = z.infer<
typeof PostAnythingOauth2ParamsSchema
>
export type PostAnythingOauth2Response = undefined
export const PutAnythingOauth2ParamsSchema = z.object({})
export type PutAnythingOauth2Params = z.infer<
typeof PutAnythingOauth2ParamsSchema
>
export type PutAnythingOauth2Response = undefined
export const DeleteAnythingOauth2ParamsSchema = z.object({})
export type DeleteAnythingOauth2Params = z.infer<
typeof DeleteAnythingOauth2ParamsSchema
>
export type DeleteAnythingOauth2Response = undefined
export const PatchAnythingOauth2ParamsSchema = z.object({})
export type PatchAnythingOauth2Params = z.infer<
typeof PatchAnythingOauth2ParamsSchema
>
export type PatchAnythingOauth2Response = undefined
export const PostAnythingOpenIdConnectParamsSchema = z.object({})
export type PostAnythingOpenIdConnectParams = z.infer<
typeof PostAnythingOpenIdConnectParamsSchema
>
export type PostAnythingOpenIdConnectResponse = undefined
export const PostAnythingNoAuthParamsSchema = z.object({})
export type PostAnythingNoAuthParams = z.infer<
typeof PostAnythingNoAuthParamsSchema
>
export type PostAnythingNoAuthResponse = undefined
export const GetAnythingOptionalAuthParamsSchema = z.object({})
export type GetAnythingOptionalAuthParams = z.infer<
typeof GetAnythingOptionalAuthParamsSchema
>
export type GetAnythingOptionalAuthResponse = undefined
export const PostStatus401ParamsSchema = z.object({})
export type PostStatus401Params = z.infer<typeof PostStatus401ParamsSchema>
export type PostStatus401Response = undefined
}
import { security } from './security'
/**
* Agentic Security client.
@ -153,7 +40,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_get_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`apiKey\` query parameter.`,
inputSchema: security.GetAnythingApiKeyParamsSchema
inputSchema: security.GetAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async getAnythingApiKey(
_params: security.GetAnythingApiKeyParams
@ -169,7 +57,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_post_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`api_key\` cookie.`,
inputSchema: security.PostAnythingApiKeyParamsSchema
inputSchema: security.PostAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async postAnythingApiKey(
_params: security.PostAnythingApiKeyParams
@ -185,7 +74,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_put_anything_api_key',
description: `\`apiKey\` auth will be supplied within an \`X-API-KEY\` header.`,
inputSchema: security.PutAnythingApiKeyParamsSchema
inputSchema: security.PutAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async putAnythingApiKey(
_params: security.PutAnythingApiKeyParams
@ -205,7 +95,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
description: `Authentication credentials will be supplied within a \`Basic\` \`Authorization\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.`,
inputSchema: security.PostAnythingBasicParamsSchema
inputSchema: security.PostAnythingBasicParamsSchema,
tags: ['HTTP']
})
async postAnythingBasic(
_params: security.PostAnythingBasicParams
@ -225,7 +116,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
description: `Authentication credentials will be supplied within a \`Bearer\` \`Authorization\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.`,
inputSchema: security.PostAnythingBearerParamsSchema
inputSchema: security.PostAnythingBearerParamsSchema,
tags: ['HTTP']
})
async postAnythingBearer(
_params: security.PostAnythingBearerParams
@ -251,7 +143,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
>
> We currently do not support any special handling for this so they're handled as a standard \`Bearer\` authentication token.`,
inputSchema: security.PutAnythingBearerParamsSchema
inputSchema: security.PutAnythingBearerParamsSchema,
tags: ['HTTP']
})
async putAnythingBearer(
_params: security.PutAnythingBearerParams
@ -273,7 +166,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \`oauth2\` requirement we assume that the user, or the projects JWT, has a qualified \`bearer\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.GetAnythingOauth2ParamsSchema
inputSchema: security.GetAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async getAnythingOauth2(
_params: security.GetAnythingOauth2Params
@ -295,7 +189,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \`oauth2\` requirement we assume that the user, or the projects JWT, has a qualified \`bearer\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PostAnythingOauth2ParamsSchema
inputSchema: security.PostAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async postAnythingOauth2(
_params: security.PostAnythingOauth2Params
@ -317,7 +212,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \`oauth2\` requirement we assume that the user, or the projects JWT, has a qualified \`bearer\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PutAnythingOauth2ParamsSchema
inputSchema: security.PutAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async putAnythingOauth2(
_params: security.PutAnythingOauth2Params
@ -339,7 +235,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \`oauth2\` requirement we assume that the user, or the projects JWT, has a qualified \`bearer\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.DeleteAnythingOauth2ParamsSchema
inputSchema: security.DeleteAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async deleteAnythingOauth2(
_params: security.DeleteAnythingOauth2Params
@ -361,7 +258,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \`oauth2\` requirement we assume that the user, or the projects JWT, has a qualified \`bearer\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.`,
inputSchema: security.PatchAnythingOauth2ParamsSchema
inputSchema: security.PatchAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async patchAnythingOauth2(
_params: security.PatchAnythingOauth2Params
@ -377,7 +275,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
@aiFunction({
name: 'security_post_anything_open_id_connect',
description: `🚧 This is not supported.`,
inputSchema: security.PostAnythingOpenIdConnectParamsSchema
inputSchema: security.PostAnythingOpenIdConnectParamsSchema,
tags: ['OpenID Connect']
})
async postAnythingOpenIdConnect(
_params: security.PostAnythingOpenIdConnectParams
@ -393,7 +292,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
@aiFunction({
name: 'security_post_anything_no_auth',
description: `This operation does not have any authentication requirements.`,
inputSchema: security.PostAnythingNoAuthParamsSchema
inputSchema: security.PostAnythingNoAuthParamsSchema,
tags: ['Other']
})
async postAnythingNoAuth(
_params: security.PostAnythingNoAuthParams
@ -413,7 +313,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securit
description: `The \`apiKey\` query parameter auth on this operation is optional.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object.`,
inputSchema: security.GetAnythingOptionalAuthParamsSchema
inputSchema: security.GetAnythingOptionalAuthParamsSchema,
tags: ['Other']
})
async getAnythingOptionalAuth(
_params: security.GetAnythingOptionalAuthParams
@ -429,7 +330,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securit
@aiFunction({
name: 'security_post_status401',
description: `This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.`,
inputSchema: security.PostStatus401ParamsSchema
inputSchema: security.PostStatus401ParamsSchema,
tags: ['Other']
})
async postStatus401(
_params: security.PostStatus401Params

Wyświetl plik

@ -0,0 +1,116 @@
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'
export namespace security {
export const apiBaseUrl = 'https://httpbin.org'
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetAnythingApiKeyParamsSchema = z.object({})
export type GetAnythingApiKeyParams = z.infer<
typeof GetAnythingApiKeyParamsSchema
>
export type GetAnythingApiKeyResponse = undefined
export const PostAnythingApiKeyParamsSchema = z.object({})
export type PostAnythingApiKeyParams = z.infer<
typeof PostAnythingApiKeyParamsSchema
>
export type PostAnythingApiKeyResponse = undefined
export const PutAnythingApiKeyParamsSchema = z.object({})
export type PutAnythingApiKeyParams = z.infer<
typeof PutAnythingApiKeyParamsSchema
>
export type PutAnythingApiKeyResponse = undefined
export const PostAnythingBasicParamsSchema = z.object({})
export type PostAnythingBasicParams = z.infer<
typeof PostAnythingBasicParamsSchema
>
export type PostAnythingBasicResponse = undefined
export const PostAnythingBearerParamsSchema = z.object({})
export type PostAnythingBearerParams = z.infer<
typeof PostAnythingBearerParamsSchema
>
export type PostAnythingBearerResponse = undefined
export const PutAnythingBearerParamsSchema = z.object({})
export type PutAnythingBearerParams = z.infer<
typeof PutAnythingBearerParamsSchema
>
export type PutAnythingBearerResponse = undefined
export const GetAnythingOauth2ParamsSchema = z.object({})
export type GetAnythingOauth2Params = z.infer<
typeof GetAnythingOauth2ParamsSchema
>
export type GetAnythingOauth2Response = undefined
export const PostAnythingOauth2ParamsSchema = z.object({})
export type PostAnythingOauth2Params = z.infer<
typeof PostAnythingOauth2ParamsSchema
>
export type PostAnythingOauth2Response = undefined
export const PutAnythingOauth2ParamsSchema = z.object({})
export type PutAnythingOauth2Params = z.infer<
typeof PutAnythingOauth2ParamsSchema
>
export type PutAnythingOauth2Response = undefined
export const DeleteAnythingOauth2ParamsSchema = z.object({})
export type DeleteAnythingOauth2Params = z.infer<
typeof DeleteAnythingOauth2ParamsSchema
>
export type DeleteAnythingOauth2Response = undefined
export const PatchAnythingOauth2ParamsSchema = z.object({})
export type PatchAnythingOauth2Params = z.infer<
typeof PatchAnythingOauth2ParamsSchema
>
export type PatchAnythingOauth2Response = undefined
export const PostAnythingOpenIdConnectParamsSchema = z.object({})
export type PostAnythingOpenIdConnectParams = z.infer<
typeof PostAnythingOpenIdConnectParamsSchema
>
export type PostAnythingOpenIdConnectResponse = undefined
export const PostAnythingNoAuthParamsSchema = z.object({})
export type PostAnythingNoAuthParams = z.infer<
typeof PostAnythingNoAuthParamsSchema
>
export type PostAnythingNoAuthResponse = undefined
export const GetAnythingOptionalAuthParamsSchema = z.object({})
export type GetAnythingOptionalAuthParams = z.infer<
typeof GetAnythingOptionalAuthParamsSchema
>
export type GetAnythingOptionalAuthResponse = undefined
export const PostStatus401ParamsSchema = z.object({})
export type PostStatus401Params = z.infer<typeof PostStatus401ParamsSchema>
export type PostStatus401Response = undefined
}

Wyświetl plik

@ -1,6 +1,3 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
@ -64086,12 +64083,12 @@ Updating an invoices line item is only possible before the invoice is finaliz
}
/**
* <p>[Deprecated] Approves a pending Issuing <code>Authorization</code> object. This request should be made within the timeout window of the <a href="/docs/issuing/controls/real-time-authorizations">real-time authorization</a> flow.
* <p>[Deprecated] Approves a pending Issuing <code>Authorization</code> object. This request should be made within the timeout window of the <a href="/docs/issuing/controls/real-time-authorizations">real-time authorization</a> flow.
This method is deprecated. Instead, <a href="/docs/issuing/controls/real-time-authorizations#authorization-handling">respond directly to the webhook request to approve an authorization</a>.</p>.
*/
@aiFunction({
name: 'post_issuing_authorizations_authorization_approve',
description: `<p>[Deprecated] Approves a pending Issuing <code>Authorization</code> object. This request should be made within the timeout window of the <a href="/docs/issuing/controls/real-time-authorizations">real-time authorization</a> flow.
description: `<p>[Deprecated] Approves a pending Issuing <code>Authorization</code> object. This request should be made within the timeout window of the <a href="/docs/issuing/controls/real-time-authorizations">real-time authorization</a> flow.
This method is deprecated. Instead, <a href="/docs/issuing/controls/real-time-authorizations#authorization-handling">respond directly to the webhook request to approve an authorization</a>.</p>.`,
inputSchema:
stripe.PostIssuingAuthorizationsAuthorizationApproveParamsSchema

Wyświetl plik

@ -1,65 +1,11 @@
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace tictactoe {
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
/** Winner of the game. `.` means nobody has won yet. */
export const WinnerSchema = z
.enum(['.', 'X', 'O'])
.describe('Winner of the game. `.` means nobody has won yet.')
export type Winner = z.infer<typeof WinnerSchema>
/** Possible values for a board square. `.` means empty square. */
export const MarkSchema = z
.enum(['.', 'X', 'O'])
.describe('Possible values for a board square. `.` means empty square.')
export type Mark = z.infer<typeof MarkSchema>
export const BoardSchema = z
.array(z.array(MarkSchema).min(3).max(3))
.min(3)
.max(3)
export type Board = z.infer<typeof BoardSchema>
export const StatusSchema = z.object({
winner: WinnerSchema.optional(),
board: BoardSchema.optional()
})
export type Status = z.infer<typeof StatusSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetBoardParamsSchema = z.object({})
export type GetBoardParams = z.infer<typeof GetBoardParamsSchema>
export const GetBoardResponseSchema = StatusSchema
export type GetBoardResponse = z.infer<typeof GetBoardResponseSchema>
export const GetSquareParamsSchema = z.object({})
export type GetSquareParams = z.infer<typeof GetSquareParamsSchema>
export const GetSquareResponseSchema = MarkSchema
export type GetSquareResponse = z.infer<typeof GetSquareResponseSchema>
export const PutSquareParamsSchema = MarkSchema
export type PutSquareParams = z.infer<typeof PutSquareParamsSchema>
export const PutSquareResponseSchema = StatusSchema
export type PutSquareResponse = z.infer<typeof PutSquareResponseSchema>
}
import { tictactoe } from './tic-tac-toe'
/**
* Agentic TicTacToe client.
@ -96,7 +42,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_get_board',
description: `Retrieves the current state of the board and the winner.`,
inputSchema: tictactoe.GetBoardParamsSchema
inputSchema: tictactoe.GetBoardParamsSchema,
tags: ['Gameplay']
})
async getBoard(
_params: tictactoe.GetBoardParams
@ -110,7 +57,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_get_square',
description: `Retrieves the requested square.`,
inputSchema: tictactoe.GetSquareParamsSchema
inputSchema: tictactoe.GetSquareParamsSchema,
tags: ['Gameplay']
})
async getSquare(
_params: tictactoe.GetSquareParams
@ -126,7 +74,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_put_square',
description: `Places a mark on the board and retrieves the whole board and the winner (if any).`,
inputSchema: tictactoe.PutSquareParamsSchema
inputSchema: tictactoe.PutSquareParamsSchema,
tags: ['Gameplay']
})
async putSquare(
_params: tictactoe.PutSquareParams

Wyświetl plik

@ -0,0 +1,57 @@
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'
export namespace tictactoe {
// -----------------------------------------------------------------------------
// Component schemas
// -----------------------------------------------------------------------------
/** Winner of the game. `.` means nobody has won yet. */
export const WinnerSchema = z
.enum(['.', 'X', 'O'])
.describe('Winner of the game. `.` means nobody has won yet.')
export type Winner = z.infer<typeof WinnerSchema>
/** Possible values for a board square. `.` means empty square. */
export const MarkSchema = z
.enum(['.', 'X', 'O'])
.describe('Possible values for a board square. `.` means empty square.')
export type Mark = z.infer<typeof MarkSchema>
export const BoardSchema = z
.array(z.array(MarkSchema).min(3).max(3))
.min(3)
.max(3)
export type Board = z.infer<typeof BoardSchema>
export const StatusSchema = z.object({
winner: WinnerSchema.optional(),
board: BoardSchema.optional()
})
export type Status = z.infer<typeof StatusSchema>
// -----------------------------------------------------------------------------
// Operation schemas
// -----------------------------------------------------------------------------
export const GetBoardParamsSchema = z.object({})
export type GetBoardParams = z.infer<typeof GetBoardParamsSchema>
export const GetBoardResponseSchema = StatusSchema
export type GetBoardResponse = z.infer<typeof GetBoardResponseSchema>
export const GetSquareParamsSchema = z.object({})
export type GetSquareParams = z.infer<typeof GetSquareParamsSchema>
export const GetSquareResponseSchema = MarkSchema
export type GetSquareResponse = z.infer<typeof GetSquareResponseSchema>
export const PutSquareParamsSchema = MarkSchema
export type PutSquareParams = z.infer<typeof PutSquareParamsSchema>
export const PutSquareResponseSchema = StatusSchema
export type PutSquareResponse = z.infer<typeof PutSquareResponseSchema>
}

Wyświetl plik

@ -1,21 +1,10 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`openapi-to-ts > firecrawl.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
assert,
getEnv,
pick
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace firecrawl {
@ -487,6 +476,21 @@ export namespace firecrawl {
>
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
assert,
getEnv,
pick
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { firecrawl } from './firecrawl'
/**
* Agentic Firecrawl client.
*
@ -529,7 +533,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_scrape',
description: \`Scrape a single URL.\`,
inputSchema: firecrawl.ScrapeParamsSchema
inputSchema: firecrawl.ScrapeParamsSchema,
tags: ['Scraping']
})
async scrape(
params: firecrawl.ScrapeParams
@ -557,7 +562,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_crawl_urls',
description: \`Crawl multiple URLs based on options.\`,
inputSchema: firecrawl.CrawlUrlsParamsSchema
inputSchema: firecrawl.CrawlUrlsParamsSchema,
tags: ['Crawling']
})
async crawlUrls(
params: firecrawl.CrawlUrlsParams
@ -575,7 +581,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_search_google',
description: \`Search for a keyword in Google, returns top page results with markdown content for each page.\`,
inputSchema: firecrawl.SearchGoogleParamsSchema
inputSchema: firecrawl.SearchGoogleParamsSchema,
tags: ['Search']
})
async searchGoogle(
params: firecrawl.SearchGoogleParams
@ -593,7 +600,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_get_crawl_status',
description: \`Get the status of a crawl job.\`,
inputSchema: firecrawl.GetCrawlStatusParamsSchema
inputSchema: firecrawl.GetCrawlStatusParamsSchema,
tags: ['Crawl']
})
async getCrawlStatus(
params: firecrawl.GetCrawlStatusParams
@ -609,7 +617,8 @@ export class FirecrawlClient extends AIFunctionsProvider {
@aiFunction({
name: 'firecrawl_cancel_crawl_job',
description: \`Cancel a crawl job.\`,
inputSchema: firecrawl.CancelCrawlJobParamsSchema
inputSchema: firecrawl.CancelCrawlJobParamsSchema,
tags: ['Crawl']
})
async cancelCrawlJob(
params: firecrawl.CancelCrawlJobParams
@ -623,22 +632,10 @@ export class FirecrawlClient extends AIFunctionsProvider {
`;
exports[`openapi-to-ts > notion.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
assert,
getEnv,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace notion {
@ -2090,6 +2087,22 @@ export namespace notion {
export type OauthTokenParams = z.infer<typeof OauthTokenParamsSchema>
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
assert,
getEnv,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { notion } from './notion'
/**
* Agentic Notion client.
*
@ -2567,20 +2580,10 @@ export class NotionClient extends AIFunctionsProvider {
`;
exports[`openapi-to-ts > pet-store.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace petstore {
@ -2633,6 +2636,20 @@ export namespace petstore {
export type ShowPetByIdResponse = z.infer<typeof ShowPetByIdResponseSchema>
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { petstore } from './pet-store'
/**
* Agentic PetStore client.
*/
@ -2664,7 +2681,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_list_pets',
description: \`List all pets.\`,
inputSchema: petstore.ListPetsParamsSchema
inputSchema: petstore.ListPetsParamsSchema,
tags: ['pets']
})
async listPets(
params: petstore.ListPetsParams
@ -2682,7 +2700,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_create_pets',
description: \`Create a pet.\`,
inputSchema: petstore.CreatePetsParamsSchema
inputSchema: petstore.CreatePetsParamsSchema,
tags: ['pets']
})
async createPets(
params: petstore.CreatePetsParams
@ -2700,7 +2719,8 @@ export class PetStoreClient extends AIFunctionsProvider {
@aiFunction({
name: 'pet_store_show_pet_by_id',
description: \`Info for a specific pet.\`,
inputSchema: petstore.ShowPetByIdParamsSchema
inputSchema: petstore.ShowPetByIdParamsSchema,
tags: ['pets']
})
async showPetById(
params: petstore.ShowPetByIdParams
@ -2714,20 +2734,10 @@ export class PetStoreClient extends AIFunctionsProvider {
`;
exports[`openapi-to-ts > petstore-expanded.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace petstoreexpanded {
@ -2792,6 +2802,20 @@ export namespace petstoreexpanded {
export type DeletePetResponse = undefined
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import {
AIFunctionsProvider,
aiFunction,
pick,
sanitizeSearchParams
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { petstoreexpanded } from './petstore-expanded'
/**
* Agentic PetstoreExpanded client.
*
@ -2897,15 +2921,10 @@ Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condime
`;
exports[`openapi-to-ts > security.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import { AIFunctionsProvider, aiFunction } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace security {
@ -3019,6 +3038,15 @@ export namespace security {
export type PostStatus401Response = undefined
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { AIFunctionsProvider, aiFunction } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { security } from './security'
/**
* Agentic Security client.
*
@ -3052,7 +3080,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_get_anything_api_key',
description: \`\\\`apiKey\\\` auth will be supplied within an \\\`apiKey\\\` query parameter.\`,
inputSchema: security.GetAnythingApiKeyParamsSchema
inputSchema: security.GetAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async getAnythingApiKey(
_params: security.GetAnythingApiKeyParams
@ -3068,7 +3097,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_post_anything_api_key',
description: \`\\\`apiKey\\\` auth will be supplied within an \\\`api_key\\\` cookie.\`,
inputSchema: security.PostAnythingApiKeyParamsSchema
inputSchema: security.PostAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async postAnythingApiKey(
_params: security.PostAnythingApiKeyParams
@ -3084,7 +3114,8 @@ export class SecurityClient extends AIFunctionsProvider {
@aiFunction({
name: 'security_put_anything_api_key',
description: \`\\\`apiKey\\\` auth will be supplied within an \\\`X-API-KEY\\\` header.\`,
inputSchema: security.PutAnythingApiKeyParamsSchema
inputSchema: security.PutAnythingApiKeyParamsSchema,
tags: ['API Key']
})
async putAnythingApiKey(
_params: security.PutAnythingApiKeyParams
@ -3104,7 +3135,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
description: \`Authentication credentials will be supplied within a \\\`Basic\\\` \\\`Authorization\\\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.\`,
inputSchema: security.PostAnythingBasicParamsSchema
inputSchema: security.PostAnythingBasicParamsSchema,
tags: ['HTTP']
})
async postAnythingBasic(
_params: security.PostAnythingBasicParams
@ -3124,7 +3156,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
description: \`Authentication credentials will be supplied within a \\\`Bearer\\\` \\\`Authorization\\\` header.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample.\`,
inputSchema: security.PostAnythingBearerParamsSchema
inputSchema: security.PostAnythingBearerParamsSchema,
tags: ['HTTP']
})
async postAnythingBearer(
_params: security.PostAnythingBearerParams
@ -3150,7 +3183,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-a
>
> We currently do not support any special handling for this so they're handled as a standard \\\`Bearer\\\` authentication token.\`,
inputSchema: security.PutAnythingBearerParamsSchema
inputSchema: security.PutAnythingBearerParamsSchema,
tags: ['HTTP']
})
async putAnythingBearer(
_params: security.PutAnythingBearerParams
@ -3172,7 +3206,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \\\`oauth2\\\` requirement we assume that the user, or the projects JWT, has a qualified \\\`bearer\\\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.\`,
inputSchema: security.GetAnythingOauth2ParamsSchema
inputSchema: security.GetAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async getAnythingOauth2(
_params: security.GetAnythingOauth2Params
@ -3194,7 +3229,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \\\`oauth2\\\` requirement we assume that the user, or the projects JWT, has a qualified \\\`bearer\\\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.\`,
inputSchema: security.PostAnythingOauth2ParamsSchema
inputSchema: security.PostAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async postAnythingOauth2(
_params: security.PostAnythingOauth2Params
@ -3216,7 +3252,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \\\`oauth2\\\` requirement we assume that the user, or the projects JWT, has a qualified \\\`bearer\\\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.\`,
inputSchema: security.PutAnythingOauth2ParamsSchema
inputSchema: security.PutAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async putAnythingOauth2(
_params: security.PutAnythingOauth2Params
@ -3238,7 +3275,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \\\`oauth2\\\` requirement we assume that the user, or the projects JWT, has a qualified \\\`bearer\\\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.\`,
inputSchema: security.DeleteAnythingOauth2ParamsSchema
inputSchema: security.DeleteAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async deleteAnythingOauth2(
_params: security.DeleteAnythingOauth2Params
@ -3260,7 +3298,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
> We currently do not handle OAuth 2 authentication flows so if an operation has an \\\`oauth2\\\` requirement we assume that the user, or the projects JWT, has a qualified \\\`bearer\\\` token and will use that.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-23.\`,
inputSchema: security.PatchAnythingOauth2ParamsSchema
inputSchema: security.PatchAnythingOauth2ParamsSchema,
tags: ['OAuth 2']
})
async patchAnythingOauth2(
_params: security.PatchAnythingOauth2Params
@ -3276,7 +3315,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
@aiFunction({
name: 'security_post_anything_open_id_connect',
description: \`🚧 This is not supported.\`,
inputSchema: security.PostAnythingOpenIdConnectParamsSchema
inputSchema: security.PostAnythingOpenIdConnectParamsSchema,
tags: ['OpenID Connect']
})
async postAnythingOpenIdConnect(
_params: security.PostAnythingOpenIdConnectParams
@ -3292,7 +3332,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-f
@aiFunction({
name: 'security_post_anything_no_auth',
description: \`This operation does not have any authentication requirements.\`,
inputSchema: security.PostAnythingNoAuthParamsSchema
inputSchema: security.PostAnythingNoAuthParamsSchema,
tags: ['Other']
})
async postAnythingNoAuth(
_params: security.PostAnythingNoAuthParams
@ -3312,7 +3353,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securit
description: \`The \\\`apiKey\\\` query parameter auth on this operation is optional.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object.\`,
inputSchema: security.GetAnythingOptionalAuthParamsSchema
inputSchema: security.GetAnythingOptionalAuthParamsSchema,
tags: ['Other']
})
async getAnythingOptionalAuth(
_params: security.GetAnythingOptionalAuthParams
@ -3328,7 +3370,8 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securit
@aiFunction({
name: 'security_post_status401',
description: \`This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.\`,
inputSchema: security.PostStatus401ParamsSchema
inputSchema: security.PostStatus401ParamsSchema,
tags: ['Other']
})
async postStatus401(
_params: security.PostStatus401Params
@ -3340,15 +3383,10 @@ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securit
`;
exports[`openapi-to-ts > tic-tac-toe.json 1`] = `
"/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
/**
"/**
* This file was auto-generated from an OpenAPI spec.
*/
import { AIFunctionsProvider, aiFunction } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'
export namespace tictactoe {
@ -3403,6 +3441,15 @@ export namespace tictactoe {
export type PutSquareResponse = z.infer<typeof PutSquareResponseSchema>
}
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { AIFunctionsProvider, aiFunction } from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { tictactoe } from './tic-tac-toe'
/**
* Agentic TicTacToe client.
*
@ -3438,7 +3485,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_get_board',
description: \`Retrieves the current state of the board and the winner.\`,
inputSchema: tictactoe.GetBoardParamsSchema
inputSchema: tictactoe.GetBoardParamsSchema,
tags: ['Gameplay']
})
async getBoard(
_params: tictactoe.GetBoardParams
@ -3452,7 +3500,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_get_square',
description: \`Retrieves the requested square.\`,
inputSchema: tictactoe.GetSquareParamsSchema
inputSchema: tictactoe.GetSquareParamsSchema,
tags: ['Gameplay']
})
async getSquare(
_params: tictactoe.GetSquareParams
@ -3468,7 +3517,8 @@ export class TicTacToeClient extends AIFunctionsProvider {
@aiFunction({
name: 'tic_tac_toe_put_square',
description: \`Places a mark on the board and retrieves the whole board and the winner (if any).\`,
inputSchema: tictactoe.PutSquareParamsSchema
inputSchema: tictactoe.PutSquareParamsSchema,
tags: ['Gameplay']
})
async putSquare(
_params: tictactoe.PutSquareParams

Wyświetl plik

@ -75,6 +75,7 @@ export async function generateTSFromOpenAPI({
const namespaceName = nameLowerCase
const destFileClient = path.join(outputDir, `${nameKebabCase}-client.ts`)
const destFileTypes = path.join(outputDir, `${nameKebabCase}.ts`)
const apiBaseUrl = spec.servers?.[0]?.url
const securitySchemes = spec.components?.securitySchemes
@ -515,12 +516,15 @@ export async function generateTSFromOpenAPI({
operation.description || operation.summary
)
const { tags } = operation
const hasTags = !!tags?.length
const aiClientMethod = `
${description ? `/**\n * ${description}\n */` : ''}
@aiFunction({
name: '${operationNameSnakeCase}',
${description ? `description: \`${description.replaceAll('`', '\\`')}\`,` : ''}${hasUnionParams ? '\n// TODO: Improve handling of union params' : ''}
inputSchema: ${namespaceName}.${operationParamsName}Schema${hasUnionParams ? ' as any' : ''},
inputSchema: ${namespaceName}.${operationParamsName}Schema${hasUnionParams ? ' as any' : ''}, ${hasTags ? `tags: [ '${tags.join("', '")}' ]` : ''}
})
async ${operationName}(${!hasParams ? '_' : ''}params: ${namespaceName}.${operationParamsName}): Promise<${namespaceName}.${operationResponseName}> {
return this.ky.${method}(${pathTemplate}${
@ -613,10 +617,24 @@ export async function generateTSFromOpenAPI({
const aiClientMethodsString = aiClientMethods.join('\n\n')
const header = `
/* eslint-disable unicorn/no-unreadable-iife */
/* eslint-disable unicorn/no-array-reduce */
const prettifyImpl = async (code: string) => {
if (prettier) {
code = await prettify(code)
}
return code
.replaceAll(/z\s*\.object\({}\)\s*\.merge\(([^)]*)\)/gm, '$1')
.replaceAll(/\/\*\*(\S.*\S)\*\//g, '/** $1 */')
}
const typesHeader = `
/**
* This file was auto-generated from an OpenAPI spec.
*/
import { z } from 'zod'`.trim()
const clientHeader = `
/**
* This file was auto-generated from an OpenAPI spec.
*/
@ -630,34 +648,34 @@ import {
${aiClientMethodsString.includes('sanitizeSearchParams(') ? 'sanitizeSearchParams,' : ''}
} from '@agentic/core'
import defaultKy, { type KyInstance } from 'ky'
import { z } from 'zod'`.trim()
import { ${namespaceName} } from './${nameKebabCase}'`.trim()
const commentLine = `// ${'-'.repeat(77)}`
const outputTypes = [
header,
`export namespace ${namespaceName} {`,
apiBaseUrl ? `export const apiBaseUrl = '${apiBaseUrl}'` : undefined,
Object.values(componentSchemas).length
? `${commentLine}\n// Component schemas\n${commentLine}`
: undefined,
...Object.values(componentSchemas),
Object.values(operationSchemas).length
? `${commentLine}\n// Operation schemas\n${commentLine}`
: undefined,
...Object.values(operationSchemas),
'}'
]
.filter(Boolean)
.join('\n\n')
const typesOutput = await prettifyImpl(
[
typesHeader,
`export namespace ${namespaceName} {`,
apiBaseUrl ? `export const apiBaseUrl = '${apiBaseUrl}'` : undefined,
Object.values(componentSchemas).length
? `${commentLine}\n// Component schemas\n${commentLine}`
: undefined,
...Object.values(componentSchemas),
Object.values(operationSchemas).length
? `${commentLine}\n// Operation schemas\n${commentLine}`
: undefined,
...Object.values(operationSchemas),
'}'
]
.filter(Boolean)
.join('\n\n')
)
const description = getDescription(spec.info?.description)
const prettifyImpl = prettier ? prettify : (code: string) => code
const output = (
await prettifyImpl(
[
outputTypes,
`
const clientOutput = await prettifyImpl(
[
clientHeader,
`
/**
* Agentic ${name} client.${description ? `\n *\n * ${description}` : ''}
*/
@ -700,23 +718,28 @@ export class ${clientName} extends AIFunctionsProvider {
})
}
`,
aiClientMethodsString,
'}'
].join('\n\n')
)
aiClientMethodsString,
'}'
].join('\n\n')
)
.replaceAll(/z\s*\.object\({}\)\s*\.merge\(([^)]*)\)/gm, '$1')
.replaceAll(/\/\*\*(\S.*\S)\*\//g, '/** $1 */')
const output = [typesOutput, clientOutput].join('\n\n')
if (dryRun) {
return output
}
await fs.mkdir(outputDir, { recursive: true })
await fs.writeFile(destFileClient, output)
await fs.writeFile(destFileTypes, typesOutput)
await fs.writeFile(destFileClient, clientOutput)
if (eslint) {
await execa('npx', ['eslint', '--fix', '--no-ignore', destFileClient])
await execa('npx', [
'eslint',
'--fix',
'--no-ignore',
destFileClient,
destFileTypes
])
}
return output

Wyświetl plik

@ -34,6 +34,7 @@
"@agentic/apollo": "workspace:*",
"@agentic/arxiv": "workspace:*",
"@agentic/bing": "workspace:*",
"@agentic/brave-search": "workspace:*",
"@agentic/calculator": "workspace:*",
"@agentic/clearbit": "workspace:*",
"@agentic/core": "workspace:*",

Wyświetl plik

@ -1,6 +1,7 @@
export * from '@agentic/apollo'
export * from '@agentic/arxiv'
export * from '@agentic/bing'
export * from '@agentic/brave-search'
export * from '@agentic/calculator'
export * from '@agentic/clearbit'
export * from '@agentic/dexa'

Wyświetl plik

@ -541,6 +541,22 @@ importers:
specifier: workspace:*
version: link:../tsconfig
packages/brave-search:
dependencies:
'@agentic/core':
specifier: workspace:*
version: link:../core
ky:
specifier: 'catalog:'
version: 1.7.5
zod:
specifier: 'catalog:'
version: 3.24.2
devDependencies:
'@agentic/tsconfig':
specifier: workspace:*
version: link:../tsconfig
packages/calculator:
dependencies:
'@agentic/core':
@ -1222,6 +1238,9 @@ importers:
'@agentic/bing':
specifier: workspace:*
version: link:../bing
'@agentic/brave-search':
specifier: workspace:*
version: link:../brave-search
'@agentic/calculator':
specifier: workspace:*
version: link:../calculator

Wyświetl plik

@ -183,6 +183,7 @@ Full docs are available at [agentic.so](https://agentic.so).
| [Apollo](https://docs.apollo.io) | `@agentic/apollo` | [docs](https://agentic.so/tools/apollo) | B2B person and company enrichment API. |
| [ArXiv](https://arxiv.org) | `@agentic/arxiv` | [docs](https://agentic.so/tools/arxiv) | Search for research articles. |
| [Bing](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api) | `@agentic/bing` | [docs](https://agentic.so/tools/bing) | Bing web search. |
| [Brave Search](https://brave.com/search/api) | `@agentic/brave-search` | [docs](https://agentic.so/tools/brave-search) | Brave web search and local places search. |
| [Calculator](https://github.com/josdejong/mathjs) | `@agentic/calculator` | [docs](https://agentic.so/tools/calculator) | Basic calculator for simple mathematical expressions. |
| [Clearbit](https://dashboard.clearbit.com/docs) | `@agentic/clearbit` | [docs](https://agentic.so/tools/clearbit) | Resolving and enriching people and company data. |
| [Dexa](https://dexa.ai) | `@agentic/dexa` | [docs](https://agentic.so/tools/dexa) | Answers questions from the world's best podcasters. |