kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Merge pull request #701 from transitive-bullshit/feature/moarrr
Misc fixes and additionsold-agentic
commit
bc65546bf5
|
@ -58,6 +58,7 @@
|
|||
"tools/apollo",
|
||||
"tools/arxiv",
|
||||
"tools/bing",
|
||||
"tools/brave-search",
|
||||
"tools/calculator",
|
||||
"tools/clearbit",
|
||||
"tools/dexa",
|
||||
|
@ -68,12 +69,15 @@
|
|||
"tools/firecrawl",
|
||||
"tools/hacker-news",
|
||||
"tools/gravatar",
|
||||
"tools/google-custom-search",
|
||||
"tools/hunter",
|
||||
"tools/jina",
|
||||
"tools/leadmagic",
|
||||
"tools/midjourney",
|
||||
"tools/mcp",
|
||||
"tools/notion",
|
||||
"tools/novu",
|
||||
"tools/open-meteo",
|
||||
"tools/people-data-labs",
|
||||
"tools/perigon",
|
||||
"tools/polygon",
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
title: Brave Search
|
||||
description: Brave web search and local places search.
|
||||
---
|
||||
|
||||
- package: `@agentic/brave-search`
|
||||
- exports: `class BraveSearchClient`, `namespace braveSearch`
|
||||
- env vars: `BRAVE_SEARCH_API_KEY`
|
||||
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/brave-search/src/brave-search-client.ts)
|
||||
- [brave search docs](https://brave.com/search/api)
|
||||
|
||||
## Install
|
||||
|
||||
<CodeGroup>
|
||||
```bash npm
|
||||
npm install @agentic/brave-search
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add @agentic/brave-search
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm add @agentic/brave-search
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { BraveSearchClient } from '@agentic/brave-search'
|
||||
|
||||
const braveSearch = new BraveSearchClient()
|
||||
const res = await braveSearch.search('latest news about openai')
|
||||
```
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: Google Custom Search
|
||||
description: Google Custom Search for online trends, news, current events, real-time information, or research topics.
|
||||
---
|
||||
|
||||
- package: `@agentic/google-custom-search`
|
||||
- exports: `class GoogleCustomSearchClient`, `namespace googleCustomSearch`
|
||||
- env vars: `GOOGLE_API_KEY`, `GOOGLE_CSE_ID`
|
||||
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/google-custom-search/src/google-custom-search-client.ts)
|
||||
- [google custom search docs](https://developers.google.com/custom-search/v1/overview)
|
||||
|
||||
## Install
|
||||
|
||||
<CodeGroup>
|
||||
```bash npm
|
||||
npm install @agentic/google-custom-search
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add @agentic/google-custom-search
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm add @agentic/google-custom-search
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { GoogleCustomSearchClient } from '@agentic/google-custom-search'
|
||||
|
||||
const googleCustomSearch = new GoogleCustomSearchClient()
|
||||
const results = await googleCustomSearch.search('latest news about openai')
|
||||
```
|
||||
|
||||
Make sure to set the `GOOGLE_API_KEY` and `GOOGLE_CSE_ID` environment variables or pass them to the constructor using the `apiKey` and `cseId` options.
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
title: Notion
|
||||
description: Notion API client.
|
||||
---
|
||||
|
||||
The [Notion API](https://developers.notion.com/docs) provides a router for accessing pages, databases, and content.
|
||||
|
||||
- package: `@agentic/notion`
|
||||
- exports: `class NotionClient`, `namespace notion`
|
||||
- env vars: `NOTION_API_KEY`
|
||||
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/notion/src/notion-client.ts)
|
||||
- [notion api docs](https://developers.notion.com/docs)
|
||||
|
||||
## Install
|
||||
|
||||
<CodeGroup>
|
||||
```bash npm
|
||||
npm install @agentic/notion
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add @agentic/notion
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm add @agentic/notion
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { NotionClient } from '@agentic/notion'
|
||||
|
||||
const notion = new NotionClient()
|
||||
const authenticatedUser = await notion.getSelf()
|
||||
```
|
||||
|
||||
You'll need to set up a [Notion Integration](https://developers.notion.com/docs/authorization), give it access to some pages in your Notion workspace, and then set the `NOTION_API_KEY` environment variable to the integration's token.
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
title: Open Meteo
|
||||
description: Open-Meteo weather API client.
|
||||
---
|
||||
|
||||
The [Open-Meteo weather API](https://open-meteo.com) provides a free weather forecast API for open-source developers and non-commercial use.
|
||||
|
||||
- package: `@agentic/open-meteo`
|
||||
- exports: `class OpenMeteoClient`, `namespace openmeteo`
|
||||
- env vars: `OPEN_METEO_API_KEY`
|
||||
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/open-meteo/src/open-meteo-client.ts)
|
||||
- [open-meteo api docs](https://open-meteo.com/en/docs)
|
||||
|
||||
## Install
|
||||
|
||||
<CodeGroup>
|
||||
```bash npm
|
||||
npm install @agentic/open-meteo
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add @agentic/open-meteo
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm add @agentic/open-meteo
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { OpenMeteoClient } from '@agentic/open-meteo'
|
||||
|
||||
const openMeteo = new OpenMeteoClient()
|
||||
const res = await openMeteo.getForecast({
|
||||
location: {
|
||||
name: 'San Francisco'
|
||||
}
|
||||
})
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git"
|
||||
},
|
||||
"packageManager": "pnpm@10.6.4",
|
||||
"packageManager": "pnpm@10.6.5",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "@agentic/brave-search",
|
||||
"version": "0.1.0",
|
||||
"description": "Agentic SDK for the Brave search engine.",
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/brave-search"
|
||||
},
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"clean": "del dist",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*",
|
||||
"ky": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@agentic/tsconfig": "workspace:*"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<p align="center">
|
||||
<a href="https://agentic.so">
|
||||
<img alt="Agentic" src="https://raw.githubusercontent.com/transitive-bullshit/agentic/main/docs/media/agentic-header.jpg" width="308">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<em>AI agent stdlib that works with any LLM and TypeScript AI SDK.</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml/badge.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/@agentic/stdlib"><img alt="NPM" src="https://img.shields.io/npm/v/@agentic/stdlib.svg" /></a>
|
||||
<a href="https://github.com/transitive-bullshit/agentic/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
||||
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
|
||||
</p>
|
||||
|
||||
# Agentic
|
||||
|
||||
**See the [github repo](https://github.com/transitive-bullshit/agentic) or [docs](https://agentic.so) for more info.**
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Travis Fischer](https://x.com/transitive_bs)
|
|
@ -0,0 +1,154 @@
|
|||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
assert,
|
||||
getEnv,
|
||||
sanitizeSearchParams
|
||||
} from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { bravesearch } from './brave-search'
|
||||
|
||||
/**
|
||||
* Agentic client for the Brave search engine.
|
||||
*
|
||||
* @see https://brave.com/search/api
|
||||
*/
|
||||
export class BraveSearchClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
protected readonly apiKey: string
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiKey = getEnv('BRAVE_SEARCH_API_KEY'),
|
||||
apiBaseUrl = bravesearch.apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
assert(
|
||||
apiKey,
|
||||
'BraveSearchClient missing required "apiKey" (defaults to "BRAVE_SEARCH_API_KEY")'
|
||||
)
|
||||
super()
|
||||
|
||||
this.apiKey = apiKey
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl,
|
||||
headers: {
|
||||
'X-Subscription-Token': apiKey
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Brave web search.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'brave_search',
|
||||
description:
|
||||
'Performs a web search using the Brave Search API, ideal for general queries, news, articles, and online content. ' +
|
||||
'Use this for broad information gathering, recent events, or when you need diverse web sources. ' +
|
||||
'Supports pagination, content filtering, and freshness controls. ' +
|
||||
'Maximum 20 results per request, with offset for pagination. ',
|
||||
inputSchema: bravesearch.SearchParamsSchema
|
||||
})
|
||||
async search(
|
||||
queryOrParams: string | bravesearch.SearchParams
|
||||
): Promise<bravesearch.SearchResponse> {
|
||||
const { query: q, ...params } =
|
||||
typeof queryOrParams === 'string'
|
||||
? { query: queryOrParams }
|
||||
: queryOrParams
|
||||
|
||||
return this.ky
|
||||
.get('res/v1/web/search', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
...params,
|
||||
q
|
||||
})
|
||||
})
|
||||
.json<bravesearch.SearchResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Brave local search for businesses and places.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'brave_local_search',
|
||||
description:
|
||||
"Searches for local businesses and places using Brave's Local Search API. " +
|
||||
'Best for queries related to physical locations, businesses, restaurants, services, etc. ' +
|
||||
'Returns detailed information including:\n' +
|
||||
'- Business names and addresses\n' +
|
||||
'- Ratings and review counts\n' +
|
||||
'- Phone numbers and opening hours\n' +
|
||||
"Use this when the query implies 'near me' or mentions specific locations. " +
|
||||
'Automatically falls back to web search if no local results are found.',
|
||||
inputSchema: bravesearch.LocalSearchParamsSchema
|
||||
})
|
||||
async localSearch(
|
||||
queryOrParams: string | bravesearch.LocalSearchParams
|
||||
): Promise<bravesearch.LocalSearchResponse | bravesearch.SearchResponse> {
|
||||
const { query: q, ...params } =
|
||||
typeof queryOrParams === 'string'
|
||||
? { query: queryOrParams }
|
||||
: queryOrParams
|
||||
|
||||
const webData = await this.ky
|
||||
.get('res/v1/web/search', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
search_lang: 'en',
|
||||
result_filter: 'locations',
|
||||
...params,
|
||||
q
|
||||
})
|
||||
})
|
||||
.json<bravesearch.SearchResponse>()
|
||||
|
||||
const locationIds = webData.locations?.results
|
||||
?.filter((r) => !!r.id)
|
||||
.map((r) => r.id)
|
||||
|
||||
if (!locationIds?.length) {
|
||||
return this.search(queryOrParams)
|
||||
}
|
||||
|
||||
// Get POI details and descriptions in parallel
|
||||
const [pois, descriptions] = await Promise.all([
|
||||
this.getPoisData(locationIds),
|
||||
this.getDescriptionsData(locationIds)
|
||||
])
|
||||
|
||||
const desc = descriptions.descriptions
|
||||
|
||||
return Object.entries(desc).map(([id, description]) => ({
|
||||
description,
|
||||
...pois.results.find((r) => r.id === id)!
|
||||
}))
|
||||
}
|
||||
|
||||
async getPoisData(ids: string[]): Promise<bravesearch.PoiResponse> {
|
||||
return this.ky
|
||||
.get('res/v1/local/pois', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
ids: ids.filter(Boolean)
|
||||
})
|
||||
})
|
||||
.json<bravesearch.PoiResponse>()
|
||||
}
|
||||
|
||||
async getDescriptionsData(ids: string[]): Promise<bravesearch.Description> {
|
||||
return this.ky
|
||||
.get('res/v1/local/descriptions', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
ids: ids.filter(Boolean)
|
||||
})
|
||||
})
|
||||
.json<bravesearch.Description>()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
import { z } from 'zod'
|
||||
|
||||
export namespace bravesearch {
|
||||
export const apiBaseUrl = 'https://api.search.brave.com'
|
||||
|
||||
export const SearchParamsSchema = z.object({
|
||||
query: z
|
||||
.string()
|
||||
.describe('Search query (max 400 chars, 50 words)')
|
||||
.optional(),
|
||||
count: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(20)
|
||||
.describe('Number of results (1-20, default 10)')
|
||||
.optional(),
|
||||
offset: z
|
||||
.number()
|
||||
.describe('Pagination offset (max 9, default 0)')
|
||||
.optional()
|
||||
})
|
||||
export type SearchParams = z.infer<typeof SearchParamsSchema>
|
||||
|
||||
export const LocalSearchParamsSchema = z.object({
|
||||
query: z
|
||||
.string()
|
||||
.describe('Search query (max 400 chars, 50 words)')
|
||||
.optional(),
|
||||
count: z
|
||||
.number()
|
||||
.describe('Number of results (1-20, default 10)')
|
||||
.int()
|
||||
.min(1)
|
||||
.max(20)
|
||||
.optional()
|
||||
})
|
||||
export type LocalSearchParams = z.infer<typeof LocalSearchParamsSchema>
|
||||
|
||||
export interface SearchResponse {
|
||||
web?: {
|
||||
results?: Array<{
|
||||
title: string
|
||||
description: string
|
||||
url: string
|
||||
language?: string
|
||||
published?: string
|
||||
rank?: number
|
||||
}>
|
||||
}
|
||||
locations?: {
|
||||
results?: Array<{
|
||||
id: string // Required by API
|
||||
title?: string
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
id: string
|
||||
name: string
|
||||
address: {
|
||||
streetAddress?: string
|
||||
addressLocality?: string
|
||||
addressRegion?: string
|
||||
postalCode?: string
|
||||
}
|
||||
coordinates?: {
|
||||
latitude: number
|
||||
longitude: number
|
||||
}
|
||||
phone?: string
|
||||
rating?: {
|
||||
ratingValue?: number
|
||||
ratingCount?: number
|
||||
}
|
||||
openingHours?: string[]
|
||||
priceRange?: string
|
||||
}
|
||||
|
||||
export interface PoiResponse {
|
||||
results: Location[]
|
||||
}
|
||||
|
||||
export interface Description {
|
||||
descriptions: { [id: string]: string }
|
||||
}
|
||||
|
||||
export type LocalSearchResponse = Array<Location & { description: string }>
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
export * from './brave-search'
|
||||
export * from './brave-search-client'
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@agentic/tsconfig/base.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
|
@ -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`.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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> =
|
||||
|
|
|
@ -40,7 +40,7 @@ export namespace github {
|
|||
}
|
||||
|
||||
/**
|
||||
* Basic GitHub API wrapper.
|
||||
* Agentic GitHub client.
|
||||
*/
|
||||
export class GitHubClient extends AIFunctionsProvider {
|
||||
protected readonly apiKey: string
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "@agentic/google-custom-search",
|
||||
"version": "0.1.0",
|
||||
"description": "Agentic client for the Google Custom Search API.",
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/google-custom-search"
|
||||
},
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"clean": "del dist",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*",
|
||||
"@googleapis/customsearch": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@agentic/tsconfig": "workspace:*"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<p align="center">
|
||||
<a href="https://agentic.so">
|
||||
<img alt="Agentic" src="https://raw.githubusercontent.com/transitive-bullshit/agentic/main/docs/media/agentic-header.jpg" width="308">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<em>AI agent stdlib that works with any LLM and TypeScript AI SDK.</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml/badge.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/@agentic/stdlib"><img alt="NPM" src="https://img.shields.io/npm/v/@agentic/stdlib.svg" /></a>
|
||||
<a href="https://github.com/transitive-bullshit/agentic/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
||||
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
|
||||
</p>
|
||||
|
||||
# Agentic
|
||||
|
||||
**See the [github repo](https://github.com/transitive-bullshit/agentic) or [docs](https://agentic.so) for more info.**
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Travis Fischer](https://x.com/transitive_bs)
|
|
@ -0,0 +1,99 @@
|
|||
import { aiFunction, AIFunctionsProvider, assert, getEnv } from '@agentic/core'
|
||||
import { customsearch_v1 as GoogleSearchAPI } from '@googleapis/customsearch'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { paginate } from './paginate'
|
||||
|
||||
export namespace googleCustomSearch {
|
||||
export const SearchParamsSchema = z.object({
|
||||
query: z.string().min(1).max(2048).describe('Search query'),
|
||||
maxResults: z.number().optional(),
|
||||
safeSearch: z
|
||||
.union([z.literal('active'), z.literal('off')])
|
||||
.optional()
|
||||
.describe('Search safety level. Defaults to "active".')
|
||||
})
|
||||
export type SearchParams = z.infer<typeof SearchParamsSchema>
|
||||
}
|
||||
|
||||
/**
|
||||
* Agentic client for the official Google Custom Search API.
|
||||
*
|
||||
* @see https://developers.google.com/custom-search/v1/overview
|
||||
*/
|
||||
export class GoogleCustomSearchClient extends AIFunctionsProvider {
|
||||
protected readonly apiKey: string
|
||||
|
||||
readonly cseId: string
|
||||
readonly client: GoogleSearchAPI.Customsearch
|
||||
|
||||
constructor({
|
||||
apiKey = getEnv('GOOGLE_API_KEY'),
|
||||
cseId = getEnv('GOOGLE_CSE_ID')
|
||||
}: {
|
||||
/** Google API key */
|
||||
apiKey?: string
|
||||
|
||||
/** Google Custom Search Engine ID */
|
||||
cseId?: string
|
||||
} = {}) {
|
||||
assert(
|
||||
apiKey,
|
||||
'GoogleCustomSearchClient missing required "apiKey" (defaults to "GOOGLE_API_KEY")'
|
||||
)
|
||||
assert(
|
||||
cseId,
|
||||
'GoogleCustomSearchClient missing required "cseId" (defaults to "GOOGLE_CSE_ID")'
|
||||
)
|
||||
super()
|
||||
|
||||
this.apiKey = apiKey
|
||||
this.cseId = cseId
|
||||
|
||||
this.client = new GoogleSearchAPI.Customsearch({
|
||||
auth: this.apiKey
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Custom Search for online trends, news, current events, real-time information, or research topics.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'google_custom_search',
|
||||
description: `Google Custom Search for online trends, news, current events, real-time information, or research topics.`,
|
||||
inputSchema: googleCustomSearch.SearchParamsSchema
|
||||
})
|
||||
async search(
|
||||
queryOrParams: string | googleCustomSearch.SearchParams
|
||||
): Promise<any> {
|
||||
const params =
|
||||
typeof queryOrParams === 'string'
|
||||
? { query: queryOrParams }
|
||||
: queryOrParams
|
||||
|
||||
const results = await paginate({
|
||||
size: params.maxResults ?? 10,
|
||||
handler: async ({ cursor = 0, limit }) => {
|
||||
const maxChunkSize = 10
|
||||
|
||||
const {
|
||||
data: { items = [] }
|
||||
} = await this.client.cse.list({
|
||||
cx: this.cseId,
|
||||
q: params.query,
|
||||
start: cursor,
|
||||
num: Math.min(limit, maxChunkSize),
|
||||
safe: params.safeSearch ?? 'active'
|
||||
})
|
||||
|
||||
return {
|
||||
data: items,
|
||||
nextCursor:
|
||||
items.length < maxChunkSize ? undefined : cursor + items.length
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return results
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from './google-custom-search-client'
|
|
@ -0,0 +1,34 @@
|
|||
export interface PaginateInput<T, C> {
|
||||
size: number
|
||||
handler: (data: {
|
||||
cursor?: C
|
||||
limit: number
|
||||
}) => Promise<{ data: T[]; nextCursor?: C }>
|
||||
}
|
||||
|
||||
export async function paginate<T, C = number>(
|
||||
input: PaginateInput<T, C>
|
||||
): Promise<T[]> {
|
||||
const acc: T[] = []
|
||||
let cursor: C | undefined
|
||||
|
||||
while (acc.length < input.size) {
|
||||
const { data, nextCursor } = await input.handler({
|
||||
cursor,
|
||||
limit: input.size - acc.length
|
||||
})
|
||||
acc.push(...data)
|
||||
|
||||
if (nextCursor === undefined || data.length === 0) {
|
||||
break
|
||||
}
|
||||
|
||||
cursor = nextCursor
|
||||
}
|
||||
|
||||
if (acc.length > input.size) {
|
||||
acc.length = input.size
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@agentic/tsconfig/base.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "@agentic/notion",
|
||||
"version": "0.1.0",
|
||||
"description": "Agentic SDK for Notion.",
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/notion"
|
||||
},
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"clean": "del dist",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*",
|
||||
"ky": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@agentic/tsconfig": "workspace:*"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<p align="center">
|
||||
<a href="https://agentic.so">
|
||||
<img alt="Agentic" src="https://raw.githubusercontent.com/transitive-bullshit/agentic/main/docs/media/agentic-header.jpg" width="308">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<em>AI agent stdlib that works with any LLM and TypeScript AI SDK.</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml/badge.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/@agentic/stdlib"><img alt="NPM" src="https://img.shields.io/npm/v/@agentic/stdlib.svg" /></a>
|
||||
<a href="https://github.com/transitive-bullshit/agentic/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
||||
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
|
||||
</p>
|
||||
|
||||
# Agentic
|
||||
|
||||
**See the [github repo](https://github.com/transitive-bullshit/agentic) or [docs](https://agentic.so) for more info.**
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Travis Fischer](https://x.com/transitive_bs)
|
|
@ -0,0 +1,2 @@
|
|||
export * from './notion'
|
||||
export * from './notion-client'
|
|
@ -0,0 +1,483 @@
|
|||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
assert,
|
||||
getEnv,
|
||||
pick,
|
||||
sanitizeSearchParams
|
||||
} from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { notion } from './notion'
|
||||
|
||||
/**
|
||||
* Agentic Notion client.
|
||||
*/
|
||||
export class NotionClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
protected readonly apiKey: string
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiKey = getEnv('NOTION_API_KEY'),
|
||||
apiBaseUrl = notion.apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
assert(
|
||||
apiKey,
|
||||
'NotionClient missing required "apiKey" (defaults to "NOTION_API_KEY")'
|
||||
)
|
||||
super()
|
||||
|
||||
this.apiKey = apiKey
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl,
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_self',
|
||||
description: `Get current user.`,
|
||||
inputSchema: notion.GetSelfParamsSchema
|
||||
})
|
||||
async getSelf(
|
||||
_params: notion.GetSelfParams
|
||||
): Promise<notion.GetSelfResponse> {
|
||||
return this.ky.get('/users/me').json<notion.GetSelfResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_user',
|
||||
description: `Get user.`,
|
||||
inputSchema: notion.GetUserParamsSchema
|
||||
})
|
||||
async getUser(params: notion.GetUserParams): Promise<notion.GetUserResponse> {
|
||||
return this.ky
|
||||
.get(`/users/${params.user_id}`)
|
||||
.json<notion.GetUserResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* List users.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_list_users',
|
||||
description: `List users.`,
|
||||
inputSchema: notion.ListUsersParamsSchema
|
||||
})
|
||||
async listUsers(
|
||||
params: notion.ListUsersParams
|
||||
): Promise<notion.ListUsersResponse> {
|
||||
return this.ky
|
||||
.get('/users', {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(params, 'start_cursor', 'page_size')
|
||||
)
|
||||
})
|
||||
.json<notion.ListUsersResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create page.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_create_page',
|
||||
description: `Create page.`,
|
||||
inputSchema: notion.CreatePageParamsSchema
|
||||
})
|
||||
async createPage(
|
||||
params: notion.CreatePageParams
|
||||
): Promise<notion.CreatePageResponse> {
|
||||
return this.ky
|
||||
.post('/pages', {
|
||||
json: pick(params, 'parent', 'properties')
|
||||
})
|
||||
.json<notion.CreatePageResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_page',
|
||||
description: `Get page.`,
|
||||
inputSchema: notion.GetPageParamsSchema
|
||||
})
|
||||
async getPage(params: notion.GetPageParams): Promise<notion.GetPageResponse> {
|
||||
return this.ky
|
||||
.get(`/pages/${params.page_id}`, {
|
||||
searchParams: sanitizeSearchParams(pick(params, 'filter_properties'))
|
||||
})
|
||||
.json<notion.GetPageResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update page.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_update_page',
|
||||
description: `Update page.`,
|
||||
inputSchema: notion.UpdatePageParamsSchema
|
||||
})
|
||||
async updatePage(
|
||||
params: notion.UpdatePageParams
|
||||
): Promise<notion.UpdatePageResponse> {
|
||||
return this.ky
|
||||
.patch(`/pages/${params.page_id}`, {
|
||||
json: pick(params, 'properties', 'archived')
|
||||
})
|
||||
.json<notion.UpdatePageResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page property.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_page_property',
|
||||
description: `Get page property.`,
|
||||
inputSchema: notion.GetPagePropertyParamsSchema
|
||||
})
|
||||
async getPageProperty(
|
||||
params: notion.GetPagePropertyParams
|
||||
): Promise<notion.GetPagePropertyResponse> {
|
||||
return this.ky
|
||||
.get(`/pages/${params.page_id}/properties/${params.property_id}`, {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(params, 'start_cursor', 'page_size')
|
||||
)
|
||||
})
|
||||
.json<notion.GetPagePropertyResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_block',
|
||||
description: `Get block.`,
|
||||
inputSchema: notion.GetBlockParamsSchema
|
||||
})
|
||||
async getBlock(
|
||||
params: notion.GetBlockParams
|
||||
): Promise<notion.GetBlockResponse> {
|
||||
return this.ky
|
||||
.get(`/blocks/${params.block_id}`)
|
||||
.json<notion.GetBlockResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete block.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_delete_block',
|
||||
description: `Delete block.`,
|
||||
inputSchema: notion.DeleteBlockParamsSchema
|
||||
})
|
||||
async deleteBlock(
|
||||
params: notion.DeleteBlockParams
|
||||
): Promise<notion.DeleteBlockResponse> {
|
||||
return this.ky
|
||||
.delete(`/blocks/${params.block_id}`)
|
||||
.json<notion.DeleteBlockResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update block.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_update_block',
|
||||
description: `Update block.`,
|
||||
inputSchema: notion.UpdateBlockParamsSchema
|
||||
})
|
||||
async updateBlock(
|
||||
params: notion.UpdateBlockParams
|
||||
): Promise<notion.UpdateBlockResponse> {
|
||||
return this.ky
|
||||
.patch(`/blocks/${params.block_id}`, {
|
||||
json: pick(
|
||||
params,
|
||||
'paragraph',
|
||||
'heading_1',
|
||||
'heading_2',
|
||||
'heading_3',
|
||||
'bulleted_list_item',
|
||||
'numbered_list_item',
|
||||
'quote',
|
||||
'to_do',
|
||||
'toggle',
|
||||
'code',
|
||||
'embed',
|
||||
'image',
|
||||
'video',
|
||||
'file',
|
||||
'pdf',
|
||||
'bookmark',
|
||||
'equation',
|
||||
'divider',
|
||||
'table_of_contents',
|
||||
'breadcrumb',
|
||||
'column_list',
|
||||
'column',
|
||||
'link_to_page',
|
||||
'table_row',
|
||||
'archived'
|
||||
)
|
||||
})
|
||||
.json<notion.UpdateBlockResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* List block children.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_list_block_children',
|
||||
description: `List block children.`,
|
||||
inputSchema: notion.ListBlockChildrenParamsSchema
|
||||
})
|
||||
async listBlockChildren(
|
||||
params: notion.ListBlockChildrenParams
|
||||
): Promise<notion.ListBlockChildrenResponse> {
|
||||
return this.ky
|
||||
.get(`/blocks/${params.block_id}/children`, {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(params, 'start_cursor', 'page_size')
|
||||
)
|
||||
})
|
||||
.json<notion.ListBlockChildrenResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Append block children.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_append_block_children',
|
||||
description: `Append block children.`,
|
||||
inputSchema: notion.AppendBlockChildrenParamsSchema
|
||||
})
|
||||
async appendBlockChildren(
|
||||
params: notion.AppendBlockChildrenParams
|
||||
): Promise<notion.AppendBlockChildrenResponse> {
|
||||
return this.ky
|
||||
.patch(`/blocks/${params.block_id}/children`, {
|
||||
json: pick(params, 'children')
|
||||
})
|
||||
.json<notion.AppendBlockChildrenResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_get_database',
|
||||
description: `Get database.`,
|
||||
inputSchema: notion.GetDatabaseParamsSchema
|
||||
})
|
||||
async getDatabase(
|
||||
params: notion.GetDatabaseParams
|
||||
): Promise<notion.GetDatabaseResponse> {
|
||||
return this.ky
|
||||
.get(`/databases/${params.database_id}`)
|
||||
.json<notion.GetDatabaseResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update database.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_update_database',
|
||||
description: `Update database.`,
|
||||
inputSchema: notion.UpdateDatabaseParamsSchema
|
||||
})
|
||||
async updateDatabase(
|
||||
params: notion.UpdateDatabaseParams
|
||||
): Promise<notion.UpdateDatabaseResponse> {
|
||||
return this.ky
|
||||
.patch(`/databases/${params.database_id}`, {
|
||||
json: pick(
|
||||
params,
|
||||
'title',
|
||||
'description',
|
||||
'icon',
|
||||
'cover',
|
||||
'properties',
|
||||
'is_inline',
|
||||
'archived'
|
||||
)
|
||||
})
|
||||
.json<notion.UpdateDatabaseResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Query database.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_query_database',
|
||||
description: `Query database.`,
|
||||
inputSchema: notion.QueryDatabaseParamsSchema
|
||||
})
|
||||
async queryDatabase(
|
||||
params: notion.QueryDatabaseParams
|
||||
): Promise<notion.QueryDatabaseResponse> {
|
||||
return this.ky
|
||||
.post(`/databases/${params.database_id}/query`, {
|
||||
searchParams: sanitizeSearchParams(pick(params, 'filter_properties')),
|
||||
json: pick(
|
||||
params,
|
||||
'sorts',
|
||||
'filter',
|
||||
'start_cursor',
|
||||
'page_size',
|
||||
'archived'
|
||||
)
|
||||
})
|
||||
.json<notion.QueryDatabaseResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* List databases.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_list_databases',
|
||||
description: `List databases.`,
|
||||
inputSchema: notion.ListDatabasesParamsSchema
|
||||
})
|
||||
async listDatabases(
|
||||
params: notion.ListDatabasesParams
|
||||
): Promise<notion.ListDatabasesResponse> {
|
||||
return this.ky
|
||||
.get('/databases', {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(params, 'start_cursor', 'page_size')
|
||||
)
|
||||
})
|
||||
.json<notion.ListDatabasesResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create database.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_create_database',
|
||||
description: `Create database.`,
|
||||
inputSchema: notion.CreateDatabaseParamsSchema
|
||||
})
|
||||
async createDatabase(
|
||||
params: notion.CreateDatabaseParams
|
||||
): Promise<notion.CreateDatabaseResponse> {
|
||||
return this.ky
|
||||
.post('/databases', {
|
||||
json: pick(
|
||||
params,
|
||||
'parent',
|
||||
'properties',
|
||||
'icon',
|
||||
'cover',
|
||||
'title',
|
||||
'description',
|
||||
'is_inline'
|
||||
)
|
||||
})
|
||||
.json<notion.CreateDatabaseResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Search.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_search',
|
||||
description: `Search.`,
|
||||
inputSchema: notion.SearchParamsSchema
|
||||
})
|
||||
async search(params: notion.SearchParams): Promise<notion.SearchResponse> {
|
||||
return this.ky
|
||||
.post('/search', {
|
||||
json: pick(
|
||||
params,
|
||||
'query',
|
||||
'sort',
|
||||
'filter',
|
||||
'start_cursor',
|
||||
'page_size'
|
||||
)
|
||||
})
|
||||
.json<notion.SearchResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* List comments.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_list_comments',
|
||||
description: `List comments.`,
|
||||
inputSchema: notion.ListCommentsParamsSchema
|
||||
})
|
||||
async listComments(
|
||||
params: notion.ListCommentsParams
|
||||
): Promise<notion.ListCommentsResponse> {
|
||||
return this.ky
|
||||
.get('/comments', {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(params, 'block_id', 'start_cursor', 'page_size')
|
||||
)
|
||||
})
|
||||
.json<notion.ListCommentsResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create comment.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_create_comment',
|
||||
description: `Create comment.`,
|
||||
// TODO: Improve handling of union params
|
||||
inputSchema: notion.CreateCommentParamsSchema as any
|
||||
})
|
||||
async createComment(
|
||||
params: notion.CreateCommentParams
|
||||
): Promise<notion.CreateCommentResponse> {
|
||||
return this.ky
|
||||
.post('/comments', {
|
||||
json: params
|
||||
})
|
||||
.json<notion.CreateCommentResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* OAuth token.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'notion_oauth_token',
|
||||
description: `OAuth token.`,
|
||||
inputSchema: notion.OauthTokenParamsSchema
|
||||
})
|
||||
async oauthToken(
|
||||
params: notion.OauthTokenParams
|
||||
): Promise<notion.OauthTokenResponse> {
|
||||
return this.ky
|
||||
.post('/oauth/token', {
|
||||
json: pick(
|
||||
params,
|
||||
'grant_type',
|
||||
'code',
|
||||
'redirect_uri',
|
||||
'external_account'
|
||||
)
|
||||
})
|
||||
.json<notion.OauthTokenResponse>()
|
||||
}
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@agentic/tsconfig/base.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "@agentic/open-meteo",
|
||||
"version": "7.6.1",
|
||||
"description": "Agentic SDK for the Open-Meteo weather API.",
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git"
|
||||
},
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"clean": "del dist",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*",
|
||||
"ky": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@agentic/tsconfig": "workspace:*"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<p align="center">
|
||||
<a href="https://agentic.so">
|
||||
<img alt="Agentic" src="https://raw.githubusercontent.com/transitive-bullshit/agentic/main/docs/media/agentic-header.jpg" width="308">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<em>AI agent stdlib that works with any LLM and TypeScript AI SDK.</em>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/agentic/actions/workflows/main.yml/badge.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/@agentic/stdlib"><img alt="NPM" src="https://img.shields.io/npm/v/@agentic/stdlib.svg" /></a>
|
||||
<a href="https://github.com/transitive-bullshit/agentic/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
||||
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
|
||||
</p>
|
||||
|
||||
# Agentic
|
||||
|
||||
**See the [github repo](https://github.com/transitive-bullshit/agentic) or [docs](https://agentic.so) for more info.**
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Travis Fischer](https://x.com/transitive_bs)
|
|
@ -0,0 +1,2 @@
|
|||
export * from './open-meteo'
|
||||
export * from './open-meteo-client'
|
|
@ -0,0 +1,159 @@
|
|||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
getEnv,
|
||||
omit,
|
||||
pick,
|
||||
sanitizeSearchParams
|
||||
} from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { openmeteo } from './open-meteo'
|
||||
|
||||
/**
|
||||
* Agentic OpenMeteo weather client.
|
||||
*
|
||||
* Open-Meteo offers free weather forecast APIs for open-source developers
|
||||
* and non-commercial use.
|
||||
*
|
||||
* @note The API key is optional.
|
||||
*
|
||||
* @see https://open-meteo.com/en/docs
|
||||
*/
|
||||
export class OpenMeteoClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
protected readonly apiKey: string | undefined
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiKey = getEnv('OPEN_METEO_API_KEY'),
|
||||
apiBaseUrl = openmeteo.apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
super()
|
||||
|
||||
this.apiKey = apiKey
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl,
|
||||
...(apiKey
|
||||
? {
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`
|
||||
}
|
||||
}
|
||||
: {})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 7-day weather variables in hourly and daily resolution for given WGS84 latitude and longitude coordinates. Available worldwide.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'open_meteo_get_forecast',
|
||||
description: `Gets the 7-day weather forecast in hourly and daily resolution for given location. Available worldwide.`,
|
||||
inputSchema: openmeteo.GetV1ForecastParamsSchema
|
||||
})
|
||||
async getForecast(
|
||||
params: openmeteo.GetV1ForecastParams
|
||||
): Promise<openmeteo.GetV1ForecastResponse> {
|
||||
const extractLocation = async (): Promise<openmeteo.Location> => {
|
||||
if ('name' in params.location) {
|
||||
const response = await this._geocode(params.location)
|
||||
return pick(response, 'latitude', 'longitude')
|
||||
}
|
||||
|
||||
return params.location
|
||||
}
|
||||
|
||||
const { start, end } = validateAndSetDates(params.startDate, params.endDate)
|
||||
|
||||
const response = await this.ky
|
||||
.get('forecast', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
...(await extractLocation()),
|
||||
temperature_unit: params.temperatureUnit,
|
||||
start_date: toDateString(start),
|
||||
end_date: toDateString(end),
|
||||
current: [
|
||||
'temperature_2m',
|
||||
'rain',
|
||||
'relative_humidity_2m',
|
||||
'wind_speed_10m'
|
||||
],
|
||||
daily: ['temperature_2m_max', 'temperature_2m_min', 'rain_sum'],
|
||||
hourly: ['temperature_2m', 'relative_humidity_2m', 'rain'],
|
||||
timezone: 'UTC'
|
||||
})
|
||||
})
|
||||
.json<openmeteo.GetV1ForecastResponse>()
|
||||
|
||||
return omit(
|
||||
response,
|
||||
'latitude',
|
||||
'longitude',
|
||||
'elevation',
|
||||
'generationtime_ms',
|
||||
'utc_offset_seconds',
|
||||
'timezone',
|
||||
'timezone_abbreviation',
|
||||
'elevation',
|
||||
'hourly',
|
||||
'hourly_units'
|
||||
)
|
||||
}
|
||||
|
||||
protected async _geocode(
|
||||
location: openmeteo.LocationSearch
|
||||
): Promise<openmeteo.Location> {
|
||||
const { results } = await this.ky
|
||||
.get('search', {
|
||||
searchParams: sanitizeSearchParams({
|
||||
name: location.name,
|
||||
language: location.language,
|
||||
country: location.country,
|
||||
format: 'json',
|
||||
count: 1
|
||||
})
|
||||
})
|
||||
.json<any>()
|
||||
|
||||
if (!results?.length) {
|
||||
throw new Error(`No results found for location "${location.name}"`)
|
||||
}
|
||||
|
||||
return results[0]
|
||||
}
|
||||
}
|
||||
|
||||
function toDateString(date: Date): string {
|
||||
return date.toISOString().split('T')[0]!
|
||||
}
|
||||
|
||||
function validateAndSetDates(
|
||||
startDateStr: string,
|
||||
endDateStr?: string
|
||||
): { start: Date; end: Date } {
|
||||
const now = new Date()
|
||||
const start = startDateStr
|
||||
? new Date(startDateStr)
|
||||
: new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()))
|
||||
|
||||
if (endDateStr) {
|
||||
const end = new Date(endDateStr)
|
||||
if (end < start) {
|
||||
throw new Error(
|
||||
`The 'end_date' (${endDateStr}) has to occur on or after the 'start_date' (${startDateStr}).`
|
||||
)
|
||||
}
|
||||
return { start, end }
|
||||
} else {
|
||||
// If endDate is undefined, set it to the start date
|
||||
return { start, end: new Date(start) }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
import { z } from 'zod'
|
||||
|
||||
export namespace openmeteo {
|
||||
export const apiBaseUrl = 'https://api.open-meteo.com/v1'
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Component schemas
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps. */
|
||||
export const HourlyResponseSchema = z
|
||||
.object({
|
||||
time: z.array(z.string()),
|
||||
temperature_2m: z.array(z.number()).optional(),
|
||||
relative_humidity_2m: z.array(z.number()).optional(),
|
||||
dew_point_2m: z.array(z.number()).optional(),
|
||||
apparent_temperature: z.array(z.number()).optional(),
|
||||
pressure_msl: z.array(z.number()).optional(),
|
||||
cloud_cover: z.array(z.number()).optional(),
|
||||
cloud_cover_low: z.array(z.number()).optional(),
|
||||
cloud_cover_mid: z.array(z.number()).optional(),
|
||||
cloud_cover_high: z.array(z.number()).optional(),
|
||||
wind_speed_10m: z.array(z.number()).optional(),
|
||||
wind_speed_80m: z.array(z.number()).optional(),
|
||||
wind_speed_120m: z.array(z.number()).optional(),
|
||||
wind_speed_180m: z.array(z.number()).optional(),
|
||||
wind_direction_10m: z.array(z.number()).optional(),
|
||||
wind_direction_80m: z.array(z.number()).optional(),
|
||||
wind_direction_120m: z.array(z.number()).optional(),
|
||||
wind_direction_180m: z.array(z.number()).optional(),
|
||||
wind_gusts_10m: z.array(z.number()).optional(),
|
||||
shortwave_radiation: z.array(z.number()).optional(),
|
||||
direct_radiation: z.array(z.number()).optional(),
|
||||
direct_normal_irradiance: z.array(z.number()).optional(),
|
||||
diffuse_radiation: z.array(z.number()).optional(),
|
||||
vapour_pressure_deficit: z.array(z.number()).optional(),
|
||||
evapotranspiration: z.array(z.number()).optional(),
|
||||
precipitation: z.array(z.number()).optional(),
|
||||
weather_code: z.array(z.number()).optional(),
|
||||
snow_height: z.array(z.number()).optional(),
|
||||
freezing_level_height: z.array(z.number()).optional(),
|
||||
soil_temperature_0cm: z.array(z.number()).optional(),
|
||||
soil_temperature_6cm: z.array(z.number()).optional(),
|
||||
soil_temperature_18cm: z.array(z.number()).optional(),
|
||||
soil_temperature_54cm: z.array(z.number()).optional(),
|
||||
soil_moisture_0_1cm: z.array(z.number()).optional(),
|
||||
soil_moisture_1_3cm: z.array(z.number()).optional(),
|
||||
soil_moisture_3_9cm: z.array(z.number()).optional(),
|
||||
soil_moisture_9_27cm: z.array(z.number()).optional(),
|
||||
soil_moisture_27_81cm: z.array(z.number()).optional()
|
||||
})
|
||||
.describe(
|
||||
'For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.'
|
||||
)
|
||||
export type HourlyResponse = z.infer<typeof HourlyResponseSchema>
|
||||
|
||||
/** For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps. */
|
||||
export const DailyResponseSchema = z
|
||||
.object({
|
||||
time: z.array(z.string()),
|
||||
temperature_2m_max: z.array(z.number()).optional(),
|
||||
temperature_2m_min: z.array(z.number()).optional(),
|
||||
apparent_temperature_max: z.array(z.number()).optional(),
|
||||
apparent_temperature_min: z.array(z.number()).optional(),
|
||||
precipitation_sum: z.array(z.number()).optional(),
|
||||
precipitation_hours: z.array(z.number()).optional(),
|
||||
weather_code: z.array(z.number()).optional(),
|
||||
sunrise: z.array(z.number()).optional(),
|
||||
sunset: z.array(z.number()).optional(),
|
||||
wind_speed_10m_max: z.array(z.number()).optional(),
|
||||
wind_gusts_10m_max: z.array(z.number()).optional(),
|
||||
wind_direction_10m_dominant: z.array(z.number()).optional(),
|
||||
shortwave_radiation_sum: z.array(z.number()).optional(),
|
||||
uv_index_max: z.array(z.number()).optional(),
|
||||
uv_index_clear_sky_max: z.array(z.number()).optional(),
|
||||
et0_fao_evapotranspiration: z.array(z.number()).optional()
|
||||
})
|
||||
.describe(
|
||||
'For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.'
|
||||
)
|
||||
export type DailyResponse = z.infer<typeof DailyResponseSchema>
|
||||
|
||||
/** Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code */
|
||||
export const CurrentWeatherSchema = z
|
||||
.object({
|
||||
time: z.string(),
|
||||
temperature: z.number(),
|
||||
wind_speed: z.number(),
|
||||
wind_direction: z.number(),
|
||||
weather_code: z.number().int()
|
||||
})
|
||||
.describe(
|
||||
'Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code'
|
||||
)
|
||||
export type CurrentWeather = z.infer<typeof CurrentWeatherSchema>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Operation schemas
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
export const GetV1ForecastParamsSchema = z.object({
|
||||
location: z.union([
|
||||
z
|
||||
.object({
|
||||
name: z.string().min(1),
|
||||
country: z.string().optional(),
|
||||
language: z.string().default('English')
|
||||
})
|
||||
.strip(),
|
||||
z
|
||||
.object({
|
||||
latitude: z.coerce.number(),
|
||||
longitude: z.coerce.number()
|
||||
})
|
||||
.strip()
|
||||
]),
|
||||
startDate: z
|
||||
.string()
|
||||
.date()
|
||||
.describe(
|
||||
'Start date for the weather forecast in the format YYYY-MM-DD (UTC)'
|
||||
),
|
||||
endDate: z
|
||||
.string()
|
||||
.date()
|
||||
.describe(
|
||||
'End date for the weather forecast in the format YYYY-MM-DD (UTC)'
|
||||
)
|
||||
.optional(),
|
||||
temperatureUnit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit')
|
||||
})
|
||||
export type GetV1ForecastParams = z.infer<typeof GetV1ForecastParamsSchema>
|
||||
|
||||
export const GetV1ForecastResponseSchema = z.object({
|
||||
/** WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away. */
|
||||
latitude: z
|
||||
.number()
|
||||
.describe(
|
||||
'WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.'
|
||||
)
|
||||
.optional(),
|
||||
/** WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away. */
|
||||
longitude: z
|
||||
.number()
|
||||
.describe(
|
||||
'WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.'
|
||||
)
|
||||
.optional(),
|
||||
/** The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect. */
|
||||
elevation: z
|
||||
.number()
|
||||
.describe(
|
||||
'The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect.'
|
||||
)
|
||||
.optional(),
|
||||
/** Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements. */
|
||||
generationtime_ms: z
|
||||
.number()
|
||||
.describe(
|
||||
'Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements.'
|
||||
)
|
||||
.optional(),
|
||||
/** Applied timezone offset from the &timezone= parameter. */
|
||||
utc_offset_seconds: z
|
||||
.number()
|
||||
.int()
|
||||
.describe('Applied timezone offset from the &timezone= parameter.')
|
||||
.optional(),
|
||||
hourly: HourlyResponseSchema.optional(),
|
||||
/** For each selected weather variable, the unit will be listed here. */
|
||||
hourly_units: z
|
||||
.record(z.string())
|
||||
.describe(
|
||||
'For each selected weather variable, the unit will be listed here.'
|
||||
)
|
||||
.optional(),
|
||||
daily: DailyResponseSchema.optional(),
|
||||
/** For each selected daily weather variable, the unit will be listed here. */
|
||||
daily_units: z
|
||||
.record(z.string())
|
||||
.describe(
|
||||
'For each selected daily weather variable, the unit will be listed here.'
|
||||
)
|
||||
.optional(),
|
||||
current_weather: CurrentWeatherSchema.optional()
|
||||
})
|
||||
export type GetV1ForecastResponse = z.infer<
|
||||
typeof GetV1ForecastResponseSchema
|
||||
>
|
||||
|
||||
export interface Location {
|
||||
latitude: number
|
||||
longitude: number
|
||||
}
|
||||
|
||||
export interface LocationSearch {
|
||||
name: string
|
||||
country?: string
|
||||
language?: string
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@agentic/tsconfig/base.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -1,498 +1,17 @@
|
|||
/* eslint-disable unicorn/no-unreadable-iife */
|
||||
/* eslint-disable unicorn/no-array-reduce */
|
||||
|
||||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import { aiFunction, AIFunctionsProvider, assert, getEnv } from '@agentic/core'
|
||||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
assert,
|
||||
getEnv,
|
||||
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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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())
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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().nullable().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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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())
|
||||
.nullable()
|
||||
.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()
|
||||
.nullable()
|
||||
.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().nullable().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()
|
||||
.nullable()
|
||||
.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.
|
||||
|
@ -534,16 +53,27 @@ export class FirecrawlClient extends AIFunctionsProvider {
|
|||
* Scrape a single URL.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'scrape',
|
||||
description: 'Scrape a single URL.',
|
||||
inputSchema: firecrawl.ScrapeParamsSchema
|
||||
name: 'firecrawl_scrape',
|
||||
description: `Scrape a single URL.`,
|
||||
inputSchema: firecrawl.ScrapeParamsSchema,
|
||||
tags: ['Scraping']
|
||||
})
|
||||
async scrape(
|
||||
params: firecrawl.ScrapeParams
|
||||
): Promise<firecrawl.ScrapeResponse> {
|
||||
return this.ky
|
||||
.post('/scrape', {
|
||||
json: params
|
||||
json: pick(
|
||||
params,
|
||||
'url',
|
||||
'formats',
|
||||
'headers',
|
||||
'includeTags',
|
||||
'excludeTags',
|
||||
'onlyMainContent',
|
||||
'timeout',
|
||||
'waitFor'
|
||||
)
|
||||
})
|
||||
.json<firecrawl.ScrapeResponse>()
|
||||
}
|
||||
|
@ -552,16 +82,17 @@ export class FirecrawlClient extends AIFunctionsProvider {
|
|||
* Crawl multiple URLs based on options.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'crawl_urls',
|
||||
description: 'Crawl multiple URLs based on options.',
|
||||
inputSchema: firecrawl.CrawlUrlsParamsSchema
|
||||
name: 'firecrawl_crawl_urls',
|
||||
description: `Crawl multiple URLs based on options.`,
|
||||
inputSchema: firecrawl.CrawlUrlsParamsSchema,
|
||||
tags: ['Crawling']
|
||||
})
|
||||
async crawlUrls(
|
||||
params: firecrawl.CrawlUrlsParams
|
||||
): Promise<firecrawl.CrawlUrlsResponse> {
|
||||
return this.ky
|
||||
.post('/crawl', {
|
||||
json: params
|
||||
json: pick(params, 'url', 'crawlerOptions', 'pageOptions')
|
||||
})
|
||||
.json<firecrawl.CrawlUrlsResponse>()
|
||||
}
|
||||
|
@ -570,17 +101,17 @@ export class FirecrawlClient extends AIFunctionsProvider {
|
|||
* Search for a keyword in Google, returns top page results with markdown content for each page.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'search_google',
|
||||
description:
|
||||
'Search for a keyword in Google, returns top page results with markdown content for each page.',
|
||||
inputSchema: firecrawl.SearchGoogleParamsSchema
|
||||
name: 'firecrawl_search_google',
|
||||
description: `Search for a keyword in Google, returns top page results with markdown content for each page.`,
|
||||
inputSchema: firecrawl.SearchGoogleParamsSchema,
|
||||
tags: ['Search']
|
||||
})
|
||||
async searchGoogle(
|
||||
params: firecrawl.SearchGoogleParams
|
||||
): Promise<firecrawl.SearchGoogleResponse> {
|
||||
return this.ky
|
||||
.post('/search', {
|
||||
json: params
|
||||
json: pick(params, 'query', 'pageOptions', 'searchOptions')
|
||||
})
|
||||
.json<firecrawl.SearchGoogleResponse>()
|
||||
}
|
||||
|
@ -589,9 +120,10 @@ export class FirecrawlClient extends AIFunctionsProvider {
|
|||
* Get the status of a crawl job.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'get_crawl_status',
|
||||
description: 'Get the status of a crawl job.',
|
||||
inputSchema: firecrawl.GetCrawlStatusParamsSchema
|
||||
name: 'firecrawl_get_crawl_status',
|
||||
description: `Get the status of a crawl job.`,
|
||||
inputSchema: firecrawl.GetCrawlStatusParamsSchema,
|
||||
tags: ['Crawl']
|
||||
})
|
||||
async getCrawlStatus(
|
||||
params: firecrawl.GetCrawlStatusParams
|
||||
|
@ -605,9 +137,10 @@ export class FirecrawlClient extends AIFunctionsProvider {
|
|||
* Cancel a crawl job.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'cancel_crawl_job',
|
||||
description: 'Cancel a crawl job.',
|
||||
inputSchema: firecrawl.CancelCrawlJobParamsSchema
|
||||
name: 'firecrawl_cancel_crawl_job',
|
||||
description: `Cancel a crawl job.`,
|
||||
inputSchema: firecrawl.CancelCrawlJobParamsSchema,
|
||||
tags: ['Crawl']
|
||||
})
|
||||
async cancelCrawlJob(
|
||||
params: firecrawl.CancelCrawlJobParams
|
||||
|
|
|
@ -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
|
||||
>
|
||||
}
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
pick,
|
||||
sanitizeSearchParams
|
||||
} from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { openmeteo } from './open-meteo'
|
||||
|
||||
/**
|
||||
* Agentic OpenMeteo client.
|
||||
*
|
||||
* Open-Meteo offers free weather forecast APIs for open-source developers and non-commercial use. No API key is required.
|
||||
*/
|
||||
export class OpenMeteoClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
super()
|
||||
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 7 day weather variables in hourly and daily resolution for given WGS84 latitude and longitude coordinates. Available worldwide.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'open_meteo_get_v1_forecast',
|
||||
description: `7 day weather variables in hourly and daily resolution for given WGS84 latitude and longitude coordinates. Available worldwide.`,
|
||||
inputSchema: openmeteo.GetV1ForecastParamsSchema,
|
||||
tags: ['Weather Forecast APIs']
|
||||
})
|
||||
async getV1Forecast(
|
||||
params: openmeteo.GetV1ForecastParams
|
||||
): Promise<openmeteo.GetV1ForecastResponse> {
|
||||
return this.ky
|
||||
.get('/v1/forecast', {
|
||||
searchParams: sanitizeSearchParams(
|
||||
pick(
|
||||
params,
|
||||
'hourly',
|
||||
'daily',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'current_weather',
|
||||
'temperature_unit',
|
||||
'wind_speed_unit',
|
||||
'timeformat',
|
||||
'timezone',
|
||||
'past_days'
|
||||
)
|
||||
)
|
||||
})
|
||||
.json<openmeteo.GetV1ForecastResponse>()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import { z } from 'zod'
|
||||
|
||||
export namespace openmeteo {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Component schemas
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps. */
|
||||
export const HourlyResponseSchema = z
|
||||
.object({
|
||||
time: z.array(z.string()),
|
||||
temperature_2m: z.array(z.number()).optional(),
|
||||
relative_humidity_2m: z.array(z.number()).optional(),
|
||||
dew_point_2m: z.array(z.number()).optional(),
|
||||
apparent_temperature: z.array(z.number()).optional(),
|
||||
pressure_msl: z.array(z.number()).optional(),
|
||||
cloud_cover: z.array(z.number()).optional(),
|
||||
cloud_cover_low: z.array(z.number()).optional(),
|
||||
cloud_cover_mid: z.array(z.number()).optional(),
|
||||
cloud_cover_high: z.array(z.number()).optional(),
|
||||
wind_speed_10m: z.array(z.number()).optional(),
|
||||
wind_speed_80m: z.array(z.number()).optional(),
|
||||
wind_speed_120m: z.array(z.number()).optional(),
|
||||
wind_speed_180m: z.array(z.number()).optional(),
|
||||
wind_direction_10m: z.array(z.number()).optional(),
|
||||
wind_direction_80m: z.array(z.number()).optional(),
|
||||
wind_direction_120m: z.array(z.number()).optional(),
|
||||
wind_direction_180m: z.array(z.number()).optional(),
|
||||
wind_gusts_10m: z.array(z.number()).optional(),
|
||||
shortwave_radiation: z.array(z.number()).optional(),
|
||||
direct_radiation: z.array(z.number()).optional(),
|
||||
direct_normal_irradiance: z.array(z.number()).optional(),
|
||||
diffuse_radiation: z.array(z.number()).optional(),
|
||||
vapour_pressure_deficit: z.array(z.number()).optional(),
|
||||
evapotranspiration: z.array(z.number()).optional(),
|
||||
precipitation: z.array(z.number()).optional(),
|
||||
weather_code: z.array(z.number()).optional(),
|
||||
snow_height: z.array(z.number()).optional(),
|
||||
freezing_level_height: z.array(z.number()).optional(),
|
||||
soil_temperature_0cm: z.array(z.number()).optional(),
|
||||
soil_temperature_6cm: z.array(z.number()).optional(),
|
||||
soil_temperature_18cm: z.array(z.number()).optional(),
|
||||
soil_temperature_54cm: z.array(z.number()).optional(),
|
||||
soil_moisture_0_1cm: z.array(z.number()).optional(),
|
||||
soil_moisture_1_3cm: z.array(z.number()).optional(),
|
||||
soil_moisture_3_9cm: z.array(z.number()).optional(),
|
||||
soil_moisture_9_27cm: z.array(z.number()).optional(),
|
||||
soil_moisture_27_81cm: z.array(z.number()).optional()
|
||||
})
|
||||
.describe(
|
||||
'For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.'
|
||||
)
|
||||
export type HourlyResponse = z.infer<typeof HourlyResponseSchema>
|
||||
|
||||
/** For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps. */
|
||||
export const DailyResponseSchema = z
|
||||
.object({
|
||||
time: z.array(z.string()),
|
||||
temperature_2m_max: z.array(z.number()).optional(),
|
||||
temperature_2m_min: z.array(z.number()).optional(),
|
||||
apparent_temperature_max: z.array(z.number()).optional(),
|
||||
apparent_temperature_min: z.array(z.number()).optional(),
|
||||
precipitation_sum: z.array(z.number()).optional(),
|
||||
precipitation_hours: z.array(z.number()).optional(),
|
||||
weather_code: z.array(z.number()).optional(),
|
||||
sunrise: z.array(z.number()).optional(),
|
||||
sunset: z.array(z.number()).optional(),
|
||||
wind_speed_10m_max: z.array(z.number()).optional(),
|
||||
wind_gusts_10m_max: z.array(z.number()).optional(),
|
||||
wind_direction_10m_dominant: z.array(z.number()).optional(),
|
||||
shortwave_radiation_sum: z.array(z.number()).optional(),
|
||||
uv_index_max: z.array(z.number()).optional(),
|
||||
uv_index_clear_sky_max: z.array(z.number()).optional(),
|
||||
et0_fao_evapotranspiration: z.array(z.number()).optional()
|
||||
})
|
||||
.describe(
|
||||
'For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.'
|
||||
)
|
||||
export type DailyResponse = z.infer<typeof DailyResponseSchema>
|
||||
|
||||
/** Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code */
|
||||
export const CurrentWeatherSchema = z
|
||||
.object({
|
||||
time: z.string(),
|
||||
temperature: z.number(),
|
||||
wind_speed: z.number(),
|
||||
wind_direction: z.number(),
|
||||
weather_code: z.number().int()
|
||||
})
|
||||
.describe(
|
||||
'Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code'
|
||||
)
|
||||
export type CurrentWeather = z.infer<typeof CurrentWeatherSchema>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Operation schemas
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
export const GetV1ForecastParamsSchema = z.object({
|
||||
hourly: z
|
||||
.array(
|
||||
z.enum([
|
||||
'temperature_2m',
|
||||
'relative_humidity_2m',
|
||||
'dew_point_2m',
|
||||
'apparent_temperature',
|
||||
'pressure_msl',
|
||||
'cloud_cover',
|
||||
'cloud_cover_low',
|
||||
'cloud_cover_mid',
|
||||
'cloud_cover_high',
|
||||
'wind_speed_10m',
|
||||
'wind_speed_80m',
|
||||
'wind_speed_120m',
|
||||
'wind_speed_180m',
|
||||
'wind_direction_10m',
|
||||
'wind_direction_80m',
|
||||
'wind_direction_120m',
|
||||
'wind_direction_180m',
|
||||
'wind_gusts_10m',
|
||||
'shortwave_radiation',
|
||||
'direct_radiation',
|
||||
'direct_normal_irradiance',
|
||||
'diffuse_radiation',
|
||||
'vapour_pressure_deficit',
|
||||
'evapotranspiration',
|
||||
'precipitation',
|
||||
'weather_code',
|
||||
'snow_height',
|
||||
'freezing_level_height',
|
||||
'soil_temperature_0cm',
|
||||
'soil_temperature_6cm',
|
||||
'soil_temperature_18cm',
|
||||
'soil_temperature_54cm',
|
||||
'soil_moisture_0_1cm',
|
||||
'soil_moisture_1_3cm',
|
||||
'soil_moisture_3_9cm',
|
||||
'soil_moisture_9_27cm',
|
||||
'soil_moisture_27_81cm'
|
||||
])
|
||||
)
|
||||
.optional(),
|
||||
daily: z
|
||||
.array(
|
||||
z.enum([
|
||||
'temperature_2m_max',
|
||||
'temperature_2m_min',
|
||||
'apparent_temperature_max',
|
||||
'apparent_temperature_min',
|
||||
'precipitation_sum',
|
||||
'precipitation_hours',
|
||||
'weather_code',
|
||||
'sunrise',
|
||||
'sunset',
|
||||
'wind_speed_10m_max',
|
||||
'wind_gusts_10m_max',
|
||||
'wind_direction_10m_dominant',
|
||||
'shortwave_radiation_sum',
|
||||
'uv_index_max',
|
||||
'uv_index_clear_sky_max',
|
||||
'et0_fao_evapotranspiration'
|
||||
])
|
||||
)
|
||||
.optional(),
|
||||
/** WGS84 coordinate */
|
||||
latitude: z.number().describe('WGS84 coordinate'),
|
||||
/** WGS84 coordinate */
|
||||
longitude: z.number().describe('WGS84 coordinate'),
|
||||
current_weather: z.boolean().optional(),
|
||||
temperature_unit: z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
||||
wind_speed_unit: z.enum(['kmh', 'ms', 'mph', 'kn']).default('kmh'),
|
||||
/** If format `unixtime` is selected, all time values are returned in UNIX epoch time in seconds. Please not that all time is then in GMT+0! For daily values with unix timestamp, please apply `utc_offset_seconds` again to get the correct date. */
|
||||
timeformat: z
|
||||
.enum(['iso8601', 'unixtime'])
|
||||
.describe(
|
||||
'If format `unixtime` is selected, all time values are returned in UNIX epoch time in seconds. Please not that all time is then in GMT+0! For daily values with unix timestamp, please apply `utc_offset_seconds` again to get the correct date.'
|
||||
)
|
||||
.default('iso8601'),
|
||||
/** If `timezone` is set, all timestamps are returned as local-time and data is returned starting at 0:00 local-time. Any time zone name from the [time zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is supported. */
|
||||
timezone: z
|
||||
.string()
|
||||
.describe(
|
||||
'If `timezone` is set, all timestamps are returned as local-time and data is returned starting at 0:00 local-time. Any time zone name from the [time zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is supported.'
|
||||
)
|
||||
.optional(),
|
||||
/** If `past_days` is set, yesterdays or the day before yesterdays data are also returned. */
|
||||
past_days: z
|
||||
.union([z.literal(1), z.literal(2)])
|
||||
.describe(
|
||||
'If `past_days` is set, yesterdays or the day before yesterdays data are also returned.'
|
||||
)
|
||||
.optional()
|
||||
})
|
||||
export type GetV1ForecastParams = z.infer<typeof GetV1ForecastParamsSchema>
|
||||
|
||||
export const GetV1ForecastResponseSchema = z.object({
|
||||
/** WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away. */
|
||||
latitude: z
|
||||
.number()
|
||||
.describe(
|
||||
'WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.'
|
||||
)
|
||||
.optional(),
|
||||
/** WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away. */
|
||||
longitude: z
|
||||
.number()
|
||||
.describe(
|
||||
'WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.'
|
||||
)
|
||||
.optional(),
|
||||
/** The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect. */
|
||||
elevation: z
|
||||
.number()
|
||||
.describe(
|
||||
'The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect.'
|
||||
)
|
||||
.optional(),
|
||||
/** Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements. */
|
||||
generationtime_ms: z
|
||||
.number()
|
||||
.describe(
|
||||
'Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements.'
|
||||
)
|
||||
.optional(),
|
||||
/** Applied timezone offset from the &timezone= parameter. */
|
||||
utc_offset_seconds: z
|
||||
.number()
|
||||
.int()
|
||||
.describe('Applied timezone offset from the &timezone= parameter.')
|
||||
.optional(),
|
||||
hourly: HourlyResponseSchema.optional(),
|
||||
/** For each selected weather variable, the unit will be listed here. */
|
||||
hourly_units: z
|
||||
.record(z.string())
|
||||
.describe(
|
||||
'For each selected weather variable, the unit will be listed here.'
|
||||
)
|
||||
.optional(),
|
||||
daily: DailyResponseSchema.optional(),
|
||||
/** For each selected daily weather variable, the unit will be listed here. */
|
||||
daily_units: z
|
||||
.record(z.string())
|
||||
.describe(
|
||||
'For each selected daily weather variable, the unit will be listed here.'
|
||||
)
|
||||
.optional(),
|
||||
current_weather: CurrentWeatherSchema.optional()
|
||||
})
|
||||
export type GetV1ForecastResponse = z.infer<
|
||||
typeof GetV1ForecastResponseSchema
|
||||
>
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
@ -8,60 +5,12 @@
|
|||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
pick,
|
||||
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.
|
||||
|
@ -92,9 +41,10 @@ export class PetStoreClient extends AIFunctionsProvider {
|
|||
* List all pets.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'list_pets',
|
||||
description: 'List all pets.',
|
||||
inputSchema: petstore.ListPetsParamsSchema
|
||||
name: 'pet_store_list_pets',
|
||||
description: `List all pets.`,
|
||||
inputSchema: petstore.ListPetsParamsSchema,
|
||||
tags: ['pets']
|
||||
})
|
||||
async listPets(
|
||||
params: petstore.ListPetsParams
|
||||
|
@ -110,16 +60,17 @@ export class PetStoreClient extends AIFunctionsProvider {
|
|||
* Create a pet.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'create_pets',
|
||||
description: 'Create a pet.',
|
||||
inputSchema: petstore.CreatePetsParamsSchema
|
||||
name: 'pet_store_create_pets',
|
||||
description: `Create a pet.`,
|
||||
inputSchema: petstore.CreatePetsParamsSchema,
|
||||
tags: ['pets']
|
||||
})
|
||||
async createPets(
|
||||
params: petstore.CreatePetsParams
|
||||
): Promise<petstore.CreatePetsResponse> {
|
||||
return this.ky
|
||||
.post('/pets', {
|
||||
json: params
|
||||
json: pick(params, 'id', 'name', 'tag')
|
||||
})
|
||||
.json<petstore.CreatePetsResponse>()
|
||||
}
|
||||
|
@ -128,9 +79,10 @@ export class PetStoreClient extends AIFunctionsProvider {
|
|||
* Info for a specific pet.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'show_pet_by_id',
|
||||
description: 'Info for a specific pet.',
|
||||
inputSchema: petstore.ShowPetByIdParamsSchema
|
||||
name: 'pet_store_show_pet_by_id',
|
||||
description: `Info for a specific pet.`,
|
||||
inputSchema: petstore.ShowPetByIdParamsSchema,
|
||||
tags: ['pets']
|
||||
})
|
||||
async showPetById(
|
||||
params: petstore.ShowPetByIdParams
|
||||
|
|
|
@ -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>
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import {
|
||||
aiFunction,
|
||||
AIFunctionsProvider,
|
||||
pick,
|
||||
sanitizeSearchParams
|
||||
} from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { petstoreexpanded } from './petstore-expanded'
|
||||
|
||||
/**
|
||||
* Agentic PetstoreExpanded client.
|
||||
*
|
||||
* A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification.
|
||||
*/
|
||||
export class PetstoreExpandedClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiBaseUrl = petstoreexpanded.apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
super()
|
||||
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all pets from the system that the user has access to
|
||||
Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
|
||||
|
||||
Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'petstore_expanded_find_pets',
|
||||
description: `Returns all pets from the system that the user has access to
|
||||
Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
|
||||
|
||||
Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.`,
|
||||
inputSchema: petstoreexpanded.FindPetsParamsSchema
|
||||
})
|
||||
async findPets(
|
||||
params: petstoreexpanded.FindPetsParams
|
||||
): Promise<petstoreexpanded.FindPetsResponse> {
|
||||
return this.ky
|
||||
.get('/pets', {
|
||||
searchParams: sanitizeSearchParams(pick(params, 'tags', 'limit'))
|
||||
})
|
||||
.json<petstoreexpanded.FindPetsResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new pet in the store. Duplicates are allowed.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'petstore_expanded_add_pet',
|
||||
description: `Creates a new pet in the store. Duplicates are allowed.`,
|
||||
inputSchema: petstoreexpanded.AddPetParamsSchema
|
||||
})
|
||||
async addPet(
|
||||
params: petstoreexpanded.AddPetParams
|
||||
): Promise<petstoreexpanded.AddPetResponse> {
|
||||
return this.ky
|
||||
.post('/pets', {
|
||||
json: pick(params, 'name', 'tag')
|
||||
})
|
||||
.json<petstoreexpanded.AddPetResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user based on a single ID, if the user does not have access to the pet.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'petstore_expanded_find_pet_by_id',
|
||||
description: `Returns a user based on a single ID, if the user does not have access to the pet.`,
|
||||
inputSchema: petstoreexpanded.FindPetByIdParamsSchema
|
||||
})
|
||||
async findPetById(
|
||||
params: petstoreexpanded.FindPetByIdParams
|
||||
): Promise<petstoreexpanded.FindPetByIdResponse> {
|
||||
return this.ky
|
||||
.get(`/pets/${params.id}`)
|
||||
.json<petstoreexpanded.FindPetByIdResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a single pet based on the ID supplied.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'petstore_expanded_delete_pet',
|
||||
description: `deletes a single pet based on the ID supplied.`,
|
||||
inputSchema: petstoreexpanded.DeletePetParamsSchema
|
||||
})
|
||||
async deletePet(
|
||||
params: petstoreexpanded.DeletePetParams
|
||||
): Promise<petstoreexpanded.DeletePetResponse> {
|
||||
return this.ky
|
||||
.delete(`/pets/${params.id}`)
|
||||
.json<petstoreexpanded.DeletePetResponse>()
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,341 @@
|
|||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { security } from './security'
|
||||
|
||||
/**
|
||||
* Agentic Security client.
|
||||
*
|
||||
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject.
|
||||
*/
|
||||
export class SecurityClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiBaseUrl = security.apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
super()
|
||||
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* `apiKey` auth will be supplied within an `apiKey` query parameter.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_get_anything_api_key',
|
||||
description: `\`apiKey\` auth will be supplied within an \`apiKey\` query parameter.`,
|
||||
inputSchema: security.GetAnythingApiKeyParamsSchema,
|
||||
tags: ['API Key']
|
||||
})
|
||||
async getAnythingApiKey(
|
||||
_params: security.GetAnythingApiKeyParams
|
||||
): Promise<security.GetAnythingApiKeyResponse> {
|
||||
return this.ky
|
||||
.get('/anything/apiKey')
|
||||
.json<security.GetAnythingApiKeyResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* `apiKey` auth will be supplied within an `api_key` cookie.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_api_key',
|
||||
description: `\`apiKey\` auth will be supplied within an \`api_key\` cookie.`,
|
||||
inputSchema: security.PostAnythingApiKeyParamsSchema,
|
||||
tags: ['API Key']
|
||||
})
|
||||
async postAnythingApiKey(
|
||||
_params: security.PostAnythingApiKeyParams
|
||||
): Promise<security.PostAnythingApiKeyResponse> {
|
||||
return this.ky
|
||||
.post('/anything/apiKey')
|
||||
.json<security.PostAnythingApiKeyResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* `apiKey` auth will be supplied within an `X-API-KEY` header.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_put_anything_api_key',
|
||||
description: `\`apiKey\` auth will be supplied within an \`X-API-KEY\` header.`,
|
||||
inputSchema: security.PutAnythingApiKeyParamsSchema,
|
||||
tags: ['API Key']
|
||||
})
|
||||
async putAnythingApiKey(
|
||||
_params: security.PutAnythingApiKeyParams
|
||||
): Promise<security.PutAnythingApiKeyResponse> {
|
||||
return this.ky
|
||||
.put('/anything/apiKey')
|
||||
.json<security.PutAnythingApiKeyResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_basic',
|
||||
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,
|
||||
tags: ['HTTP']
|
||||
})
|
||||
async postAnythingBasic(
|
||||
_params: security.PostAnythingBasicParams
|
||||
): Promise<security.PostAnythingBasicResponse> {
|
||||
return this.ky
|
||||
.post('/anything/basic')
|
||||
.json<security.PostAnythingBasicResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_bearer',
|
||||
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,
|
||||
tags: ['HTTP']
|
||||
})
|
||||
async postAnythingBearer(
|
||||
_params: security.PostAnythingBearerParams
|
||||
): Promise<security.PostAnythingBearerResponse> {
|
||||
return this.ky
|
||||
.post('/anything/bearer')
|
||||
.json<security.PostAnythingBearerResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Authentication credentials will be supplied within a `Bearer` `Authorization` header, but its data should be controlled as a JWT.
|
||||
|
||||
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample
|
||||
|
||||
> ℹ️
|
||||
> We currently do not support any special handling for this so they're handled as a standard `Bearer` authentication token.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_put_anything_bearer',
|
||||
description: `Authentication credentials will be supplied within a \`Bearer\` \`Authorization\` header, but its data should be controlled as a JWT.
|
||||
|
||||
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#basic-authentication-sample
|
||||
|
||||
> ℹ️
|
||||
> We currently do not support any special handling for this so they're handled as a standard \`Bearer\` authentication token.`,
|
||||
inputSchema: security.PutAnythingBearerParamsSchema,
|
||||
tags: ['HTTP']
|
||||
})
|
||||
async putAnythingBearer(
|
||||
_params: security.PutAnythingBearerParams
|
||||
): Promise<security.PutAnythingBearerResponse> {
|
||||
return this.ky
|
||||
.put('/anything/bearer')
|
||||
.json<security.PutAnythingBearerResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* > ℹ️
|
||||
> 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_get_anything_oauth2',
|
||||
description: `> ℹ️
|
||||
> 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,
|
||||
tags: ['OAuth 2']
|
||||
})
|
||||
async getAnythingOauth2(
|
||||
_params: security.GetAnythingOauth2Params
|
||||
): Promise<security.GetAnythingOauth2Response> {
|
||||
return this.ky
|
||||
.get('/anything/oauth2')
|
||||
.json<security.GetAnythingOauth2Response>()
|
||||
}
|
||||
|
||||
/**
|
||||
* > ℹ️
|
||||
> 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_oauth2',
|
||||
description: `> ℹ️
|
||||
> 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,
|
||||
tags: ['OAuth 2']
|
||||
})
|
||||
async postAnythingOauth2(
|
||||
_params: security.PostAnythingOauth2Params
|
||||
): Promise<security.PostAnythingOauth2Response> {
|
||||
return this.ky
|
||||
.post('/anything/oauth2')
|
||||
.json<security.PostAnythingOauth2Response>()
|
||||
}
|
||||
|
||||
/**
|
||||
* > ℹ️
|
||||
> 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_put_anything_oauth2',
|
||||
description: `> ℹ️
|
||||
> 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,
|
||||
tags: ['OAuth 2']
|
||||
})
|
||||
async putAnythingOauth2(
|
||||
_params: security.PutAnythingOauth2Params
|
||||
): Promise<security.PutAnythingOauth2Response> {
|
||||
return this.ky
|
||||
.put('/anything/oauth2')
|
||||
.json<security.PutAnythingOauth2Response>()
|
||||
}
|
||||
|
||||
/**
|
||||
* > ℹ️
|
||||
> 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_delete_anything_oauth2',
|
||||
description: `> ℹ️
|
||||
> 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,
|
||||
tags: ['OAuth 2']
|
||||
})
|
||||
async deleteAnythingOauth2(
|
||||
_params: security.DeleteAnythingOauth2Params
|
||||
): Promise<security.DeleteAnythingOauth2Response> {
|
||||
return this.ky
|
||||
.delete('/anything/oauth2')
|
||||
.json<security.DeleteAnythingOauth2Response>()
|
||||
}
|
||||
|
||||
/**
|
||||
* > ℹ️
|
||||
> 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_patch_anything_oauth2',
|
||||
description: `> ℹ️
|
||||
> 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,
|
||||
tags: ['OAuth 2']
|
||||
})
|
||||
async patchAnythingOauth2(
|
||||
_params: security.PatchAnythingOauth2Params
|
||||
): Promise<security.PatchAnythingOauth2Response> {
|
||||
return this.ky
|
||||
.patch('/anything/oauth2')
|
||||
.json<security.PatchAnythingOauth2Response>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 🚧 This is not supported.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_open_id_connect',
|
||||
description: `🚧 This is not supported.`,
|
||||
inputSchema: security.PostAnythingOpenIdConnectParamsSchema,
|
||||
tags: ['OpenID Connect']
|
||||
})
|
||||
async postAnythingOpenIdConnect(
|
||||
_params: security.PostAnythingOpenIdConnectParams
|
||||
): Promise<security.PostAnythingOpenIdConnectResponse> {
|
||||
return this.ky
|
||||
.post('/anything/openIdConnect')
|
||||
.json<security.PostAnythingOpenIdConnectResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* This operation does not have any authentication requirements.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_post_anything_no_auth',
|
||||
description: `This operation does not have any authentication requirements.`,
|
||||
inputSchema: security.PostAnythingNoAuthParamsSchema,
|
||||
tags: ['Other']
|
||||
})
|
||||
async postAnythingNoAuth(
|
||||
_params: security.PostAnythingNoAuthParams
|
||||
): Promise<security.PostAnythingNoAuthResponse> {
|
||||
return this.ky
|
||||
.post('/anything/no-auth')
|
||||
.json<security.PostAnythingNoAuthResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'security_get_anything_optional_auth',
|
||||
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,
|
||||
tags: ['Other']
|
||||
})
|
||||
async getAnythingOptionalAuth(
|
||||
_params: security.GetAnythingOptionalAuthParams
|
||||
): Promise<security.GetAnythingOptionalAuthResponse> {
|
||||
return this.ky
|
||||
.get('/anything/optional-auth')
|
||||
.json<security.GetAnythingOptionalAuthResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.
|
||||
*/
|
||||
@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,
|
||||
tags: ['Other']
|
||||
})
|
||||
async postStatus401(
|
||||
_params: security.PostStatus401Params
|
||||
): Promise<security.PostStatus401Response> {
|
||||
return this.ky.post('/status/401').json<security.PostStatus401Response>()
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* This file was auto-generated from an OpenAPI spec.
|
||||
*/
|
||||
|
||||
import { aiFunction,AIFunctionsProvider } from '@agentic/core'
|
||||
import defaultKy, { type KyInstance } from 'ky'
|
||||
|
||||
import { tictactoe } from './tic-tac-toe'
|
||||
|
||||
/**
|
||||
* Agentic TicTacToe client.
|
||||
*
|
||||
* This API allows writing down marks on a Tic Tac Toe board
|
||||
and requesting the state of the board or of individual squares.
|
||||
.
|
||||
*/
|
||||
export class TicTacToeClient extends AIFunctionsProvider {
|
||||
protected readonly ky: KyInstance
|
||||
|
||||
protected readonly apiBaseUrl: string
|
||||
|
||||
constructor({
|
||||
apiBaseUrl,
|
||||
ky = defaultKy
|
||||
}: {
|
||||
apiKey?: string
|
||||
apiBaseUrl?: string
|
||||
ky?: KyInstance
|
||||
} = {}) {
|
||||
super()
|
||||
|
||||
this.apiBaseUrl = apiBaseUrl
|
||||
|
||||
this.ky = ky.extend({
|
||||
prefixUrl: apiBaseUrl
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current state of the board and the winner.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'tic_tac_toe_get_board',
|
||||
description: `Retrieves the current state of the board and the winner.`,
|
||||
inputSchema: tictactoe.GetBoardParamsSchema,
|
||||
tags: ['Gameplay']
|
||||
})
|
||||
async getBoard(
|
||||
_params: tictactoe.GetBoardParams
|
||||
): Promise<tictactoe.GetBoardResponse> {
|
||||
return this.ky.get('/board').json<tictactoe.GetBoardResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the requested square.
|
||||
*/
|
||||
@aiFunction({
|
||||
name: 'tic_tac_toe_get_square',
|
||||
description: `Retrieves the requested square.`,
|
||||
inputSchema: tictactoe.GetSquareParamsSchema,
|
||||
tags: ['Gameplay']
|
||||
})
|
||||
async getSquare(
|
||||
_params: tictactoe.GetSquareParams
|
||||
): Promise<tictactoe.GetSquareResponse> {
|
||||
return this.ky
|
||||
.get('/board/{row}/{column}')
|
||||
.json<tictactoe.GetSquareResponse>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Places a mark on the board and retrieves the whole board and the winner (if any).
|
||||
*/
|
||||
@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,
|
||||
tags: ['Gameplay']
|
||||
})
|
||||
async putSquare(
|
||||
_params: tictactoe.PutSquareParams
|
||||
): Promise<tictactoe.PutSquareResponse> {
|
||||
return this.ky
|
||||
.put('/board/{row}/{column}')
|
||||
.json<tictactoe.PutSquareResponse>()
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
}
|
|
@ -1,988 +0,0 @@
|
|||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"email": "apiteam@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "http://petstore.swagger.io/v2"
|
||||
}
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "Find out more about Swagger",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "pet",
|
||||
"description": "Everything about your Pets",
|
||||
"externalDocs": {
|
||||
"description": "Find out more",
|
||||
"url": "http://swagger.io"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "store",
|
||||
"description": "Access to Petstore orders"
|
||||
},
|
||||
{
|
||||
"name": "user",
|
||||
"description": "Operations about user",
|
||||
"externalDocs": {
|
||||
"description": "Find out more about our store",
|
||||
"url": "http://swagger.io"
|
||||
}
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/pet": {
|
||||
"post": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Add a new pet to the store",
|
||||
"description": "",
|
||||
"operationId": "addPet",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/Pet"
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Update an existing pet",
|
||||
"description": "",
|
||||
"operationId": "updatePet",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Validation exception"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet/findByStatus": {
|
||||
"get": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Finds Pets by status",
|
||||
"description": "Multiple status values can be provided with comma separated strings",
|
||||
"operationId": "findPetsByStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"description": "Status values that need to be considered for filter",
|
||||
"required": true,
|
||||
"explode": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": ["available", "pending", "sold"],
|
||||
"default": "available"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid status value"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/findByTags": {
|
||||
"get": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Finds Pets by tags",
|
||||
"description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
"operationId": "findPetsByTags",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "Tags to filter by",
|
||||
"required": true,
|
||||
"explode": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid tag value"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
],
|
||||
"deprecated": true
|
||||
}
|
||||
},
|
||||
"/pet/{petId}": {
|
||||
"get": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Find pet by ID",
|
||||
"description": "Returns a single pet",
|
||||
"operationId": "getPetById",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet to return",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"default": {
|
||||
"description": "successful response"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Updates a pet in the store with form data",
|
||||
"description": "",
|
||||
"operationId": "updatePetWithForm",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be updated",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/x-www-form-urlencoded": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Updated name of the pet",
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"description": "Updated status of the pet",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": ["pet"],
|
||||
"summary": "Deletes a pet",
|
||||
"description": "",
|
||||
"operationId": "deletePet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "api_key",
|
||||
"in": "header",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "Pet id to delete",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/{petId}/uploadImage": {
|
||||
"post": {
|
||||
"tags": ["pet"],
|
||||
"summary": "uploads an image",
|
||||
"description": "",
|
||||
"operationId": "uploadFile",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet to update",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": ["write:pets", "read:pets"]
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/inventory": {
|
||||
"get": {
|
||||
"tags": ["store"],
|
||||
"summary": "Returns pet inventories by status",
|
||||
"description": "Returns a map of status codes to quantities",
|
||||
"operationId": "getInventory",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/store/order": {
|
||||
"post": {
|
||||
"tags": ["store"],
|
||||
"summary": "Place an order for a pet",
|
||||
"description": "",
|
||||
"operationId": "placeOrder",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Order"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid Order"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Order"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "order placed for purchasing the pet",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/order/{orderId}": {
|
||||
"get": {
|
||||
"tags": ["store"],
|
||||
"summary": "Find purchase order by ID",
|
||||
"description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions",
|
||||
"operationId": "getOrderById",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"minimum": 1,
|
||||
"maximum": 10
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Order"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": ["store"],
|
||||
"summary": "Delete purchase order by ID",
|
||||
"description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors",
|
||||
"operationId": "deleteOrder",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of the order that needs to be deleted",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user": {
|
||||
"post": {
|
||||
"tags": ["user"],
|
||||
"summary": "Create user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "createUser",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Created user object",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithArray": {
|
||||
"post": {
|
||||
"tags": ["user"],
|
||||
"summary": "Creates list of users with given input array",
|
||||
"description": "",
|
||||
"operationId": "createUsersWithArrayInput",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/UserArray"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithList": {
|
||||
"post": {
|
||||
"tags": ["user"],
|
||||
"summary": "Creates list of users with given input array",
|
||||
"description": "",
|
||||
"operationId": "createUsersWithListInput",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/UserArray"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/login": {
|
||||
"get": {
|
||||
"tags": ["user"],
|
||||
"summary": "Logs user into the system",
|
||||
"description": "",
|
||||
"operationId": "loginUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "query",
|
||||
"description": "The user name for login",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"in": "query",
|
||||
"description": "The password for login in clear text",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"headers": {
|
||||
"X-Rate-Limit": {
|
||||
"description": "calls per hour allowed by the user",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"X-Expires-After": {
|
||||
"description": "date in UTC when token expires",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username/password supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/logout": {
|
||||
"get": {
|
||||
"tags": ["user"],
|
||||
"summary": "Logs out current logged in user session",
|
||||
"description": "",
|
||||
"operationId": "logoutUser",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{username}": {
|
||||
"get": {
|
||||
"tags": ["user"],
|
||||
"summary": "Get user by user name",
|
||||
"description": "",
|
||||
"operationId": "getUserByName",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "The name that needs to be fetched. Use user1 for testing. ",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": ["user"],
|
||||
"summary": "Updated user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "updateUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "name that need to be updated",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid user supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Updated user object",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": ["user"],
|
||||
"summary": "Delete user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "deleteUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "The name that needs to be deleted",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid username supplied"
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Order": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"petId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"shipDate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "Order Status",
|
||||
"enum": ["placed", "approved", "delivered"]
|
||||
},
|
||||
"complete": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Order"
|
||||
}
|
||||
},
|
||||
"Category": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Category"
|
||||
}
|
||||
},
|
||||
"User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"userStatus": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": "User Status"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "User"
|
||||
}
|
||||
},
|
||||
"Tag": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Tag"
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"type": "object",
|
||||
"required": ["name", "photoUrls"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"readOnly": true
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/components/schemas/Category"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "doggie"
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "photoUrl",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "tag",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Tag"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "pet status in the store",
|
||||
"enum": ["available", "pending", "sold"]
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Pet"
|
||||
}
|
||||
},
|
||||
"ApiResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodies": {
|
||||
"Pet": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
},
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": true
|
||||
},
|
||||
"UserArray": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "List of user object",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
"petstore_auth": {
|
||||
"type": "oauth2",
|
||||
"flows": {
|
||||
"implicit": {
|
||||
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
|
||||
"scopes": {
|
||||
"write:pets": "modify pets in your account",
|
||||
"read:pets": "read your pets"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"api_key": {
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,397 +0,0 @@
|
|||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Support for different security types",
|
||||
"description": "https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securitySchemeObject"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://httpbin.org"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "API Key"
|
||||
},
|
||||
{
|
||||
"name": "HTTP"
|
||||
},
|
||||
{
|
||||
"name": "Mutual TLS"
|
||||
},
|
||||
{
|
||||
"name": "OAuth 2"
|
||||
},
|
||||
{
|
||||
"name": "OpenID Connect"
|
||||
},
|
||||
{
|
||||
"name": "Other"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/anything/apiKey": {
|
||||
"get": {
|
||||
"summary": "Query parameter",
|
||||
"description": "`apiKey` auth will be supplied within an `apiKey` query parameter.",
|
||||
"tags": ["API Key"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"apiKey_query": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"summary": "Cookie",
|
||||
"description": "`apiKey` auth will be supplied within an `api_key` cookie.",
|
||||
"tags": ["API Key"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"apiKey_cookie": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"summary": "Header",
|
||||
"description": "`apiKey` auth will be supplied within an `X-API-KEY` header.",
|
||||
"tags": ["API Key"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"apiKey_header": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/basic": {
|
||||
"post": {
|
||||
"summary": "Basic",
|
||||
"description": "Authentication credentials will be supplied within a `Basic` `Authorization` header.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#basic-authentication-sample",
|
||||
"tags": ["HTTP"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"basic": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/bearer": {
|
||||
"post": {
|
||||
"summary": "Bearer",
|
||||
"description": "Authentication credentials will be supplied within a `Bearer` `Authorization` header.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#basic-authentication-sample",
|
||||
"tags": ["HTTP"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"summary": "Bearer (`jwt` format)",
|
||||
"description": "Authentication credentials will be supplied within a `Bearer` `Authorization` header, but its data should be controlled as a JWT.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#basic-authentication-sample\n\n> ℹ️We currently do not support any special handling for this so they're handled as a standard `Bearer` authentication token.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer_jwt": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/mutualTLS": {
|
||||
"post": {
|
||||
"summary": "`mutualTLS` auth",
|
||||
"description": "🚧 This is not supported.",
|
||||
"tags": ["Mutual TLS"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"mutualTLS": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/oauth2": {
|
||||
"post": {
|
||||
"summary": "General support (all flow types)",
|
||||
"description": "> ℹ️\n> 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.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"tags": ["OAuth 2"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"oauth2": ["write:things"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"get": {
|
||||
"summary": "General support (authorizationCode flow type)",
|
||||
"description": "> ℹ️\n> 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.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"tags": ["OAuth 2"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"oauth2_authorizationCode": ["write:things"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"summary": "General support (clientCredentials flow type)",
|
||||
"description": "> ℹ️\n> 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.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"tags": ["OAuth 2"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"oauth2_clientCredentials": ["write:things"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"patch": {
|
||||
"summary": "General support (implicit flow type)",
|
||||
"description": "> ℹ️\n> 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.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"tags": ["OAuth 2"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"oauth2_implicit": ["write:things"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"summary": "General support (password flow type)",
|
||||
"description": "> ℹ️\n> 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.\n\nhttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"tags": ["OAuth 2"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"oauth2_password": ["write:things"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/openIdConnect": {
|
||||
"post": {
|
||||
"summary": "General support",
|
||||
"description": "🚧 This is not supported.",
|
||||
"tags": ["OpenID Connect"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"openIdConnect": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/anything/no-auth": {
|
||||
"post": {
|
||||
"summary": "No auth requirements",
|
||||
"description": "This operation does not have any authentication requirements.",
|
||||
"tags": ["Other"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/status/401": {
|
||||
"post": {
|
||||
"summary": "Forced invalid authentication",
|
||||
"description": "This endpoint requires an authentication header but making any request to it will forcefully return a 401 status code for invalid auth.",
|
||||
"tags": ["Other"],
|
||||
"responses": {
|
||||
"401": {
|
||||
"description": "Unauthorized"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"apiKey_header": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"apiKey_cookie": {
|
||||
"type": "apiKey",
|
||||
"in": "cookie",
|
||||
"name": "api_key",
|
||||
"description": "An API key that will be supplied in a named cookie. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object"
|
||||
},
|
||||
"apiKey_header": {
|
||||
"type": "apiKey",
|
||||
"in": "header",
|
||||
"name": "X-API-KEY",
|
||||
"description": "An API key that will be supplied in a named header. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object"
|
||||
},
|
||||
"apiKey_query": {
|
||||
"type": "apiKey",
|
||||
"in": "query",
|
||||
"name": "apiKey",
|
||||
"description": "An API key that will be supplied in a named query parameter. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object"
|
||||
},
|
||||
"basic": {
|
||||
"type": "http",
|
||||
"scheme": "basic",
|
||||
"description": "Basic auth that takes a base64'd combination of `user:password`. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#basic-authentication-sample"
|
||||
},
|
||||
"bearer": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"description": "A bearer token that will be supplied within an `Authentication` header as `bearer <token>`. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#basic-authentication-sample"
|
||||
},
|
||||
"bearer_jwt": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT",
|
||||
"description": "A bearer token that will be supplied within an `Authentication` header as `bearer <token>`. In this case, the format of the token is specified as JWT. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#jwt-bearer-sample"
|
||||
},
|
||||
"mutualTLS": {
|
||||
"type": "mutualTLS",
|
||||
"description": "Requires a specific mutual TLS certificate to use when making a HTTP request. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23"
|
||||
},
|
||||
"oauth2": {
|
||||
"type": "oauth2",
|
||||
"description": "An OAuth 2 security flow. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23",
|
||||
"flows": {
|
||||
"authorizationCode": {
|
||||
"authorizationUrl": "http://example.com/oauth/dialog",
|
||||
"tokenUrl": "http://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
},
|
||||
"clientCredentials": {
|
||||
"tokenUrl": "http://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
},
|
||||
"implicit": {
|
||||
"authorizationUrl": "http://example.com/oauth/dialog",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
},
|
||||
"password": {
|
||||
"tokenUrl": "http://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"oauth2_authorizationCode": {
|
||||
"type": "oauth2",
|
||||
"description": "An OAuth 2 security flow that only supports the `authorizationCode` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oauth-flows-object",
|
||||
"flows": {
|
||||
"authorizationCode": {
|
||||
"authorizationUrl": "http://alt.example.com/oauth/dialog",
|
||||
"tokenUrl": "http://alt.example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"oauth2_clientCredentials": {
|
||||
"type": "oauth2",
|
||||
"description": "An OAuth 2 security flow that only supports the `clientCredentials` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oauth-flows-object",
|
||||
"flows": {
|
||||
"clientCredentials": {
|
||||
"tokenUrl": "http://alt.example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"oauth2_implicit": {
|
||||
"type": "oauth2",
|
||||
"description": "An OAuth 2 security flow that only supports the `implicit` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oauth-flows-object",
|
||||
"flows": {
|
||||
"implicit": {
|
||||
"authorizationUrl": "http://alt.example.com/oauth/dialog",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"oauth2_password": {
|
||||
"type": "oauth2",
|
||||
"description": "An OAuth 2 security flow that only supports the `password` flow type. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oauth-flows-object",
|
||||
"flows": {
|
||||
"password": {
|
||||
"tokenUrl": "http://alt.example.com/oauth/token",
|
||||
"scopes": {
|
||||
"write:things": "Add things to your account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"openIdConnect": {
|
||||
"type": "openIdConnect",
|
||||
"openIdConnectUrl": "https://example.com/.well-known/openid-configuration",
|
||||
"description": "OpenAPI authentication. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-23"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,461 @@
|
|||
openapi: 3.0.0
|
||||
info:
|
||||
title: Open-Meteo APIs
|
||||
description: 'Open-Meteo offers free weather forecast APIs for open-source developers and non-commercial use. No API key is required.'
|
||||
version: '1.0'
|
||||
contact:
|
||||
name: Open-Meteo
|
||||
url: https://open-meteo.com
|
||||
email: info@open-meteo.com
|
||||
license:
|
||||
name: Attribution 4.0 International (CC BY 4.0)
|
||||
url: https://creativecommons.org/licenses/by/4.0/
|
||||
termsOfService: https://open-meteo.com/en/features#terms
|
||||
paths:
|
||||
/v1/forecast:
|
||||
servers:
|
||||
- url: https://api.open-meteo.com
|
||||
get:
|
||||
tags:
|
||||
- Weather Forecast APIs
|
||||
summary: 7 day weather forecast for coordinates
|
||||
description: 7 day weather variables in hourly and daily resolution for given WGS84 latitude and longitude coordinates. Available worldwide.
|
||||
parameters:
|
||||
- name: hourly
|
||||
in: query
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- temperature_2m
|
||||
- relative_humidity_2m
|
||||
- dew_point_2m
|
||||
- apparent_temperature
|
||||
- pressure_msl
|
||||
- cloud_cover
|
||||
- cloud_cover_low
|
||||
- cloud_cover_mid
|
||||
- cloud_cover_high
|
||||
- wind_speed_10m
|
||||
- wind_speed_80m
|
||||
- wind_speed_120m
|
||||
- wind_speed_180m
|
||||
- wind_direction_10m
|
||||
- wind_direction_80m
|
||||
- wind_direction_120m
|
||||
- wind_direction_180m
|
||||
- wind_gusts_10m
|
||||
- shortwave_radiation
|
||||
- direct_radiation
|
||||
- direct_normal_irradiance
|
||||
- diffuse_radiation
|
||||
- vapour_pressure_deficit
|
||||
- evapotranspiration
|
||||
- precipitation
|
||||
- weather_code
|
||||
- snow_height
|
||||
- freezing_level_height
|
||||
- soil_temperature_0cm
|
||||
- soil_temperature_6cm
|
||||
- soil_temperature_18cm
|
||||
- soil_temperature_54cm
|
||||
- soil_moisture_0_1cm
|
||||
- soil_moisture_1_3cm
|
||||
- soil_moisture_3_9cm
|
||||
- soil_moisture_9_27cm
|
||||
- soil_moisture_27_81cm
|
||||
- name: daily
|
||||
in: query
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- temperature_2m_max
|
||||
- temperature_2m_min
|
||||
- apparent_temperature_max
|
||||
- apparent_temperature_min
|
||||
- precipitation_sum
|
||||
- precipitation_hours
|
||||
- weather_code
|
||||
- sunrise
|
||||
- sunset
|
||||
- wind_speed_10m_max
|
||||
- wind_gusts_10m_max
|
||||
- wind_direction_10m_dominant
|
||||
- shortwave_radiation_sum
|
||||
- uv_index_max
|
||||
- uv_index_clear_sky_max
|
||||
- et0_fao_evapotranspiration
|
||||
- name: latitude
|
||||
in: query
|
||||
required: true
|
||||
description: 'WGS84 coordinate'
|
||||
schema:
|
||||
type: number
|
||||
format: double
|
||||
- name: longitude
|
||||
in: query
|
||||
required: true
|
||||
description: 'WGS84 coordinate'
|
||||
schema:
|
||||
type: number
|
||||
format: double
|
||||
- name: current_weather
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
- name: temperature_unit
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
default: celsius
|
||||
enum:
|
||||
- celsius
|
||||
- fahrenheit
|
||||
- name: wind_speed_unit
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
default: kmh
|
||||
enum:
|
||||
- kmh
|
||||
- ms
|
||||
- mph
|
||||
- kn
|
||||
- name: timeformat
|
||||
in: query
|
||||
description: If format `unixtime` is selected, all time values are returned in UNIX epoch time in seconds. Please not that all time is then in GMT+0! For daily values with unix timestamp, please apply `utc_offset_seconds` again to get the correct date.
|
||||
schema:
|
||||
type: string
|
||||
default: iso8601
|
||||
enum:
|
||||
- iso8601
|
||||
- unixtime
|
||||
- name: timezone
|
||||
in: query
|
||||
description: If `timezone` is set, all timestamps are returned as local-time and data is returned starting at 0:00 local-time. Any time zone name from the [time zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is supported.
|
||||
schema:
|
||||
type: string
|
||||
- name: past_days
|
||||
in: query
|
||||
description: If `past_days` is set, yesterdays or the day before yesterdays data are also returned.
|
||||
schema:
|
||||
type: integer
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
latitude:
|
||||
type: number
|
||||
example: 52.52
|
||||
description: WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.
|
||||
longitude:
|
||||
type: number
|
||||
example: 13.419.52
|
||||
description: WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be up to 5 km away.
|
||||
elevation:
|
||||
type: number
|
||||
example: 44.812
|
||||
description: The elevation in meters of the selected weather grid-cell. In mountain terrain it might differ from the location you would expect.
|
||||
generationtime_ms:
|
||||
type: number
|
||||
example: 2.2119
|
||||
description: Generation time of the weather forecast in milli seconds. This is mainly used for performance monitoring and improvements.
|
||||
utc_offset_seconds:
|
||||
type: integer
|
||||
example: 3600
|
||||
description: Applied timezone offset from the &timezone= parameter.
|
||||
hourly:
|
||||
$ref: '#/components/schemas/HourlyResponse'
|
||||
hourly_units:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: For each selected weather variable, the unit will be listed here.
|
||||
daily:
|
||||
$ref: '#/components/schemas/DailyResponse'
|
||||
daily_units:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: For each selected daily weather variable, the unit will be listed here.
|
||||
current_weather:
|
||||
$ref: '#/components/schemas/CurrentWeather'
|
||||
'400':
|
||||
description: Bad Request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: boolean
|
||||
description: Always set true for errors
|
||||
reason:
|
||||
type: string
|
||||
description: Description of the error
|
||||
example: 'Latitude must be in range of -90 to 90°. Given: 300'
|
||||
components:
|
||||
schemas:
|
||||
HourlyResponse:
|
||||
type: object
|
||||
description: For each selected weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.
|
||||
required:
|
||||
- time
|
||||
properties:
|
||||
time:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
temperature_2m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
relative_humidity_2m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
dew_point_2m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
apparent_temperature:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
pressure_msl:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
cloud_cover:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
cloud_cover_low:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
cloud_cover_mid:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
cloud_cover_high:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_speed_10m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_speed_80m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_speed_120m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_speed_180m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_direction_10m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_direction_80m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_direction_120m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_direction_180m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_gusts_10m:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
shortwave_radiation:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
direct_radiation:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
direct_normal_irradiance:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
diffuse_radiation:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
vapour_pressure_deficit:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
evapotranspiration:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
precipitation:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
weather_code:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
snow_height:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
freezing_level_height:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_temperature_0cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_temperature_6cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_temperature_18cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_temperature_54cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_moisture_0_1cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_moisture_1_3cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_moisture_3_9cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_moisture_9_27cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
soil_moisture_27_81cm:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
DailyResponse:
|
||||
type: object
|
||||
description: For each selected daily weather variable, data will be returned as a floating point array. Additionally a `time` array will be returned with ISO8601 timestamps.
|
||||
properties:
|
||||
time:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
temperature_2m_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
temperature_2m_min:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
apparent_temperature_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
apparent_temperature_min:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
precipitation_sum:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
precipitation_hours:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
weather_code:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
sunrise:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
sunset:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_speed_10m_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_gusts_10m_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
wind_direction_10m_dominant:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
shortwave_radiation_sum:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
uv_index_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
uv_index_clear_sky_max:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
et0_fao_evapotranspiration:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
required:
|
||||
- time
|
||||
CurrentWeather:
|
||||
type: object
|
||||
description: 'Current weather conditions with the attributes: time, temperature, wind_speed, wind_direction and weather_code'
|
||||
properties:
|
||||
time:
|
||||
type: string
|
||||
temperature:
|
||||
type: number
|
||||
wind_speed:
|
||||
type: number
|
||||
wind_direction:
|
||||
type: number
|
||||
weather_code:
|
||||
type: integer
|
||||
required:
|
||||
- time
|
||||
- temperature
|
||||
- wind_speed
|
||||
- wind_direction
|
||||
- weather_code
|
|
@ -24,7 +24,8 @@
|
|||
"clean": "del dist",
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
"test:typecheck": "tsc --noEmit",
|
||||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*",
|
||||
|
|
|
@ -60,6 +60,7 @@ Some things you may want to tweak:
|
|||
- Fix github example issue with `nullable()` zod schema parameter
|
||||
- Fix github `json-schema-to-zod` example issue with string enum given default value `true` as a non-string boolean
|
||||
- Fix github `gists/get-revision` missing path parameter because of ref
|
||||
- Fix github `activity_star_repo_for_authenticated_user` path seems incorrect
|
||||
|
||||
## License
|
||||
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,41 @@
|
|||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { generateTSFromOpenAPI } from './generate-ts-from-openapi'
|
||||
|
||||
const fixtures = [
|
||||
'firecrawl.json',
|
||||
// 'github.json', // TODO: not working 100% yet
|
||||
'notion.json',
|
||||
'open-meteo.yaml',
|
||||
'pet-store.json',
|
||||
'petstore-expanded.json',
|
||||
'security.json',
|
||||
// 'stripe.json', // TODO: not working 100% yet
|
||||
'tic-tac-toe.json'
|
||||
]
|
||||
|
||||
const dirname = path.join(fileURLToPath(import.meta.url), '..', '..')
|
||||
|
||||
describe('openapi-to-ts', () => {
|
||||
for (const fixture of fixtures) {
|
||||
test(
|
||||
fixture,
|
||||
{
|
||||
timeout: 60_000
|
||||
},
|
||||
async () => {
|
||||
const fixturePath = path.join(dirname, 'fixtures', 'openapi', fixture)
|
||||
const outputDir = path.join(dirname, 'fixtures', 'generated')
|
||||
|
||||
const result = await generateTSFromOpenAPI({
|
||||
openapiFilePath: fixturePath,
|
||||
outputDir
|
||||
})
|
||||
expect(result).toMatchSnapshot()
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
|
@ -61,7 +61,10 @@ export async function generateTSFromOpenAPI({
|
|||
throw new Error(`Unexpected OpenAPI version "${spec.openapi}"`)
|
||||
}
|
||||
|
||||
const openapiSpecName = path.basename(openapiFilePath, '.json')
|
||||
const openapiSpecName = path
|
||||
.basename(openapiFilePath)
|
||||
.replace(/\.json$/, '')
|
||||
.replace(/\.yaml$/, '')
|
||||
assert(
|
||||
openapiSpecName.toLowerCase() === openapiSpecName,
|
||||
`OpenAPI spec name "${openapiSpecName}" must be in kebab case`
|
||||
|
@ -75,6 +78,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
|
||||
|
@ -179,7 +183,12 @@ export async function generateTSFromOpenAPI({
|
|||
`Duplicate operation name "${operationName}"`
|
||||
)
|
||||
operationNames.add(operationName)
|
||||
const operationNameSnakeCase = decamelize(operationName)
|
||||
const operationNameSnakeCaseTemp = decamelize(operationName)
|
||||
const operationNameSnakeCase = operationNameSnakeCaseTemp.startsWith(
|
||||
`${nameSnakeCase}_`
|
||||
)
|
||||
? operationNameSnakeCaseTemp
|
||||
: `${nameSnakeCase}_${operationNameSnakeCaseTemp}`
|
||||
|
||||
// if (path !== '/comments' || method !== 'post') continue
|
||||
// if (path !== '/crawl/status/{jobId}') continue
|
||||
|
@ -199,7 +208,7 @@ export async function generateTSFromOpenAPI({
|
|||
|
||||
const operationResponseJSONSchemas: Record<string, IJsonSchema> = {}
|
||||
|
||||
const operationParamsSources: Record<string, string> = {}
|
||||
const operationParamsSources: Record<string, Set<string>> = {}
|
||||
let operationParamsUnionSource: string | undefined
|
||||
|
||||
// eslint-disable-next-line unicorn/consistent-function-scoping
|
||||
|
@ -212,15 +221,21 @@ export async function generateTSFromOpenAPI({
|
|||
const derefed = dereference(schema, parser.$refs, componentsToProcess)
|
||||
if (derefed?.properties) {
|
||||
for (const key of Object.keys(derefed.properties)) {
|
||||
assert(
|
||||
!operationParamsSources[key],
|
||||
`Duplicate params key ${key} for operation ${operationName} from ${operationParamsSources[key]} and ${source}`
|
||||
)
|
||||
operationParamsSources[key] = source
|
||||
// assert(
|
||||
// !operationParamsSources[key],
|
||||
// `Duplicate params key ${key} for operation ${operationName} from ${operationParamsSources[key]} and ${source}`
|
||||
// )
|
||||
operationParamsSources[key] = new Set([
|
||||
...(operationParamsSources[key] || []),
|
||||
source
|
||||
])
|
||||
}
|
||||
} else if (derefed?.anyOf || derefed?.oneOf) {
|
||||
const componentName = getComponentDisplayName(schema.$ref)
|
||||
operationParamsSources[componentName] = source
|
||||
operationParamsSources[componentName] = new Set([
|
||||
...(operationParamsSources[componentName] || []),
|
||||
source
|
||||
])
|
||||
|
||||
// TODO: handle this case
|
||||
assert(
|
||||
|
@ -237,11 +252,14 @@ export async function generateTSFromOpenAPI({
|
|||
}
|
||||
|
||||
for (const key of Object.keys(schema.properties)) {
|
||||
assert(
|
||||
!operationParamsSources[key],
|
||||
`Duplicate params key ${key} for operation ${operationName} from ${operationParamsSources[key]} and ${source}`
|
||||
)
|
||||
operationParamsSources[key] = source
|
||||
// assert(
|
||||
// !operationParamsSources[key],
|
||||
// `Duplicate params key "${key}" for operation "${operationName}" from "${operationParamsSources[key]}" and "${source}"`
|
||||
// )
|
||||
operationParamsSources[key] = new Set([
|
||||
...(operationParamsSources[key] || []),
|
||||
source
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +273,10 @@ export async function generateTSFromOpenAPI({
|
|||
if (schema.anyOf || schema.oneOf) {
|
||||
operationParamsJSONSchema.anyOf = schema.anyOf
|
||||
operationParamsJSONSchema.oneOf = schema.oneOf
|
||||
operationParamsSources[schema.title || '__union__'] = source
|
||||
operationParamsSources[schema.title || '__union__'] = new Set([
|
||||
...(operationParamsSources[schema.title || '__union__'] || []),
|
||||
source
|
||||
])
|
||||
|
||||
// TODO: handle this case
|
||||
assert(
|
||||
|
@ -311,7 +332,10 @@ export async function generateTSFromOpenAPI({
|
|||
}
|
||||
|
||||
if (operation.parameters) {
|
||||
const params = convertParametersToJSONSchema(operation.parameters)
|
||||
const parameters = operation.parameters.map((param) =>
|
||||
dereference(param, parser.$refs, componentsToProcess)
|
||||
)
|
||||
const params = convertParametersToJSONSchema(parameters)
|
||||
|
||||
if (params.body) {
|
||||
addJSONSchemaParams(params.body, 'body')
|
||||
|
@ -458,28 +482,28 @@ export async function generateTSFromOpenAPI({
|
|||
// )
|
||||
// )
|
||||
|
||||
const queryParams = Object.keys(operationParamsSources).filter(
|
||||
(key) => operationParamsSources[key] === 'query'
|
||||
const queryParams = Object.keys(operationParamsSources).filter((key) =>
|
||||
operationParamsSources[key]?.has('query')
|
||||
)
|
||||
const hasQueryParams = queryParams.length > 0
|
||||
|
||||
const bodyParams = Object.keys(operationParamsSources).filter(
|
||||
(key) => operationParamsSources[key] === 'body'
|
||||
const bodyParams = Object.keys(operationParamsSources).filter((key) =>
|
||||
operationParamsSources[key]?.has('body')
|
||||
)
|
||||
const hasBodyParams = bodyParams.length > 0
|
||||
|
||||
const formDataParams = Object.keys(operationParamsSources).filter(
|
||||
(key) => operationParamsSources[key] === 'formData'
|
||||
const formDataParams = Object.keys(operationParamsSources).filter((key) =>
|
||||
operationParamsSources[key]?.has('formData')
|
||||
)
|
||||
const hasFormDataParams = formDataParams.length > 0
|
||||
|
||||
const pathParams = Object.keys(operationParamsSources).filter(
|
||||
(key) => operationParamsSources[key] === 'path'
|
||||
const pathParams = Object.keys(operationParamsSources).filter((key) =>
|
||||
operationParamsSources[key]?.has('path')
|
||||
)
|
||||
const hasPathParams = pathParams.length > 0
|
||||
|
||||
const headersParams = Object.keys(operationParamsSources).filter(
|
||||
(key) => operationParamsSources[key] === 'headers'
|
||||
const headersParams = Object.keys(operationParamsSources).filter((key) =>
|
||||
operationParamsSources[key]?.has('headers')
|
||||
)
|
||||
const hasHeadersParams = headersParams.length > 0
|
||||
|
||||
|
@ -495,12 +519,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}${
|
||||
|
@ -593,10 +620,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.
|
||||
*/
|
||||
|
@ -610,34 +651,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}` : ''}
|
||||
*/
|
||||
|
@ -680,22 +721,28 @@ export class ${clientName} extends AIFunctionsProvider {
|
|||
})
|
||||
}
|
||||
`,
|
||||
aiClientMethodsString,
|
||||
'}'
|
||||
].join('\n\n')
|
||||
)
|
||||
).replaceAll(/z\s*\.object\({}\)\s*\.merge\(([^)]*)\)/gm, '$1')
|
||||
// .replaceAll(/\/\*\*(\S.*\S)\*\//g, '/** $1 */')
|
||||
aiClientMethodsString,
|
||||
'}'
|
||||
].join('\n\n')
|
||||
)
|
||||
|
||||
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
|
||||
|
|
|
@ -123,6 +123,10 @@ function createParserOverride({
|
|||
withJsdocs: boolean
|
||||
}): ParserOverride {
|
||||
const jsonSchemaToZodParserOverride: ParserOverride = (schema, _refs) => {
|
||||
if ('nullable' in schema && schema.nullable) {
|
||||
delete schema.nullable
|
||||
}
|
||||
|
||||
if ('$ref' in schema) {
|
||||
const ref = schema.$ref as string
|
||||
assert(ref, `Invalid schema: $ref not found for ${schema.$ref}`)
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"extends": "@agentic/tsconfig/base.json",
|
||||
"include": ["src", "bin"],
|
||||
"include": [
|
||||
"src",
|
||||
"bin",
|
||||
"../open-meteo/src/open-meteo-client.ts",
|
||||
"../open-meteo/src/open-meteo.ts"
|
||||
],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export * from './slack'
|
||||
export * from './slack-client'
|
||||
|
|
|
@ -9,263 +9,10 @@ import {
|
|||
import defaultKy, { type KyInstance } from 'ky'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { slack } from './slack'
|
||||
|
||||
// TODO: need to expose more aiFunctions
|
||||
|
||||
export namespace slack {
|
||||
export const API_BASE_URL = 'https://slack.com/api'
|
||||
|
||||
export const DEFAULT_TIMEOUT_MS = 120_000
|
||||
export const DEFAULT_INTERVAL_MS = 5000
|
||||
|
||||
export interface BotProfile {
|
||||
id: string
|
||||
app_id: string
|
||||
name: string
|
||||
icons: Record<string, unknown>
|
||||
deleted: boolean
|
||||
updated: number
|
||||
team_id: string
|
||||
}
|
||||
|
||||
export interface Replies {
|
||||
messages: Message[]
|
||||
has_more: boolean
|
||||
ok: boolean
|
||||
response_metadata: ResponseMetadata
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
bot_id?: string
|
||||
client_msg_id?: string
|
||||
type: string
|
||||
text: string
|
||||
user: string
|
||||
ts: string
|
||||
app_id?: string
|
||||
blocks?: Record<string, unknown>[]
|
||||
reply_count?: number
|
||||
subscribed?: boolean
|
||||
last_read?: string
|
||||
unread_count?: number
|
||||
team?: string
|
||||
thread_ts: string
|
||||
parent_user_id?: string
|
||||
bot_profile?: BotProfile
|
||||
}
|
||||
|
||||
export interface ResponseMetadata {
|
||||
next_cursor: string
|
||||
}
|
||||
|
||||
export type Attachment = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type Block = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `chat.postMessage` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/chat.postMessage}
|
||||
*/
|
||||
export type PostMessageParams = {
|
||||
/**
|
||||
* The formatted text of the message to be published.
|
||||
*/
|
||||
text: string
|
||||
|
||||
/**
|
||||
* Channel, private group, or IM channel to send the message to. Can be an encoded ID, or a name.
|
||||
*/
|
||||
channel?: string
|
||||
|
||||
/**
|
||||
* Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead.
|
||||
*/
|
||||
thread_ts?: string
|
||||
|
||||
/**
|
||||
* A JSON-based array of structured attachments, presented as a URL-encoded string.
|
||||
*/
|
||||
attachments?: Attachment[]
|
||||
|
||||
/**
|
||||
* A JSON-based array of structured blocks, presented as a URL-encoded string.
|
||||
*/
|
||||
blocks?: Block[]
|
||||
|
||||
/**
|
||||
* Emoji to use as the icon for this message. Overrides icon_url.
|
||||
*/
|
||||
icon_emoji?: string
|
||||
|
||||
/**
|
||||
* URL to an image to use as the icon for this message.
|
||||
*/
|
||||
icon_url?: string
|
||||
|
||||
/**
|
||||
* If set to true, user group handles (to name just one example) will be linked in the message text.
|
||||
*/
|
||||
link_names?: boolean
|
||||
|
||||
/**
|
||||
* Change how messages are treated (default: 'none').
|
||||
*/
|
||||
parse?: 'full' | 'none'
|
||||
|
||||
/**
|
||||
* Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation.
|
||||
*/
|
||||
reply_broadcast?: boolean
|
||||
|
||||
/**
|
||||
* Pass true to enable unfurling of primarily text-based content.
|
||||
*/
|
||||
unfurl_links?: boolean
|
||||
|
||||
/**
|
||||
* Pass false to disable unfurling of media content.
|
||||
*/
|
||||
unfurl_media?: boolean
|
||||
|
||||
/**
|
||||
* Set your bot's user name.
|
||||
*/
|
||||
username?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `conversations.history` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/conversations.history}
|
||||
*/
|
||||
export type ConversationHistoryParams = {
|
||||
/**
|
||||
* The conversation ID to fetch history for.
|
||||
*/
|
||||
channel: string
|
||||
|
||||
/**
|
||||
* Only messages after this Unix timestamp will be included in results (default: `0`).
|
||||
*/
|
||||
oldest?: string
|
||||
|
||||
/**
|
||||
* The cursor value used for pagination of results (default: first page).
|
||||
*/
|
||||
cursor?: string
|
||||
|
||||
/**
|
||||
* Only messages before this Unix timestamp will be included in results (default: now).
|
||||
*/
|
||||
latest?: string
|
||||
|
||||
/**
|
||||
* The maximum number of items to return (default: `100`).
|
||||
*/
|
||||
limit?: number
|
||||
|
||||
/**
|
||||
* Include messages with the oldest or latest timestamps in results. Ignored unless either timestamp is specified (default: `false`).
|
||||
*/
|
||||
inclusive?: boolean
|
||||
|
||||
/**
|
||||
* Return all metadata associated with the messages (default: `false`).
|
||||
*/
|
||||
include_all_metadata?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `conversations.replies` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/conversations.replies}
|
||||
*/
|
||||
export type ConversationRepliesParams = {
|
||||
/**
|
||||
* The conversation ID to fetch the thread from.
|
||||
*/
|
||||
channel: string
|
||||
|
||||
/**
|
||||
* Unique identifier of either a thread’s parent message or a message in the thread.
|
||||
*
|
||||
* ### Notes
|
||||
*
|
||||
* - ts must be the timestamp of an existing message with 0 or more replies.
|
||||
* - If there are no replies then just the single message referenced by ts will return - it is just an ordinary, unthreaded message.
|
||||
*/
|
||||
ts: string
|
||||
|
||||
/**
|
||||
* The cursor value used for pagination of results.
|
||||
* Set this to the `next_cursor` attribute returned by a previous request's response_metadata.
|
||||
*/
|
||||
cursor?: string
|
||||
|
||||
/**
|
||||
* Only messages before this Unix timestamp will be included in results.
|
||||
*/
|
||||
latest?: string
|
||||
|
||||
/**
|
||||
* Only messages after this Unix timestamp will be included in results.
|
||||
*/
|
||||
oddest?: string
|
||||
|
||||
/**
|
||||
* The maximum number of items to return.
|
||||
* Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
|
||||
*/
|
||||
limit?: number
|
||||
|
||||
/**
|
||||
* Include messages with the oldest or latest timestamps in results. Ignored unless either timestamp is specified.
|
||||
*/
|
||||
inclusive?: boolean
|
||||
|
||||
/**
|
||||
* Return all metadata associated with this message.
|
||||
*/
|
||||
include_thread_metadata?: boolean
|
||||
}
|
||||
|
||||
export type SendAndWaitOptions = {
|
||||
/**
|
||||
* The text of the message to send.
|
||||
*/
|
||||
text: string
|
||||
|
||||
/**
|
||||
* The ID of the channel to send the message to.
|
||||
*/
|
||||
channel?: string
|
||||
|
||||
/**
|
||||
* The timeout in milliseconds to wait for a reply before throwing an error.
|
||||
*/
|
||||
timeoutMs?: number
|
||||
|
||||
/**
|
||||
* The interval in milliseconds to poll for replies.
|
||||
*/
|
||||
intervalMs?: number
|
||||
|
||||
/**
|
||||
* A function to validate the reply message. If the function returns `true`, the reply is considered valid and the function will return the message. If the function returns `false`, the reply is considered invalid and the function will continue to wait for a reply until the timeout is reached.
|
||||
*/
|
||||
validate?: (message: Message) => boolean
|
||||
|
||||
/**
|
||||
* A stop signal from an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), which can be used to abort retrying. More specifically, when `AbortController.abort(reason)` is called, the function will throw an error with the `reason` argument as the error message.
|
||||
*/
|
||||
stopSignal?: AbortSignal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal Slack API client for sending and receiving Slack messages.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,295 @@
|
|||
export namespace slack {
|
||||
export const API_BASE_URL = 'https://slack.com/api'
|
||||
|
||||
export const DEFAULT_TIMEOUT_MS = 120_000
|
||||
export const DEFAULT_INTERVAL_MS = 5000
|
||||
|
||||
export interface BotProfile {
|
||||
id: string
|
||||
app_id: string
|
||||
name: string
|
||||
icons: Record<string, unknown>
|
||||
deleted: boolean
|
||||
updated: number
|
||||
team_id: string
|
||||
}
|
||||
|
||||
export interface Replies {
|
||||
messages: Message[]
|
||||
has_more: boolean
|
||||
ok: boolean
|
||||
response_metadata: ResponseMetadata
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
bot_id?: string
|
||||
client_msg_id?: string
|
||||
type: string
|
||||
text: string
|
||||
user: string
|
||||
ts: string
|
||||
app_id?: string
|
||||
blocks?: Record<string, unknown>[]
|
||||
reply_count?: number
|
||||
subscribed?: boolean
|
||||
last_read?: string
|
||||
unread_count?: number
|
||||
team?: string
|
||||
thread_ts: string
|
||||
parent_user_id?: string
|
||||
bot_profile?: BotProfile
|
||||
}
|
||||
|
||||
export interface ResponseMetadata {
|
||||
next_cursor: string
|
||||
}
|
||||
|
||||
export type Attachment = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type Block = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `chat.postMessage` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/chat.postMessage}
|
||||
*/
|
||||
export type PostMessageParams = {
|
||||
/**
|
||||
* The formatted text of the message to be published.
|
||||
*/
|
||||
text: string
|
||||
|
||||
/**
|
||||
* Channel, private group, or IM channel to send the message to. Can be an encoded ID, or a name.
|
||||
*/
|
||||
channel?: string
|
||||
|
||||
/**
|
||||
* Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead.
|
||||
*/
|
||||
thread_ts?: string
|
||||
|
||||
/**
|
||||
* A JSON-based array of structured attachments, presented as a URL-encoded string.
|
||||
*/
|
||||
attachments?: Attachment[]
|
||||
|
||||
/**
|
||||
* A JSON-based array of structured blocks, presented as a URL-encoded string.
|
||||
*/
|
||||
blocks?: Block[]
|
||||
|
||||
/**
|
||||
* Emoji to use as the icon for this message. Overrides icon_url.
|
||||
*/
|
||||
icon_emoji?: string
|
||||
|
||||
/**
|
||||
* URL to an image to use as the icon for this message.
|
||||
*/
|
||||
icon_url?: string
|
||||
|
||||
/**
|
||||
* If set to true, user group handles (to name just one example) will be linked in the message text.
|
||||
*/
|
||||
link_names?: boolean
|
||||
|
||||
/**
|
||||
* Change how messages are treated (default: 'none').
|
||||
*/
|
||||
parse?: 'full' | 'none'
|
||||
|
||||
/**
|
||||
* Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation.
|
||||
*/
|
||||
reply_broadcast?: boolean
|
||||
|
||||
/**
|
||||
* Pass true to enable unfurling of primarily text-based content.
|
||||
*/
|
||||
unfurl_links?: boolean
|
||||
|
||||
/**
|
||||
* Pass false to disable unfurling of media content.
|
||||
*/
|
||||
unfurl_media?: boolean
|
||||
|
||||
/**
|
||||
* Set your bot's user name.
|
||||
*/
|
||||
username?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `conversations.history` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/conversations.history}
|
||||
*/
|
||||
export type ConversationHistoryParams = {
|
||||
/**
|
||||
* The conversation ID to fetch history for.
|
||||
*/
|
||||
channel: string
|
||||
|
||||
/**
|
||||
* Only messages after this Unix timestamp will be included in results (default: `0`).
|
||||
*/
|
||||
oldest?: string
|
||||
|
||||
/**
|
||||
* The cursor value used for pagination of results (default: first page).
|
||||
*/
|
||||
cursor?: string
|
||||
|
||||
/**
|
||||
* Only messages before this Unix timestamp will be included in results (default: now).
|
||||
*/
|
||||
latest?: string
|
||||
|
||||
/**
|
||||
* The maximum number of items to return (default: `100`).
|
||||
*/
|
||||
limit?: number
|
||||
|
||||
/**
|
||||
* Include messages with the oldest or latest timestamps in results. Ignored unless either timestamp is specified (default: `false`).
|
||||
*/
|
||||
inclusive?: boolean
|
||||
|
||||
/**
|
||||
* Return all metadata associated with the messages (default: `false`).
|
||||
*/
|
||||
include_all_metadata?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the Slack API's `conversations.replies` method.
|
||||
*
|
||||
* @see {@link https://api.slack.com/methods/conversations.replies}
|
||||
*/
|
||||
export type ConversationRepliesParams = {
|
||||
/**
|
||||
* The conversation ID to fetch the thread from.
|
||||
*/
|
||||
channel: string
|
||||
|
||||
/**
|
||||
* Unique identifier of either a thread’s parent message or a message in the thread.
|
||||
*
|
||||
* ### Notes
|
||||
*
|
||||
* - ts must be the timestamp of an existing message with 0 or more replies.
|
||||
* - If there are no replies then just the single message referenced by ts will return - it is just an ordinary, unthreaded message.
|
||||
*/
|
||||
ts: string
|
||||
|
||||
/**
|
||||
* The cursor value used for pagination of results.
|
||||
* Set this to the `next_cursor` attribute returned by a previous request's response_metadata.
|
||||
*/
|
||||
cursor?: string
|
||||
|
||||
/**
|
||||
* Only messages before this Unix timestamp will be included in results.
|
||||
*/
|
||||
latest?: string
|
||||
|
||||
/**
|
||||
* Only messages after this Unix timestamp will be included in results.
|
||||
*/
|
||||
oddest?: string
|
||||
|
||||
/**
|
||||
* The maximum number of items to return.
|
||||
* Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
|
||||
*/
|
||||
limit?: number
|
||||
|
||||
/**
|
||||
* Include messages with the oldest or latest timestamps in results. Ignored unless either timestamp is specified.
|
||||
*/
|
||||
inclusive?: boolean
|
||||
|
||||
/**
|
||||
* Return all metadata associated with this message.
|
||||
*/
|
||||
include_thread_metadata?: boolean
|
||||
}
|
||||
|
||||
export type SendAndWaitOptions = {
|
||||
/**
|
||||
* The text of the message to send.
|
||||
*/
|
||||
text: string
|
||||
|
||||
/**
|
||||
* The ID of the channel to send the message to.
|
||||
*/
|
||||
channel?: string
|
||||
|
||||
/**
|
||||
* The timeout in milliseconds to wait for a reply before throwing an error.
|
||||
*/
|
||||
timeoutMs?: number
|
||||
|
||||
/**
|
||||
* The interval in milliseconds to poll for replies.
|
||||
*/
|
||||
intervalMs?: number
|
||||
|
||||
/**
|
||||
* A function to validate the reply message. If the function returns `true`, the reply is considered valid and the function will return the message. If the function returns `false`, the reply is considered invalid and the function will continue to wait for a reply until the timeout is reached.
|
||||
*/
|
||||
validate?: (message: Message) => boolean
|
||||
|
||||
/**
|
||||
* A stop signal from an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), which can be used to abort retrying. More specifically, when `AbortController.abort(reason)` is called, the function will throw an error with the `reason` argument as the error message.
|
||||
*/
|
||||
stopSignal?: AbortSignal
|
||||
}
|
||||
|
||||
export interface ListChannelsArgs {
|
||||
limit?: number
|
||||
cursor?: string
|
||||
}
|
||||
|
||||
export interface PostMessageArgs {
|
||||
channel_id: string
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface ReplyToThreadArgs {
|
||||
channel_id: string
|
||||
thread_ts: string
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface AddReactionArgs {
|
||||
channel_id: string
|
||||
timestamp: string
|
||||
reaction: string
|
||||
}
|
||||
|
||||
export interface GetChannelHistoryArgs {
|
||||
channel_id: string
|
||||
limit?: number
|
||||
}
|
||||
|
||||
export interface GetThreadRepliesArgs {
|
||||
channel_id: string
|
||||
thread_ts: string
|
||||
}
|
||||
|
||||
export interface GetUsersArgs {
|
||||
cursor?: string
|
||||
limit?: number
|
||||
}
|
||||
|
||||
export interface GetUserProfileArgs {
|
||||
user_id: string
|
||||
}
|
||||
}
|
|
@ -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:*",
|
||||
|
@ -44,6 +45,7 @@
|
|||
"@agentic/exa": "workspace:*",
|
||||
"@agentic/firecrawl": "workspace:*",
|
||||
"@agentic/github": "workspace:*",
|
||||
"@agentic/google-custom-search": "workspace:*",
|
||||
"@agentic/gravatar": "workspace:*",
|
||||
"@agentic/hacker-news": "workspace:*",
|
||||
"@agentic/hunter": "workspace:*",
|
||||
|
@ -51,7 +53,9 @@
|
|||
"@agentic/leadmagic": "workspace:*",
|
||||
"@agentic/midjourney": "workspace:*",
|
||||
"@agentic/mcp": "workspace:*",
|
||||
"@agentic/notion": "workspace:*",
|
||||
"@agentic/novu": "workspace:*",
|
||||
"@agentic/open-meteo": "workspace:*",
|
||||
"@agentic/people-data-labs": "workspace:*",
|
||||
"@agentic/perigon": "workspace:*",
|
||||
"@agentic/polygon": "workspace:*",
|
||||
|
|
|
@ -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'
|
||||
|
@ -10,6 +11,7 @@ export * from '@agentic/e2b'
|
|||
export * from '@agentic/exa'
|
||||
export * from '@agentic/firecrawl'
|
||||
export * from '@agentic/github'
|
||||
export * from '@agentic/google-custom-search'
|
||||
export * from '@agentic/gravatar'
|
||||
export * from '@agentic/hacker-news'
|
||||
export * from '@agentic/hunter'
|
||||
|
@ -17,7 +19,9 @@ export * from '@agentic/jina'
|
|||
export * from '@agentic/leadmagic'
|
||||
export * from '@agentic/mcp'
|
||||
export * from '@agentic/midjourney'
|
||||
export * from '@agentic/notion'
|
||||
export * from '@agentic/novu'
|
||||
export * from '@agentic/open-meteo'
|
||||
export * from '@agentic/people-data-labs'
|
||||
export * from '@agentic/perigon'
|
||||
export * from '@agentic/polygon'
|
||||
|
|
|
@ -7,8 +7,8 @@ settings:
|
|||
catalogs:
|
||||
default:
|
||||
'@ai-sdk/openai':
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.1
|
||||
specifier: ^1.3.2
|
||||
version: 1.3.2
|
||||
'@apidevtools/swagger-parser':
|
||||
specifier: ^10.1.1
|
||||
version: 10.1.1
|
||||
|
@ -21,6 +21,9 @@ catalogs:
|
|||
'@fisch0920/eslint-config':
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0
|
||||
'@googleapis/customsearch':
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0
|
||||
'@langchain/core':
|
||||
specifier: ^0.3.43
|
||||
version: 0.3.43
|
||||
|
@ -271,7 +274,7 @@ importers:
|
|||
version: link:../../packages/weather
|
||||
'@ai-sdk/openai':
|
||||
specifier: 'catalog:'
|
||||
version: 1.3.1(zod@3.24.2)
|
||||
version: 1.3.2(zod@3.24.2)
|
||||
ai:
|
||||
specifier: 'catalog:'
|
||||
version: 4.2.2(react@18.3.1)(zod@3.24.2)
|
||||
|
@ -402,7 +405,7 @@ importers:
|
|||
version: link:../../packages/weather
|
||||
'@ai-sdk/openai':
|
||||
specifier: 'catalog:'
|
||||
version: 1.3.1(zod@3.24.2)
|
||||
version: 1.3.2(zod@3.24.2)
|
||||
'@mastra/core':
|
||||
specifier: 'catalog:'
|
||||
version: 0.6.4(encoding@0.1.13)(react@18.3.1)
|
||||
|
@ -541,6 +544,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':
|
||||
|
@ -763,6 +782,22 @@ importers:
|
|||
specifier: workspace:*
|
||||
version: link:../tsconfig
|
||||
|
||||
packages/google-custom-search:
|
||||
dependencies:
|
||||
'@agentic/core':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@googleapis/customsearch':
|
||||
specifier: 'catalog:'
|
||||
version: 3.2.0(encoding@0.1.13)
|
||||
zod:
|
||||
specifier: 'catalog:'
|
||||
version: 3.24.2
|
||||
devDependencies:
|
||||
'@agentic/tsconfig':
|
||||
specifier: workspace:*
|
||||
version: link:../tsconfig
|
||||
|
||||
packages/gravatar:
|
||||
dependencies:
|
||||
'@agentic/core':
|
||||
|
@ -831,7 +866,7 @@ importers:
|
|||
version: link:../tsconfig
|
||||
'@ai-sdk/openai':
|
||||
specifier: 'catalog:'
|
||||
version: 1.3.1(zod@3.24.2)
|
||||
version: 1.3.2(zod@3.24.2)
|
||||
ai:
|
||||
specifier: 'catalog:'
|
||||
version: 4.2.2(react@18.3.1)(zod@3.24.2)
|
||||
|
@ -945,6 +980,22 @@ importers:
|
|||
specifier: workspace:*
|
||||
version: link:../tsconfig
|
||||
|
||||
packages/notion:
|
||||
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/novu:
|
||||
dependencies:
|
||||
'@agentic/core':
|
||||
|
@ -961,6 +1012,22 @@ importers:
|
|||
specifier: workspace:*
|
||||
version: link:../tsconfig
|
||||
|
||||
packages/open-meteo:
|
||||
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/openapi-to-ts:
|
||||
dependencies:
|
||||
'@agentic/core':
|
||||
|
@ -1206,6 +1273,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
|
||||
|
@ -1236,6 +1306,9 @@ importers:
|
|||
'@agentic/github':
|
||||
specifier: workspace:*
|
||||
version: link:../github
|
||||
'@agentic/google-custom-search':
|
||||
specifier: workspace:*
|
||||
version: link:../google-custom-search
|
||||
'@agentic/gravatar':
|
||||
specifier: workspace:*
|
||||
version: link:../gravatar
|
||||
|
@ -1257,9 +1330,15 @@ importers:
|
|||
'@agentic/midjourney':
|
||||
specifier: workspace:*
|
||||
version: link:../midjourney
|
||||
'@agentic/notion':
|
||||
specifier: workspace:*
|
||||
version: link:../notion
|
||||
'@agentic/novu':
|
||||
specifier: workspace:*
|
||||
version: link:../novu
|
||||
'@agentic/open-meteo':
|
||||
specifier: workspace:*
|
||||
version: link:../open-meteo
|
||||
'@agentic/people-data-labs':
|
||||
specifier: workspace:*
|
||||
version: link:../people-data-labs
|
||||
|
@ -1509,8 +1588,8 @@ importers:
|
|||
|
||||
packages:
|
||||
|
||||
'@ai-sdk/openai@1.3.1':
|
||||
resolution: {integrity: sha512-Fhb9IYEJdS9vIFwOxr9igiWF8x0xYSqAB7eYuHtZ9D6ovo4RB2JO7lSg0qQWGIGYxtwoipXwLjgF/ov25W23Hw==}
|
||||
'@ai-sdk/openai@1.3.2':
|
||||
resolution: {integrity: sha512-TgtD2NbDKiOipaLb5/eY6fN64Gu32V/sZ0VM5UndsWAGKkB1if3jSLic6TcQjNvnBuhkzZY6L9deVDe4z+2PBg==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
zod: ^3.0.0
|
||||
|
@ -1972,6 +2051,10 @@ packages:
|
|||
'@genkit-ai/core@1.3.0':
|
||||
resolution: {integrity: sha512-vwoHaiKkA8VBgGbp7a2oDzBFCicCFOihwCup48PvOY8kA9VYCws/qdUkFnrDh5NqzL7urXmjKE2wNf/59UmU9g==}
|
||||
|
||||
'@googleapis/customsearch@3.2.0':
|
||||
resolution: {integrity: sha512-NTS4S3YepwYTqvk3aYKzm6g7oXjE7rQjswoXtw4leX7ykpyu2GWwflW6haaqctZHj6IJbJ1k0xgbgLTn1BByYQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
'@grpc/grpc-js@1.13.1':
|
||||
resolution: {integrity: sha512-z5nNuIs75S73ZULjPDe5QCNTiCv7FyBZXEVWOyAHtcebnuJf0g1SuueI3U1/z/KK39XyAQRUC+C9ZQJOtgHynA==}
|
||||
engines: {node: '>=12.10.0'}
|
||||
|
@ -3645,6 +3728,9 @@ packages:
|
|||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||
hasBin: true
|
||||
|
||||
buffer-equal-constant-time@1.0.1:
|
||||
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}
|
||||
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
|
@ -4049,6 +4135,9 @@ packages:
|
|||
eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
|
||||
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
|
@ -4630,10 +4719,18 @@ packages:
|
|||
resolution: {integrity: sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
google-auth-library@9.15.1:
|
||||
resolution: {integrity: sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
google-logging-utils@0.0.2:
|
||||
resolution: {integrity: sha512-NEgUnEcBiP5HrPzufUkBzJOD/Sxsco3rLNo1F1TNf7ieU8ryUzBhqba8r756CjLX7rn3fHl6iLEwPYuqpoKgQQ==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
googleapis-common@7.2.0:
|
||||
resolution: {integrity: sha512-/fhDZEJZvOV3X5jmD+fKxMqma5q2Q9nZNSF3kn1F18tpxmA86BcTxAGBQdM0N89Z3bEaIs+HVznSmFJEAmMTjA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
gopd@1.2.0:
|
||||
resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
@ -4647,6 +4744,10 @@ packages:
|
|||
graphemer@1.4.0:
|
||||
resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}
|
||||
|
||||
gtoken@7.1.0:
|
||||
resolution: {integrity: sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
handlebars@4.7.8:
|
||||
resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==}
|
||||
engines: {node: '>=0.4.7'}
|
||||
|
@ -5046,6 +5147,12 @@ packages:
|
|||
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
|
||||
engines: {node: '>=4.0'}
|
||||
|
||||
jwa@2.0.0:
|
||||
resolution: {integrity: sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==}
|
||||
|
||||
jws@4.0.0:
|
||||
resolution: {integrity: sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==}
|
||||
|
||||
keyv@4.5.4:
|
||||
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
|
||||
|
||||
|
@ -6583,6 +6690,9 @@ packages:
|
|||
url-join@4.0.1:
|
||||
resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==}
|
||||
|
||||
url-template@2.0.8:
|
||||
resolution: {integrity: sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==}
|
||||
|
||||
use-sync-external-store@1.4.0:
|
||||
resolution: {integrity: sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==}
|
||||
peerDependencies:
|
||||
|
@ -6853,7 +6963,7 @@ packages:
|
|||
|
||||
snapshots:
|
||||
|
||||
'@ai-sdk/openai@1.3.1(zod@3.24.2)':
|
||||
'@ai-sdk/openai@1.3.2(zod@3.24.2)':
|
||||
dependencies:
|
||||
'@ai-sdk/provider': 1.1.0
|
||||
'@ai-sdk/provider-utils': 2.2.1(zod@3.24.2)
|
||||
|
@ -7569,8 +7679,8 @@ snapshots:
|
|||
'@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.2)
|
||||
'@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.8.2)
|
||||
eslint-config-prettier: 9.1.0(eslint@8.57.1)
|
||||
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1)
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||
eslint-plugin-jest: 28.9.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1)(typescript@5.8.2)
|
||||
eslint-plugin-jest-dom: 5.4.0(eslint@8.57.1)
|
||||
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
|
||||
|
@ -7626,6 +7736,13 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@googleapis/customsearch@3.2.0(encoding@0.1.13)':
|
||||
dependencies:
|
||||
googleapis-common: 7.2.0(encoding@0.1.13)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
'@grpc/grpc-js@1.13.1':
|
||||
dependencies:
|
||||
'@grpc/proto-loader': 0.7.13
|
||||
|
@ -9841,6 +9958,8 @@ snapshots:
|
|||
node-releases: 2.0.18
|
||||
update-browserslist-db: 1.1.1(browserslist@4.24.2)
|
||||
|
||||
buffer-equal-constant-time@1.0.1: {}
|
||||
|
||||
buffer@6.0.3:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
|
@ -10233,6 +10352,10 @@ snapshots:
|
|||
|
||||
eastasianwidth@0.2.0: {}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
electron-to-chromium@1.5.53: {}
|
||||
|
@ -10415,37 +10538,37 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1):
|
||||
eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1):
|
||||
dependencies:
|
||||
'@nolyfill/is-core-module': 1.0.39
|
||||
debug: 4.4.0
|
||||
enhanced-resolve: 5.17.1
|
||||
eslint: 8.57.1
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||
fast-glob: 3.3.3
|
||||
get-tsconfig: 4.10.0
|
||||
is-bun-module: 1.2.1
|
||||
is-glob: 4.0.3
|
||||
optionalDependencies:
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/parser'
|
||||
- eslint-import-resolver-node
|
||||
- eslint-import-resolver-webpack
|
||||
- supports-color
|
||||
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1):
|
||||
eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1):
|
||||
dependencies:
|
||||
debug: 3.2.7
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.8.2)
|
||||
eslint: 8.57.1
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0)(eslint@8.57.1)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1):
|
||||
eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1):
|
||||
dependencies:
|
||||
'@rtsao/scc': 1.1.0
|
||||
array-includes: 3.1.8
|
||||
|
@ -10456,7 +10579,7 @@ snapshots:
|
|||
doctrine: 2.1.0
|
||||
eslint: 8.57.1
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
|
||||
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||
hasown: 2.0.2
|
||||
is-core-module: 2.16.1
|
||||
is-glob: 4.0.3
|
||||
|
@ -11083,8 +11206,32 @@ snapshots:
|
|||
slash: 5.1.0
|
||||
unicorn-magic: 0.1.0
|
||||
|
||||
google-auth-library@9.15.1(encoding@0.1.13):
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ecdsa-sig-formatter: 1.0.11
|
||||
gaxios: 6.7.1(encoding@0.1.13)
|
||||
gcp-metadata: 6.1.1(encoding@0.1.13)
|
||||
gtoken: 7.1.0(encoding@0.1.13)
|
||||
jws: 4.0.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
google-logging-utils@0.0.2: {}
|
||||
|
||||
googleapis-common@7.2.0(encoding@0.1.13):
|
||||
dependencies:
|
||||
extend: 3.0.2
|
||||
gaxios: 6.7.1(encoding@0.1.13)
|
||||
google-auth-library: 9.15.1(encoding@0.1.13)
|
||||
qs: 6.14.0
|
||||
url-template: 2.0.8
|
||||
uuid: 9.0.1
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
gopd@1.2.0: {}
|
||||
|
||||
gpt-tokenizer@2.8.1: {}
|
||||
|
@ -11093,6 +11240,14 @@ snapshots:
|
|||
|
||||
graphemer@1.4.0: {}
|
||||
|
||||
gtoken@7.1.0(encoding@0.1.13):
|
||||
dependencies:
|
||||
gaxios: 6.7.1(encoding@0.1.13)
|
||||
jws: 4.0.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
handlebars@4.7.8:
|
||||
dependencies:
|
||||
minimist: 1.2.8
|
||||
|
@ -11443,6 +11598,17 @@ snapshots:
|
|||
object.assign: 4.1.5
|
||||
object.values: 1.2.0
|
||||
|
||||
jwa@2.0.0:
|
||||
dependencies:
|
||||
buffer-equal-constant-time: 1.0.1
|
||||
ecdsa-sig-formatter: 1.0.11
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
jws@4.0.0:
|
||||
dependencies:
|
||||
jwa: 2.0.0
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
keyv@4.5.4:
|
||||
dependencies:
|
||||
json-buffer: 3.0.1
|
||||
|
@ -12997,6 +13163,8 @@ snapshots:
|
|||
|
||||
url-join@4.0.1: {}
|
||||
|
||||
url-template@2.0.8: {}
|
||||
|
||||
use-sync-external-store@1.4.0(react@18.3.1):
|
||||
dependencies:
|
||||
react: 18.3.1
|
||||
|
|
|
@ -6,7 +6,7 @@ updateConfig:
|
|||
- p-throttle
|
||||
- eslint
|
||||
catalog:
|
||||
'@ai-sdk/openai': ^1.3.1
|
||||
'@ai-sdk/openai': ^1.3.2
|
||||
'@apidevtools/swagger-parser': ^10.1.1
|
||||
'@dexaai/dexter': ^4.1.1
|
||||
'@e2b/code-interpreter': ^1.0.4
|
||||
|
@ -36,6 +36,7 @@ catalog:
|
|||
fast-xml-parser: ^5.0.9
|
||||
genkit: ^1.3.0
|
||||
genkitx-openai: ^0.20.2
|
||||
'@googleapis/customsearch': ^3.2.0
|
||||
json-schema-to-zod: ^2.6.0
|
||||
jsonrepair: ^3.12.0
|
||||
jsrsasign: ^10.9.0
|
||||
|
|
|
@ -178,46 +178,50 @@ Full docs are available at [agentic.so](https://agentic.so).
|
|||
|
||||
## Tools
|
||||
|
||||
| Service / Tool | Package | Docs | Description |
|
||||
| ------------------------------------------------------------------------ | --------------------------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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. |
|
||||
| [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. |
|
||||
| [Diffbot](https://docs.diffbot.com) | `@agentic/diffbot` | [docs](https://agentic.so/tools/diffbot) | Web page classification and scraping; person and company data enrichment. |
|
||||
| [DuckDuckGo](https://duckduckgo.com) | `@agentic/duck-duck-go` | [docs](https://agentic.so/tools/duck-duck-go) | Privacy-focused web search API. |
|
||||
| [E2B](https://e2b.dev) | `@agentic/e2b` | [docs](https://agentic.so/tools/e2b) | Hosted Python code interpreter sandbox which is really useful for data analysis, flexible code execution, and advanced reasoning on-the-fly. |
|
||||
| [Exa](https://docs.exa.ai) | `@agentic/exa` | [docs](https://agentic.so/tools/exa) | Web search tailored for LLMs. |
|
||||
| [Firecrawl](https://www.firecrawl.dev) | `@agentic/firecrawl` | [docs](https://agentic.so/tools/firecrawl) | Website scraping and structured data extraction. |
|
||||
| [Gravatar](https://docs.gravatar.com/api/profiles/rest-api/) | `@agentic/gravatar` | [docs](https://agentic.so/tools/gravatar) | Gravatar profile API. |
|
||||
| [HackerNews](https://github.com/HackerNews/API) | `@agentic/hacker-news` | [docs](https://agentic.so/tools/hacker-news) | Official HackerNews API. |
|
||||
| [Hunter](https://hunter.io) | `@agentic/hunter` | [docs](https://agentic.so/tools/hunter) | Email finder, verifier, and enrichment. |
|
||||
| [Jina](https://jina.ai/reader) | `@agentic/jina` | [docs](https://agentic.so/tools/jina) | URL scraper and web search. |
|
||||
| [LeadMagic](https://leadmagic.io) | `@agentic/leadmagic` | [docs](https://agentic.so/tools/leadmagic) | B2B person, company, and email enrichment API. |
|
||||
| [Midjourney](https://www.imagineapi.dev) | `@agentic/midjourney` | [docs](https://agentic.so/tools/midjourney) | Unofficial Midjourney client for generative images. |
|
||||
| [McpTools](https://modelcontextprotocol.io) | `@agentic/mcp` | [docs](https://agentic.so/tools/mcp) | Model Context Protocol (MCP) client, supporting any MCP server. Use [createMcpTools](https://agentic.so/tools/mcp) to spawn or connect to an MCP server. |
|
||||
| [Novu](https://novu.co) | `@agentic/novu` | [docs](https://agentic.so/tools/novu) | Sending notifications (email, SMS, in-app, push, etc). |
|
||||
| [People Data Labs](https://www.peopledatalabs.com) | `@agentic/people-data-labs` | [docs](https://agentic.so/tools/people-data-labs) | People & company data (WIP). |
|
||||
| [Perigon](https://www.goperigon.com/products/news-api) | `@agentic/perigon` | [docs](https://agentic.so/tools/perigon) | Real-time news API and web content data from 140,000+ sources. Structured and enriched by AI, primed for LLMs. |
|
||||
| [Polygon](https://polygon.io) | `@agentic/polygon` | [docs](https://agentic.so/tools/polygon) | Stock market and company financial data. |
|
||||
| [PredictLeads](https://predictleads.com) | `@agentic/predict-leads` | [docs](https://agentic.so/tools/predict-leads) | In-depth company data including signals like fundraising events, hiring news, product launches, technologies used, etc. |
|
||||
| [Proxycurl](https://nubela.co/proxycurl) | `@agentic/proxycurl` | [docs](https://agentic.so/tools/proxycurl) | People and company data from LinkedIn & Crunchbase. |
|
||||
| [RocketReach](https://rocketreach.co/api/v2/docs) | `@agentic/rocketreach` | [docs](https://agentic.so/tools/rocketreach) | B2B person and company enrichment API. |
|
||||
| [Searxng](https://docs.searxng.org) | `@agentic/searxng` | [docs](https://agentic.so/tools/searxng) | OSS meta search engine capable of searching across many providers like Reddit, Google, Brave, Arxiv, Genius, IMDB, Rotten Tomatoes, Wikidata, Wolfram Alpha, YouTube, GitHub, [etc](https://docs.searxng.org/user/configured_engines.html#configured-engines). |
|
||||
| [SerpAPI](https://serpapi.com/search-api) | `@agentic/serpapi` | [docs](https://agentic.so/tools/serpapi) | Lightweight wrapper around SerpAPI for Google search. |
|
||||
| [Serper](https://serper.dev) | `@agentic/serper` | [docs](https://agentic.so/tools/serper) | Lightweight wrapper around Serper for Google search. |
|
||||
| [Slack](https://api.slack.com/docs) | `@agentic/slack` | [docs](https://agentic.so/tools/slack) | Send and receive Slack messages. |
|
||||
| [SocialData](https://socialdata.tools) | `@agentic/social-data` | [docs](https://agentic.so/tools/social-data) | Unofficial Twitter / X client (readonly) which is much cheaper than the official Twitter API. |
|
||||
| [Tavily](https://tavily.com) | `@agentic/tavily` | [docs](https://agentic.so/tools/tavily) | Web search API tailored for LLMs. |
|
||||
| [Twilio](https://www.twilio.com/docs/conversations/api) | `@agentic/twilio` | [docs](https://agentic.so/tools/twilio) | Twilio conversation API to send and receive SMS messages. |
|
||||
| [Twitter](https://developer.x.com/en/docs/twitter-api) | `@agentic/twitter` | [docs](https://agentic.so/tools/twitter) | Basic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting. Uses [Nango](https://www.nango.dev) for OAuth support. |
|
||||
| [Weather](https://www.weatherapi.com) | `@agentic/weather` | [docs](https://agentic.so/tools/weather) | Basic access to current weather data based on location. |
|
||||
| [Wikidata](https://www.wikidata.org/wiki/Wikidata:Data_access) | `@agentic/wikidata` | [docs](https://agentic.so/tools/wikidata) | Basic Wikidata client. |
|
||||
| [Wikipedia](https://www.mediawiki.org/wiki/API) | `@agentic/wikipedia` | [docs](https://agentic.so/tools/wikipedia) | Wikipedia page search and summaries. |
|
||||
| [Wolfram Alpha](https://products.wolframalpha.com/llm-api/documentation) | `@agentic/wolfram-alpha` | [docs](https://agentic.so/tools/wolfram-alpha) | Wolfram Alpha LLM API client for answering computational, mathematical, and scientific questions. |
|
||||
| [ZoomInfo](https://api-docs.zoominfo.com) | `@agentic/zoominfo` | [docs](https://agentic.so/tools/zoominfo) | Powerful B2B person and company data enrichment. |
|
||||
| Service / Tool | Package | Docs | Description |
|
||||
| ------------------------------------------------------------------------------- | ------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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. |
|
||||
| [Diffbot](https://docs.diffbot.com) | `@agentic/diffbot` | [docs](https://agentic.so/tools/diffbot) | Web page classification and scraping; person and company data enrichment. |
|
||||
| [DuckDuckGo](https://duckduckgo.com) | `@agentic/duck-duck-go` | [docs](https://agentic.so/tools/duck-duck-go) | Privacy-focused web search API. |
|
||||
| [E2B](https://e2b.dev) | `@agentic/e2b` | [docs](https://agentic.so/tools/e2b) | Hosted Python code interpreter sandbox which is really useful for data analysis, flexible code execution, and advanced reasoning on-the-fly. |
|
||||
| [Exa](https://docs.exa.ai) | `@agentic/exa` | [docs](https://agentic.so/tools/exa) | Web search tailored for LLMs. |
|
||||
| [Firecrawl](https://www.firecrawl.dev) | `@agentic/firecrawl` | [docs](https://agentic.so/tools/firecrawl) | Website scraping and structured data extraction. |
|
||||
| [Google Custom Search](https://developers.google.com/custom-search/v1/overview) | `@agentic/google-custom-search` | [docs](https://agentic.so/tools/google-custom-search) | Official Google Custom Search API. |
|
||||
| [Gravatar](https://docs.gravatar.com/api/profiles/rest-api/) | `@agentic/gravatar` | [docs](https://agentic.so/tools/gravatar) | Gravatar profile API. |
|
||||
| [HackerNews](https://github.com/HackerNews/API) | `@agentic/hacker-news` | [docs](https://agentic.so/tools/hacker-news) | Official HackerNews API. |
|
||||
| [Hunter](https://hunter.io) | `@agentic/hunter` | [docs](https://agentic.so/tools/hunter) | Email finder, verifier, and enrichment. |
|
||||
| [Jina](https://jina.ai/reader) | `@agentic/jina` | [docs](https://agentic.so/tools/jina) | URL scraper and web search. |
|
||||
| [LeadMagic](https://leadmagic.io) | `@agentic/leadmagic` | [docs](https://agentic.so/tools/leadmagic) | B2B person, company, and email enrichment API. |
|
||||
| [Midjourney](https://www.imagineapi.dev) | `@agentic/midjourney` | [docs](https://agentic.so/tools/midjourney) | Unofficial Midjourney client for generative images. |
|
||||
| [McpTools](https://modelcontextprotocol.io) | `@agentic/mcp` | [docs](https://agentic.so/tools/mcp) | Model Context Protocol (MCP) client, supporting any MCP server. Use [createMcpTools](https://agentic.so/tools/mcp) to spawn or connect to an MCP server. |
|
||||
| [Notion](https://developers.notion.com/docs) | `@agentic/notion` | [docs](https://agentic.so/tools/notion) | Official Notion API for accessing pages, databases, and content. |
|
||||
| [Novu](https://novu.co) | `@agentic/novu` | [docs](https://agentic.so/tools/novu) | Sending notifications (email, SMS, in-app, push, etc). |
|
||||
| [Open Meteo](https://open-meteo.com) | `@agentic/open-meteo` | [docs](https://agentic.so/tools/open-meteo) | Free weather API (no API key required). |
|
||||
| [People Data Labs](https://www.peopledatalabs.com) | `@agentic/people-data-labs` | [docs](https://agentic.so/tools/people-data-labs) | People & company data (WIP). |
|
||||
| [Perigon](https://www.goperigon.com/products/news-api) | `@agentic/perigon` | [docs](https://agentic.so/tools/perigon) | Real-time news API and web content data from 140,000+ sources. Structured and enriched by AI, primed for LLMs. |
|
||||
| [Polygon](https://polygon.io) | `@agentic/polygon` | [docs](https://agentic.so/tools/polygon) | Stock market and company financial data. |
|
||||
| [PredictLeads](https://predictleads.com) | `@agentic/predict-leads` | [docs](https://agentic.so/tools/predict-leads) | In-depth company data including signals like fundraising events, hiring news, product launches, technologies used, etc. |
|
||||
| [Proxycurl](https://nubela.co/proxycurl) | `@agentic/proxycurl` | [docs](https://agentic.so/tools/proxycurl) | People and company data from LinkedIn & Crunchbase. |
|
||||
| [RocketReach](https://rocketreach.co/api/v2/docs) | `@agentic/rocketreach` | [docs](https://agentic.so/tools/rocketreach) | B2B person and company enrichment API. |
|
||||
| [Searxng](https://docs.searxng.org) | `@agentic/searxng` | [docs](https://agentic.so/tools/searxng) | OSS meta search engine capable of searching across many providers like Reddit, Google, Brave, Arxiv, Genius, IMDB, Rotten Tomatoes, Wikidata, Wolfram Alpha, YouTube, GitHub, [etc](https://docs.searxng.org/user/configured_engines.html#configured-engines). |
|
||||
| [SerpAPI](https://serpapi.com/search-api) | `@agentic/serpapi` | [docs](https://agentic.so/tools/serpapi) | Lightweight wrapper around SerpAPI for Google search. |
|
||||
| [Serper](https://serper.dev) | `@agentic/serper` | [docs](https://agentic.so/tools/serper) | Lightweight wrapper around Serper for Google search. |
|
||||
| [Slack](https://api.slack.com/docs) | `@agentic/slack` | [docs](https://agentic.so/tools/slack) | Send and receive Slack messages. |
|
||||
| [SocialData](https://socialdata.tools) | `@agentic/social-data` | [docs](https://agentic.so/tools/social-data) | Unofficial Twitter / X client (readonly) which is much cheaper than the official Twitter API. |
|
||||
| [Tavily](https://tavily.com) | `@agentic/tavily` | [docs](https://agentic.so/tools/tavily) | Web search API tailored for LLMs. |
|
||||
| [Twilio](https://www.twilio.com/docs/conversations/api) | `@agentic/twilio` | [docs](https://agentic.so/tools/twilio) | Twilio conversation API to send and receive SMS messages. |
|
||||
| [Twitter](https://developer.x.com/en/docs/twitter-api) | `@agentic/twitter` | [docs](https://agentic.so/tools/twitter) | Basic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting. Uses [Nango](https://www.nango.dev) for OAuth support. |
|
||||
| [Weather](https://www.weatherapi.com) | `@agentic/weather` | [docs](https://agentic.so/tools/weather) | Basic access to current weather data based on location. |
|
||||
| [Wikidata](https://www.wikidata.org/wiki/Wikidata:Data_access) | `@agentic/wikidata` | [docs](https://agentic.so/tools/wikidata) | Basic Wikidata client. |
|
||||
| [Wikipedia](https://www.mediawiki.org/wiki/API) | `@agentic/wikipedia` | [docs](https://agentic.so/tools/wikipedia) | Wikipedia page search and summaries. |
|
||||
| [Wolfram Alpha](https://products.wolframalpha.com/llm-api/documentation) | `@agentic/wolfram-alpha` | [docs](https://agentic.so/tools/wolfram-alpha) | Wolfram Alpha LLM API client for answering computational, mathematical, and scientific questions. |
|
||||
| [ZoomInfo](https://api-docs.zoominfo.com) | `@agentic/zoominfo` | [docs](https://agentic.so/tools/zoominfo) | Powerful B2B person and company data enrichment. |
|
||||
|
||||
> [!NOTE]
|
||||
> Missing a tool or want to add your own tool to this list? If you have an OpenAPI v3 spec for your tool's API, we make it extremely easy to add support using our [@agentic/openapi-to-ts](./packages/openapi-to-ts) CLI. Otherwise, feel free to [open an issue to discuss](https://github.com/transitive-bullshit/agentic/issues/new?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) or submit a PR.
|
||||
|
|
Ładowanie…
Reference in New Issue