praisonai 1.5.4 → 1.6.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 +12 -12
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +2 -1
- package/dist/agent/proxy.d.ts +11 -1
- package/dist/agent/proxy.js +16 -6
- package/dist/agent/simple.d.ts +28 -11
- package/dist/agent/simple.js +17 -14
- package/dist/agent/types.d.ts +7 -3
- package/dist/agent/types.js +6 -6
- package/dist/cli/commands/flow.js +2 -2
- package/dist/cli/features/flow-display.d.ts +1 -1
- package/dist/cli/features/flow-display.js +2 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +24 -12
- package/dist/llm/providers/registry.js +22 -9
- package/dist/os/agentos.d.ts +145 -0
- package/dist/os/agentos.js +268 -0
- package/dist/os/config.d.ts +65 -0
- package/dist/os/config.js +50 -0
- package/dist/os/index.d.ts +31 -0
- package/dist/os/index.js +37 -0
- package/dist/os/protocols.d.ts +55 -0
- package/dist/os/protocols.js +21 -0
- package/dist/workflows/index.d.ts +28 -8
- package/dist/workflows/index.js +29 -9
- package/dist/workflows/loop.js +1 -1
- package/dist/workflows/repeat.js +1 -1
- package/dist/workflows/yaml-parser.d.ts +2 -2
- package/dist/workflows/yaml-parser.js +1 -1
- package/package.json +2 -2
|
@@ -168,20 +168,33 @@ class ProviderRegistry {
|
|
|
168
168
|
* Constructors have a prototype with constructor
|
|
169
169
|
*/
|
|
170
170
|
isLoaderFunction(value) {
|
|
171
|
-
//
|
|
171
|
+
// Check if it's a class by looking at the string representation
|
|
172
|
+
const str = value.toString();
|
|
173
|
+
// Classes start with 'class ' in their toString
|
|
174
|
+
if (str.startsWith('class ')) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
// If it has a prototype with methods (more than just constructor), it's a class
|
|
172
178
|
if (value.prototype && Object.getOwnPropertyNames(value.prototype).length > 1) {
|
|
173
179
|
return false;
|
|
174
180
|
}
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
181
|
+
// Jest mock functions and arrow functions are loaders
|
|
182
|
+
// They don't have a meaningful prototype or their prototype doesn't match class pattern
|
|
183
|
+
if (typeof value === 'function') {
|
|
184
|
+
// Arrow functions have no prototype or an empty prototype
|
|
185
|
+
if (!value.prototype) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
// Jest mocks have _isMockFunction property
|
|
189
|
+
if (value._isMockFunction) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
// Regular functions that aren't classes are loaders
|
|
193
|
+
if (!str.startsWith('class ') && !str.startsWith('function ')) {
|
|
194
|
+
return true;
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
|
-
|
|
184
|
-
return typeof value === 'function' && !value.prototype?.constructor;
|
|
197
|
+
return false;
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
200
|
exports.ProviderRegistry = ProviderRegistry;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOS Implementation
|
|
3
|
+
*
|
|
4
|
+
* Production platform for deploying AI agents as web services.
|
|
5
|
+
* Implements the AgentOSProtocol for serving agents via HTTP.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic Usage
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentOS, Agent } from 'praisonai';
|
|
10
|
+
*
|
|
11
|
+
* const assistant = new Agent({
|
|
12
|
+
* name: 'assistant',
|
|
13
|
+
* instructions: 'Be helpful'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const app = new AgentOS({
|
|
17
|
+
* name: 'My AI App',
|
|
18
|
+
* agents: [assistant]
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* await app.serve({ port: 8000 });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example With Teams and Flows
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const app = new AgentOS({
|
|
27
|
+
* name: 'My AI App',
|
|
28
|
+
* agents: [assistant],
|
|
29
|
+
* teams: [myTeam],
|
|
30
|
+
* flows: [myFlow],
|
|
31
|
+
* config: { port: 9000, debug: true }
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import type { AgentOSProtocol } from './protocols';
|
|
36
|
+
import type { AgentOSConfig } from './config';
|
|
37
|
+
type Agent = {
|
|
38
|
+
name?: string;
|
|
39
|
+
role?: string;
|
|
40
|
+
instructions?: string;
|
|
41
|
+
chat: (message: string) => Promise<string>;
|
|
42
|
+
};
|
|
43
|
+
type AgentTeam = {
|
|
44
|
+
agents?: Agent[];
|
|
45
|
+
start: () => Promise<string[]>;
|
|
46
|
+
};
|
|
47
|
+
type AgentFlow = {
|
|
48
|
+
name?: string;
|
|
49
|
+
run: (input: any) => Promise<any>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* AgentOS constructor options
|
|
53
|
+
*/
|
|
54
|
+
export interface AgentOSOptions {
|
|
55
|
+
/** Name of the application */
|
|
56
|
+
name?: string;
|
|
57
|
+
/** List of Agent instances to serve */
|
|
58
|
+
agents?: any[];
|
|
59
|
+
/** List of AgentTeam instances to serve */
|
|
60
|
+
teams?: any[];
|
|
61
|
+
/** List of AgentFlow instances to serve */
|
|
62
|
+
flows?: any[];
|
|
63
|
+
/** Server configuration */
|
|
64
|
+
config?: AgentOSConfig;
|
|
65
|
+
/** @deprecated Use `teams` instead */
|
|
66
|
+
managers?: any[];
|
|
67
|
+
/** @deprecated Use `flows` instead */
|
|
68
|
+
workflows?: any[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Production platform for deploying AI agents as web services.
|
|
72
|
+
*
|
|
73
|
+
* AgentOS wraps agents, teams, and flows into a unified HTTP
|
|
74
|
+
* application with REST endpoints.
|
|
75
|
+
*/
|
|
76
|
+
export declare class AgentOS implements AgentOSProtocol {
|
|
77
|
+
/** Application name */
|
|
78
|
+
readonly name: string;
|
|
79
|
+
/** List of Agent instances */
|
|
80
|
+
readonly agents: Agent[];
|
|
81
|
+
/** List of AgentTeam instances */
|
|
82
|
+
readonly teams: AgentTeam[];
|
|
83
|
+
/** List of AgentFlow instances */
|
|
84
|
+
readonly flows: AgentFlow[];
|
|
85
|
+
/** Merged configuration */
|
|
86
|
+
readonly config: Required<Omit<AgentOSConfig, 'metadata'>> & {
|
|
87
|
+
metadata: Record<string, any>;
|
|
88
|
+
};
|
|
89
|
+
/** HTTP server instance (lazy initialized) */
|
|
90
|
+
private _server;
|
|
91
|
+
/** Express app instance (lazy initialized) */
|
|
92
|
+
private _app;
|
|
93
|
+
/**
|
|
94
|
+
* Create a new AgentOS instance.
|
|
95
|
+
*
|
|
96
|
+
* @param options - AgentOS options
|
|
97
|
+
*/
|
|
98
|
+
constructor(options?: AgentOSOptions);
|
|
99
|
+
/**
|
|
100
|
+
* Create the Express application.
|
|
101
|
+
*
|
|
102
|
+
* @returns Express app instance
|
|
103
|
+
*/
|
|
104
|
+
private _createApp;
|
|
105
|
+
/**
|
|
106
|
+
* Register API routes.
|
|
107
|
+
*
|
|
108
|
+
* @param app - Express app instance
|
|
109
|
+
*/
|
|
110
|
+
private _registerRoutes;
|
|
111
|
+
/**
|
|
112
|
+
* Get the Express application instance.
|
|
113
|
+
*
|
|
114
|
+
* @returns The Express application instance for custom mounting or configuration
|
|
115
|
+
*/
|
|
116
|
+
getApp(): any;
|
|
117
|
+
/**
|
|
118
|
+
* Start the AgentOS server.
|
|
119
|
+
*
|
|
120
|
+
* @param options - Server options
|
|
121
|
+
* @returns Promise that resolves when server is listening
|
|
122
|
+
*/
|
|
123
|
+
serve(options?: {
|
|
124
|
+
host?: string;
|
|
125
|
+
port?: number;
|
|
126
|
+
reload?: boolean;
|
|
127
|
+
}): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Stop the AgentOS server.
|
|
130
|
+
*
|
|
131
|
+
* @returns Promise that resolves when server is stopped
|
|
132
|
+
*/
|
|
133
|
+
stop(): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* AgentApp - Silent alias for AgentOS (backward compatibility)
|
|
137
|
+
* @deprecated Use AgentOS instead
|
|
138
|
+
*/
|
|
139
|
+
export declare const AgentApp: typeof AgentOS;
|
|
140
|
+
/**
|
|
141
|
+
* AgentAppOptions - Silent alias for AgentOSOptions (backward compatibility)
|
|
142
|
+
* @deprecated Use AgentOSOptions instead
|
|
143
|
+
*/
|
|
144
|
+
export type AgentAppOptions = AgentOSOptions;
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentOS Implementation
|
|
4
|
+
*
|
|
5
|
+
* Production platform for deploying AI agents as web services.
|
|
6
|
+
* Implements the AgentOSProtocol for serving agents via HTTP.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic Usage
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AgentOS, Agent } from 'praisonai';
|
|
11
|
+
*
|
|
12
|
+
* const assistant = new Agent({
|
|
13
|
+
* name: 'assistant',
|
|
14
|
+
* instructions: 'Be helpful'
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const app = new AgentOS({
|
|
18
|
+
* name: 'My AI App',
|
|
19
|
+
* agents: [assistant]
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* await app.serve({ port: 8000 });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example With Teams and Flows
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const app = new AgentOS({
|
|
28
|
+
* name: 'My AI App',
|
|
29
|
+
* agents: [assistant],
|
|
30
|
+
* teams: [myTeam],
|
|
31
|
+
* flows: [myFlow],
|
|
32
|
+
* config: { port: 9000, debug: true }
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.AgentApp = exports.AgentOS = void 0;
|
|
38
|
+
const config_1 = require("./config");
|
|
39
|
+
/**
|
|
40
|
+
* Production platform for deploying AI agents as web services.
|
|
41
|
+
*
|
|
42
|
+
* AgentOS wraps agents, teams, and flows into a unified HTTP
|
|
43
|
+
* application with REST endpoints.
|
|
44
|
+
*/
|
|
45
|
+
class AgentOS {
|
|
46
|
+
/**
|
|
47
|
+
* Create a new AgentOS instance.
|
|
48
|
+
*
|
|
49
|
+
* @param options - AgentOS options
|
|
50
|
+
*/
|
|
51
|
+
constructor(options = {}) {
|
|
52
|
+
/** HTTP server instance (lazy initialized) */
|
|
53
|
+
this._server = null;
|
|
54
|
+
/** Express app instance (lazy initialized) */
|
|
55
|
+
this._app = null;
|
|
56
|
+
this.name = options.name || config_1.DEFAULT_AGENTOS_CONFIG.name;
|
|
57
|
+
this.agents = options.agents || [];
|
|
58
|
+
// Support both new names and legacy aliases
|
|
59
|
+
this.teams = options.teams || options.managers || [];
|
|
60
|
+
this.flows = options.flows || options.workflows || [];
|
|
61
|
+
// Merge config with defaults
|
|
62
|
+
this.config = (0, config_1.mergeConfig)({
|
|
63
|
+
name: this.name,
|
|
64
|
+
...options.config,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create the Express application.
|
|
69
|
+
*
|
|
70
|
+
* @returns Express app instance
|
|
71
|
+
*/
|
|
72
|
+
_createApp() {
|
|
73
|
+
// Lazy import express
|
|
74
|
+
let express;
|
|
75
|
+
let cors;
|
|
76
|
+
try {
|
|
77
|
+
express = require('express');
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new Error('Express is required for AgentOS. ' +
|
|
81
|
+
'Install with: npm install express');
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
cors = require('cors');
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// cors is optional, we'll handle manually if not available
|
|
88
|
+
cors = null;
|
|
89
|
+
}
|
|
90
|
+
const app = express();
|
|
91
|
+
// Parse JSON bodies
|
|
92
|
+
app.use(express.json());
|
|
93
|
+
// Add CORS middleware
|
|
94
|
+
if (cors) {
|
|
95
|
+
app.use(cors({
|
|
96
|
+
origin: this.config.corsOrigins,
|
|
97
|
+
credentials: true,
|
|
98
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
99
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Manual CORS handling
|
|
104
|
+
app.use((req, res, next) => {
|
|
105
|
+
res.header('Access-Control-Allow-Origin', this.config.corsOrigins[0] || '*');
|
|
106
|
+
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
107
|
+
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
108
|
+
res.header('Access-Control-Allow-Credentials', 'true');
|
|
109
|
+
if (req.method === 'OPTIONS') {
|
|
110
|
+
return res.sendStatus(200);
|
|
111
|
+
}
|
|
112
|
+
next();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Register routes
|
|
116
|
+
this._registerRoutes(app);
|
|
117
|
+
return app;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Register API routes.
|
|
121
|
+
*
|
|
122
|
+
* @param app - Express app instance
|
|
123
|
+
*/
|
|
124
|
+
_registerRoutes(app) {
|
|
125
|
+
const { apiPrefix } = this.config;
|
|
126
|
+
// GET / - Root info
|
|
127
|
+
app.get('/', (req, res) => {
|
|
128
|
+
res.json({
|
|
129
|
+
name: this.name,
|
|
130
|
+
status: 'running',
|
|
131
|
+
agents: this.agents.map(a => a.name || 'unnamed'),
|
|
132
|
+
teams: this.teams.length,
|
|
133
|
+
flows: this.flows.length,
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
// GET /health - Health check
|
|
137
|
+
app.get('/health', (req, res) => {
|
|
138
|
+
res.json({ status: 'healthy' });
|
|
139
|
+
});
|
|
140
|
+
// GET /api/agents - List agents
|
|
141
|
+
app.get(`${apiPrefix}/agents`, (req, res) => {
|
|
142
|
+
res.json({
|
|
143
|
+
agents: this.agents.map((agent, i) => ({
|
|
144
|
+
name: agent.name || `agent_${i}`,
|
|
145
|
+
role: agent.role || null,
|
|
146
|
+
instructions: agent.instructions
|
|
147
|
+
? (agent.instructions.length > 100
|
|
148
|
+
? agent.instructions.substring(0, 100) + '...'
|
|
149
|
+
: agent.instructions)
|
|
150
|
+
: null,
|
|
151
|
+
})),
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
// POST /api/chat - Chat with an agent
|
|
155
|
+
app.post(`${apiPrefix}/chat`, async (req, res) => {
|
|
156
|
+
try {
|
|
157
|
+
const { message, agent_name, session_id } = req.body;
|
|
158
|
+
if (!message) {
|
|
159
|
+
return res.status(400).json({ error: 'Message is required' });
|
|
160
|
+
}
|
|
161
|
+
// Find the agent
|
|
162
|
+
let agent;
|
|
163
|
+
if (agent_name) {
|
|
164
|
+
agent = this.agents.find(a => a.name === agent_name);
|
|
165
|
+
if (!agent) {
|
|
166
|
+
return res.status(404).json({ error: `Agent '${agent_name}' not found` });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (this.agents.length > 0) {
|
|
170
|
+
agent = this.agents[0];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return res.status(400).json({ error: 'No agents available' });
|
|
174
|
+
}
|
|
175
|
+
// Call the agent
|
|
176
|
+
const response = await agent.chat(message);
|
|
177
|
+
const result = {
|
|
178
|
+
response: String(response),
|
|
179
|
+
agent_name: agent.name || 'unknown',
|
|
180
|
+
session_id,
|
|
181
|
+
};
|
|
182
|
+
res.json(result);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
console.error('Chat error:', error);
|
|
186
|
+
res.status(500).json({ error: error.message || 'Internal server error' });
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
// GET /api/teams - List teams
|
|
190
|
+
app.get(`${apiPrefix}/teams`, (req, res) => {
|
|
191
|
+
res.json({
|
|
192
|
+
teams: this.teams.map((team, i) => ({
|
|
193
|
+
name: `team_${i}`,
|
|
194
|
+
agents: team.agents?.length || 0,
|
|
195
|
+
})),
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
// GET /api/flows - List flows
|
|
199
|
+
app.get(`${apiPrefix}/flows`, (req, res) => {
|
|
200
|
+
res.json({
|
|
201
|
+
flows: this.flows.map((flow, i) => ({
|
|
202
|
+
name: flow.name || `flow_${i}`,
|
|
203
|
+
})),
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get the Express application instance.
|
|
209
|
+
*
|
|
210
|
+
* @returns The Express application instance for custom mounting or configuration
|
|
211
|
+
*/
|
|
212
|
+
getApp() {
|
|
213
|
+
if (!this._app) {
|
|
214
|
+
this._app = this._createApp();
|
|
215
|
+
}
|
|
216
|
+
return this._app;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Start the AgentOS server.
|
|
220
|
+
*
|
|
221
|
+
* @param options - Server options
|
|
222
|
+
* @returns Promise that resolves when server is listening
|
|
223
|
+
*/
|
|
224
|
+
async serve(options = {}) {
|
|
225
|
+
const host = options.host || this.config.host;
|
|
226
|
+
const port = options.port || this.config.port;
|
|
227
|
+
const app = this.getApp();
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
try {
|
|
230
|
+
this._server = app.listen(port, host, () => {
|
|
231
|
+
console.log(`🚀 AgentOS "${this.name}" running at http://${host}:${port}`);
|
|
232
|
+
console.log(` Agents: ${this.agents.length}`);
|
|
233
|
+
console.log(` Teams: ${this.teams.length}`);
|
|
234
|
+
console.log(` Flows: ${this.flows.length}`);
|
|
235
|
+
console.log(` API: http://${host}:${port}${this.config.apiPrefix}`);
|
|
236
|
+
resolve();
|
|
237
|
+
});
|
|
238
|
+
this._server.on('error', (error) => {
|
|
239
|
+
reject(error);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
reject(error);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Stop the AgentOS server.
|
|
249
|
+
*
|
|
250
|
+
* @returns Promise that resolves when server is stopped
|
|
251
|
+
*/
|
|
252
|
+
async stop() {
|
|
253
|
+
if (this._server) {
|
|
254
|
+
return new Promise((resolve) => {
|
|
255
|
+
this._server.close(() => {
|
|
256
|
+
this._server = null;
|
|
257
|
+
resolve();
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.AgentOS = AgentOS;
|
|
264
|
+
/**
|
|
265
|
+
* AgentApp - Silent alias for AgentOS (backward compatibility)
|
|
266
|
+
* @deprecated Use AgentOS instead
|
|
267
|
+
*/
|
|
268
|
+
exports.AgentApp = AgentOS;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOS Configuration
|
|
3
|
+
*
|
|
4
|
+
* This module defines the configuration interface for AgentOS.
|
|
5
|
+
* It follows PraisonAI's principle of sensible defaults with explicit overrides.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const config: AgentOSConfig = {
|
|
10
|
+
* name: 'My AI App',
|
|
11
|
+
* port: 9000,
|
|
12
|
+
* debug: true
|
|
13
|
+
* };
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for AgentOS.
|
|
18
|
+
*
|
|
19
|
+
* All properties are optional with sensible defaults.
|
|
20
|
+
*/
|
|
21
|
+
export interface AgentOSConfig {
|
|
22
|
+
/** Name of the application (default: "PraisonAI App") */
|
|
23
|
+
name?: string;
|
|
24
|
+
/** Host address to bind to (default: "0.0.0.0") */
|
|
25
|
+
host?: string;
|
|
26
|
+
/** Port number to listen on (default: 8000) */
|
|
27
|
+
port?: number;
|
|
28
|
+
/** Enable auto-reload for development (default: false) */
|
|
29
|
+
reload?: boolean;
|
|
30
|
+
/** List of allowed CORS origins (default: ["*"]) */
|
|
31
|
+
corsOrigins?: string[];
|
|
32
|
+
/** API route prefix (default: "/api") */
|
|
33
|
+
apiPrefix?: string;
|
|
34
|
+
/** URL for API documentation (default: "/docs") */
|
|
35
|
+
docsUrl?: string;
|
|
36
|
+
/** URL for OpenAPI schema (default: "/openapi.json") */
|
|
37
|
+
openapiUrl?: string;
|
|
38
|
+
/** Enable debug mode (default: false) */
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
/** Logging level (default: "info") */
|
|
41
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
42
|
+
/** Number of worker processes (default: 1) */
|
|
43
|
+
workers?: number;
|
|
44
|
+
/** Request timeout in seconds (default: 60) */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/** Additional metadata for the app */
|
|
47
|
+
metadata?: Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Default configuration values for AgentOS.
|
|
51
|
+
*/
|
|
52
|
+
export declare const DEFAULT_AGENTOS_CONFIG: Required<Omit<AgentOSConfig, 'metadata'>> & {
|
|
53
|
+
metadata: Record<string, any>;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Merge user config with defaults.
|
|
57
|
+
*/
|
|
58
|
+
export declare function mergeConfig(userConfig?: AgentOSConfig): Required<Omit<AgentOSConfig, 'metadata'>> & {
|
|
59
|
+
metadata: Record<string, any>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* AgentAppConfig - Silent alias for AgentOSConfig (backward compatibility)
|
|
63
|
+
* @deprecated Use AgentOSConfig instead
|
|
64
|
+
*/
|
|
65
|
+
export type AgentAppConfig = AgentOSConfig;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentOS Configuration
|
|
4
|
+
*
|
|
5
|
+
* This module defines the configuration interface for AgentOS.
|
|
6
|
+
* It follows PraisonAI's principle of sensible defaults with explicit overrides.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const config: AgentOSConfig = {
|
|
11
|
+
* name: 'My AI App',
|
|
12
|
+
* port: 9000,
|
|
13
|
+
* debug: true
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DEFAULT_AGENTOS_CONFIG = void 0;
|
|
19
|
+
exports.mergeConfig = mergeConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Default configuration values for AgentOS.
|
|
22
|
+
*/
|
|
23
|
+
exports.DEFAULT_AGENTOS_CONFIG = {
|
|
24
|
+
name: 'PraisonAI App',
|
|
25
|
+
host: '0.0.0.0',
|
|
26
|
+
port: 8000,
|
|
27
|
+
reload: false,
|
|
28
|
+
corsOrigins: ['*'],
|
|
29
|
+
apiPrefix: '/api',
|
|
30
|
+
docsUrl: '/docs',
|
|
31
|
+
openapiUrl: '/openapi.json',
|
|
32
|
+
debug: false,
|
|
33
|
+
logLevel: 'info',
|
|
34
|
+
workers: 1,
|
|
35
|
+
timeout: 60,
|
|
36
|
+
metadata: {},
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Merge user config with defaults.
|
|
40
|
+
*/
|
|
41
|
+
function mergeConfig(userConfig) {
|
|
42
|
+
return {
|
|
43
|
+
...exports.DEFAULT_AGENTOS_CONFIG,
|
|
44
|
+
...userConfig,
|
|
45
|
+
metadata: {
|
|
46
|
+
...exports.DEFAULT_AGENTOS_CONFIG.metadata,
|
|
47
|
+
...userConfig?.metadata,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Module for Production Deployment of AI Agents
|
|
3
|
+
*
|
|
4
|
+
* This module provides AgentOS, a production platform for deploying
|
|
5
|
+
* agents as web services with REST endpoints.
|
|
6
|
+
*
|
|
7
|
+
* AgentOS, AgentOSConfig, AgentOSProtocol are the primary names (v1.0+).
|
|
8
|
+
* AgentApp, AgentAppConfig, AgentAppProtocol are silent aliases for backward compatibility.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { AgentOS, Agent } from 'praisonai';
|
|
13
|
+
*
|
|
14
|
+
* const assistant = new Agent({
|
|
15
|
+
* name: 'assistant',
|
|
16
|
+
* instructions: 'Be helpful'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const app = new AgentOS({
|
|
20
|
+
* name: 'My AI App',
|
|
21
|
+
* agents: [assistant],
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* await app.serve({ port: 8000 });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export { AgentOSConfig, AgentAppConfig, // Silent alias
|
|
28
|
+
DEFAULT_AGENTOS_CONFIG, mergeConfig, } from './config';
|
|
29
|
+
export { AgentOSProtocol, AgentAppProtocol, } from './protocols';
|
|
30
|
+
export { AgentOS, AgentApp, // Silent alias
|
|
31
|
+
AgentOSOptions, AgentAppOptions, } from './agentos';
|
package/dist/os/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* App Module for Production Deployment of AI Agents
|
|
4
|
+
*
|
|
5
|
+
* This module provides AgentOS, a production platform for deploying
|
|
6
|
+
* agents as web services with REST endpoints.
|
|
7
|
+
*
|
|
8
|
+
* AgentOS, AgentOSConfig, AgentOSProtocol are the primary names (v1.0+).
|
|
9
|
+
* AgentApp, AgentAppConfig, AgentAppProtocol are silent aliases for backward compatibility.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AgentOS, Agent } from 'praisonai';
|
|
14
|
+
*
|
|
15
|
+
* const assistant = new Agent({
|
|
16
|
+
* name: 'assistant',
|
|
17
|
+
* instructions: 'Be helpful'
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const app = new AgentOS({
|
|
21
|
+
* name: 'My AI App',
|
|
22
|
+
* agents: [assistant],
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* await app.serve({ port: 8000 });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AgentApp = exports.AgentOS = exports.mergeConfig = exports.DEFAULT_AGENTOS_CONFIG = void 0;
|
|
30
|
+
// Config
|
|
31
|
+
var config_1 = require("./config");
|
|
32
|
+
Object.defineProperty(exports, "DEFAULT_AGENTOS_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_AGENTOS_CONFIG; } });
|
|
33
|
+
Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return config_1.mergeConfig; } });
|
|
34
|
+
// Implementation
|
|
35
|
+
var agentos_1 = require("./agentos");
|
|
36
|
+
Object.defineProperty(exports, "AgentOS", { enumerable: true, get: function () { return agentos_1.AgentOS; } });
|
|
37
|
+
Object.defineProperty(exports, "AgentApp", { enumerable: true, get: function () { return agentos_1.AgentApp; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOS Protocol Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module defines the protocol (interface) for AgentOS implementations.
|
|
5
|
+
* The protocol is lightweight and lives in the core SDK.
|
|
6
|
+
*
|
|
7
|
+
* AgentOSProtocol is the primary name (v1.0+).
|
|
8
|
+
* AgentAppProtocol is a silent alias for backward compatibility.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { AgentOSProtocol, AgentOSConfig } from 'praisonai';
|
|
13
|
+
*
|
|
14
|
+
* class CustomAgentOS implements AgentOSProtocol {
|
|
15
|
+
* serve(options?: AgentOSConfig): Promise<void> { ... }
|
|
16
|
+
* getApp(): any { ... }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Protocol for AgentOS implementations.
|
|
22
|
+
*
|
|
23
|
+
* AgentOS is a production platform for deploying agents as web services.
|
|
24
|
+
* It wraps agents, teams, and flows into a unified API server.
|
|
25
|
+
*
|
|
26
|
+
* Implementations should:
|
|
27
|
+
* - Provide HTTP endpoints for agent interaction
|
|
28
|
+
* - Support health checks and monitoring endpoints
|
|
29
|
+
* - Handle agent lifecycle management
|
|
30
|
+
* - Provide CORS support for web clients
|
|
31
|
+
*/
|
|
32
|
+
export interface AgentOSProtocol {
|
|
33
|
+
/**
|
|
34
|
+
* Start the AgentOS server.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Server configuration options
|
|
37
|
+
* @returns Promise that resolves when server is ready
|
|
38
|
+
*/
|
|
39
|
+
serve(options?: {
|
|
40
|
+
host?: string;
|
|
41
|
+
port?: number;
|
|
42
|
+
reload?: boolean;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the underlying web application instance.
|
|
46
|
+
*
|
|
47
|
+
* @returns The Express/HTTP application instance for custom mounting or configuration
|
|
48
|
+
*/
|
|
49
|
+
getApp(): any;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* AgentAppProtocol - Silent alias for AgentOSProtocol (backward compatibility)
|
|
53
|
+
* @deprecated Use AgentOSProtocol instead
|
|
54
|
+
*/
|
|
55
|
+
export type AgentAppProtocol = AgentOSProtocol;
|