@agentxjs/runtime 0.1.1
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/README.md +598 -0
- package/dist/index.cjs +3214 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +131 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +3176 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Persistence } from '@agentxjs/types';
|
|
2
|
+
import { LLMProvider, ClaudeLLMConfig, Runtime } from '@agentxjs/types/runtime';
|
|
3
|
+
import { Environment, Persistence as Persistence$1, ImageRepository, ContainerRepository, SessionRepository } from '@agentxjs/types/runtime/internal';
|
|
4
|
+
import { Storage } from 'unstorage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* createRuntime - Factory for creating Runtime instances
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Runtime configuration
|
|
12
|
+
*/
|
|
13
|
+
interface RuntimeConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Persistence layer for data storage
|
|
16
|
+
*/
|
|
17
|
+
persistence: Persistence;
|
|
18
|
+
/**
|
|
19
|
+
* LLM provider for AI model access
|
|
20
|
+
*/
|
|
21
|
+
llmProvider: LLMProvider<ClaudeLLMConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional custom environment (for testing)
|
|
24
|
+
* If not provided, ClaudeEnvironment will be created from llmProvider
|
|
25
|
+
*/
|
|
26
|
+
environment?: Environment;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a Runtime instance
|
|
30
|
+
*
|
|
31
|
+
* @param config - Runtime configuration
|
|
32
|
+
* @returns Runtime instance
|
|
33
|
+
*/
|
|
34
|
+
declare function createRuntime(config: RuntimeConfig): Runtime;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* PersistenceImpl - Multi-backend Persistence implementation
|
|
38
|
+
*
|
|
39
|
+
* Uses unstorage for backend-agnostic storage.
|
|
40
|
+
* Supports: Memory, FileSystem, Redis, MongoDB, SQLite, MySQL, PostgreSQL
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Memory (default)
|
|
45
|
+
* const persistence = await createPersistence();
|
|
46
|
+
*
|
|
47
|
+
* // SQLite
|
|
48
|
+
* const persistence = await createPersistence({
|
|
49
|
+
* driver: "sqlite",
|
|
50
|
+
* path: "./data.db",
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // PostgreSQL
|
|
54
|
+
* const persistence = await createPersistence({
|
|
55
|
+
* driver: "postgresql",
|
|
56
|
+
* url: "postgres://user:pass@localhost:5432/agentx",
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Redis
|
|
60
|
+
* const persistence = await createPersistence({
|
|
61
|
+
* driver: "redis",
|
|
62
|
+
* url: "redis://localhost:6379",
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Storage driver type
|
|
69
|
+
*/
|
|
70
|
+
type StorageDriver = "memory" | "fs" | "redis" | "mongodb" | "sqlite" | "mysql" | "postgresql";
|
|
71
|
+
/**
|
|
72
|
+
* Persistence configuration
|
|
73
|
+
*/
|
|
74
|
+
interface PersistenceConfig {
|
|
75
|
+
/**
|
|
76
|
+
* Storage driver (default: "memory")
|
|
77
|
+
*/
|
|
78
|
+
driver?: StorageDriver;
|
|
79
|
+
/**
|
|
80
|
+
* File path (for sqlite, fs drivers)
|
|
81
|
+
* @example "./data.db" for sqlite
|
|
82
|
+
* @example "./data" for fs
|
|
83
|
+
*/
|
|
84
|
+
path?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Connection URL (for redis, mongodb, mysql, postgresql)
|
|
87
|
+
* @example "redis://localhost:6379"
|
|
88
|
+
* @example "mongodb://localhost:27017/agentx"
|
|
89
|
+
* @example "mysql://user:pass@localhost:3306/agentx"
|
|
90
|
+
* @example "postgres://user:pass@localhost:5432/agentx"
|
|
91
|
+
*/
|
|
92
|
+
url?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Custom unstorage instance (advanced)
|
|
95
|
+
*/
|
|
96
|
+
storage?: Storage;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* PersistenceImpl - Multi-backend Persistence implementation
|
|
100
|
+
*/
|
|
101
|
+
declare class PersistenceImpl implements Persistence$1 {
|
|
102
|
+
readonly images: ImageRepository;
|
|
103
|
+
readonly containers: ContainerRepository;
|
|
104
|
+
readonly sessions: SessionRepository;
|
|
105
|
+
private readonly storage;
|
|
106
|
+
/**
|
|
107
|
+
* Private constructor - use createPersistence() factory function
|
|
108
|
+
*/
|
|
109
|
+
private constructor();
|
|
110
|
+
/**
|
|
111
|
+
* Create a PersistenceImpl instance (async factory)
|
|
112
|
+
*/
|
|
113
|
+
static create(config?: PersistenceConfig): Promise<PersistenceImpl>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the underlying storage instance
|
|
116
|
+
*/
|
|
117
|
+
getStorage(): Storage;
|
|
118
|
+
/**
|
|
119
|
+
* Dispose and cleanup resources
|
|
120
|
+
*/
|
|
121
|
+
dispose(): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create Persistence instance (async)
|
|
125
|
+
*
|
|
126
|
+
* @param config - Configuration options
|
|
127
|
+
* @returns Promise<Persistence> instance
|
|
128
|
+
*/
|
|
129
|
+
declare function createPersistence(config?: PersistenceConfig): Promise<PersistenceImpl>;
|
|
130
|
+
|
|
131
|
+
export { type PersistenceConfig, type RuntimeConfig, type StorageDriver, createPersistence, createRuntime };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Persistence } from '@agentxjs/types';
|
|
2
|
+
import { LLMProvider, ClaudeLLMConfig, Runtime } from '@agentxjs/types/runtime';
|
|
3
|
+
import { Environment, Persistence as Persistence$1, ImageRepository, ContainerRepository, SessionRepository } from '@agentxjs/types/runtime/internal';
|
|
4
|
+
import { Storage } from 'unstorage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* createRuntime - Factory for creating Runtime instances
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Runtime configuration
|
|
12
|
+
*/
|
|
13
|
+
interface RuntimeConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Persistence layer for data storage
|
|
16
|
+
*/
|
|
17
|
+
persistence: Persistence;
|
|
18
|
+
/**
|
|
19
|
+
* LLM provider for AI model access
|
|
20
|
+
*/
|
|
21
|
+
llmProvider: LLMProvider<ClaudeLLMConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional custom environment (for testing)
|
|
24
|
+
* If not provided, ClaudeEnvironment will be created from llmProvider
|
|
25
|
+
*/
|
|
26
|
+
environment?: Environment;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a Runtime instance
|
|
30
|
+
*
|
|
31
|
+
* @param config - Runtime configuration
|
|
32
|
+
* @returns Runtime instance
|
|
33
|
+
*/
|
|
34
|
+
declare function createRuntime(config: RuntimeConfig): Runtime;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* PersistenceImpl - Multi-backend Persistence implementation
|
|
38
|
+
*
|
|
39
|
+
* Uses unstorage for backend-agnostic storage.
|
|
40
|
+
* Supports: Memory, FileSystem, Redis, MongoDB, SQLite, MySQL, PostgreSQL
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Memory (default)
|
|
45
|
+
* const persistence = await createPersistence();
|
|
46
|
+
*
|
|
47
|
+
* // SQLite
|
|
48
|
+
* const persistence = await createPersistence({
|
|
49
|
+
* driver: "sqlite",
|
|
50
|
+
* path: "./data.db",
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // PostgreSQL
|
|
54
|
+
* const persistence = await createPersistence({
|
|
55
|
+
* driver: "postgresql",
|
|
56
|
+
* url: "postgres://user:pass@localhost:5432/agentx",
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Redis
|
|
60
|
+
* const persistence = await createPersistence({
|
|
61
|
+
* driver: "redis",
|
|
62
|
+
* url: "redis://localhost:6379",
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Storage driver type
|
|
69
|
+
*/
|
|
70
|
+
type StorageDriver = "memory" | "fs" | "redis" | "mongodb" | "sqlite" | "mysql" | "postgresql";
|
|
71
|
+
/**
|
|
72
|
+
* Persistence configuration
|
|
73
|
+
*/
|
|
74
|
+
interface PersistenceConfig {
|
|
75
|
+
/**
|
|
76
|
+
* Storage driver (default: "memory")
|
|
77
|
+
*/
|
|
78
|
+
driver?: StorageDriver;
|
|
79
|
+
/**
|
|
80
|
+
* File path (for sqlite, fs drivers)
|
|
81
|
+
* @example "./data.db" for sqlite
|
|
82
|
+
* @example "./data" for fs
|
|
83
|
+
*/
|
|
84
|
+
path?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Connection URL (for redis, mongodb, mysql, postgresql)
|
|
87
|
+
* @example "redis://localhost:6379"
|
|
88
|
+
* @example "mongodb://localhost:27017/agentx"
|
|
89
|
+
* @example "mysql://user:pass@localhost:3306/agentx"
|
|
90
|
+
* @example "postgres://user:pass@localhost:5432/agentx"
|
|
91
|
+
*/
|
|
92
|
+
url?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Custom unstorage instance (advanced)
|
|
95
|
+
*/
|
|
96
|
+
storage?: Storage;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* PersistenceImpl - Multi-backend Persistence implementation
|
|
100
|
+
*/
|
|
101
|
+
declare class PersistenceImpl implements Persistence$1 {
|
|
102
|
+
readonly images: ImageRepository;
|
|
103
|
+
readonly containers: ContainerRepository;
|
|
104
|
+
readonly sessions: SessionRepository;
|
|
105
|
+
private readonly storage;
|
|
106
|
+
/**
|
|
107
|
+
* Private constructor - use createPersistence() factory function
|
|
108
|
+
*/
|
|
109
|
+
private constructor();
|
|
110
|
+
/**
|
|
111
|
+
* Create a PersistenceImpl instance (async factory)
|
|
112
|
+
*/
|
|
113
|
+
static create(config?: PersistenceConfig): Promise<PersistenceImpl>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the underlying storage instance
|
|
116
|
+
*/
|
|
117
|
+
getStorage(): Storage;
|
|
118
|
+
/**
|
|
119
|
+
* Dispose and cleanup resources
|
|
120
|
+
*/
|
|
121
|
+
dispose(): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create Persistence instance (async)
|
|
125
|
+
*
|
|
126
|
+
* @param config - Configuration options
|
|
127
|
+
* @returns Promise<Persistence> instance
|
|
128
|
+
*/
|
|
129
|
+
declare function createPersistence(config?: PersistenceConfig): Promise<PersistenceImpl>;
|
|
130
|
+
|
|
131
|
+
export { type PersistenceConfig, type RuntimeConfig, type StorageDriver, createPersistence, createRuntime };
|