agentic-kit 0.1.1 → 0.3.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 +2 -1
- package/README.md +66 -63
- package/esm/index.js +48 -47
- package/index.d.ts +22 -32
- package/index.js +52 -51
- package/package.json +15 -14
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
Copyright (c) 2025 Constructive <developers@constructive.io>
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,108 +1,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agentic-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center" width="100%">
|
|
4
|
+
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center" width="100%">
|
|
8
|
+
<a href="https://github.com/constructive-io/agentic-kit/actions/workflows/run-tests.yaml">
|
|
9
|
+
<img height="20" src="https://github.com/constructive-io/agentic-kit/actions/workflows/run-tests.yaml/badge.svg" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/constructive-io/agentic-kit/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/agentic-kit"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/agentic-kit?filename=packages%2Fagentic-kit%2Fpackage.json"/></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
A unified, streaming-capable interface for multiple LLM providers. Plug in any supported adapter and swap between them at runtime.
|
|
4
16
|
|
|
5
17
|
## Installation
|
|
6
18
|
|
|
7
19
|
```bash
|
|
8
20
|
npm install agentic-kit
|
|
9
|
-
# or
|
|
10
|
-
yarn add agentic-kit
|
|
11
21
|
```
|
|
12
22
|
|
|
13
|
-
Agentic Kit includes adapters for Ollama and Bradie out of the box.
|
|
14
|
-
|
|
15
23
|
## Quick Start
|
|
16
24
|
|
|
17
25
|
```typescript
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Core type
|
|
29
|
-
AgentKit
|
|
30
|
-
} from 'agentic-kit';
|
|
31
|
-
|
|
32
|
-
// Ollama-only client
|
|
33
|
-
const ollamaKit: AgentKit = createOllamaKit('http://localhost:11434');
|
|
34
|
-
const text = await ollamaKit.generate({ model: 'mistral', prompt: 'Hello' });
|
|
35
|
-
console.log(text);
|
|
36
|
-
|
|
37
|
-
// Bradie-only client
|
|
38
|
-
const bradieKit: AgentKit = createBradieKit({
|
|
39
|
-
domain: 'http://localhost:3000',
|
|
40
|
-
onSystemMessage: (msg) => console.log('[system]', msg),
|
|
41
|
-
onAssistantReply: (msg) => console.log('[assistant]', msg),
|
|
42
|
-
});
|
|
43
|
-
await bradieKit.generate({ prompt: 'Hello' });
|
|
44
|
-
|
|
45
|
-
// Multi-provider client
|
|
46
|
-
const multiKit = createMultiProviderKit();
|
|
47
|
-
multiKit.addProvider(new OllamaAdapter('http://localhost:11434'));
|
|
48
|
-
multiKit.addProvider(new BradieAdapter({
|
|
49
|
-
domain: 'http://localhost:3000',
|
|
50
|
-
onSystemMessage: console.log,
|
|
51
|
-
onAssistantReply: console.log
|
|
52
|
-
}));
|
|
53
|
-
const reply = await multiKit.generate({ model: 'mistral', prompt: 'Hello' });
|
|
54
|
-
console.log(reply);
|
|
26
|
+
import { createOllamaKit, createMultiProviderKit, OllamaAdapter, AgentKit } from 'agentic-kit';
|
|
27
|
+
|
|
28
|
+
// Ollama
|
|
29
|
+
const kit = createOllamaKit('http://localhost:11434');
|
|
30
|
+
const text = await kit.generate({ model: 'mistral', prompt: 'Hello' });
|
|
31
|
+
|
|
32
|
+
// Multi-provider with fallback
|
|
33
|
+
const multi = createMultiProviderKit();
|
|
34
|
+
multi.addProvider(new OllamaAdapter('http://localhost:11434'));
|
|
35
|
+
const reply = await multi.generate({ model: 'mistral', prompt: 'Hello' });
|
|
55
36
|
```
|
|
56
37
|
|
|
57
38
|
## Streaming
|
|
58
39
|
|
|
59
|
-
Both adapters support a streaming mode that invokes a callback for each data chunk.
|
|
60
|
-
|
|
61
40
|
```typescript
|
|
62
|
-
await
|
|
41
|
+
await kit.generate(
|
|
63
42
|
{ model: 'mistral', prompt: 'Hello', stream: true },
|
|
64
|
-
(chunk) =>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
await bradieKit.generate(
|
|
68
|
-
{ model: 'mistral', prompt: 'Hello', stream: true },
|
|
69
|
-
(chunk) => console.log('Bradie chunk:', chunk)
|
|
43
|
+
{ onChunk: (chunk) => process.stdout.write(chunk) }
|
|
70
44
|
);
|
|
71
45
|
```
|
|
72
46
|
|
|
73
47
|
## API Reference
|
|
74
48
|
|
|
75
|
-
### AgentKit
|
|
49
|
+
### `AgentKit`
|
|
76
50
|
|
|
77
51
|
- `.generate(input: GenerateInput, options?: StreamingOptions): Promise<string | void>`
|
|
78
|
-
- `.
|
|
52
|
+
- `.addProvider(provider: AgentProvider): void`
|
|
79
53
|
- `.setProvider(name: string): void`
|
|
54
|
+
- `.listProviders(): string[]`
|
|
80
55
|
- `.getCurrentProvider(): AgentProvider | undefined`
|
|
81
56
|
|
|
82
|
-
### GenerateInput
|
|
57
|
+
### `GenerateInput`
|
|
83
58
|
|
|
84
59
|
```ts
|
|
85
60
|
interface GenerateInput {
|
|
86
|
-
model
|
|
87
|
-
prompt: string;
|
|
88
|
-
stream?: boolean;
|
|
61
|
+
model: string;
|
|
62
|
+
prompt: string;
|
|
63
|
+
stream?: boolean;
|
|
89
64
|
}
|
|
90
65
|
```
|
|
91
66
|
|
|
92
|
-
### StreamingOptions
|
|
67
|
+
### `StreamingOptions`
|
|
93
68
|
|
|
94
69
|
```ts
|
|
95
70
|
interface StreamingOptions {
|
|
96
71
|
onChunk?: (chunk: string) => void;
|
|
97
72
|
onStateChange?: (state: string) => void;
|
|
98
73
|
onError?: (error: Error) => void;
|
|
74
|
+
onComplete?: () => void;
|
|
99
75
|
}
|
|
100
76
|
```
|
|
101
77
|
|
|
102
|
-
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Related Constructive Tooling
|
|
103
81
|
|
|
104
|
-
|
|
82
|
+
### 🤖 AI & Agent Development
|
|
105
83
|
|
|
106
|
-
|
|
84
|
+
* [agentic-kit](https://github.com/constructive-io/agentic-kit): **🧰 Provider-agnostic LLM adapter** with streaming and multi-turn support. Swap between Anthropic, OpenAI, Ollama, and any OpenAI-compatible endpoint.
|
|
85
|
+
|
|
86
|
+
### 📦 Package Management
|
|
87
|
+
|
|
88
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
89
|
+
|
|
90
|
+
### 🧪 Testing
|
|
91
|
+
|
|
92
|
+
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
93
|
+
* [pgsql-seed](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-seed): **🌱 PostgreSQL seeding utilities** for CSV, JSON, SQL data loading, and pgpm deployment.
|
|
94
|
+
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
95
|
+
|
|
96
|
+
### 🧠 Parsing & AST
|
|
97
|
+
|
|
98
|
+
* [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
|
|
99
|
+
* [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
100
|
+
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
101
|
+
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
102
|
+
|
|
103
|
+
## Credits
|
|
104
|
+
|
|
105
|
+
**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
|
|
106
|
+
|
|
107
|
+
## Disclaimer
|
|
108
|
+
|
|
109
|
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { Bradie } from '@agentic-kit/bradie';
|
|
2
1
|
import OllamaClient from '@agentic-kit/ollama';
|
|
2
|
+
import { AnthropicAdapter } from '@agentic-kit/anthropic';
|
|
3
|
+
import { OpenAIAdapter } from '@agentic-kit/openai';
|
|
4
|
+
export { OllamaClient };
|
|
5
|
+
export { AnthropicAdapter };
|
|
6
|
+
export { OpenAIAdapter };
|
|
7
|
+
// ─── Ollama Adapter ───────────────────────────────────────────────────────────
|
|
3
8
|
export class OllamaAdapter {
|
|
4
9
|
name = 'ollama';
|
|
5
10
|
client;
|
|
@@ -10,72 +15,68 @@ export class OllamaAdapter {
|
|
|
10
15
|
return this.client.generate(input);
|
|
11
16
|
}
|
|
12
17
|
async generateStreaming(input, onChunk) {
|
|
13
|
-
|
|
18
|
+
return this.client.generate(input, onChunk);
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
name = 'bradie';
|
|
18
|
-
client;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.client = new Bradie(config);
|
|
21
|
-
}
|
|
22
|
-
async generate(input) {
|
|
23
|
-
const requestId = await this.client.sendMessage(input.prompt);
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
this.client.subscribeToResponse(requestId)
|
|
26
|
-
.then(() => resolve('Response completed'))
|
|
27
|
-
.catch(reject);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async generateStreaming(input, onChunk) {
|
|
31
|
-
const requestId = await this.client.sendMessage(input.prompt);
|
|
32
|
-
await this.client.subscribeToResponse(requestId);
|
|
33
|
-
}
|
|
34
|
-
getState() {
|
|
35
|
-
return this.client.getState();
|
|
20
|
+
async listModels() {
|
|
21
|
+
return this.client.listModels();
|
|
36
22
|
}
|
|
37
23
|
}
|
|
24
|
+
// ─── AgentKit ─────────────────────────────────────────────────────────────────
|
|
38
25
|
export class AgentKit {
|
|
39
26
|
providers = new Map();
|
|
40
|
-
|
|
27
|
+
current;
|
|
41
28
|
addProvider(provider) {
|
|
42
29
|
this.providers.set(provider.name, provider);
|
|
43
|
-
if (!this.
|
|
44
|
-
this.
|
|
45
|
-
|
|
30
|
+
if (!this.current)
|
|
31
|
+
this.current = provider;
|
|
32
|
+
return this;
|
|
46
33
|
}
|
|
47
34
|
setProvider(name) {
|
|
48
35
|
const provider = this.providers.get(name);
|
|
49
|
-
if (!provider)
|
|
36
|
+
if (!provider)
|
|
50
37
|
throw new Error(`Provider '${name}' not found`);
|
|
51
|
-
|
|
52
|
-
this
|
|
53
|
-
}
|
|
54
|
-
getCurrentProvider() {
|
|
55
|
-
return this.currentProvider;
|
|
38
|
+
this.current = provider;
|
|
39
|
+
return this;
|
|
56
40
|
}
|
|
41
|
+
getCurrentProvider() { return this.current; }
|
|
42
|
+
listProviders() { return Array.from(this.providers.keys()); }
|
|
57
43
|
async generate(input, options) {
|
|
58
|
-
if (!this.
|
|
59
|
-
throw new Error('No provider set');
|
|
44
|
+
if (!this.current)
|
|
45
|
+
throw new Error('No provider set. Call addProvider() first.');
|
|
46
|
+
if (options?.onChunk) {
|
|
47
|
+
try {
|
|
48
|
+
await this.current.generateStreaming(input, options.onChunk);
|
|
49
|
+
options.onComplete?.();
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
options.onError?.(err);
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const result = await this.current.generate(input);
|
|
59
|
+
options?.onComplete?.();
|
|
60
|
+
return result;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
catch (err) {
|
|
63
|
+
options?.onError?.(err);
|
|
64
|
+
throw err;
|
|
63
65
|
}
|
|
64
|
-
return this.currentProvider.generate(input);
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
return
|
|
67
|
+
async listModels() {
|
|
68
|
+
return this.current?.listModels?.() ?? [];
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
// ─── Factory helpers ──────────────────────────────────────────────────────────
|
|
70
72
|
export function createOllamaKit(baseUrl) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
return new AgentKit().addProvider(new OllamaAdapter(baseUrl));
|
|
74
|
+
}
|
|
75
|
+
export function createAnthropicKit(options) {
|
|
76
|
+
return new AgentKit().addProvider(new AnthropicAdapter(options));
|
|
74
77
|
}
|
|
75
|
-
export function
|
|
76
|
-
|
|
77
|
-
kit.addProvider(new BradieAdapter(config));
|
|
78
|
-
return kit;
|
|
78
|
+
export function createOpenAIKit(options) {
|
|
79
|
+
return new AgentKit().addProvider(new OpenAIAdapter(options));
|
|
79
80
|
}
|
|
80
81
|
export function createMultiProviderKit() {
|
|
81
82
|
return new AgentKit();
|
package/index.d.ts
CHANGED
|
@@ -1,51 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import OllamaClient, { ChatMessage, GenerateInput } from '@agentic-kit/ollama';
|
|
2
|
+
import { AnthropicAdapter, type AnthropicOptions } from '@agentic-kit/anthropic';
|
|
3
|
+
import { OpenAIAdapter, type OpenAIOptions } from '@agentic-kit/openai';
|
|
4
|
+
export type { ChatMessage, GenerateInput };
|
|
5
|
+
export { OllamaClient };
|
|
6
|
+
export { AnthropicAdapter, type AnthropicOptions };
|
|
7
|
+
export { OpenAIAdapter, type OpenAIOptions };
|
|
8
8
|
export interface StreamingOptions {
|
|
9
9
|
onChunk?: (chunk: string) => void;
|
|
10
10
|
onStateChange?: (state: string) => void;
|
|
11
11
|
onError?: (error: Error) => void;
|
|
12
|
+
onComplete?: () => void;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
readonly name
|
|
15
|
-
private client;
|
|
16
|
-
constructor(baseUrl?: string);
|
|
14
|
+
export interface AgentProvider {
|
|
15
|
+
readonly name: string;
|
|
17
16
|
generate(input: GenerateInput): Promise<string>;
|
|
18
17
|
generateStreaming(input: GenerateInput, onChunk: (chunk: string) => void): Promise<void>;
|
|
18
|
+
listModels?(): Promise<string[]>;
|
|
19
19
|
}
|
|
20
|
-
export declare class
|
|
21
|
-
readonly name = "
|
|
20
|
+
export declare class OllamaAdapter implements AgentProvider {
|
|
21
|
+
readonly name = "ollama";
|
|
22
22
|
private client;
|
|
23
|
-
constructor(
|
|
24
|
-
domain: string;
|
|
25
|
-
onSystemMessage: (msg: string) => void;
|
|
26
|
-
onAssistantReply: (msg: string) => void;
|
|
27
|
-
onError?: (err: Error) => void;
|
|
28
|
-
onComplete?: () => void;
|
|
29
|
-
});
|
|
23
|
+
constructor(baseUrl?: string);
|
|
30
24
|
generate(input: GenerateInput): Promise<string>;
|
|
31
25
|
generateStreaming(input: GenerateInput, onChunk: (chunk: string) => void): Promise<void>;
|
|
32
|
-
|
|
26
|
+
listModels(): Promise<string[]>;
|
|
33
27
|
}
|
|
34
28
|
export declare class AgentKit {
|
|
35
29
|
private providers;
|
|
36
|
-
private
|
|
37
|
-
addProvider(provider: AgentProvider):
|
|
38
|
-
setProvider(name: string):
|
|
30
|
+
private current?;
|
|
31
|
+
addProvider(provider: AgentProvider): this;
|
|
32
|
+
setProvider(name: string): this;
|
|
39
33
|
getCurrentProvider(): AgentProvider | undefined;
|
|
40
|
-
generate(input: GenerateInput, options?: StreamingOptions): Promise<string | void>;
|
|
41
34
|
listProviders(): string[];
|
|
35
|
+
generate(input: GenerateInput, options?: StreamingOptions): Promise<string | void>;
|
|
36
|
+
listModels(): Promise<string[]>;
|
|
42
37
|
}
|
|
43
38
|
export declare function createOllamaKit(baseUrl?: string): AgentKit;
|
|
44
|
-
export declare function
|
|
45
|
-
|
|
46
|
-
onSystemMessage: (msg: string) => void;
|
|
47
|
-
onAssistantReply: (msg: string) => void;
|
|
48
|
-
onError?: (err: Error) => void;
|
|
49
|
-
onComplete?: () => void;
|
|
50
|
-
}): AgentKit;
|
|
39
|
+
export declare function createAnthropicKit(options: AnthropicOptions | string): AgentKit;
|
|
40
|
+
export declare function createOpenAIKit(options: OpenAIOptions | string): AgentKit;
|
|
51
41
|
export declare function createMultiProviderKit(): AgentKit;
|
package/index.js
CHANGED
|
@@ -3,12 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AgentKit = exports.
|
|
6
|
+
exports.AgentKit = exports.OllamaAdapter = exports.OpenAIAdapter = exports.AnthropicAdapter = exports.OllamaClient = void 0;
|
|
7
7
|
exports.createOllamaKit = createOllamaKit;
|
|
8
|
-
exports.
|
|
8
|
+
exports.createAnthropicKit = createAnthropicKit;
|
|
9
|
+
exports.createOpenAIKit = createOpenAIKit;
|
|
9
10
|
exports.createMultiProviderKit = createMultiProviderKit;
|
|
10
|
-
const bradie_1 = require("@agentic-kit/bradie");
|
|
11
11
|
const ollama_1 = __importDefault(require("@agentic-kit/ollama"));
|
|
12
|
+
exports.OllamaClient = ollama_1.default;
|
|
13
|
+
const anthropic_1 = require("@agentic-kit/anthropic");
|
|
14
|
+
Object.defineProperty(exports, "AnthropicAdapter", { enumerable: true, get: function () { return anthropic_1.AnthropicAdapter; } });
|
|
15
|
+
const openai_1 = require("@agentic-kit/openai");
|
|
16
|
+
Object.defineProperty(exports, "OpenAIAdapter", { enumerable: true, get: function () { return openai_1.OpenAIAdapter; } });
|
|
17
|
+
// ─── Ollama Adapter ───────────────────────────────────────────────────────────
|
|
12
18
|
class OllamaAdapter {
|
|
13
19
|
name = 'ollama';
|
|
14
20
|
client;
|
|
@@ -19,75 +25,70 @@ class OllamaAdapter {
|
|
|
19
25
|
return this.client.generate(input);
|
|
20
26
|
}
|
|
21
27
|
async generateStreaming(input, onChunk) {
|
|
22
|
-
|
|
28
|
+
return this.client.generate(input, onChunk);
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class BradieAdapter {
|
|
27
|
-
name = 'bradie';
|
|
28
|
-
client;
|
|
29
|
-
constructor(config) {
|
|
30
|
-
this.client = new bradie_1.Bradie(config);
|
|
31
|
-
}
|
|
32
|
-
async generate(input) {
|
|
33
|
-
const requestId = await this.client.sendMessage(input.prompt);
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
this.client.subscribeToResponse(requestId)
|
|
36
|
-
.then(() => resolve('Response completed'))
|
|
37
|
-
.catch(reject);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async generateStreaming(input, onChunk) {
|
|
41
|
-
const requestId = await this.client.sendMessage(input.prompt);
|
|
42
|
-
await this.client.subscribeToResponse(requestId);
|
|
43
|
-
}
|
|
44
|
-
getState() {
|
|
45
|
-
return this.client.getState();
|
|
30
|
+
async listModels() {
|
|
31
|
+
return this.client.listModels();
|
|
46
32
|
}
|
|
47
33
|
}
|
|
48
|
-
exports.
|
|
34
|
+
exports.OllamaAdapter = OllamaAdapter;
|
|
35
|
+
// ─── AgentKit ─────────────────────────────────────────────────────────────────
|
|
49
36
|
class AgentKit {
|
|
50
37
|
providers = new Map();
|
|
51
|
-
|
|
38
|
+
current;
|
|
52
39
|
addProvider(provider) {
|
|
53
40
|
this.providers.set(provider.name, provider);
|
|
54
|
-
if (!this.
|
|
55
|
-
this.
|
|
56
|
-
|
|
41
|
+
if (!this.current)
|
|
42
|
+
this.current = provider;
|
|
43
|
+
return this;
|
|
57
44
|
}
|
|
58
45
|
setProvider(name) {
|
|
59
46
|
const provider = this.providers.get(name);
|
|
60
|
-
if (!provider)
|
|
47
|
+
if (!provider)
|
|
61
48
|
throw new Error(`Provider '${name}' not found`);
|
|
62
|
-
|
|
63
|
-
this
|
|
64
|
-
}
|
|
65
|
-
getCurrentProvider() {
|
|
66
|
-
return this.currentProvider;
|
|
49
|
+
this.current = provider;
|
|
50
|
+
return this;
|
|
67
51
|
}
|
|
52
|
+
getCurrentProvider() { return this.current; }
|
|
53
|
+
listProviders() { return Array.from(this.providers.keys()); }
|
|
68
54
|
async generate(input, options) {
|
|
69
|
-
if (!this.
|
|
70
|
-
throw new Error('No provider set');
|
|
55
|
+
if (!this.current)
|
|
56
|
+
throw new Error('No provider set. Call addProvider() first.');
|
|
57
|
+
if (options?.onChunk) {
|
|
58
|
+
try {
|
|
59
|
+
await this.current.generateStreaming(input, options.onChunk);
|
|
60
|
+
options.onComplete?.();
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
options.onError?.(err);
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const result = await this.current.generate(input);
|
|
70
|
+
options?.onComplete?.();
|
|
71
|
+
return result;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
catch (err) {
|
|
74
|
+
options?.onError?.(err);
|
|
75
|
+
throw err;
|
|
74
76
|
}
|
|
75
|
-
return this.currentProvider.generate(input);
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
return
|
|
78
|
+
async listModels() {
|
|
79
|
+
return this.current?.listModels?.() ?? [];
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
exports.AgentKit = AgentKit;
|
|
83
|
+
// ─── Factory helpers ──────────────────────────────────────────────────────────
|
|
82
84
|
function createOllamaKit(baseUrl) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
return new AgentKit().addProvider(new OllamaAdapter(baseUrl));
|
|
86
|
+
}
|
|
87
|
+
function createAnthropicKit(options) {
|
|
88
|
+
return new AgentKit().addProvider(new anthropic_1.AnthropicAdapter(options));
|
|
86
89
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
kit.addProvider(new BradieAdapter(config));
|
|
90
|
-
return kit;
|
|
90
|
+
function createOpenAIKit(options) {
|
|
91
|
+
return new AgentKit().addProvider(new openai_1.OpenAIAdapter(options));
|
|
91
92
|
}
|
|
92
93
|
function createMultiProviderKit() {
|
|
93
94
|
return new AgentKit();
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Provider-agnostic LLM adapter with streaming and multi-turn support",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "esm/index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
|
-
"homepage": "https://github.com/
|
|
9
|
+
"homepage": "https://github.com/constructive-io/agentic-kit",
|
|
10
10
|
"license": "SEE LICENSE IN LICENSE",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public",
|
|
@@ -14,25 +14,26 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/constructive-io/agentic-kit"
|
|
18
18
|
},
|
|
19
19
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "https://github.com/constructive-io/agentic-kit/issues"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
|
|
27
|
-
"build:dev": "npm run clean; tsc --declarationMap; tsc -p tsconfig.esm.json; npm run copy",
|
|
23
|
+
"clean": "makage clean",
|
|
24
|
+
"build": "makage build",
|
|
25
|
+
"build:dev": "makage build --dev",
|
|
28
26
|
"lint": "eslint . --fix",
|
|
29
27
|
"test": "jest",
|
|
30
28
|
"test:watch": "jest --watch"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
|
-
"@agentic-kit/
|
|
34
|
-
"@agentic-kit/ollama": "
|
|
31
|
+
"@agentic-kit/anthropic": "workspace:*",
|
|
32
|
+
"@agentic-kit/ollama": "workspace:*",
|
|
33
|
+
"@agentic-kit/openai": "workspace:*"
|
|
35
34
|
},
|
|
36
|
-
"
|
|
37
|
-
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"cross-fetch": "^4.1.0"
|
|
37
|
+
},
|
|
38
|
+
"keywords": []
|
|
38
39
|
}
|