agent-pulse 1.0.0 → 1.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/README.md CHANGED
@@ -36,13 +36,21 @@ import { Agent, openAI } from 'agent-pulse';
36
36
  import * as dotenv from 'dotenv';
37
37
  dotenv.config();
38
38
 
39
- // Instantiate the provider directly
39
+ // Option A: Use environment variables (OPENAI_API_KEY)
40
40
  const agent = new Agent({
41
41
  name: 'my-bot',
42
- provider: new openAI('gpt-4o'), // Or new google('gemini-1.5-pro'), new grok('grok-beta')
42
+ provider: new openAI('gpt-4o'),
43
43
  system: 'You are a helpful assistant.'
44
44
  });
45
45
 
46
+ // Option B: Pass API key directly (Recommended for Serverless/Vercel)
47
+ const agentWithKey = new Agent({
48
+ name: 'secure-bot',
49
+ provider: new openAI('gpt-4o', process.env.CUSTOM_KEY_NAME || 'your-key'),
50
+ system: 'You are a helpful assistant.'
51
+ });
52
+ ```
53
+
46
54
  // Real-time typing effect
47
55
  agent.on('token', (chunk) => {
48
56
  process.stdout.write(chunk);
@@ -118,7 +126,7 @@ import { Agent, OpenAIProvider, GoogleProvider, GrokProvider } from 'agent-pulse
118
126
  | Option | Type | Description |
119
127
  |---|---|---|
120
128
  | `name` | string | Unique identifier for debugging. |
121
- | `provider` | LLMProvider | An instance of a provider class (e.g., `new OpenAIProvider(...)`). |
129
+ | `provider` | LLMProvider | An instance of a provider class (e.g., `new openAI('model', 'optional_key')`). |
122
130
  | `system` | string | System instructions. |
123
131
  | `prompt` | string | Base prompt template (optional). |
124
132
  | `files` | string[] | Array of file paths or content strings to include in context. |
@@ -3,6 +3,6 @@ import { z } from 'zod';
3
3
  export declare class GoogleProvider implements LLMProvider {
4
4
  private client;
5
5
  private model;
6
- constructor(model: string);
6
+ constructor(model: string, apiKey?: string);
7
7
  generate(system: string | undefined, prompt: string | any[], files: string[] | undefined, tools: AgentTool[] | undefined, config: Record<string, any> | undefined, output_schema: z.ZodType<any> | undefined, onToken: (token: string) => void): Promise<AgentResponse>;
8
8
  }
@@ -5,10 +5,11 @@ const genai_1 = require("@google/genai");
5
5
  const zod_1 = require("zod");
6
6
  const file_utils_1 = require("../utils/file-utils");
7
7
  class GoogleProvider {
8
- constructor(model) {
8
+ constructor(model, apiKey) {
9
9
  // Google GenAI SDK expects model names in format "models/model-name"
10
10
  this.model = model.startsWith('models/') ? model : `models/${model}`;
11
- this.client = new genai_1.GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY });
11
+ const key = apiKey || process.env.GOOGLE_API_KEY;
12
+ this.client = new genai_1.GoogleGenAI({ apiKey: key });
12
13
  }
13
14
  async generate(system, prompt, files, tools, config, output_schema, onToken) {
14
15
  // 1. Prepare Tools
@@ -3,6 +3,6 @@ import { z } from 'zod';
3
3
  export declare class GrokProvider implements LLMProvider {
4
4
  private client;
5
5
  private model;
6
- constructor(model: string);
6
+ constructor(model: string, apiKey?: string);
7
7
  generate(system: string | undefined, prompt: string | any[], files: string[] | undefined, tools: AgentTool[] | undefined, config: Record<string, any> | undefined, output_schema: z.ZodType<any> | undefined, onToken: (token: string) => void): Promise<AgentResponse>;
8
8
  }
@@ -8,11 +8,12 @@ const openai_1 = __importDefault(require("openai"));
8
8
  const zod_1 = require("zod");
9
9
  const file_utils_1 = require("../utils/file-utils");
10
10
  class GrokProvider {
11
- constructor(model) {
11
+ constructor(model, apiKey) {
12
12
  this.model = model;
13
+ const key = apiKey || process.env.GROK_API_KEY;
13
14
  // Grok uses the OpenAI SDK with a custom base URL
14
15
  this.client = new openai_1.default({
15
- apiKey: process.env.GROK_API_KEY,
16
+ apiKey: key,
16
17
  baseURL: 'https://api.x.ai/v1',
17
18
  });
18
19
  }
@@ -3,6 +3,6 @@ import { z } from 'zod';
3
3
  export declare class OpenAIProvider implements LLMProvider {
4
4
  private client;
5
5
  private model;
6
- constructor(model: string);
6
+ constructor(model: string, apiKey?: string);
7
7
  generate(system: string | undefined, prompt: string | any[], files: string[] | undefined, tools: AgentTool[] | undefined, config: Record<string, any> | undefined, output_schema: z.ZodType<any> | undefined, onToken: (token: string) => void): Promise<AgentResponse>;
8
8
  }
@@ -8,10 +8,11 @@ const openai_1 = __importDefault(require("openai"));
8
8
  const zod_1 = require("zod");
9
9
  const file_utils_1 = require("../utils/file-utils");
10
10
  class OpenAIProvider {
11
- constructor(model) {
11
+ constructor(model, apiKey) {
12
12
  this.model = model;
13
+ const key = apiKey || process.env.OPENAI_API_KEY;
13
14
  this.client = new openai_1.default({
14
- apiKey: process.env.OPENAI_API_KEY,
15
+ apiKey: key,
15
16
  });
16
17
  }
17
18
  async generate(system, prompt, files, tools, config, output_schema, onToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-pulse",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight, agentic AI framework for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",