@openforge-ai/adapters 0.1.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/LICENSE +21 -0
- package/dist/index.cjs +118 -0
- package/dist/index.d.cts +80 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +88 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Forge AI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AnthropicAdapter: () => AnthropicAdapter,
|
|
24
|
+
GoogleAdapter: () => GoogleAdapter,
|
|
25
|
+
OllamaAdapter: () => OllamaAdapter,
|
|
26
|
+
OpenAIAdapter: () => OpenAIAdapter
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/anthropic.ts
|
|
31
|
+
var AnthropicAdapter = class {
|
|
32
|
+
apiKey;
|
|
33
|
+
baseUrl;
|
|
34
|
+
constructor(options = {}) {
|
|
35
|
+
this.apiKey = options.apiKey ?? process.env.ANTHROPIC_API_KEY ?? "";
|
|
36
|
+
this.baseUrl = options.baseUrl ?? "https://api.anthropic.com";
|
|
37
|
+
}
|
|
38
|
+
validateModel(model) {
|
|
39
|
+
return model.name.startsWith("claude-");
|
|
40
|
+
}
|
|
41
|
+
// TODO: Implement full deployment to Anthropic
|
|
42
|
+
async deploy(_model) {
|
|
43
|
+
if (!this.apiKey) {
|
|
44
|
+
return { success: false };
|
|
45
|
+
}
|
|
46
|
+
return { success: true, endpoint: this.baseUrl };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/google.ts
|
|
51
|
+
var GoogleAdapter = class {
|
|
52
|
+
apiKey;
|
|
53
|
+
projectId;
|
|
54
|
+
location;
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this.apiKey = options.apiKey ?? process.env.GOOGLE_API_KEY ?? "";
|
|
57
|
+
this.projectId = options.projectId ?? process.env.GOOGLE_CLOUD_PROJECT ?? "";
|
|
58
|
+
this.location = options.location ?? "us-central1";
|
|
59
|
+
}
|
|
60
|
+
validateModel(model) {
|
|
61
|
+
return model.name.startsWith("gemini-");
|
|
62
|
+
}
|
|
63
|
+
// TODO: Implement full deployment to Google Gemini / Vertex AI
|
|
64
|
+
async deploy(_model) {
|
|
65
|
+
if (!this.apiKey && !this.projectId) {
|
|
66
|
+
return { success: false };
|
|
67
|
+
}
|
|
68
|
+
const endpoint = this.projectId ? `https://${this.location}-aiplatform.googleapis.com` : "https://generativelanguage.googleapis.com";
|
|
69
|
+
return { success: true, endpoint };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/openai.ts
|
|
74
|
+
var OpenAIAdapter = class {
|
|
75
|
+
apiKey;
|
|
76
|
+
baseUrl;
|
|
77
|
+
constructor(options = {}) {
|
|
78
|
+
this.apiKey = options.apiKey ?? process.env.OPENAI_API_KEY ?? "";
|
|
79
|
+
this.baseUrl = options.baseUrl ?? "https://api.openai.com";
|
|
80
|
+
}
|
|
81
|
+
validateModel(model) {
|
|
82
|
+
return model.name.startsWith("gpt-") || /^o\d/.test(model.name);
|
|
83
|
+
}
|
|
84
|
+
// TODO: Implement full deployment to OpenAI
|
|
85
|
+
async deploy(_model) {
|
|
86
|
+
if (!this.apiKey) {
|
|
87
|
+
return { success: false };
|
|
88
|
+
}
|
|
89
|
+
return { success: true, endpoint: this.baseUrl };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/ollama.ts
|
|
94
|
+
var OllamaAdapter = class {
|
|
95
|
+
host;
|
|
96
|
+
port;
|
|
97
|
+
constructor(options = {}) {
|
|
98
|
+
this.host = options.host ?? "localhost";
|
|
99
|
+
this.port = options.port ?? 11434;
|
|
100
|
+
}
|
|
101
|
+
get baseUrl() {
|
|
102
|
+
return `http://${this.host}:${this.port}`;
|
|
103
|
+
}
|
|
104
|
+
validateModel(_model) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
// TODO: Implement full deployment to Ollama
|
|
108
|
+
async deploy(_model) {
|
|
109
|
+
return { success: true, endpoint: this.baseUrl };
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
AnthropicAdapter,
|
|
115
|
+
GoogleAdapter,
|
|
116
|
+
OllamaAdapter,
|
|
117
|
+
OpenAIAdapter
|
|
118
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ModelConfig } from '@openforge-ai/sdk';
|
|
2
|
+
|
|
3
|
+
interface AnthropicDeployOptions {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Adapter for deploying agents to the Anthropic API.
|
|
9
|
+
* Validates model names and translates Forge config to Anthropic SDK params.
|
|
10
|
+
*/
|
|
11
|
+
declare class AnthropicAdapter {
|
|
12
|
+
private apiKey;
|
|
13
|
+
private baseUrl;
|
|
14
|
+
constructor(options?: AnthropicDeployOptions);
|
|
15
|
+
validateModel(model: ModelConfig): boolean;
|
|
16
|
+
deploy(_model: ModelConfig): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
endpoint?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GoogleDeployOptions {
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
projectId?: string;
|
|
25
|
+
location?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adapter for deploying agents to Google Gemini / Vertex AI.
|
|
29
|
+
* Validates model names and translates Forge config to Google AI SDK params.
|
|
30
|
+
*/
|
|
31
|
+
declare class GoogleAdapter {
|
|
32
|
+
private apiKey;
|
|
33
|
+
private projectId;
|
|
34
|
+
private location;
|
|
35
|
+
constructor(options?: GoogleDeployOptions);
|
|
36
|
+
validateModel(model: ModelConfig): boolean;
|
|
37
|
+
deploy(_model: ModelConfig): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
endpoint?: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface OpenAIDeployOptions {
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adapter for deploying agents to the OpenAI API.
|
|
49
|
+
*/
|
|
50
|
+
declare class OpenAIAdapter {
|
|
51
|
+
private apiKey;
|
|
52
|
+
private baseUrl;
|
|
53
|
+
constructor(options?: OpenAIDeployOptions);
|
|
54
|
+
validateModel(model: ModelConfig): boolean;
|
|
55
|
+
deploy(_model: ModelConfig): Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
endpoint?: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface OllamaDeployOptions {
|
|
62
|
+
host?: string;
|
|
63
|
+
port?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adapter for deploying agents to a local Ollama instance.
|
|
67
|
+
*/
|
|
68
|
+
declare class OllamaAdapter {
|
|
69
|
+
private host;
|
|
70
|
+
private port;
|
|
71
|
+
constructor(options?: OllamaDeployOptions);
|
|
72
|
+
get baseUrl(): string;
|
|
73
|
+
validateModel(_model: ModelConfig): boolean;
|
|
74
|
+
deploy(_model: ModelConfig): Promise<{
|
|
75
|
+
success: boolean;
|
|
76
|
+
endpoint?: string;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { AnthropicAdapter, type AnthropicDeployOptions, GoogleAdapter, type GoogleDeployOptions, OllamaAdapter, type OllamaDeployOptions, OpenAIAdapter, type OpenAIDeployOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ModelConfig } from '@openforge-ai/sdk';
|
|
2
|
+
|
|
3
|
+
interface AnthropicDeployOptions {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Adapter for deploying agents to the Anthropic API.
|
|
9
|
+
* Validates model names and translates Forge config to Anthropic SDK params.
|
|
10
|
+
*/
|
|
11
|
+
declare class AnthropicAdapter {
|
|
12
|
+
private apiKey;
|
|
13
|
+
private baseUrl;
|
|
14
|
+
constructor(options?: AnthropicDeployOptions);
|
|
15
|
+
validateModel(model: ModelConfig): boolean;
|
|
16
|
+
deploy(_model: ModelConfig): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
endpoint?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GoogleDeployOptions {
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
projectId?: string;
|
|
25
|
+
location?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adapter for deploying agents to Google Gemini / Vertex AI.
|
|
29
|
+
* Validates model names and translates Forge config to Google AI SDK params.
|
|
30
|
+
*/
|
|
31
|
+
declare class GoogleAdapter {
|
|
32
|
+
private apiKey;
|
|
33
|
+
private projectId;
|
|
34
|
+
private location;
|
|
35
|
+
constructor(options?: GoogleDeployOptions);
|
|
36
|
+
validateModel(model: ModelConfig): boolean;
|
|
37
|
+
deploy(_model: ModelConfig): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
endpoint?: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface OpenAIDeployOptions {
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adapter for deploying agents to the OpenAI API.
|
|
49
|
+
*/
|
|
50
|
+
declare class OpenAIAdapter {
|
|
51
|
+
private apiKey;
|
|
52
|
+
private baseUrl;
|
|
53
|
+
constructor(options?: OpenAIDeployOptions);
|
|
54
|
+
validateModel(model: ModelConfig): boolean;
|
|
55
|
+
deploy(_model: ModelConfig): Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
endpoint?: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface OllamaDeployOptions {
|
|
62
|
+
host?: string;
|
|
63
|
+
port?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adapter for deploying agents to a local Ollama instance.
|
|
67
|
+
*/
|
|
68
|
+
declare class OllamaAdapter {
|
|
69
|
+
private host;
|
|
70
|
+
private port;
|
|
71
|
+
constructor(options?: OllamaDeployOptions);
|
|
72
|
+
get baseUrl(): string;
|
|
73
|
+
validateModel(_model: ModelConfig): boolean;
|
|
74
|
+
deploy(_model: ModelConfig): Promise<{
|
|
75
|
+
success: boolean;
|
|
76
|
+
endpoint?: string;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { AnthropicAdapter, type AnthropicDeployOptions, GoogleAdapter, type GoogleDeployOptions, OllamaAdapter, type OllamaDeployOptions, OpenAIAdapter, type OpenAIDeployOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/anthropic.ts
|
|
2
|
+
var AnthropicAdapter = class {
|
|
3
|
+
apiKey;
|
|
4
|
+
baseUrl;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.apiKey = options.apiKey ?? process.env.ANTHROPIC_API_KEY ?? "";
|
|
7
|
+
this.baseUrl = options.baseUrl ?? "https://api.anthropic.com";
|
|
8
|
+
}
|
|
9
|
+
validateModel(model) {
|
|
10
|
+
return model.name.startsWith("claude-");
|
|
11
|
+
}
|
|
12
|
+
// TODO: Implement full deployment to Anthropic
|
|
13
|
+
async deploy(_model) {
|
|
14
|
+
if (!this.apiKey) {
|
|
15
|
+
return { success: false };
|
|
16
|
+
}
|
|
17
|
+
return { success: true, endpoint: this.baseUrl };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/google.ts
|
|
22
|
+
var GoogleAdapter = class {
|
|
23
|
+
apiKey;
|
|
24
|
+
projectId;
|
|
25
|
+
location;
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
this.apiKey = options.apiKey ?? process.env.GOOGLE_API_KEY ?? "";
|
|
28
|
+
this.projectId = options.projectId ?? process.env.GOOGLE_CLOUD_PROJECT ?? "";
|
|
29
|
+
this.location = options.location ?? "us-central1";
|
|
30
|
+
}
|
|
31
|
+
validateModel(model) {
|
|
32
|
+
return model.name.startsWith("gemini-");
|
|
33
|
+
}
|
|
34
|
+
// TODO: Implement full deployment to Google Gemini / Vertex AI
|
|
35
|
+
async deploy(_model) {
|
|
36
|
+
if (!this.apiKey && !this.projectId) {
|
|
37
|
+
return { success: false };
|
|
38
|
+
}
|
|
39
|
+
const endpoint = this.projectId ? `https://${this.location}-aiplatform.googleapis.com` : "https://generativelanguage.googleapis.com";
|
|
40
|
+
return { success: true, endpoint };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/openai.ts
|
|
45
|
+
var OpenAIAdapter = class {
|
|
46
|
+
apiKey;
|
|
47
|
+
baseUrl;
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
this.apiKey = options.apiKey ?? process.env.OPENAI_API_KEY ?? "";
|
|
50
|
+
this.baseUrl = options.baseUrl ?? "https://api.openai.com";
|
|
51
|
+
}
|
|
52
|
+
validateModel(model) {
|
|
53
|
+
return model.name.startsWith("gpt-") || /^o\d/.test(model.name);
|
|
54
|
+
}
|
|
55
|
+
// TODO: Implement full deployment to OpenAI
|
|
56
|
+
async deploy(_model) {
|
|
57
|
+
if (!this.apiKey) {
|
|
58
|
+
return { success: false };
|
|
59
|
+
}
|
|
60
|
+
return { success: true, endpoint: this.baseUrl };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/ollama.ts
|
|
65
|
+
var OllamaAdapter = class {
|
|
66
|
+
host;
|
|
67
|
+
port;
|
|
68
|
+
constructor(options = {}) {
|
|
69
|
+
this.host = options.host ?? "localhost";
|
|
70
|
+
this.port = options.port ?? 11434;
|
|
71
|
+
}
|
|
72
|
+
get baseUrl() {
|
|
73
|
+
return `http://${this.host}:${this.port}`;
|
|
74
|
+
}
|
|
75
|
+
validateModel(_model) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
// TODO: Implement full deployment to Ollama
|
|
79
|
+
async deploy(_model) {
|
|
80
|
+
return { success: true, endpoint: this.baseUrl };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
AnthropicAdapter,
|
|
85
|
+
GoogleAdapter,
|
|
86
|
+
OllamaAdapter,
|
|
87
|
+
OpenAIAdapter
|
|
88
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openforge-ai/adapters",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LLM provider adapters for Forge agent infrastructure",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/seanfraserio/forge.git",
|
|
10
|
+
"directory": "packages/adapters"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"forge",
|
|
20
|
+
"ai",
|
|
21
|
+
"agents",
|
|
22
|
+
"adapters",
|
|
23
|
+
"anthropic",
|
|
24
|
+
"openai"
|
|
25
|
+
],
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@openforge-ai/sdk": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^20.0.0",
|
|
40
|
+
"tsup": "^8.0.0",
|
|
41
|
+
"typescript": "^5.4.0",
|
|
42
|
+
"vitest": "^1.4.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
49
|
+
}
|
|
50
|
+
}
|