diff --git a/bin/scratch.ts b/bin/scratch.ts index 5e86a48..d9a4cdd 100644 --- a/bin/scratch.ts +++ b/bin/scratch.ts @@ -3,25 +3,25 @@ import 'dotenv/config' import restoreCursor from 'restore-cursor' -// import { SearxngClient } from '../src/services/searxng-client.js' -// import { ClearbitClient } from '../src/index.js' -// import { ProxycurlClient } from '../src/services/proxycurl-client.js' -// import { WikipediaClient } from '../src/index.js' -// import { PerigonClient } from '../src/index.js' -// import { FirecrawlClient } from '../src/index.js' -// import { ExaClient } from '../src/index.js' -// import { DiffbotClient } from '../src/index.js' -// import { WolframAlphaClient } from '../src/index.js' +// import { SearxngClient } from '../src/services/searxng-client' +// import { ClearbitClient } from '../src/index' +// import { ProxycurlClient } from '../src/services/proxycurl-client' +// import { WikipediaClient } from '../src/index' +// import { PerigonClient } from '../src/index' +// import { FirecrawlClient } from '../src/index' +// import { ExaClient } from '../src/index' +// import { DiffbotClient } from '../src/index' +// import { WolframAlphaClient } from '../src/index' // import { // createTwitterV2Client, // TwitterClient -// } from '../src/services/twitter/index.js' -// import { MidjourneyClient } from '../src/index.js' -// import { BingClient } from '../src/index.js' -// import { TavilyClient } from '../src/index.js' -// import { SocialDataClient } from '../src/index.js' -// import { HunterClient } from '../src/index.js' -import { JinaClient } from '../src/index.js' +// } from '../src/services/twitter/index' +// import { MidjourneyClient } from '../src/index' +// import { BingClient } from '../src/index' +// import { TavilyClient } from '../src/index' +// import { SocialDataClient } from '../src/index' +// import { HunterClient } from '../src/index' +import { JinaClient } from '../src/index' /** * Scratch pad for testing. diff --git a/src/ai-function-set.test.ts b/src/ai-function-set.test.ts index 32a3946..39dee18 100644 --- a/src/ai-function-set.test.ts +++ b/src/ai-function-set.test.ts @@ -1,9 +1,9 @@ import { expect, test } from 'vitest' import { z } from 'zod' -import { AIFunctionSet } from './ai-function-set.js' -import { aiFunction, AIFunctionsProvider } from './fns.js' -import { calculator } from './tools/calculator.js' +import { AIFunctionSet } from './ai-function-set' +import { aiFunction, AIFunctionsProvider } from './fns' +import { calculator } from './tools/calculator' class MockAITool extends AIFunctionsProvider { @aiFunction({ diff --git a/src/ai-function-set.ts b/src/ai-function-set.ts index ad2e06c..3c25f11 100644 --- a/src/ai-function-set.ts +++ b/src/ai-function-set.ts @@ -1,6 +1,6 @@ import type * as types from './types.ts' -import { AIFunctionsProvider } from './fns.js' -import { isAIFunction } from './utils.js' +import { AIFunctionsProvider } from './fns' +import { isAIFunction } from './utils' /** * A set of AI functions intended to make it easier to work with large sets of diff --git a/src/create-ai-chain.ts b/src/create-ai-chain.ts index adda7c2..8d9fc44 100644 --- a/src/create-ai-chain.ts +++ b/src/create-ai-chain.ts @@ -2,12 +2,12 @@ import type { SetOptional } from 'type-fest' import type { z } from 'zod' import pMap from 'p-map' -import type * as types from './types.js' -import { AIFunctionSet } from './ai-function-set.js' -import { AbortError } from './errors.js' -import { Msg } from './message.js' -import { asSchema, augmentSystemMessageWithJsonSchema } from './schema.js' -import { getErrorMessage } from './utils.js' +import type * as types from './types' +import { AIFunctionSet } from './ai-function-set' +import { AbortError } from './errors' +import { Msg } from './message' +import { asSchema, augmentSystemMessageWithJsonSchema } from './schema' +import { getErrorMessage } from './utils' export type AIChainParams = { chatFn: types.ChatFn diff --git a/src/create-ai-function.test.ts b/src/create-ai-function.test.ts index 94c3a62..f6a5d50 100644 --- a/src/create-ai-function.test.ts +++ b/src/create-ai-function.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { z } from 'zod' -import { createAIFunction } from './create-ai-function.js' +import { createAIFunction } from './create-ai-function' const fullName = createAIFunction( { diff --git a/src/create-ai-function.ts b/src/create-ai-function.ts index ea620f9..9880e28 100644 --- a/src/create-ai-function.ts +++ b/src/create-ai-function.ts @@ -1,9 +1,9 @@ import type { z } from 'zod' -import type * as types from './types.js' -import { parseStructuredOutput } from './parse-structured-output.js' -import { assert } from './utils.js' -import { zodToJsonSchema } from './zod-to-json-schema.js' +import type * as types from './types' +import { parseStructuredOutput } from './parse-structured-output' +import { assert } from './utils' +import { zodToJsonSchema } from './zod-to-json-schema' /** * Create a function meant to be used with OpenAI tool or function calling. diff --git a/src/extract-object.ts b/src/extract-object.ts index 484ccd0..ea9a230 100644 --- a/src/extract-object.ts +++ b/src/extract-object.ts @@ -1,5 +1,5 @@ -import type * as types from './types.js' -import { type AIChainParams, createAIChain } from './create-ai-chain.js' +import type * as types from './types' +import { type AIChainParams, createAIChain } from './create-ai-chain' export type ExtractObjectParams = types.Simplify< diff --git a/src/fns.ts b/src/fns.ts index ac0e9ac..45f9edd 100644 --- a/src/fns.ts +++ b/src/fns.ts @@ -1,9 +1,9 @@ import type { z } from 'zod' -import type * as types from './types.js' -import { AIFunctionSet } from './ai-function-set.js' -import { createAIFunction } from './create-ai-function.js' -import { assert } from './utils.js' +import type * as types from './types' +import { AIFunctionSet } from './ai-function-set' +import { createAIFunction } from './create-ai-function' +import { assert } from './utils' export interface PrivateAIFunctionMetadata { name: string diff --git a/src/index.ts b/src/index.ts index 4f0b434..877d78a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,15 @@ -export * from './ai-function-set.js' -export * from './create-ai-chain.js' -export * from './create-ai-function.js' -export * from './errors.js' -export * from './extract-object.js' -export * from './fns.js' -export * from './message.js' -export * from './parse-structured-output.js' -export * from './schema.js' -export * from './services/index.js' -export * from './tools/search-and-crawl.js' -export type * from './types.js' -export * from './url-utils.js' -export * from './utils.js' -export * from './zod-to-json-schema.js' +export * from './ai-function-set' +export * from './create-ai-chain' +export * from './create-ai-function' +export * from './errors' +export * from './extract-object' +export * from './fns' +export * from './message' +export * from './parse-structured-output' +export * from './schema' +export * from './services/index' +export * from './tools/search-and-crawl' +export type * from './types' +export * from './url-utils' +export * from './utils' +export * from './zod-to-json-schema' diff --git a/src/message.test.ts b/src/message.test.ts index 3da4301..1023e01 100644 --- a/src/message.test.ts +++ b/src/message.test.ts @@ -1,8 +1,8 @@ import type * as OpenAI from 'openai-fetch' import { describe, expect, expectTypeOf, it } from 'vitest' -import type * as types from './types.js' -import { Msg } from './message.js' +import type * as types from './types' +import { Msg } from './message' describe('Msg', () => { it('creates a message and fixes indentation', () => { diff --git a/src/message.ts b/src/message.ts index 6202c25..cd34d2e 100644 --- a/src/message.ts +++ b/src/message.ts @@ -1,6 +1,6 @@ import type { Jsonifiable } from 'type-fest' -import { cleanStringForModel, stringifyForModel } from './utils.js' +import { cleanStringForModel, stringifyForModel } from './utils' /** * Generic/default OpenAI message without any narrowing applied. diff --git a/src/parse-structured-output.test.ts b/src/parse-structured-output.test.ts index 63ffe61..79235fc 100644 --- a/src/parse-structured-output.test.ts +++ b/src/parse-structured-output.test.ts @@ -8,7 +8,7 @@ import { parseNumberOutput, parseObjectOutput, parseStructuredOutput -} from './parse-structured-output.js' +} from './parse-structured-output' test('extractJSONFromString should extract JSON object from string', () => { let jsonStr = 'Some text {"name":"John Doe"} more text' diff --git a/src/parse-structured-output.ts b/src/parse-structured-output.ts index 5300ca1..26bfef9 100644 --- a/src/parse-structured-output.ts +++ b/src/parse-structured-output.ts @@ -3,8 +3,8 @@ import { jsonrepair, JSONRepairError } from 'jsonrepair' import { z, type ZodType } from 'zod' import { fromZodError } from 'zod-validation-error' -import { ParseError } from './errors.js' -import { type SafeParseResult } from './types.js' +import { ParseError } from './errors' +import { type SafeParseResult } from './types' /** * Parses a string which is expected to contain a structured JSON value. diff --git a/src/schema.ts b/src/schema.ts index 6f85080..a72f22f 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,9 +1,9 @@ import type { z } from 'zod' -import type * as types from './types.js' -import { safeParseStructuredOutput } from './parse-structured-output.js' -import { stringifyForModel } from './utils.js' -import { zodToJsonSchema } from './zod-to-json-schema.js' +import type * as types from './types' +import { safeParseStructuredOutput } from './parse-structured-output' +import { stringifyForModel } from './utils' +import { zodToJsonSchema } from './zod-to-json-schema' /** * Used to mark schemas so we can support both Zod and custom schemas. diff --git a/src/sdks/ai-sdk.ts b/src/sdks/ai-sdk.ts index 7edaa5f..c9f381f 100644 --- a/src/sdks/ai-sdk.ts +++ b/src/sdks/ai-sdk.ts @@ -1,7 +1,7 @@ import { tool } from 'ai' -import type { AIFunctionLike } from '../types.js' -import { AIFunctionSet } from '../ai-function-set.js' +import type { AIFunctionLike } from '../types' +import { AIFunctionSet } from '../ai-function-set' /** * Converts a set of Agentic stdlib AI functions to an object compatible with diff --git a/src/sdks/dexter.ts b/src/sdks/dexter.ts index 8e8df06..fd6e1ae 100644 --- a/src/sdks/dexter.ts +++ b/src/sdks/dexter.ts @@ -1,7 +1,7 @@ import { createAIFunction } from '@dexaai/dexter' -import type { AIFunctionLike } from '../types.js' -import { AIFunctionSet } from '../ai-function-set.js' +import type { AIFunctionLike } from '../types' +import { AIFunctionSet } from '../ai-function-set' /** * Converts a set of Agentic stdlib AI functions to an array of Dexter- diff --git a/src/sdks/genkit.ts b/src/sdks/genkit.ts index a9c454b..871cad2 100644 --- a/src/sdks/genkit.ts +++ b/src/sdks/genkit.ts @@ -1,8 +1,8 @@ import { defineTool } from '@genkit-ai/ai' import { z } from 'zod' -import type { AIFunctionLike } from '../types.js' -import { AIFunctionSet } from '../ai-function-set.js' +import type { AIFunctionLike } from '../types' +import { AIFunctionSet } from '../ai-function-set' /** * Converts a set of Agentic stdlib AI functions to an array of Genkit- diff --git a/src/sdks/langchain.ts b/src/sdks/langchain.ts index f1b0cf4..22c1079 100644 --- a/src/sdks/langchain.ts +++ b/src/sdks/langchain.ts @@ -1,8 +1,8 @@ import { DynamicStructuredTool } from '@langchain/core/tools' -import type { AIFunctionLike } from '../types.js' -import { AIFunctionSet } from '../ai-function-set.js' -import { stringifyForModel } from '../utils.js' +import type { AIFunctionLike } from '../types' +import { AIFunctionSet } from '../ai-function-set' +import { stringifyForModel } from '../utils' /** * Converts a set of Agentic stdlib AI functions to an array of LangChain- diff --git a/src/sdks/llamaindex.ts b/src/sdks/llamaindex.ts index 82c8a38..056c76d 100644 --- a/src/sdks/llamaindex.ts +++ b/src/sdks/llamaindex.ts @@ -1,7 +1,7 @@ import { FunctionTool } from 'llamaindex' -import type { AIFunctionLike } from '../types.js' -import { AIFunctionSet } from '../ai-function-set.js' +import type { AIFunctionLike } from '../types' +import { AIFunctionSet } from '../ai-function-set' /** * Converts a set of Agentic stdlib AI functions to an array of LlamaIndex- diff --git a/src/services/bing-client.ts b/src/services/bing-client.ts index e48c370..32c5f2f 100644 --- a/src/services/bing-client.ts +++ b/src/services/bing-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, omit } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, omit } from '../utils' export namespace bing { export const API_BASE_URL = 'https://api.bing.microsoft.com' diff --git a/src/services/clearbit-client.ts b/src/services/clearbit-client.ts index f94b660..be306d8 100644 --- a/src/services/clearbit-client.ts +++ b/src/services/clearbit-client.ts @@ -1,7 +1,7 @@ import defaultKy from 'ky' import pThrottle from 'p-throttle' -import type { KyInstance } from '../types.js' +import type { KyInstance } from '../types' import { assert, delay, @@ -9,7 +9,7 @@ import { pruneNullOrUndefinedDeep, sanitizeSearchParams, throttleKy -} from '../utils.js' +} from '../utils' export namespace clearbit { // Allow up to 600 requests per minute by default. diff --git a/src/services/dexa-client.ts b/src/services/dexa-client.ts index 62f8955..3bef4fa 100644 --- a/src/services/dexa-client.ts +++ b/src/services/dexa-client.ts @@ -1,9 +1,9 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { Msg } from '../message.js' -import { assert, getEnv } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { Msg } from '../message' +import { assert, getEnv } from '../utils' export namespace dexa { export const AskDexaOptionsSchema = z.object({ diff --git a/src/services/diffbot-client.ts b/src/services/diffbot-client.ts index 720669a..5f1cd53 100644 --- a/src/services/diffbot-client.ts +++ b/src/services/diffbot-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils' export namespace diffbot { export const API_BASE_URL = 'https://api.diffbot.com' diff --git a/src/services/exa-client.ts b/src/services/exa-client.ts index 58d3a0b..8c8b3a4 100644 --- a/src/services/exa-client.ts +++ b/src/services/exa-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, pruneUndefined } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, pruneUndefined } from '../utils' export namespace exa { export const TextContentsOptionsSchema = z.object({ diff --git a/src/services/firecrawl-client.ts b/src/services/firecrawl-client.ts index ed13b09..85adb49 100644 --- a/src/services/firecrawl-client.ts +++ b/src/services/firecrawl-client.ts @@ -2,10 +2,10 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import z from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { isZodSchema } from '../schema.js' -import { assert, delay, getEnv, throttleKy } from '../utils.js' -import { zodToJsonSchema } from '../zod-to-json-schema.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { isZodSchema } from '../schema' +import { assert, delay, getEnv, throttleKy } from '../utils' +import { zodToJsonSchema } from '../zod-to-json-schema' export namespace firecrawl { export const BASE_URL = 'https://api.firecrawl.dev' diff --git a/src/services/github-client.ts b/src/services/github-client.ts index 8dd0e6b..b9b7072 100644 --- a/src/services/github-client.ts +++ b/src/services/github-client.ts @@ -1,7 +1,7 @@ import { Octokit } from 'octokit' -import { AIFunctionsProvider } from '../fns.js' -import { assert, getEnv } from '../utils.js' +import { AIFunctionsProvider } from '../fns' +import { assert, getEnv } from '../utils' export namespace github { export interface User { diff --git a/src/services/hacker-news-client.ts b/src/services/hacker-news-client.ts index b80a1a5..33433c4 100644 --- a/src/services/hacker-news-client.ts +++ b/src/services/hacker-news-client.ts @@ -1,7 +1,7 @@ import defaultKy, { type KyInstance } from 'ky' -import { AIFunctionsProvider } from '../fns.js' -import { assert, getEnv } from '../utils.js' +import { AIFunctionsProvider } from '../fns' +import { assert, getEnv } from '../utils' export namespace hackernews { export type ItemType = diff --git a/src/services/hunter-client.ts b/src/services/hunter-client.ts index fcb74c4..47ae737 100644 --- a/src/services/hunter-client.ts +++ b/src/services/hunter-client.ts @@ -1,13 +1,13 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' +import { aiFunction, AIFunctionsProvider } from '../fns' import { assert, getEnv, pruneNullOrUndefinedDeep, sanitizeSearchParams -} from '../utils.js' +} from '../utils' export namespace hunter { export const API_BASE_URL = 'https://api.hunter.io' diff --git a/src/services/index.ts b/src/services/index.ts index 133ac38..30dc4c4 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,28 +1,28 @@ -export * from './bing-client.js' -export * from './clearbit-client.js' -export * from './dexa-client.js' -export * from './diffbot-client.js' -export * from './exa-client.js' -export * from './firecrawl-client.js' -export * from './github-client.js' -export * from './hacker-news-client.js' -export * from './hunter-client.js' -export * from './jina-client.js' -export * from './midjourney-client.js' -export * from './novu-client.js' -export * from './people-data-labs-client.js' -export * from './perigon-client.js' -export * from './polygon-client.js' -export * from './predict-leads-client.js' -export * from './proxycurl-client.js' -export * from './scraper-client.js' -export * from './searxng-client.js' -export * from './serpapi-client.js' -export * from './serper-client.js' -export * from './slack-client.js' -export * from './social-data-client.js' -export * from './tavily-client.js' -export * from './twilio-client.js' -export * from './weather-client.js' -export * from './wikipedia-client.js' -export * from './wolfram-alpha-client.js' +export * from './bing-client' +export * from './clearbit-client' +export * from './dexa-client' +export * from './diffbot-client' +export * from './exa-client' +export * from './firecrawl-client' +export * from './github-client' +export * from './hacker-news-client' +export * from './hunter-client' +export * from './jina-client' +export * from './midjourney-client' +export * from './novu-client' +export * from './people-data-labs-client' +export * from './perigon-client' +export * from './polygon-client' +export * from './predict-leads-client' +export * from './proxycurl-client' +export * from './scraper-client' +export * from './searxng-client' +export * from './serpapi-client' +export * from './serper-client' +export * from './slack-client' +export * from './social-data-client' +export * from './tavily-client' +export * from './twilio-client' +export * from './weather-client' +export * from './wikipedia-client' +export * from './wolfram-alpha-client' diff --git a/src/services/jina-client.ts b/src/services/jina-client.ts index 507f3de..bdf20af 100644 --- a/src/services/jina-client.ts +++ b/src/services/jina-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { getEnv, pruneNullOrUndefined, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { getEnv, pruneNullOrUndefined, throttleKy } from '../utils' export namespace jina { export const ReaderFormatSchema = z.enum([ diff --git a/src/services/midjourney-client.ts b/src/services/midjourney-client.ts index 6fad242..f090cf2 100644 --- a/src/services/midjourney-client.ts +++ b/src/services/midjourney-client.ts @@ -1,9 +1,9 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { TimeoutError } from '../errors.js' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, delay, getEnv, pruneNullOrUndefined } from '../utils.js' +import { TimeoutError } from '../errors' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, delay, getEnv, pruneNullOrUndefined } from '../utils' // TODO: add additional methods for upscaling, variations, etc. diff --git a/src/services/novu-client.ts b/src/services/novu-client.ts index 5cbbe4d..ba53a6b 100644 --- a/src/services/novu-client.ts +++ b/src/services/novu-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv } from '../utils' export namespace novu { export const API_BASE_URL = 'https://api.novu.co/v1' diff --git a/src/services/people-data-labs-client.ts b/src/services/people-data-labs-client.ts index 80093b8..102d1c6 100644 --- a/src/services/people-data-labs-client.ts +++ b/src/services/people-data-labs-client.ts @@ -1,7 +1,7 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' -import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js' +import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils' /** * TODO: I'm holding off on converting this client to an `AIFunctionsProvider` diff --git a/src/services/perigon-client.ts b/src/services/perigon-client.ts index 5822be0..fc7f80d 100644 --- a/src/services/perigon-client.ts +++ b/src/services/perigon-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils' // TODO: https://docs.goperigon.com/docs/searching-sources // TODO: https://docs.goperigon.com/docs/journalist-data diff --git a/src/services/polygon-client.ts b/src/services/polygon-client.ts index 5a934a5..7f2f744 100644 --- a/src/services/polygon-client.ts +++ b/src/services/polygon-client.ts @@ -1,7 +1,7 @@ import defaultKy, { type KyInstance } from 'ky' -import { AIFunctionsProvider } from '../fns.js' -import { assert, getEnv } from '../utils.js' +import { AIFunctionsProvider } from '../fns' +import { assert, getEnv } from '../utils' // TODO: add aiFunction decorator to select methods diff --git a/src/services/predict-leads-client.ts b/src/services/predict-leads-client.ts index b3b2fd3..b09023d 100644 --- a/src/services/predict-leads-client.ts +++ b/src/services/predict-leads-client.ts @@ -2,15 +2,15 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import type { DeepNullable } from '../types.js' -import { aiFunction, AIFunctionsProvider } from '../fns.js' +import type { DeepNullable } from '../types' +import { aiFunction, AIFunctionsProvider } from '../fns' import { assert, getEnv, pruneUndefined, sanitizeSearchParams, throttleKy -} from '../utils.js' +} from '../utils' // TODO: improve `domain` validation for fast-fail diff --git a/src/services/proxycurl-client.ts b/src/services/proxycurl-client.ts index 4c88e85..82d08ac 100644 --- a/src/services/proxycurl-client.ts +++ b/src/services/proxycurl-client.ts @@ -3,8 +3,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils' // All proxycurl types are auto-generated from their openapi spec export namespace proxycurl { diff --git a/src/services/scraper-client.ts b/src/services/scraper-client.ts index 2bc7453..f284611 100644 --- a/src/services/scraper-client.ts +++ b/src/services/scraper-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, omit, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, omit, throttleKy } from '../utils' export namespace scraper { // Allow up to 1 request per second by default. diff --git a/src/services/searxng-client.ts b/src/services/searxng-client.ts index 6971781..3904206 100644 --- a/src/services/searxng-client.ts +++ b/src/services/searxng-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, omit, pick, pruneUndefined } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, omit, pick, pruneUndefined } from '../utils' export namespace searxng { export const SearchCategorySchema = z.enum([ diff --git a/src/services/serpapi-client.ts b/src/services/serpapi-client.ts index 19af9da..e5940e4 100644 --- a/src/services/serpapi-client.ts +++ b/src/services/serpapi-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv } from '../utils' /** * All types have been exported from the `serpapi` package, which we're diff --git a/src/services/serper-client.ts b/src/services/serper-client.ts index f7e6d12..e49cd8f 100644 --- a/src/services/serper-client.ts +++ b/src/services/serper-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, omit } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, omit } from '../utils' export namespace serper { export const API_BASE_URL = 'https://google.serper.dev' diff --git a/src/services/slack-client.ts b/src/services/slack-client.ts index fcf6384..708e4d0 100644 --- a/src/services/slack-client.ts +++ b/src/services/slack-client.ts @@ -1,9 +1,9 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { TimeoutError } from '../errors.js' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, delay, getEnv } from '../utils.js' +import { TimeoutError } from '../errors' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, delay, getEnv } from '../utils' // TODO: need to expose more aiFunctions diff --git a/src/services/social-data-client.ts b/src/services/social-data-client.ts index eb421c4..89fc49e 100644 --- a/src/services/social-data-client.ts +++ b/src/services/social-data-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' -import { AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js' +import { AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils' // TODO: need to add `aiFunction` wrappers for each method diff --git a/src/services/tavily-client.ts b/src/services/tavily-client.ts index f762417..2ed1b5c 100644 --- a/src/services/tavily-client.ts +++ b/src/services/tavily-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, pruneNullOrUndefined, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, pruneNullOrUndefined, throttleKy } from '../utils' export namespace tavily { export const API_BASE_URL = 'https://api.tavily.com' diff --git a/src/services/twilio-client.ts b/src/services/twilio-client.ts index b8b618c..6c2e950 100644 --- a/src/services/twilio-client.ts +++ b/src/services/twilio-client.ts @@ -1,9 +1,9 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { TimeoutError } from '../errors.js' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, delay, getEnv } from '../utils.js' +import { TimeoutError } from '../errors' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, delay, getEnv } from '../utils' export namespace twilio { export const CONVERSATION_API_BASE_URL = 'https://conversations.twilio.com/v1' diff --git a/src/services/twitter/client.ts b/src/services/twitter/client.ts index 0d4a807..bc5b637 100644 --- a/src/services/twitter/client.ts +++ b/src/services/twitter/client.ts @@ -1,7 +1,7 @@ import { auth, Client as TwitterV2Client } from 'twitter-api-sdk' -import { assert, getEnv } from '../../utils.js' -import { getNango, validateNangoConnectionOAuthScopes } from './nango.js' +import { assert, getEnv } from '../../utils' +import { getNango, validateNangoConnectionOAuthScopes } from './nango' // Auth new Nango accounts here: https://app.nango.dev/connections diff --git a/src/services/twitter/index.ts b/src/services/twitter/index.ts index 3dbe3c1..0ce6058 100644 --- a/src/services/twitter/index.ts +++ b/src/services/twitter/index.ts @@ -1,6 +1,6 @@ -export * from './client.js' -export * from './error.js' -export * from './nango.js' -export * from './twitter-client.js' -export type * from './types.js' -export * from './utils.js' +export * from './client' +export * from './error' +export * from './nango' +export * from './twitter-client' +export type * from './types' +export * from './utils' diff --git a/src/services/twitter/nango.ts b/src/services/twitter/nango.ts index 91e519f..da2db95 100644 --- a/src/services/twitter/nango.ts +++ b/src/services/twitter/nango.ts @@ -1,6 +1,6 @@ import { type Connection, Nango } from '@nangohq/node' -import { getEnv } from '../../utils.js' +import { getEnv } from '../../utils' // This is intentionally left as a global singleton to avoid re-creating the // Nango connection instance on successive calls in serverless environments. diff --git a/src/services/twitter/twitter-client.ts b/src/services/twitter/twitter-client.ts index 8c7ac9d..ecf0355 100644 --- a/src/services/twitter/twitter-client.ts +++ b/src/services/twitter/twitter-client.ts @@ -1,10 +1,10 @@ import pThrottle from 'p-throttle' import { z } from 'zod' -import type * as types from './types.js' -import { aiFunction, AIFunctionsProvider } from '../../fns.js' -import { assert, getEnv } from '../../utils.js' -import { handleKnownTwitterErrors } from './utils.js' +import type * as types from './types' +import { aiFunction, AIFunctionsProvider } from '../../fns' +import { assert, getEnv } from '../../utils' +import { handleKnownTwitterErrors } from './utils' /** * This file contains rate-limited wrappers around all of the core Twitter API diff --git a/src/services/twitter/utils.ts b/src/services/twitter/utils.ts index a4a97dd..59c01d3 100644 --- a/src/services/twitter/utils.ts +++ b/src/services/twitter/utils.ts @@ -1,6 +1,6 @@ -import type * as types from './types.js' -import { omit } from '../../utils.js' -import { TwitterError } from './error.js' +import type * as types from './types' +import { omit } from '../../utils' +import { TwitterError } from './error' /** * Error handler which takes in an unknown Error object and converts it to a diff --git a/src/services/weather-client.ts b/src/services/weather-client.ts index 1a8ca8a..3655c08 100644 --- a/src/services/weather-client.ts +++ b/src/services/weather-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams } from '../utils' export namespace weatherapi { export const BASE_URL = 'https://api.weatherapi.com/v1' diff --git a/src/services/wikipedia-client.ts b/src/services/wikipedia-client.ts index 7548d8e..5ec5717 100644 --- a/src/services/wikipedia-client.ts +++ b/src/services/wikipedia-client.ts @@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky' import pThrottle from 'p-throttle' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, throttleKy } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, throttleKy } from '../utils' export namespace wikipedia { // Allow up to 200 requests per second by default. diff --git a/src/services/wolfram-alpha-client.ts b/src/services/wolfram-alpha-client.ts index a5cdb85..3b4a61d 100644 --- a/src/services/wolfram-alpha-client.ts +++ b/src/services/wolfram-alpha-client.ts @@ -1,8 +1,8 @@ import defaultKy, { type KyInstance } from 'ky' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { assert, getEnv, sanitizeSearchParams } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { assert, getEnv, sanitizeSearchParams } from '../utils' export namespace wolframalpha { export const API_BASE_URL = 'https://www.wolframalpha.com/api/' diff --git a/src/tools/calculator.ts b/src/tools/calculator.ts index e967921..f39cc1d 100644 --- a/src/tools/calculator.ts +++ b/src/tools/calculator.ts @@ -1,7 +1,7 @@ import { evaluate } from 'mathjs' import { z } from 'zod' -import { createAIFunction } from '../create-ai-function.js' +import { createAIFunction } from '../create-ai-function' // TODO: ensure `expr` is sanitized to not run arbitrary code diff --git a/src/tools/e2b.ts b/src/tools/e2b.ts index f4a20a1..cd60b7b 100644 --- a/src/tools/e2b.ts +++ b/src/tools/e2b.ts @@ -1,8 +1,8 @@ import { CodeInterpreter, type ProcessMessage } from '@e2b/code-interpreter' import { z } from 'zod' -import { createAIFunction } from '../create-ai-function.js' -import { getEnv } from '../utils.js' +import { createAIFunction } from '../create-ai-function' +import { getEnv } from '../utils' /** * E2B Python code interpreter sandbox. diff --git a/src/tools/search-and-crawl.ts b/src/tools/search-and-crawl.ts index db5866a..7d6f17d 100644 --- a/src/tools/search-and-crawl.ts +++ b/src/tools/search-and-crawl.ts @@ -1,11 +1,11 @@ import pMap from 'p-map' import { z } from 'zod' -import { aiFunction, AIFunctionsProvider } from '../fns.js' -import { type diffbot, DiffbotClient } from '../services/diffbot-client.js' -import { SerpAPIClient } from '../services/serpapi-client.js' -import { isValidCrawlableUrl, normalizeUrl } from '../url-utils.js' -import { omit, pick } from '../utils.js' +import { aiFunction, AIFunctionsProvider } from '../fns' +import { type diffbot, DiffbotClient } from '../services/diffbot-client' +import { SerpAPIClient } from '../services/serpapi-client' +import { isValidCrawlableUrl, normalizeUrl } from '../url-utils' +import { omit, pick } from '../utils' // TODO: allow `search` tool to support other search clients // (e.g. Bing, Exa, Searxng, Serper, Tavily) diff --git a/src/types.ts b/src/types.ts index f865667..9bd12b0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,12 +1,12 @@ import type { Jsonifiable, SetOptional, Simplify } from 'type-fest' import type { z } from 'zod' -import type { AIFunctionSet } from './ai-function-set.js' -import type { AIFunctionsProvider } from './fns.js' -import type { Msg } from './message.js' +import type { AIFunctionSet } from './ai-function-set' +import type { AIFunctionsProvider } from './fns' +import type { Msg } from './message' -export type { Msg } from './message.js' -export type { Schema } from './schema.js' +export type { Msg } from './message' +export type { Schema } from './schema' export type { KyInstance } from 'ky' export type { ThrottledFunction } from 'p-throttle' export type { SetRequired, Simplify } from 'type-fest' diff --git a/src/url-utils.test.ts b/src/url-utils.test.ts index 061acc7..79bf167 100644 --- a/src/url-utils.test.ts +++ b/src/url-utils.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest' -import { normalizeUrl } from './url-utils.js' +import { normalizeUrl } from './url-utils' describe('normalizeUrl', () => { test('valid urls', async () => { diff --git a/src/url-utils.ts b/src/url-utils.ts index b11f5d2..1a2b0bd 100644 --- a/src/url-utils.ts +++ b/src/url-utils.ts @@ -4,7 +4,7 @@ import normalizeUrlImpl, { } from 'normalize-url' import QuickLRU from 'quick-lru' -import { hashObject } from './utils.js' +import { hashObject } from './utils' const protocolAllowList = new Set(['https:', 'http:']) const normalizedUrlCache = new QuickLRU({ diff --git a/src/utils.test.ts b/src/utils.test.ts index 774bbbc..d3c45c7 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -2,14 +2,14 @@ import ky from 'ky' import pThrottle from 'p-throttle' import { describe, expect, test } from 'vitest' -import { mockKyInstance } from './_utils.js' +import { mockKyInstance } from './_utils' import { omit, pick, sanitizeSearchParams, stringifyForModel, throttleKy -} from './utils.js' +} from './utils' test('pick', () => { expect(pick({ a: 1, b: 2, c: 3 }, 'a', 'c')).toEqual({ a: 1, c: 3 }) diff --git a/src/utils.ts b/src/utils.ts index c615cc9..0e4601e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,9 @@ import dedent from 'dedent' import hashObjectImpl, { type Options as HashObjectOptions } from 'hash-object' -import type * as types from './types.js' +import type * as types from './types' -export { assert } from './assert.js' +export { assert } from './assert' export { default as delay } from 'delay' /** diff --git a/src/zod-to-json-schema.test.ts b/src/zod-to-json-schema.test.ts index 24f8c2f..662e368 100644 --- a/src/zod-to-json-schema.test.ts +++ b/src/zod-to-json-schema.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { z } from 'zod' -import { zodToJsonSchema } from './zod-to-json-schema.js' +import { zodToJsonSchema } from './zod-to-json-schema' describe('zodToJsonSchema', () => { it('handles basic objects', () => { diff --git a/src/zod-to-json-schema.ts b/src/zod-to-json-schema.ts index 93298a2..b2ad680 100644 --- a/src/zod-to-json-schema.ts +++ b/src/zod-to-json-schema.ts @@ -1,8 +1,8 @@ import type { z } from 'zod' import { zodToJsonSchema as zodToJsonSchemaImpl } from 'zod-to-json-schema' -import type * as types from './types.js' -import { omit } from './utils.js' +import type * as types from './types' +import { omit } from './utils' /** Generate a JSON Schema from a Zod schema. */ export function zodToJsonSchema(schema: z.ZodType): types.JSONSchema { diff --git a/tsconfig.json b/tsconfig.json index 4f2456e..36549d9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,31 @@ { "compilerOptions": { - "target": "ES2020", - "lib": ["ESNext"], - "esModuleInterop": true, - "skipLibCheck": true, - "verbatimModuleSyntax": true, - "allowJs": true, - "resolveJsonModule": true, + "lib": ["esnext", "dom.iterable"], + "module": "esnext", + "moduleResolution": "bundler", "moduleDetection": "force", + "noEmit": true, + "target": "es2020", + "outDir": "dist", + + "allowImportingTsExtensions": false, + "allowJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "incremental": false, "isolatedModules": true, - "useDefineForClassFields": true, "jsx": "preserve", + "noUncheckedIndexedAccess": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "useDefineForClassFields": true, + "verbatimModuleSyntax": true // NOTE: these are deprecated // "experimentalDecorators": true, // "emitDecoratorMetadata": true, - - "strict": true, - "noUncheckedIndexedAccess": true, - "forceConsistentCasingInFileNames": true, - - "module": "NodeNext", - "moduleResolution": "NodeNext", - "outDir": "dist", - "sourceMap": true }, "include": ["src"] }