art-framework 0.2.6 → 0.2.7
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/dist/index.cjs +23 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +447 -104
- package/dist/index.d.ts +447 -104
- package/dist/index.js +23 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
type UnsubscribeFunction = () => void;
|
|
2
4
|
interface Subscription<DataType, FilterType> {
|
|
3
5
|
id: string;
|
|
@@ -11,7 +13,7 @@ interface Subscription<DataType, FilterType> {
|
|
|
11
13
|
* A generic class for implementing a publish/subscribe pattern with filtering capabilities.
|
|
12
14
|
* Designed for decoupling components, particularly UI updates from backend events.
|
|
13
15
|
*/
|
|
14
|
-
declare class TypedSocket
|
|
16
|
+
declare class TypedSocket<DataType, FilterType = any> {
|
|
15
17
|
protected subscriptions: Map<string, Subscription<DataType, FilterType>>;
|
|
16
18
|
constructor();
|
|
17
19
|
/**
|
|
@@ -88,6 +90,306 @@ interface IProviderManager {
|
|
|
88
90
|
getAdapter(config: RuntimeProviderConfig): Promise<ManagedAdapterAccessor>;
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Defines the available logging levels, ordered from most verbose to least verbose.
|
|
95
|
+
*/
|
|
96
|
+
declare enum LogLevel {
|
|
97
|
+
/** Detailed debugging information, useful for development. */
|
|
98
|
+
DEBUG = 0,
|
|
99
|
+
/** General informational messages about application flow. */
|
|
100
|
+
INFO = 1,
|
|
101
|
+
/** Potential issues or unexpected situations that don't prevent execution. */
|
|
102
|
+
WARN = 2,
|
|
103
|
+
/** Errors that indicate a failure or problem. */
|
|
104
|
+
ERROR = 3
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configuration options for the static Logger class.
|
|
108
|
+
*/
|
|
109
|
+
interface LoggerConfig {
|
|
110
|
+
/** The minimum log level to output messages for. Messages below this level will be ignored. */
|
|
111
|
+
level: LogLevel;
|
|
112
|
+
/** An optional prefix string to prepend to all log messages (e.g., '[MyApp]'). Defaults to '[ART]'. */
|
|
113
|
+
prefix?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A simple static logger class for outputting messages to the console at different levels.
|
|
117
|
+
* Configuration is global via the static `configure` method.
|
|
118
|
+
*/
|
|
119
|
+
declare class Logger {
|
|
120
|
+
private static config;
|
|
121
|
+
/**
|
|
122
|
+
* Configures the static logger settings.
|
|
123
|
+
* @param config - A partial `LoggerConfig` object. Provided settings will override defaults.
|
|
124
|
+
*/
|
|
125
|
+
static configure(config: Partial<LoggerConfig>): void;
|
|
126
|
+
/**
|
|
127
|
+
* Logs a message at the DEBUG level.
|
|
128
|
+
* Only outputs if the configured log level is DEBUG.
|
|
129
|
+
* @param message - The main log message string.
|
|
130
|
+
* @param args - Additional arguments to include in the console output (e.g., objects, arrays).
|
|
131
|
+
*/
|
|
132
|
+
static debug(message: string, ...args: any[]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Logs a message at the INFO level.
|
|
135
|
+
* Outputs if the configured log level is INFO or DEBUG.
|
|
136
|
+
* @param message - The main log message string.
|
|
137
|
+
* @param args - Additional arguments to include in the console output.
|
|
138
|
+
*/
|
|
139
|
+
static info(message: string, ...args: any[]): void;
|
|
140
|
+
/**
|
|
141
|
+
* Logs a message at the WARN level.
|
|
142
|
+
* Outputs if the configured log level is WARN, INFO, or DEBUG.
|
|
143
|
+
* @param message - The main log message string.
|
|
144
|
+
* @param args - Additional arguments to include in the console output.
|
|
145
|
+
*/
|
|
146
|
+
static warn(message: string, ...args: any[]): void;
|
|
147
|
+
/**
|
|
148
|
+
* Logs a message at the ERROR level.
|
|
149
|
+
* Outputs if the configured log level is ERROR, WARN, INFO, or DEBUG.
|
|
150
|
+
* @param message - The main log message string.
|
|
151
|
+
* @param args - Additional arguments to include in the console output (often an error object).
|
|
152
|
+
*/
|
|
153
|
+
static error(message: string, ...args: any[]): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Defines standard error codes for the ART framework.
|
|
158
|
+
*/
|
|
159
|
+
declare enum ErrorCode {
|
|
160
|
+
INVALID_CONFIG = "INVALID_CONFIG",
|
|
161
|
+
MISSING_API_KEY = "MISSING_API_KEY",
|
|
162
|
+
STORAGE_ERROR = "STORAGE_ERROR",
|
|
163
|
+
THREAD_NOT_FOUND = "THREAD_NOT_FOUND",
|
|
164
|
+
SAVE_FAILED = "SAVE_FAILED",
|
|
165
|
+
LLM_PROVIDER_ERROR = "LLM_PROVIDER_ERROR",
|
|
166
|
+
PROMPT_GENERATION_FAILED = "PROMPT_GENERATION_FAILED",
|
|
167
|
+
OUTPUT_PARSING_FAILED = "OUTPUT_PARSING_FAILED",
|
|
168
|
+
PROMPT_ASSEMBLY_FAILED = "PROMPT_ASSEMBLY_FAILED",// Error during prompt template rendering or initial structure creation (legacy, might be removed)
|
|
169
|
+
PROMPT_FRAGMENT_NOT_FOUND = "PROMPT_FRAGMENT_NOT_FOUND",// Requested prompt fragment does not exist
|
|
170
|
+
PROMPT_VALIDATION_FAILED = "PROMPT_VALIDATION_FAILED",// Constructed prompt object failed schema validation
|
|
171
|
+
PROMPT_TRANSLATION_FAILED = "PROMPT_TRANSLATION_FAILED",// Added for Adapter translation
|
|
172
|
+
TOOL_NOT_FOUND = "TOOL_NOT_FOUND",
|
|
173
|
+
TOOL_SCHEMA_VALIDATION_FAILED = "TOOL_SCHEMA_VALIDATION_FAILED",
|
|
174
|
+
TOOL_EXECUTION_ERROR = "TOOL_EXECUTION_ERROR",// Generic tool execution error
|
|
175
|
+
TOOL_DISABLED = "TOOL_DISABLED",
|
|
176
|
+
PLANNING_FAILED = "PLANNING_FAILED",
|
|
177
|
+
TOOL_EXECUTION_FAILED = "TOOL_EXECUTION_FAILED",// Error within the ToolSystem execution loop
|
|
178
|
+
SYNTHESIS_FAILED = "SYNTHESIS_FAILED",
|
|
179
|
+
AGENT_PROCESSING_ERROR = "AGENT_PROCESSING_ERROR",// General error during agent.process
|
|
180
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
181
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
182
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
183
|
+
UNKNOWN_PROVIDER = "UNKNOWN_PROVIDER",// Checklist item 4.7
|
|
184
|
+
LOCAL_PROVIDER_CONFLICT = "LOCAL_PROVIDER_CONFLICT",// Checklist item 4.7
|
|
185
|
+
LOCAL_INSTANCE_BUSY = "LOCAL_INSTANCE_BUSY",// Checklist item 4.7
|
|
186
|
+
API_QUEUE_TIMEOUT = "API_QUEUE_TIMEOUT",// Checklist item 4.7 (optional)
|
|
187
|
+
ADAPTER_INSTANTIATION_ERROR = "ADAPTER_INSTANTIATION_ERROR"
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Custom error class for ART framework specific errors.
|
|
191
|
+
*/
|
|
192
|
+
declare class ARTError extends Error {
|
|
193
|
+
readonly code: ErrorCode;
|
|
194
|
+
readonly originalError?: Error;
|
|
195
|
+
constructor(message: string, code: ErrorCode, originalError?: Error);
|
|
196
|
+
toString(): string;
|
|
197
|
+
}
|
|
198
|
+
declare class UnknownProviderError extends ARTError {
|
|
199
|
+
constructor(providerName: string);
|
|
200
|
+
}
|
|
201
|
+
declare class LocalProviderConflictError extends ARTError {
|
|
202
|
+
constructor(requestedProvider: string, activeProvider: string);
|
|
203
|
+
}
|
|
204
|
+
declare class LocalInstanceBusyError extends ARTError {
|
|
205
|
+
constructor(providerName: string, modelId: string);
|
|
206
|
+
}
|
|
207
|
+
declare class ApiQueueTimeoutError extends ARTError {
|
|
208
|
+
constructor(providerName: string);
|
|
209
|
+
}
|
|
210
|
+
declare class AdapterInstantiationError extends ARTError {
|
|
211
|
+
constructor(providerName: string, originalError: Error);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Zod schema for validating a single ArtStandardMessage object.
|
|
216
|
+
*/
|
|
217
|
+
declare const ArtStandardMessageSchema: z.ZodEffects<z.ZodObject<{
|
|
218
|
+
role: z.ZodType<ArtStandardMessageRole, z.ZodTypeDef, ArtStandardMessageRole>;
|
|
219
|
+
content: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>;
|
|
220
|
+
name: z.ZodOptional<z.ZodString>;
|
|
221
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
222
|
+
id: z.ZodString;
|
|
223
|
+
type: z.ZodLiteral<"function">;
|
|
224
|
+
function: z.ZodObject<{
|
|
225
|
+
name: z.ZodString;
|
|
226
|
+
arguments: z.ZodString;
|
|
227
|
+
}, "strip", z.ZodTypeAny, {
|
|
228
|
+
name: string;
|
|
229
|
+
arguments: string;
|
|
230
|
+
}, {
|
|
231
|
+
name: string;
|
|
232
|
+
arguments: string;
|
|
233
|
+
}>;
|
|
234
|
+
}, "strip", z.ZodTypeAny, {
|
|
235
|
+
function: {
|
|
236
|
+
name: string;
|
|
237
|
+
arguments: string;
|
|
238
|
+
};
|
|
239
|
+
type: "function";
|
|
240
|
+
id: string;
|
|
241
|
+
}, {
|
|
242
|
+
function: {
|
|
243
|
+
name: string;
|
|
244
|
+
arguments: string;
|
|
245
|
+
};
|
|
246
|
+
type: "function";
|
|
247
|
+
id: string;
|
|
248
|
+
}>, "many">>;
|
|
249
|
+
tool_call_id: z.ZodOptional<z.ZodString>;
|
|
250
|
+
}, "strict", z.ZodTypeAny, {
|
|
251
|
+
role: ArtStandardMessageRole;
|
|
252
|
+
content: string | Record<string, any> | null;
|
|
253
|
+
name?: string | undefined;
|
|
254
|
+
tool_calls?: {
|
|
255
|
+
function: {
|
|
256
|
+
name: string;
|
|
257
|
+
arguments: string;
|
|
258
|
+
};
|
|
259
|
+
type: "function";
|
|
260
|
+
id: string;
|
|
261
|
+
}[] | undefined;
|
|
262
|
+
tool_call_id?: string | undefined;
|
|
263
|
+
}, {
|
|
264
|
+
role: ArtStandardMessageRole;
|
|
265
|
+
content: string | Record<string, any> | null;
|
|
266
|
+
name?: string | undefined;
|
|
267
|
+
tool_calls?: {
|
|
268
|
+
function: {
|
|
269
|
+
name: string;
|
|
270
|
+
arguments: string;
|
|
271
|
+
};
|
|
272
|
+
type: "function";
|
|
273
|
+
id: string;
|
|
274
|
+
}[] | undefined;
|
|
275
|
+
tool_call_id?: string | undefined;
|
|
276
|
+
}>, {
|
|
277
|
+
role: ArtStandardMessageRole;
|
|
278
|
+
content: string | Record<string, any> | null;
|
|
279
|
+
name?: string | undefined;
|
|
280
|
+
tool_calls?: {
|
|
281
|
+
function: {
|
|
282
|
+
name: string;
|
|
283
|
+
arguments: string;
|
|
284
|
+
};
|
|
285
|
+
type: "function";
|
|
286
|
+
id: string;
|
|
287
|
+
}[] | undefined;
|
|
288
|
+
tool_call_id?: string | undefined;
|
|
289
|
+
}, {
|
|
290
|
+
role: ArtStandardMessageRole;
|
|
291
|
+
content: string | Record<string, any> | null;
|
|
292
|
+
name?: string | undefined;
|
|
293
|
+
tool_calls?: {
|
|
294
|
+
function: {
|
|
295
|
+
name: string;
|
|
296
|
+
arguments: string;
|
|
297
|
+
};
|
|
298
|
+
type: "function";
|
|
299
|
+
id: string;
|
|
300
|
+
}[] | undefined;
|
|
301
|
+
tool_call_id?: string | undefined;
|
|
302
|
+
}>;
|
|
303
|
+
/**
|
|
304
|
+
* Zod schema for validating an entire ArtStandardPrompt (an array of messages).
|
|
305
|
+
*/
|
|
306
|
+
declare const ArtStandardPromptSchema: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
307
|
+
role: z.ZodType<ArtStandardMessageRole, z.ZodTypeDef, ArtStandardMessageRole>;
|
|
308
|
+
content: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodNull]>;
|
|
309
|
+
name: z.ZodOptional<z.ZodString>;
|
|
310
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
type: z.ZodLiteral<"function">;
|
|
313
|
+
function: z.ZodObject<{
|
|
314
|
+
name: z.ZodString;
|
|
315
|
+
arguments: z.ZodString;
|
|
316
|
+
}, "strip", z.ZodTypeAny, {
|
|
317
|
+
name: string;
|
|
318
|
+
arguments: string;
|
|
319
|
+
}, {
|
|
320
|
+
name: string;
|
|
321
|
+
arguments: string;
|
|
322
|
+
}>;
|
|
323
|
+
}, "strip", z.ZodTypeAny, {
|
|
324
|
+
function: {
|
|
325
|
+
name: string;
|
|
326
|
+
arguments: string;
|
|
327
|
+
};
|
|
328
|
+
type: "function";
|
|
329
|
+
id: string;
|
|
330
|
+
}, {
|
|
331
|
+
function: {
|
|
332
|
+
name: string;
|
|
333
|
+
arguments: string;
|
|
334
|
+
};
|
|
335
|
+
type: "function";
|
|
336
|
+
id: string;
|
|
337
|
+
}>, "many">>;
|
|
338
|
+
tool_call_id: z.ZodOptional<z.ZodString>;
|
|
339
|
+
}, "strict", z.ZodTypeAny, {
|
|
340
|
+
role: ArtStandardMessageRole;
|
|
341
|
+
content: string | Record<string, any> | null;
|
|
342
|
+
name?: string | undefined;
|
|
343
|
+
tool_calls?: {
|
|
344
|
+
function: {
|
|
345
|
+
name: string;
|
|
346
|
+
arguments: string;
|
|
347
|
+
};
|
|
348
|
+
type: "function";
|
|
349
|
+
id: string;
|
|
350
|
+
}[] | undefined;
|
|
351
|
+
tool_call_id?: string | undefined;
|
|
352
|
+
}, {
|
|
353
|
+
role: ArtStandardMessageRole;
|
|
354
|
+
content: string | Record<string, any> | null;
|
|
355
|
+
name?: string | undefined;
|
|
356
|
+
tool_calls?: {
|
|
357
|
+
function: {
|
|
358
|
+
name: string;
|
|
359
|
+
arguments: string;
|
|
360
|
+
};
|
|
361
|
+
type: "function";
|
|
362
|
+
id: string;
|
|
363
|
+
}[] | undefined;
|
|
364
|
+
tool_call_id?: string | undefined;
|
|
365
|
+
}>, {
|
|
366
|
+
role: ArtStandardMessageRole;
|
|
367
|
+
content: string | Record<string, any> | null;
|
|
368
|
+
name?: string | undefined;
|
|
369
|
+
tool_calls?: {
|
|
370
|
+
function: {
|
|
371
|
+
name: string;
|
|
372
|
+
arguments: string;
|
|
373
|
+
};
|
|
374
|
+
type: "function";
|
|
375
|
+
id: string;
|
|
376
|
+
}[] | undefined;
|
|
377
|
+
tool_call_id?: string | undefined;
|
|
378
|
+
}, {
|
|
379
|
+
role: ArtStandardMessageRole;
|
|
380
|
+
content: string | Record<string, any> | null;
|
|
381
|
+
name?: string | undefined;
|
|
382
|
+
tool_calls?: {
|
|
383
|
+
function: {
|
|
384
|
+
name: string;
|
|
385
|
+
arguments: string;
|
|
386
|
+
};
|
|
387
|
+
type: "function";
|
|
388
|
+
id: string;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
tool_call_id?: string | undefined;
|
|
391
|
+
}>, "many">;
|
|
392
|
+
|
|
91
393
|
/**
|
|
92
394
|
* Represents the role of a message sender in a conversation.
|
|
93
395
|
*/
|
|
@@ -338,7 +640,11 @@ interface ThreadConfig {
|
|
|
338
640
|
* Could include user preferences, accumulated knowledge, etc. (Less defined for v1.0)
|
|
339
641
|
*/
|
|
340
642
|
interface AgentState {
|
|
341
|
-
/**
|
|
643
|
+
/** The primary data payload of the agent's state. Structure is application-defined. */
|
|
644
|
+
data: any;
|
|
645
|
+
/** An optional version number for the agent's state, useful for migrations or tracking changes. */
|
|
646
|
+
version?: number;
|
|
647
|
+
/** Allows for other arbitrary properties to be stored in the agent's state. */
|
|
342
648
|
[key: string]: any;
|
|
343
649
|
}
|
|
344
650
|
/**
|
|
@@ -609,13 +915,65 @@ interface ObservationFilter {
|
|
|
609
915
|
/** Retrieve observations recorded after this Unix timestamp (milliseconds). */
|
|
610
916
|
afterTimestamp?: number;
|
|
611
917
|
}
|
|
918
|
+
/**
|
|
919
|
+
* Defines the strategy for saving AgentState.
|
|
920
|
+
* - 'explicit': AgentState is only saved when `StateManager.setAgentState()` is explicitly called by the agent.
|
|
921
|
+
* `StateManager.saveStateIfModified()` will be a no-op for AgentState persistence.
|
|
922
|
+
* - 'implicit': AgentState is loaded by `StateManager.loadThreadContext()`, and if modified by the agent,
|
|
923
|
+
* `StateManager.saveStateIfModified()` will attempt to automatically persist these changes
|
|
924
|
+
* by comparing the current state with a snapshot taken at load time.
|
|
925
|
+
* `StateManager.setAgentState()` will still work for explicit saves.
|
|
926
|
+
*/
|
|
927
|
+
type StateSavingStrategy = 'explicit' | 'implicit';
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Configuration for creating an ART instance.
|
|
931
|
+
*/
|
|
932
|
+
interface ArtInstanceConfig {
|
|
933
|
+
/**
|
|
934
|
+
* Configuration for the storage adapter.
|
|
935
|
+
* Can be a pre-configured `StorageAdapter` instance,
|
|
936
|
+
* or an object specifying the type and options for a built-in adapter.
|
|
937
|
+
* Example: `{ type: 'indexedDB', dbName: 'MyArtDB' }`
|
|
938
|
+
*/
|
|
939
|
+
storage: StorageAdapter | {
|
|
940
|
+
type: 'memory' | 'indexedDB';
|
|
941
|
+
dbName?: string;
|
|
942
|
+
version?: number;
|
|
943
|
+
objectStores?: any[];
|
|
944
|
+
};
|
|
945
|
+
/** Configuration for the ProviderManager, defining available LLM provider adapters. */
|
|
946
|
+
providers: ProviderManagerConfig;
|
|
947
|
+
/**
|
|
948
|
+
* The agent core implementation class to use.
|
|
949
|
+
* Defaults to `PESAgent` if not provided.
|
|
950
|
+
* Example: `MyCustomAgentClass`
|
|
951
|
+
*/
|
|
952
|
+
agentCore?: new (dependencies: any) => IAgentCore;
|
|
953
|
+
/** An optional array of tool executor instances to register at initialization. */
|
|
954
|
+
tools?: IToolExecutor[];
|
|
955
|
+
/**
|
|
956
|
+
* Defines the strategy for saving `AgentState`. Defaults to 'explicit'.
|
|
957
|
+
* - 'explicit': `AgentState` is only saved when `StateManager.setAgentState()` is explicitly called by the agent.
|
|
958
|
+
* `StateManager.saveStateIfModified()` will be a no-op for `AgentState` persistence.
|
|
959
|
+
* - 'implicit': `AgentState` is loaded by `StateManager.loadThreadContext()`. If modified by the agent,
|
|
960
|
+
* `StateManager.saveStateIfModified()` will attempt to automatically persist these changes.
|
|
961
|
+
* `StateManager.setAgentState()` will still work for explicit saves in this mode.
|
|
962
|
+
*/
|
|
963
|
+
stateSavingStrategy?: StateSavingStrategy;
|
|
964
|
+
/** Optional configuration for the framework's logger. */
|
|
965
|
+
logger?: {
|
|
966
|
+
/** Minimum log level to output. Defaults to 'info'. */
|
|
967
|
+
level?: LogLevel;
|
|
968
|
+
};
|
|
969
|
+
}
|
|
612
970
|
|
|
613
971
|
type StreamEventTypeFilter = StreamEvent['type'] | Array<StreamEvent['type']>;
|
|
614
972
|
/**
|
|
615
973
|
* A dedicated socket for broadcasting LLM stream events (`StreamEvent`) to UI subscribers.
|
|
616
974
|
* Extends the generic TypedSocket and implements filtering based on `StreamEvent.type`.
|
|
617
975
|
*/
|
|
618
|
-
declare class LLMStreamSocket extends TypedSocket
|
|
976
|
+
declare class LLMStreamSocket extends TypedSocket<StreamEvent, StreamEventTypeFilter> {
|
|
619
977
|
constructor();
|
|
620
978
|
/**
|
|
621
979
|
* Notifies subscribers about a new LLM stream event.
|
|
@@ -630,7 +988,7 @@ declare class LLMStreamSocket extends TypedSocket$1<StreamEvent, StreamEventType
|
|
|
630
988
|
* Allows filtering by ObservationType.
|
|
631
989
|
* Can optionally fetch historical observations from a repository.
|
|
632
990
|
*/
|
|
633
|
-
declare class ObservationSocket$1 extends TypedSocket
|
|
991
|
+
declare class ObservationSocket$1 extends TypedSocket<Observation, ObservationType | ObservationType[]> {
|
|
634
992
|
private observationRepository?;
|
|
635
993
|
constructor(observationRepository?: IObservationRepository);
|
|
636
994
|
/**
|
|
@@ -656,7 +1014,7 @@ declare class ObservationSocket$1 extends TypedSocket$1<Observation, Observation
|
|
|
656
1014
|
* Allows filtering by MessageRole.
|
|
657
1015
|
* Can optionally fetch historical messages from a repository.
|
|
658
1016
|
*/
|
|
659
|
-
declare class ConversationSocket$1 extends TypedSocket
|
|
1017
|
+
declare class ConversationSocket$1 extends TypedSocket<ConversationMessage, MessageRole | MessageRole[]> {
|
|
660
1018
|
private conversationRepository?;
|
|
661
1019
|
constructor(conversationRepository?: IConversationRepository);
|
|
662
1020
|
/**
|
|
@@ -867,6 +1225,17 @@ interface StateManager {
|
|
|
867
1225
|
* @returns A promise that resolves when the configuration is saved.
|
|
868
1226
|
*/
|
|
869
1227
|
setThreadConfig(threadId: string, config: ThreadConfig): Promise<void>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Sets or updates the AgentState for a specific thread.
|
|
1230
|
+
* This method allows an agent to explicitly persist its internal state.
|
|
1231
|
+
* It requires that a ThreadConfig already exists for the thread, which is typically
|
|
1232
|
+
* ensured by the application calling setThreadConfig() prior to agent execution.
|
|
1233
|
+
* @param threadId - The unique identifier of the thread.
|
|
1234
|
+
* @param state - The AgentState object to save.
|
|
1235
|
+
* @returns A promise that resolves when the state is saved.
|
|
1236
|
+
* @throws {ARTError} If no ThreadConfig exists for the threadId, or if the repository fails.
|
|
1237
|
+
*/
|
|
1238
|
+
setAgentState(threadId: string, state: AgentState): Promise<void>;
|
|
870
1239
|
}
|
|
871
1240
|
/**
|
|
872
1241
|
* Interface for managing conversation history.
|
|
@@ -911,7 +1280,7 @@ interface ObservationManager {
|
|
|
911
1280
|
/**
|
|
912
1281
|
* Generic interface for a typed publish/subscribe socket.
|
|
913
1282
|
*/
|
|
914
|
-
interface
|
|
1283
|
+
interface ITypedSocket<DataType, FilterType = any> {
|
|
915
1284
|
/**
|
|
916
1285
|
* Subscribes a callback function to receive data updates.
|
|
917
1286
|
* @param callback The function to call with new data.
|
|
@@ -945,13 +1314,13 @@ interface TypedSocket<DataType, FilterType = any> {
|
|
|
945
1314
|
* TypedSocket specifically for Observation data.
|
|
946
1315
|
* FilterType is ObservationType or array of ObservationType.
|
|
947
1316
|
*/
|
|
948
|
-
interface ObservationSocket extends
|
|
1317
|
+
interface ObservationSocket extends ITypedSocket<Observation, ObservationType | ObservationType[]> {
|
|
949
1318
|
}
|
|
950
1319
|
/**
|
|
951
1320
|
* TypedSocket specifically for ConversationMessage data.
|
|
952
1321
|
* FilterType is MessageRole or array of MessageRole.
|
|
953
1322
|
*/
|
|
954
|
-
interface ConversationSocket extends
|
|
1323
|
+
interface ConversationSocket extends ITypedSocket<ConversationMessage, MessageRole | MessageRole[]> {
|
|
955
1324
|
}
|
|
956
1325
|
|
|
957
1326
|
/**
|
|
@@ -1042,99 +1411,6 @@ interface ArtInstance {
|
|
|
1042
1411
|
readonly observationManager: ObservationManager;
|
|
1043
1412
|
}
|
|
1044
1413
|
|
|
1045
|
-
/**
|
|
1046
|
-
* Defines the available logging levels, ordered from most verbose to least verbose.
|
|
1047
|
-
*/
|
|
1048
|
-
declare enum LogLevel {
|
|
1049
|
-
/** Detailed debugging information, useful for development. */
|
|
1050
|
-
DEBUG = 0,
|
|
1051
|
-
/** General informational messages about application flow. */
|
|
1052
|
-
INFO = 1,
|
|
1053
|
-
/** Potential issues or unexpected situations that don't prevent execution. */
|
|
1054
|
-
WARN = 2,
|
|
1055
|
-
/** Errors that indicate a failure or problem. */
|
|
1056
|
-
ERROR = 3
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Configuration options for the static Logger class.
|
|
1060
|
-
*/
|
|
1061
|
-
interface LoggerConfig {
|
|
1062
|
-
/** The minimum log level to output messages for. Messages below this level will be ignored. */
|
|
1063
|
-
level: LogLevel;
|
|
1064
|
-
/** An optional prefix string to prepend to all log messages (e.g., '[MyApp]'). Defaults to '[ART]'. */
|
|
1065
|
-
prefix?: string;
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* A simple static logger class for outputting messages to the console at different levels.
|
|
1069
|
-
* Configuration is global via the static `configure` method.
|
|
1070
|
-
*/
|
|
1071
|
-
declare class Logger {
|
|
1072
|
-
private static config;
|
|
1073
|
-
/**
|
|
1074
|
-
* Configures the static logger settings.
|
|
1075
|
-
* @param config - A partial `LoggerConfig` object. Provided settings will override defaults.
|
|
1076
|
-
*/
|
|
1077
|
-
static configure(config: Partial<LoggerConfig>): void;
|
|
1078
|
-
/**
|
|
1079
|
-
* Logs a message at the DEBUG level.
|
|
1080
|
-
* Only outputs if the configured log level is DEBUG.
|
|
1081
|
-
* @param message - The main log message string.
|
|
1082
|
-
* @param args - Additional arguments to include in the console output (e.g., objects, arrays).
|
|
1083
|
-
*/
|
|
1084
|
-
static debug(message: string, ...args: any[]): void;
|
|
1085
|
-
/**
|
|
1086
|
-
* Logs a message at the INFO level.
|
|
1087
|
-
* Outputs if the configured log level is INFO or DEBUG.
|
|
1088
|
-
* @param message - The main log message string.
|
|
1089
|
-
* @param args - Additional arguments to include in the console output.
|
|
1090
|
-
*/
|
|
1091
|
-
static info(message: string, ...args: any[]): void;
|
|
1092
|
-
/**
|
|
1093
|
-
* Logs a message at the WARN level.
|
|
1094
|
-
* Outputs if the configured log level is WARN, INFO, or DEBUG.
|
|
1095
|
-
* @param message - The main log message string.
|
|
1096
|
-
* @param args - Additional arguments to include in the console output.
|
|
1097
|
-
*/
|
|
1098
|
-
static warn(message: string, ...args: any[]): void;
|
|
1099
|
-
/**
|
|
1100
|
-
* Logs a message at the ERROR level.
|
|
1101
|
-
* Outputs if the configured log level is ERROR, WARN, INFO, or DEBUG.
|
|
1102
|
-
* @param message - The main log message string.
|
|
1103
|
-
* @param args - Additional arguments to include in the console output (often an error object).
|
|
1104
|
-
*/
|
|
1105
|
-
static error(message: string, ...args: any[]): void;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
/**
|
|
1109
|
-
* Configuration for the Storage System adapter.
|
|
1110
|
-
*/
|
|
1111
|
-
interface StorageConfig {
|
|
1112
|
-
/** Specifies the type of storage adapter to use. */
|
|
1113
|
-
type: 'memory' | 'indexedDB';
|
|
1114
|
-
/** The name of the database to use (required for 'indexedDB'). */
|
|
1115
|
-
dbName?: string;
|
|
1116
|
-
/** Optional: Database version for schema migrations (for 'indexedDB'). Defaults might apply. */
|
|
1117
|
-
version?: number;
|
|
1118
|
-
/** Optional: Advanced configuration for IndexedDB object stores and indexes. Defaults are usually sufficient. */
|
|
1119
|
-
objectStores?: any[];
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* Configuration object required by the AgentFactory and createArtInstance function.
|
|
1123
|
-
*/
|
|
1124
|
-
interface AgentFactoryConfig {
|
|
1125
|
-
/** Configuration for the storage adapter. */
|
|
1126
|
-
storage: StorageConfig;
|
|
1127
|
-
/** Configuration for the Provider Manager, defining available adapters and rules. */
|
|
1128
|
-
providers: ProviderManagerConfig;
|
|
1129
|
-
/** Optional array of tool executor instances to register at initialization. */
|
|
1130
|
-
tools?: IToolExecutor[];
|
|
1131
|
-
/** Optional: Specify a different Agent Core implementation class (defaults to PESAgent). */
|
|
1132
|
-
agentCore?: new (dependencies: any) => IAgentCore;
|
|
1133
|
-
/** Optional: Configuration for the logger. */
|
|
1134
|
-
logger?: {
|
|
1135
|
-
level?: LogLevel;
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
1414
|
/**
|
|
1139
1415
|
* High-level factory function to create and initialize a complete ART framework instance.
|
|
1140
1416
|
* This simplifies the setup process by handling the instantiation and wiring of all
|
|
@@ -1150,7 +1426,7 @@ interface AgentFactoryConfig {
|
|
|
1150
1426
|
* });
|
|
1151
1427
|
* const response = await art.process({ query: "Calculate 5*5", threadId: "thread1" });
|
|
1152
1428
|
*/
|
|
1153
|
-
declare function createArtInstance(config:
|
|
1429
|
+
declare function createArtInstance(config: ArtInstanceConfig): Promise<ArtInstance>;
|
|
1154
1430
|
|
|
1155
1431
|
/**
|
|
1156
1432
|
* Defines the dependencies required by the PESAgent constructor.
|
|
@@ -1730,6 +2006,73 @@ declare class DeepSeekAdapter implements ProviderAdapter {
|
|
|
1730
2006
|
private translateToOpenAI;
|
|
1731
2007
|
}
|
|
1732
2008
|
|
|
2009
|
+
/**
|
|
2010
|
+
* Configuration options required for the `OllamaAdapter`.
|
|
2011
|
+
*/
|
|
2012
|
+
interface OllamaAdapterOptions {
|
|
2013
|
+
/**
|
|
2014
|
+
* The base URL for the Ollama API. Defaults to 'http://localhost:11434'.
|
|
2015
|
+
* The '/v1' suffix for OpenAI compatibility will be added automatically.
|
|
2016
|
+
*/
|
|
2017
|
+
ollamaBaseUrl?: string;
|
|
2018
|
+
/**
|
|
2019
|
+
* The default Ollama model ID to use (e.g., 'llama3', 'mistral').
|
|
2020
|
+
* This can be overridden by `RuntimeProviderConfig.modelId` or `CallOptions.model`.
|
|
2021
|
+
* It's recommended to set this if you primarily use one model with Ollama.
|
|
2022
|
+
*/
|
|
2023
|
+
defaultModel?: string;
|
|
2024
|
+
/**
|
|
2025
|
+
* API key for Ollama (if secured). Defaults to "ollama" as commonly used.
|
|
2026
|
+
*/
|
|
2027
|
+
apiKey?: string;
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Implements the `ProviderAdapter` interface for interacting with Ollama's
|
|
2031
|
+
* OpenAI-compatible API endpoint.
|
|
2032
|
+
*
|
|
2033
|
+
* Handles formatting requests, parsing responses, streaming, and tool use.
|
|
2034
|
+
*
|
|
2035
|
+
* @implements {ProviderAdapter}
|
|
2036
|
+
*/
|
|
2037
|
+
declare class OllamaAdapter implements ProviderAdapter {
|
|
2038
|
+
readonly providerName = "ollama";
|
|
2039
|
+
private client;
|
|
2040
|
+
private defaultModel?;
|
|
2041
|
+
private ollamaBaseUrl;
|
|
2042
|
+
/**
|
|
2043
|
+
* Creates an instance of the OllamaAdapter.
|
|
2044
|
+
* @param options - Configuration options.
|
|
2045
|
+
*/
|
|
2046
|
+
constructor(options: OllamaAdapterOptions);
|
|
2047
|
+
/**
|
|
2048
|
+
* Sends a request to the Ollama API.
|
|
2049
|
+
* Translates `ArtStandardPrompt` to the OpenAI format and handles streaming and tool use.
|
|
2050
|
+
*
|
|
2051
|
+
* @param {ArtStandardPrompt} prompt - The standardized prompt messages.
|
|
2052
|
+
* @param {CallOptions} options - Call options.
|
|
2053
|
+
* @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
|
|
2054
|
+
*/
|
|
2055
|
+
call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
|
|
2058
|
+
* This is a common utility function that can be shared or adapted from other OpenAI-compatible adapters.
|
|
2059
|
+
*/
|
|
2060
|
+
private translateToOpenAI;
|
|
2061
|
+
private mapArtMessageToOpenAIMessage;
|
|
2062
|
+
/**
|
|
2063
|
+
* Translates ART ToolSchema array to OpenAI's tool format.
|
|
2064
|
+
*/
|
|
2065
|
+
private translateArtToolsToOpenAI;
|
|
2066
|
+
/**
|
|
2067
|
+
* Optional method for graceful shutdown.
|
|
2068
|
+
* For Ollama, which is typically a separate local server, this adapter
|
|
2069
|
+
* doesn't manage persistent connections that need explicit closing.
|
|
2070
|
+
* The OpenAI client used internally might have its own cleanup, but
|
|
2071
|
+
* it's generally handled by garbage collection.
|
|
2072
|
+
*/
|
|
2073
|
+
shutdown(): Promise<void>;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
1733
2076
|
/**
|
|
1734
2077
|
* An ART Framework tool that safely evaluates mathematical expressions using the mathjs library.
|
|
1735
2078
|
* It supports basic arithmetic, variables via a scope, complex numbers, and a predefined list of safe functions.
|
|
@@ -1780,6 +2123,6 @@ declare const generateUUID: () => string;
|
|
|
1780
2123
|
*/
|
|
1781
2124
|
|
|
1782
2125
|
/** The current version of the ART Framework package. */
|
|
1783
|
-
declare const VERSION = "0.2.
|
|
2126
|
+
declare const VERSION = "0.2.7";
|
|
1784
2127
|
|
|
1785
|
-
export { type AgentFinalResponse, type AgentOptions, type AgentProps, type AgentState, AnthropicAdapter, type ArtInstance, type ArtStandardMessage, type ArtStandardMessageRole, type ArtStandardPrompt, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, type ConversationSocket, DeepSeekAdapter, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type IAgentCore, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LogLevel, Logger, type ManagedAdapterAccessor, type MessageOptions, MessageRole, ModelCapability, type Observation, type ObservationFilter, type ObservationManager, type ObservationSocket, ObservationType, OpenAIAdapter, OpenRouterAdapter, type OutputParser, PESAgent, type ParsedToolCall, type PromptContext, type PromptManager, type ProviderAdapter, type ProviderManagerConfig, type ReasoningEngine, type RuntimeProviderConfig, type StateManager, type StorageAdapter, type StreamEvent, type ThreadConfig, type ThreadContext, type ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem,
|
|
2128
|
+
export { ARTError, AdapterInstantiationError, type AgentFinalResponse, type AgentOptions, type AgentProps, type AgentState, AnthropicAdapter, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, type ConversationSocket, DeepSeekAdapter, ErrorCode, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type IAgentCore, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type ManagedAdapterAccessor, type MessageOptions, MessageRole, ModelCapability, type Observation, type ObservationFilter, type ObservationManager, type ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, OpenRouterAdapter, type OutputParser, PESAgent, type ParsedToolCall, type PromptContext, type PromptManager, type ProviderAdapter, type ProviderManagerConfig, type ReasoningEngine, type RuntimeProviderConfig, type StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type ThreadConfig, type ThreadContext, type ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, type UISystem, UnknownProviderError, type UnsubscribeFunction, VERSION, createArtInstance, generateUUID };
|