@auto-engineer/ai-gateway 0.13.3 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +148 -291
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +3 -3
- package/dist/src/config.js.map +1 -1
- package/dist/src/config.specs.js +1 -1
- package/dist/src/config.specs.js.map +1 -1
- package/dist/src/core/context.d.ts +1 -1
- package/dist/src/core/context.d.ts.map +1 -1
- package/dist/src/core/context.js +2 -2
- package/dist/src/core/context.js.map +1 -1
- package/dist/src/core/generators.d.ts +1 -1
- package/dist/src/core/generators.d.ts.map +1 -1
- package/dist/src/core/generators.js +2 -2
- package/dist/src/core/generators.js.map +1 -1
- package/dist/src/core/index.d.ts +5 -5
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +4 -4
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/providers/custom.d.ts +1 -1
- package/dist/src/core/providers/custom.d.ts.map +1 -1
- package/dist/src/core/types.d.ts +1 -1
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils/errors.d.ts +1 -1
- package/dist/src/core/utils/errors.d.ts.map +1 -1
- package/dist/src/core/utils/log.js +1 -1
- package/dist/src/core/utils/log.js.map +1 -1
- package/dist/src/core/utils/validation.d.ts +1 -1
- package/dist/src/core/utils/validation.d.ts.map +1 -1
- package/dist/src/example-use.js +2 -2
- package/dist/src/example-use.js.map +1 -1
- package/dist/src/index-custom.specs.js +2 -2
- package/dist/src/index-custom.specs.js.map +1 -1
- package/dist/src/index.specs.js +2 -2
- package/dist/src/index.specs.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +1 -1
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/node/config.d.ts +1 -1
- package/dist/src/node/config.d.ts.map +1 -1
- package/dist/src/node/config.js +2 -2
- package/dist/src/node/config.js.map +1 -1
- package/dist/src/node/index.d.ts +6 -6
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/node/index.js +5 -5
- package/dist/src/node/index.js.map +1 -1
- package/dist/src/node/mcp-server.d.ts.map +1 -1
- package/dist/src/node/mcp-server.js +1 -1
- package/dist/src/node/mcp-server.js.map +1 -1
- package/dist/src/node/wrappers.d.ts +1 -1
- package/dist/src/node/wrappers.d.ts.map +1 -1
- package/dist/src/node/wrappers.js +3 -3
- package/dist/src/node/wrappers.js.map +1 -1
- package/dist/src/providers/custom.d.ts +1 -1
- package/dist/src/providers/custom.d.ts.map +1 -1
- package/dist/src/providers/custom.js.map +1 -1
- package/dist/src/providers/custom.specs.js +1 -1
- package/dist/src/providers/custom.specs.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -5
- package/src/config.specs.ts +1 -1
- package/src/config.ts +4 -4
- package/src/core/context.ts +3 -3
- package/src/core/generators.ts +8 -8
- package/src/core/index.ts +16 -21
- package/src/core/providers/custom.ts +1 -1
- package/src/core/types.ts +1 -1
- package/src/core/utils/errors.ts +1 -1
- package/src/core/utils/log.ts +1 -1
- package/src/core/utils/validation.ts +1 -1
- package/src/example-use.ts +2 -2
- package/src/index-custom.specs.ts +2 -2
- package/src/index.specs.ts +3 -3
- package/src/mcp-server.ts +1 -1
- package/src/node/config.ts +3 -3
- package/src/node/index.ts +36 -43
- package/src/node/mcp-server.ts +1 -1
- package/src/node/wrappers.ts +12 -6
- package/src/providers/custom.specs.ts +2 -2
- package/src/providers/custom.ts +1 -1
package/package.json
CHANGED
|
@@ -33,15 +33,11 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"version": "0.
|
|
36
|
+
"version": "0.15.0",
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
|
|
39
39
|
"test": "vitest run --reporter=dot",
|
|
40
|
-
"lint": "eslint 'src/**/*.ts' --max-warnings 0 --config ../../eslint.config.ts",
|
|
41
|
-
"lint:fix": "eslint 'src/**/*.ts' --fix --config ../../eslint.config.ts",
|
|
42
40
|
"type-check": "tsc --noEmit",
|
|
43
|
-
"format": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
44
|
-
"format:fix": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
45
41
|
"link:dev": "pnpm build && pnpm link --global",
|
|
46
42
|
"unlink:dev": "pnpm unlink --global"
|
|
47
43
|
}
|
package/src/config.specs.ts
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { dirname, resolve } from 'path';
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
4
3
|
import createDebug from 'debug';
|
|
5
|
-
import
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
import type { CustomProviderConfig } from './constants';
|
|
6
6
|
|
|
7
7
|
const debug = createDebug('auto:ai-gateway:config');
|
|
8
8
|
const debugEnv = createDebug('auto:ai-gateway:config:env');
|
package/src/core/context.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createOpenAI } from '@ai-sdk/openai';
|
|
2
1
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
3
2
|
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
4
|
-
import {
|
|
3
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
5
4
|
import type { LanguageModelV2 } from '@ai-sdk/provider';
|
|
6
|
-
import {
|
|
5
|
+
import { createXai } from '@ai-sdk/xai';
|
|
7
6
|
import { DEFAULT_MODELS } from './constants';
|
|
8
7
|
import { createCustomProvider } from './providers/custom';
|
|
8
|
+
import { type AIConfig, type AIContext, AIProvider } from './types';
|
|
9
9
|
import { makeLogger } from './utils/log';
|
|
10
10
|
|
|
11
11
|
const debugConfig = makeLogger('auto:ai-gateway:config');
|
package/src/core/generators.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { generateText as aiGenerateText, streamText as aiStreamText, generateObject, streamObject } from 'ai';
|
|
2
|
+
import { getDefaultModel, getDefaultProvider, getModel } from './context';
|
|
2
3
|
import {
|
|
3
|
-
AIContext,
|
|
4
|
-
AIOptions,
|
|
5
|
-
StructuredAIOptions,
|
|
6
|
-
StreamStructuredAIOptions,
|
|
4
|
+
type AIContext,
|
|
5
|
+
type AIOptions,
|
|
7
6
|
AIProvider,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type AIToolValidationError,
|
|
8
|
+
type RegisteredToolForAI,
|
|
9
|
+
type StreamStructuredAIOptions,
|
|
10
|
+
type StructuredAIOptions,
|
|
10
11
|
} from './types';
|
|
11
|
-
import { getModel, getDefaultProvider, getDefaultModel } from './context';
|
|
12
12
|
import { extractAndLogError } from './utils/errors';
|
|
13
|
-
import { getEnhancedPrompt, handleFailedRequest } from './utils/validation';
|
|
14
13
|
import { makeLogger } from './utils/log';
|
|
14
|
+
import { getEnhancedPrompt, handleFailedRequest } from './utils/validation';
|
|
15
15
|
|
|
16
16
|
const debugAPI = makeLogger('auto:ai-gateway:api');
|
|
17
17
|
const debugStream = makeLogger('auto:ai-gateway:stream');
|
package/src/core/index.ts
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
CustomProviderConfig,
|
|
4
|
-
AIConfig,
|
|
5
|
-
AIContext,
|
|
6
|
-
AIOptions,
|
|
7
|
-
StructuredAIOptions,
|
|
8
|
-
StreamStructuredAIOptions,
|
|
9
|
-
AIToolValidationError,
|
|
10
|
-
RegisteredToolForAI,
|
|
11
|
-
} from './types';
|
|
12
|
-
|
|
1
|
+
export { z } from 'zod';
|
|
13
2
|
export { DEFAULT_MODELS } from './constants';
|
|
14
|
-
|
|
15
|
-
export { createAIContext, getAvailableProviders, getDefaultProvider, getDefaultModel, getModel } from './context';
|
|
16
|
-
|
|
3
|
+
export { createAIContext, getAvailableProviders, getDefaultModel, getDefaultProvider, getModel } from './context';
|
|
17
4
|
export {
|
|
5
|
+
generateStructuredData,
|
|
18
6
|
generateText,
|
|
19
|
-
streamText,
|
|
20
7
|
generateTextStreaming,
|
|
21
8
|
generateTextWithImage,
|
|
22
|
-
generateStructuredData,
|
|
23
|
-
streamStructuredData,
|
|
24
9
|
generateTextWithTools,
|
|
10
|
+
streamStructuredData,
|
|
11
|
+
streamText,
|
|
25
12
|
} from './generators';
|
|
26
|
-
|
|
27
13
|
export { createCustomProvider } from './providers/custom';
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
export type {
|
|
15
|
+
AIConfig,
|
|
16
|
+
AIContext,
|
|
17
|
+
AIOptions,
|
|
18
|
+
AIToolValidationError,
|
|
19
|
+
CustomProviderConfig,
|
|
20
|
+
RegisteredToolForAI,
|
|
21
|
+
StreamStructuredAIOptions,
|
|
22
|
+
StructuredAIOptions,
|
|
23
|
+
} from './types';
|
|
24
|
+
export { AIProvider } from './types';
|
package/src/core/types.ts
CHANGED
package/src/core/utils/errors.ts
CHANGED
package/src/core/utils/log.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface NodeProcess {
|
|
|
9
9
|
versions?: ProcessVersions;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
let debugFactory: DebugFactory | null | undefined
|
|
12
|
+
let debugFactory: DebugFactory | null | undefined;
|
|
13
13
|
let debugPromise: Promise<void> | null = null;
|
|
14
14
|
|
|
15
15
|
function isNodeEnvironment(): boolean {
|
package/src/example-use.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { registerTool, registerTools, startServer,
|
|
2
|
+
import { isServerStarted, registerTool, registerTools, startServer, type ToolHandler } from '.';
|
|
3
3
|
|
|
4
4
|
// Example 1: Simple tool with basic types
|
|
5
5
|
interface GreetingParams extends Record<string, unknown> {
|
|
@@ -133,7 +133,7 @@ registerTool<DateFormatterParams>(
|
|
|
133
133
|
async ({ date, format }) => {
|
|
134
134
|
const dateObj = new Date(date);
|
|
135
135
|
|
|
136
|
-
if (isNaN(dateObj.getTime())) {
|
|
136
|
+
if (Number.isNaN(dateObj.getTime())) {
|
|
137
137
|
return {
|
|
138
138
|
content: [
|
|
139
139
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { AIProvider } from './core/types';
|
|
3
|
-
import { getAvailableProviders,
|
|
3
|
+
import { getAvailableProviders, getDefaultAIProvider, getDefaultModel, resetGlobalContext } from './index';
|
|
4
4
|
|
|
5
5
|
// Mock the config module
|
|
6
6
|
vi.mock('./node/config', () => ({
|
package/src/index.specs.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAvailableProviders, getDefaultAIProvider, getDefaultModel, resetGlobalContext } from './index';
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
2
|
import { DEFAULT_MODELS } from './core/constants';
|
|
4
|
-
import { AIProvider } from './core/types';
|
|
5
3
|
import type { AIConfig } from './core/types';
|
|
4
|
+
import { AIProvider } from './core/types';
|
|
5
|
+
import { getAvailableProviders, getDefaultAIProvider, getDefaultModel, resetGlobalContext } from './index';
|
|
6
6
|
|
|
7
7
|
// Mock the config module
|
|
8
8
|
vi.mock('./node/config', () => ({
|
package/src/mcp-server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
3
|
import createDebug from 'debug';
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
const debug = createDebug('auto:ai-gateway:mcp');
|
|
7
7
|
const debugServer = createDebug('auto:ai-gateway:mcp:server');
|
package/src/node/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { resolve } from 'path';
|
|
1
|
+
import { resolve } from 'node:path';
|
|
3
2
|
import createDebug from 'debug';
|
|
4
|
-
import
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import type { AIConfig, CustomProviderConfig } from '../core/types';
|
|
5
5
|
|
|
6
6
|
const debug = createDebug('auto:ai-gateway:config');
|
|
7
7
|
const debugEnv = createDebug('auto:ai-gateway:config:env');
|
package/src/node/index.ts
CHANGED
|
@@ -1,60 +1,53 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
CustomProviderConfig,
|
|
4
|
-
AIConfig,
|
|
5
|
-
AIContext,
|
|
6
|
-
AIOptions,
|
|
7
|
-
StructuredAIOptions,
|
|
8
|
-
StreamStructuredAIOptions,
|
|
9
|
-
AIToolValidationError,
|
|
10
|
-
RegisteredToolForAI,
|
|
11
|
-
} from '../core/types';
|
|
12
|
-
|
|
1
|
+
export { z } from 'zod';
|
|
13
2
|
export { DEFAULT_MODELS } from '../core/constants';
|
|
14
|
-
|
|
15
3
|
export { createAIContext, getModel } from '../core/context';
|
|
16
|
-
|
|
17
4
|
export {
|
|
5
|
+
generateStructuredData,
|
|
18
6
|
generateText,
|
|
19
|
-
streamText,
|
|
20
7
|
generateTextStreaming,
|
|
21
8
|
generateTextWithImage,
|
|
22
|
-
generateStructuredData,
|
|
23
|
-
streamStructuredData,
|
|
24
9
|
generateTextWithTools,
|
|
10
|
+
streamStructuredData,
|
|
11
|
+
streamText,
|
|
25
12
|
} from '../core/generators';
|
|
26
|
-
|
|
27
13
|
export { createCustomProvider } from '../core/providers/custom';
|
|
28
|
-
|
|
14
|
+
export type {
|
|
15
|
+
AIConfig,
|
|
16
|
+
AIContext,
|
|
17
|
+
AIOptions,
|
|
18
|
+
AIToolValidationError,
|
|
19
|
+
CustomProviderConfig,
|
|
20
|
+
RegisteredToolForAI,
|
|
21
|
+
StreamStructuredAIOptions,
|
|
22
|
+
StructuredAIOptions,
|
|
23
|
+
} from '../core/types';
|
|
24
|
+
export { AIProvider } from '../core/types';
|
|
29
25
|
export { configureAIProvider } from './config';
|
|
30
26
|
|
|
31
27
|
export {
|
|
32
|
-
|
|
33
|
-
getDefaultModel,
|
|
34
|
-
getAvailableProviders,
|
|
35
|
-
generateTextWithAI,
|
|
36
|
-
streamTextWithAI,
|
|
37
|
-
generateTextStreamingWithAI,
|
|
38
|
-
generateTextWithImageAI,
|
|
39
|
-
generateStructuredDataWithAI,
|
|
40
|
-
streamStructuredDataWithAI,
|
|
41
|
-
generateTextWithToolsAI,
|
|
42
|
-
resetGlobalContext,
|
|
43
|
-
} from './wrappers';
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
server as mcpServer,
|
|
47
|
-
registerTool,
|
|
48
|
-
registerTools,
|
|
49
|
-
startServer,
|
|
50
|
-
isServerStarted,
|
|
28
|
+
executeRegisteredTool,
|
|
51
29
|
getRegisteredTools,
|
|
52
30
|
getRegisteredToolsForAI,
|
|
53
|
-
getToolHandler,
|
|
54
31
|
getSchemaByName,
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
getToolHandler,
|
|
33
|
+
isServerStarted,
|
|
57
34
|
type RegisteredTool,
|
|
35
|
+
registerTool,
|
|
36
|
+
registerTools,
|
|
37
|
+
server as mcpServer,
|
|
38
|
+
startServer,
|
|
39
|
+
type ToolHandler,
|
|
58
40
|
} from './mcp-server';
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
export {
|
|
42
|
+
generateStructuredDataWithAI,
|
|
43
|
+
generateTextStreamingWithAI,
|
|
44
|
+
generateTextWithAI,
|
|
45
|
+
generateTextWithImageAI,
|
|
46
|
+
generateTextWithToolsAI,
|
|
47
|
+
getAvailableProviders,
|
|
48
|
+
getDefaultAIProvider,
|
|
49
|
+
getDefaultModel,
|
|
50
|
+
resetGlobalContext,
|
|
51
|
+
streamStructuredDataWithAI,
|
|
52
|
+
streamTextWithAI,
|
|
53
|
+
} from './wrappers';
|
package/src/node/mcp-server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
3
|
import createDebug from 'debug';
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
const debug = createDebug('auto:ai-gateway:mcp');
|
|
7
7
|
const debugServer = createDebug('auto:ai-gateway:mcp:server');
|
package/src/node/wrappers.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { AIContext, AIOptions, StructuredAIOptions, StreamStructuredAIOptions, AIProvider } from '../core/types';
|
|
2
1
|
import {
|
|
3
|
-
createAIContext,
|
|
4
|
-
getDefaultProvider as coreGetDefaultProvider,
|
|
5
2
|
getAvailableProviders as coreGetAvailableProviders,
|
|
6
3
|
getDefaultModel as coreGetDefaultModel,
|
|
4
|
+
getDefaultProvider as coreGetDefaultProvider,
|
|
5
|
+
createAIContext,
|
|
7
6
|
} from '../core/context';
|
|
8
7
|
import {
|
|
8
|
+
generateStructuredData as coreGenerateStructuredData,
|
|
9
9
|
generateText as coreGenerateText,
|
|
10
|
-
streamText as coreStreamText,
|
|
11
10
|
generateTextStreaming as coreGenerateTextStreaming,
|
|
12
11
|
generateTextWithImage as coreGenerateTextWithImage,
|
|
13
|
-
generateStructuredData as coreGenerateStructuredData,
|
|
14
|
-
streamStructuredData as coreStreamStructuredData,
|
|
15
12
|
generateTextWithTools as coreGenerateTextWithTools,
|
|
13
|
+
streamStructuredData as coreStreamStructuredData,
|
|
14
|
+
streamText as coreStreamText,
|
|
16
15
|
} from '../core/generators';
|
|
16
|
+
import {
|
|
17
|
+
type AIContext,
|
|
18
|
+
type AIOptions,
|
|
19
|
+
AIProvider,
|
|
20
|
+
type StreamStructuredAIOptions,
|
|
21
|
+
type StructuredAIOptions,
|
|
22
|
+
} from '../core/types';
|
|
17
23
|
import { configureAIProvider } from './config';
|
|
18
24
|
import { getRegisteredToolsForAI, startServer } from './mcp-server';
|
|
19
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { createCustomProvider } from '../core/providers/custom';
|
|
3
|
-
import { CustomProviderConfig } from '../core/types';
|
|
3
|
+
import type { CustomProviderConfig } from '../core/types';
|
|
4
4
|
|
|
5
5
|
interface MockConfig {
|
|
6
6
|
name: string;
|
package/src/providers/custom.ts
CHANGED