@agentxjs/types 0.0.9 → 0.2.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/dist/Agent-BXUYGlWZ.d.cts +510 -0
- package/dist/Agent-CaSxMF_E.d.ts +510 -0
- package/dist/CommandEvent-CbXzPolX.d.ts +495 -0
- package/dist/CommandEvent-DCdk7lzX.d.cts +495 -0
- package/dist/Container-DR-1g44i.d.ts +641 -0
- package/dist/Container-dBDOcjhk.d.cts +641 -0
- package/dist/ContentPart-CqOh-rI1.d.ts +19 -0
- package/dist/ContentPart-DEFnYXCU.d.cts +19 -0
- package/dist/DriveableEvent-Bj7nn-Uk.d.ts +161 -0
- package/dist/DriveableEvent-CCMC1h_C.d.cts +161 -0
- package/dist/ErrorMessage-BoIh3MIO.d.cts +24 -0
- package/dist/ErrorMessage-BoIh3MIO.d.ts +24 -0
- package/dist/ImageRecord-Cn0VcJWk.d.cts +71 -0
- package/dist/ImageRecord-Cn0VcJWk.d.ts +71 -0
- package/dist/LoggerFactory-DZtw0M7U.d.cts +129 -0
- package/dist/LoggerFactory-DZtw0M7U.d.ts +129 -0
- package/dist/Message-Crh81uLL.d.cts +45 -0
- package/dist/Message-DWQUt647.d.ts +45 -0
- package/dist/Persistence-BQkdKomV.d.ts +230 -0
- package/dist/Persistence-Dr70FEBh.d.cts +230 -0
- package/dist/StopReason-D4DthB1h.d.cts +39 -0
- package/dist/StopReason-D4DthB1h.d.ts +39 -0
- package/dist/SystemEvent-CPvvxdMQ.d.cts +159 -0
- package/dist/SystemEvent-CPvvxdMQ.d.ts +159 -0
- package/dist/ToolResultMessage-CDG2L7Zv.d.ts +332 -0
- package/dist/ToolResultMessage-CRKMSf5d.d.cts +332 -0
- package/dist/agent-internal.cjs +19 -0
- package/dist/agent-internal.cjs.map +1 -0
- package/dist/agent-internal.d.cts +52 -0
- package/dist/agent-internal.d.ts +52 -0
- package/dist/agent-internal.js +1 -0
- package/dist/agent-internal.js.map +1 -0
- package/dist/agent.cjs +70 -0
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.cts +229 -0
- package/dist/agent.d.ts +229 -0
- package/dist/agent.js +41 -0
- package/dist/agent.js.map +1 -0
- package/dist/agentx.cjs +38 -0
- package/dist/agentx.cjs.map +1 -0
- package/dist/agentx.d.cts +311 -0
- package/dist/agentx.d.ts +311 -0
- package/dist/agentx.js +12 -0
- package/dist/agentx.js.map +1 -0
- package/dist/chunk-2QHAIM3V.js +1 -0
- package/dist/chunk-2QHAIM3V.js.map +1 -0
- package/dist/common.cjs +19 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +43 -0
- package/dist/common.d.ts +43 -0
- package/dist/common.js +2 -0
- package/dist/common.js.map +1 -0
- package/dist/event.cjs +184 -0
- package/dist/event.cjs.map +1 -0
- package/dist/event.d.cts +769 -0
- package/dist/event.d.ts +769 -0
- package/dist/event.js +134 -0
- package/dist/event.js.map +1 -0
- package/dist/index-CjFNcCxR.d.cts +299 -0
- package/dist/index-usKuk41S.d.ts +299 -0
- package/dist/index.cjs +2 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5267
- package/dist/index.d.ts +8 -5267
- package/dist/index.js +1 -150
- package/dist/index.js.map +1 -1
- package/dist/network.cjs +19 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.d.cts +168 -0
- package/dist/network.d.ts +168 -0
- package/dist/network.js +1 -0
- package/dist/network.js.map +1 -0
- package/dist/runtime-internal.cjs +19 -0
- package/dist/runtime-internal.cjs.map +1 -0
- package/dist/runtime-internal.d.cts +943 -0
- package/dist/runtime-internal.d.ts +943 -0
- package/dist/runtime-internal.js +1 -0
- package/dist/runtime-internal.js.map +1 -0
- package/dist/runtime.cjs +19 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +217 -0
- package/dist/runtime.d.ts +217 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +82 -10
- package/LICENSE +0 -21
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogLevel - Standard log level type
|
|
3
|
+
*
|
|
4
|
+
* Defines the severity levels for logging.
|
|
5
|
+
* Uses string literal types for better readability and type safety.
|
|
6
|
+
*/
|
|
7
|
+
type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Logger - Standard logging interface
|
|
11
|
+
*
|
|
12
|
+
* Platform-agnostic logging interface that can be implemented
|
|
13
|
+
* by any logging library (console, pino, winston, etc.)
|
|
14
|
+
*
|
|
15
|
+
* Similar to SLF4J's Logger interface in Java.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Logging context metadata
|
|
20
|
+
*/
|
|
21
|
+
type LogContext = Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Logger interface
|
|
24
|
+
*
|
|
25
|
+
* All logger implementations must follow this interface.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class PinoLogger implements Logger {
|
|
30
|
+
* private pino: Pino.Logger;
|
|
31
|
+
*
|
|
32
|
+
* constructor(name: string) {
|
|
33
|
+
* this.pino = pino({ name });
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* get name() { return this.pino.name; }
|
|
37
|
+
* get level() { return LogLevel.DEBUG; }
|
|
38
|
+
*
|
|
39
|
+
* debug(message: string, context?: LogContext) {
|
|
40
|
+
* this.pino.debug(context, message);
|
|
41
|
+
* }
|
|
42
|
+
* // ... other methods
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
interface Logger {
|
|
47
|
+
/**
|
|
48
|
+
* Logger name (typically class name or module path)
|
|
49
|
+
*/
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/**
|
|
52
|
+
* Current log level
|
|
53
|
+
*/
|
|
54
|
+
readonly level: LogLevel;
|
|
55
|
+
/**
|
|
56
|
+
* Log debug message
|
|
57
|
+
*/
|
|
58
|
+
debug(message: string, context?: LogContext): void;
|
|
59
|
+
/**
|
|
60
|
+
* Log info message
|
|
61
|
+
*/
|
|
62
|
+
info(message: string, context?: LogContext): void;
|
|
63
|
+
/**
|
|
64
|
+
* Log warning message
|
|
65
|
+
*/
|
|
66
|
+
warn(message: string, context?: LogContext): void;
|
|
67
|
+
/**
|
|
68
|
+
* Log error message or Error object
|
|
69
|
+
*/
|
|
70
|
+
error(message: string | Error, context?: LogContext): void;
|
|
71
|
+
/**
|
|
72
|
+
* Check if debug level is enabled
|
|
73
|
+
*/
|
|
74
|
+
isDebugEnabled(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Check if info level is enabled
|
|
77
|
+
*/
|
|
78
|
+
isInfoEnabled(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Check if warn level is enabled
|
|
81
|
+
*/
|
|
82
|
+
isWarnEnabled(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Check if error level is enabled
|
|
85
|
+
*/
|
|
86
|
+
isErrorEnabled(): boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* LoggerFactory - Standard logger factory interface
|
|
91
|
+
*
|
|
92
|
+
* Factory for creating Logger instances. External implementations
|
|
93
|
+
* can provide their own LoggerFactory to integrate custom logging
|
|
94
|
+
* libraries (pino, winston, etc.)
|
|
95
|
+
*
|
|
96
|
+
* Similar to SLF4J's LoggerFactory in Java.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Custom pino-based factory
|
|
101
|
+
* const pinoFactory: LoggerFactory = {
|
|
102
|
+
* getLogger(name: string): Logger {
|
|
103
|
+
* return new PinoLogger(name);
|
|
104
|
+
* }
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* // Inject via Runtime
|
|
108
|
+
* const runtime = createNodeRuntime({
|
|
109
|
+
* loggerFactory: pinoFactory
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* LoggerFactory interface
|
|
116
|
+
*
|
|
117
|
+
* Factory for creating named Logger instances.
|
|
118
|
+
*/
|
|
119
|
+
interface LoggerFactory {
|
|
120
|
+
/**
|
|
121
|
+
* Get or create a logger with the specified name
|
|
122
|
+
*
|
|
123
|
+
* @param name - Logger name (typically class name or module path)
|
|
124
|
+
* @returns Logger instance
|
|
125
|
+
*/
|
|
126
|
+
getLogger(name: string): Logger;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type { LogLevel as L, Logger as a, LogContext as b, LoggerFactory as c };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage } from './ToolResultMessage-CRKMSf5d.cjs';
|
|
2
|
+
import { E as ErrorMessage } from './ErrorMessage-BoIh3MIO.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Message Subtype
|
|
6
|
+
*
|
|
7
|
+
* Represents the specific type/category of the message.
|
|
8
|
+
* Used together with role for serialization and type discrimination.
|
|
9
|
+
*/
|
|
10
|
+
type MessageSubtype = "user" | "assistant" | "tool-call" | "tool-result" | "error";
|
|
11
|
+
/**
|
|
12
|
+
* Message
|
|
13
|
+
*
|
|
14
|
+
* Discriminated union of all message types.
|
|
15
|
+
* Use `subtype` field for precise type discrimination.
|
|
16
|
+
*
|
|
17
|
+
* Role: Who sent it (user, assistant, tool, system, error)
|
|
18
|
+
* Subtype: What type of message (user, assistant, tool-call, tool-result, error)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* function handleMessage(msg: Message) {
|
|
23
|
+
* switch (msg.subtype) {
|
|
24
|
+
* case "user":
|
|
25
|
+
* console.log(msg.content);
|
|
26
|
+
* break;
|
|
27
|
+
* case "assistant":
|
|
28
|
+
* console.log(msg.content);
|
|
29
|
+
* break;
|
|
30
|
+
* case "tool-call":
|
|
31
|
+
* console.log(msg.toolCall.name);
|
|
32
|
+
* break;
|
|
33
|
+
* case "tool-result":
|
|
34
|
+
* console.log(msg.toolResult.output);
|
|
35
|
+
* break;
|
|
36
|
+
* case "error":
|
|
37
|
+
* console.log(msg.content);
|
|
38
|
+
* break;
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
type Message = UserMessage | AssistantMessage | ToolCallMessage | ToolResultMessage | ErrorMessage;
|
|
44
|
+
|
|
45
|
+
export type { Message as M, MessageSubtype as a };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage } from './ToolResultMessage-CDG2L7Zv.js';
|
|
2
|
+
import { E as ErrorMessage } from './ErrorMessage-BoIh3MIO.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Message Subtype
|
|
6
|
+
*
|
|
7
|
+
* Represents the specific type/category of the message.
|
|
8
|
+
* Used together with role for serialization and type discrimination.
|
|
9
|
+
*/
|
|
10
|
+
type MessageSubtype = "user" | "assistant" | "tool-call" | "tool-result" | "error";
|
|
11
|
+
/**
|
|
12
|
+
* Message
|
|
13
|
+
*
|
|
14
|
+
* Discriminated union of all message types.
|
|
15
|
+
* Use `subtype` field for precise type discrimination.
|
|
16
|
+
*
|
|
17
|
+
* Role: Who sent it (user, assistant, tool, system, error)
|
|
18
|
+
* Subtype: What type of message (user, assistant, tool-call, tool-result, error)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* function handleMessage(msg: Message) {
|
|
23
|
+
* switch (msg.subtype) {
|
|
24
|
+
* case "user":
|
|
25
|
+
* console.log(msg.content);
|
|
26
|
+
* break;
|
|
27
|
+
* case "assistant":
|
|
28
|
+
* console.log(msg.content);
|
|
29
|
+
* break;
|
|
30
|
+
* case "tool-call":
|
|
31
|
+
* console.log(msg.toolCall.name);
|
|
32
|
+
* break;
|
|
33
|
+
* case "tool-result":
|
|
34
|
+
* console.log(msg.toolResult.output);
|
|
35
|
+
* break;
|
|
36
|
+
* case "error":
|
|
37
|
+
* console.log(msg.content);
|
|
38
|
+
* break;
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
type Message = UserMessage | AssistantMessage | ToolCallMessage | ToolResultMessage | ErrorMessage;
|
|
44
|
+
|
|
45
|
+
export type { Message as M, MessageSubtype as a };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { I as ImageRecord, a as ImageMetadata } from './ImageRecord-Cn0VcJWk.js';
|
|
2
|
+
import { M as Message } from './Message-DWQUt647.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ImageRepository - Persistence interface for agent images
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ImageRepository - Storage operations for images
|
|
10
|
+
*/
|
|
11
|
+
interface ImageRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Save an image record (create or update)
|
|
14
|
+
*/
|
|
15
|
+
saveImage(record: ImageRecord): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Find image by ID
|
|
18
|
+
*/
|
|
19
|
+
findImageById(imageId: string): Promise<ImageRecord | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Find all images
|
|
22
|
+
*/
|
|
23
|
+
findAllImages(): Promise<ImageRecord[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Find images by agent name
|
|
26
|
+
*/
|
|
27
|
+
findImagesByName(name: string): Promise<ImageRecord[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Find images by container ID
|
|
30
|
+
*/
|
|
31
|
+
findImagesByContainerId(containerId: string): Promise<ImageRecord[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Delete image by ID
|
|
34
|
+
*/
|
|
35
|
+
deleteImage(imageId: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Check if image exists
|
|
38
|
+
*/
|
|
39
|
+
imageExists(imageId: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Update image metadata (e.g., Claude SDK session ID)
|
|
42
|
+
* Merges with existing metadata
|
|
43
|
+
*/
|
|
44
|
+
updateMetadata(imageId: string, metadata: Partial<ImageMetadata>): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ContainerRecord - Storage record for Container
|
|
49
|
+
*
|
|
50
|
+
* Represents a logical container (resource isolation unit).
|
|
51
|
+
* Each container provides an isolated environment for running Agents.
|
|
52
|
+
*
|
|
53
|
+
* In multi-tenant scenarios:
|
|
54
|
+
* - Application layer maps tenant → containerId
|
|
55
|
+
* - ContainerManager manages containers
|
|
56
|
+
* - Each container has its own Sandbox (workspace, LLM config)
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Container configuration (extensible)
|
|
60
|
+
*
|
|
61
|
+
* Future configurations may include:
|
|
62
|
+
* - Resource quotas (max tokens, max agents)
|
|
63
|
+
* - Custom workspace path
|
|
64
|
+
* - LLM provider overrides
|
|
65
|
+
*/
|
|
66
|
+
interface ContainerConfig {
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ContainerRecord - Persistent container data
|
|
71
|
+
*
|
|
72
|
+
* Stored in Repository for container lifecycle management.
|
|
73
|
+
*/
|
|
74
|
+
interface ContainerRecord {
|
|
75
|
+
/** Unique container identifier (auto-generated on create) */
|
|
76
|
+
containerId: string;
|
|
77
|
+
/** Container creation timestamp */
|
|
78
|
+
createdAt: number;
|
|
79
|
+
/** Last update timestamp */
|
|
80
|
+
updatedAt: number;
|
|
81
|
+
/** Container configuration (extensible for future needs) */
|
|
82
|
+
config?: ContainerConfig;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* ContainerRepository - Persistence interface for containers
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ContainerRepository - Storage operations for containers
|
|
91
|
+
*/
|
|
92
|
+
interface ContainerRepository {
|
|
93
|
+
/**
|
|
94
|
+
* Save a container record (create or update)
|
|
95
|
+
*/
|
|
96
|
+
saveContainer(record: ContainerRecord): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Find container by ID
|
|
99
|
+
*/
|
|
100
|
+
findContainerById(containerId: string): Promise<ContainerRecord | null>;
|
|
101
|
+
/**
|
|
102
|
+
* Find all containers
|
|
103
|
+
*/
|
|
104
|
+
findAllContainers(): Promise<ContainerRecord[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Delete container by ID
|
|
107
|
+
*/
|
|
108
|
+
deleteContainer(containerId: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if container exists
|
|
111
|
+
*/
|
|
112
|
+
containerExists(containerId: string): Promise<boolean>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* SessionRecord - Storage schema for Session persistence
|
|
117
|
+
*
|
|
118
|
+
* Session stores conversation messages for an Image.
|
|
119
|
+
* Each Image has exactly one Session.
|
|
120
|
+
*/
|
|
121
|
+
/**
|
|
122
|
+
* Session storage record
|
|
123
|
+
*/
|
|
124
|
+
interface SessionRecord {
|
|
125
|
+
/**
|
|
126
|
+
* Unique session identifier
|
|
127
|
+
*/
|
|
128
|
+
sessionId: string;
|
|
129
|
+
/**
|
|
130
|
+
* Associated image ID (owner of this session)
|
|
131
|
+
*/
|
|
132
|
+
imageId: string;
|
|
133
|
+
/**
|
|
134
|
+
* Container this session belongs to
|
|
135
|
+
*/
|
|
136
|
+
containerId: string;
|
|
137
|
+
/**
|
|
138
|
+
* Creation timestamp (Unix milliseconds)
|
|
139
|
+
*/
|
|
140
|
+
createdAt: number;
|
|
141
|
+
/**
|
|
142
|
+
* Last update timestamp (Unix milliseconds)
|
|
143
|
+
*/
|
|
144
|
+
updatedAt: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* SessionRepository - Persistence interface for sessions
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* SessionRepository - Storage operations for sessions
|
|
153
|
+
*/
|
|
154
|
+
interface SessionRepository {
|
|
155
|
+
/**
|
|
156
|
+
* Save a session record (create or update)
|
|
157
|
+
*/
|
|
158
|
+
saveSession(record: SessionRecord): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Find session by ID
|
|
161
|
+
*/
|
|
162
|
+
findSessionById(sessionId: string): Promise<SessionRecord | null>;
|
|
163
|
+
/**
|
|
164
|
+
* Find session by image ID
|
|
165
|
+
*/
|
|
166
|
+
findSessionByImageId(imageId: string): Promise<SessionRecord | null>;
|
|
167
|
+
/**
|
|
168
|
+
* Find all sessions for a container
|
|
169
|
+
*/
|
|
170
|
+
findSessionsByContainerId(containerId: string): Promise<SessionRecord[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Find all sessions
|
|
173
|
+
*/
|
|
174
|
+
findAllSessions(): Promise<SessionRecord[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Delete session by ID
|
|
177
|
+
*/
|
|
178
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Check if session exists
|
|
181
|
+
*/
|
|
182
|
+
sessionExists(sessionId: string): Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* Add a message to a session
|
|
185
|
+
*/
|
|
186
|
+
addMessage(sessionId: string, message: Message): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Get all messages for a session
|
|
189
|
+
*/
|
|
190
|
+
getMessages(sessionId: string): Promise<Message[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Clear all messages for a session
|
|
193
|
+
*/
|
|
194
|
+
clearMessages(sessionId: string): Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Persistence - Unified storage interface
|
|
199
|
+
*
|
|
200
|
+
* Symmetric with Runtime:
|
|
201
|
+
* - Runtime: event handling
|
|
202
|
+
* - Persistence: data storage
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* // Access via domain-specific repositories
|
|
207
|
+
* await persistence.images.findById(imageId);
|
|
208
|
+
* await persistence.sessions.findByContainerId(containerId);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Persistence - Unified storage interface with domain-specific access
|
|
214
|
+
*/
|
|
215
|
+
interface Persistence {
|
|
216
|
+
/**
|
|
217
|
+
* Image storage operations
|
|
218
|
+
*/
|
|
219
|
+
readonly images: ImageRepository;
|
|
220
|
+
/**
|
|
221
|
+
* Container storage operations
|
|
222
|
+
*/
|
|
223
|
+
readonly containers: ContainerRepository;
|
|
224
|
+
/**
|
|
225
|
+
* Session storage operations
|
|
226
|
+
*/
|
|
227
|
+
readonly sessions: SessionRepository;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type { ContainerRepository as C, ImageRepository as I, Persistence as P, SessionRepository as S, ContainerRecord as a, SessionRecord as b, ContainerConfig as c };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { I as ImageRecord, a as ImageMetadata } from './ImageRecord-Cn0VcJWk.cjs';
|
|
2
|
+
import { M as Message } from './Message-Crh81uLL.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ImageRepository - Persistence interface for agent images
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ImageRepository - Storage operations for images
|
|
10
|
+
*/
|
|
11
|
+
interface ImageRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Save an image record (create or update)
|
|
14
|
+
*/
|
|
15
|
+
saveImage(record: ImageRecord): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Find image by ID
|
|
18
|
+
*/
|
|
19
|
+
findImageById(imageId: string): Promise<ImageRecord | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Find all images
|
|
22
|
+
*/
|
|
23
|
+
findAllImages(): Promise<ImageRecord[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Find images by agent name
|
|
26
|
+
*/
|
|
27
|
+
findImagesByName(name: string): Promise<ImageRecord[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Find images by container ID
|
|
30
|
+
*/
|
|
31
|
+
findImagesByContainerId(containerId: string): Promise<ImageRecord[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Delete image by ID
|
|
34
|
+
*/
|
|
35
|
+
deleteImage(imageId: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Check if image exists
|
|
38
|
+
*/
|
|
39
|
+
imageExists(imageId: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Update image metadata (e.g., Claude SDK session ID)
|
|
42
|
+
* Merges with existing metadata
|
|
43
|
+
*/
|
|
44
|
+
updateMetadata(imageId: string, metadata: Partial<ImageMetadata>): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ContainerRecord - Storage record for Container
|
|
49
|
+
*
|
|
50
|
+
* Represents a logical container (resource isolation unit).
|
|
51
|
+
* Each container provides an isolated environment for running Agents.
|
|
52
|
+
*
|
|
53
|
+
* In multi-tenant scenarios:
|
|
54
|
+
* - Application layer maps tenant → containerId
|
|
55
|
+
* - ContainerManager manages containers
|
|
56
|
+
* - Each container has its own Sandbox (workspace, LLM config)
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Container configuration (extensible)
|
|
60
|
+
*
|
|
61
|
+
* Future configurations may include:
|
|
62
|
+
* - Resource quotas (max tokens, max agents)
|
|
63
|
+
* - Custom workspace path
|
|
64
|
+
* - LLM provider overrides
|
|
65
|
+
*/
|
|
66
|
+
interface ContainerConfig {
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ContainerRecord - Persistent container data
|
|
71
|
+
*
|
|
72
|
+
* Stored in Repository for container lifecycle management.
|
|
73
|
+
*/
|
|
74
|
+
interface ContainerRecord {
|
|
75
|
+
/** Unique container identifier (auto-generated on create) */
|
|
76
|
+
containerId: string;
|
|
77
|
+
/** Container creation timestamp */
|
|
78
|
+
createdAt: number;
|
|
79
|
+
/** Last update timestamp */
|
|
80
|
+
updatedAt: number;
|
|
81
|
+
/** Container configuration (extensible for future needs) */
|
|
82
|
+
config?: ContainerConfig;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* ContainerRepository - Persistence interface for containers
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ContainerRepository - Storage operations for containers
|
|
91
|
+
*/
|
|
92
|
+
interface ContainerRepository {
|
|
93
|
+
/**
|
|
94
|
+
* Save a container record (create or update)
|
|
95
|
+
*/
|
|
96
|
+
saveContainer(record: ContainerRecord): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Find container by ID
|
|
99
|
+
*/
|
|
100
|
+
findContainerById(containerId: string): Promise<ContainerRecord | null>;
|
|
101
|
+
/**
|
|
102
|
+
* Find all containers
|
|
103
|
+
*/
|
|
104
|
+
findAllContainers(): Promise<ContainerRecord[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Delete container by ID
|
|
107
|
+
*/
|
|
108
|
+
deleteContainer(containerId: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if container exists
|
|
111
|
+
*/
|
|
112
|
+
containerExists(containerId: string): Promise<boolean>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* SessionRecord - Storage schema for Session persistence
|
|
117
|
+
*
|
|
118
|
+
* Session stores conversation messages for an Image.
|
|
119
|
+
* Each Image has exactly one Session.
|
|
120
|
+
*/
|
|
121
|
+
/**
|
|
122
|
+
* Session storage record
|
|
123
|
+
*/
|
|
124
|
+
interface SessionRecord {
|
|
125
|
+
/**
|
|
126
|
+
* Unique session identifier
|
|
127
|
+
*/
|
|
128
|
+
sessionId: string;
|
|
129
|
+
/**
|
|
130
|
+
* Associated image ID (owner of this session)
|
|
131
|
+
*/
|
|
132
|
+
imageId: string;
|
|
133
|
+
/**
|
|
134
|
+
* Container this session belongs to
|
|
135
|
+
*/
|
|
136
|
+
containerId: string;
|
|
137
|
+
/**
|
|
138
|
+
* Creation timestamp (Unix milliseconds)
|
|
139
|
+
*/
|
|
140
|
+
createdAt: number;
|
|
141
|
+
/**
|
|
142
|
+
* Last update timestamp (Unix milliseconds)
|
|
143
|
+
*/
|
|
144
|
+
updatedAt: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* SessionRepository - Persistence interface for sessions
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* SessionRepository - Storage operations for sessions
|
|
153
|
+
*/
|
|
154
|
+
interface SessionRepository {
|
|
155
|
+
/**
|
|
156
|
+
* Save a session record (create or update)
|
|
157
|
+
*/
|
|
158
|
+
saveSession(record: SessionRecord): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Find session by ID
|
|
161
|
+
*/
|
|
162
|
+
findSessionById(sessionId: string): Promise<SessionRecord | null>;
|
|
163
|
+
/**
|
|
164
|
+
* Find session by image ID
|
|
165
|
+
*/
|
|
166
|
+
findSessionByImageId(imageId: string): Promise<SessionRecord | null>;
|
|
167
|
+
/**
|
|
168
|
+
* Find all sessions for a container
|
|
169
|
+
*/
|
|
170
|
+
findSessionsByContainerId(containerId: string): Promise<SessionRecord[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Find all sessions
|
|
173
|
+
*/
|
|
174
|
+
findAllSessions(): Promise<SessionRecord[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Delete session by ID
|
|
177
|
+
*/
|
|
178
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Check if session exists
|
|
181
|
+
*/
|
|
182
|
+
sessionExists(sessionId: string): Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* Add a message to a session
|
|
185
|
+
*/
|
|
186
|
+
addMessage(sessionId: string, message: Message): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Get all messages for a session
|
|
189
|
+
*/
|
|
190
|
+
getMessages(sessionId: string): Promise<Message[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Clear all messages for a session
|
|
193
|
+
*/
|
|
194
|
+
clearMessages(sessionId: string): Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Persistence - Unified storage interface
|
|
199
|
+
*
|
|
200
|
+
* Symmetric with Runtime:
|
|
201
|
+
* - Runtime: event handling
|
|
202
|
+
* - Persistence: data storage
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* // Access via domain-specific repositories
|
|
207
|
+
* await persistence.images.findById(imageId);
|
|
208
|
+
* await persistence.sessions.findByContainerId(containerId);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Persistence - Unified storage interface with domain-specific access
|
|
214
|
+
*/
|
|
215
|
+
interface Persistence {
|
|
216
|
+
/**
|
|
217
|
+
* Image storage operations
|
|
218
|
+
*/
|
|
219
|
+
readonly images: ImageRepository;
|
|
220
|
+
/**
|
|
221
|
+
* Container storage operations
|
|
222
|
+
*/
|
|
223
|
+
readonly containers: ContainerRepository;
|
|
224
|
+
/**
|
|
225
|
+
* Session storage operations
|
|
226
|
+
*/
|
|
227
|
+
readonly sessions: SessionRepository;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type { ContainerRepository as C, ImageRepository as I, Persistence as P, SessionRepository as S, ContainerRecord as a, SessionRecord as b, ContainerConfig as c };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reason why the LLM stopped generating
|
|
3
|
+
*
|
|
4
|
+
* Based on common stop reasons across multiple LLM providers:
|
|
5
|
+
* - Anthropic Claude: end_turn, max_tokens, tool_use, stop_sequence
|
|
6
|
+
* - OpenAI: stop, length, tool_calls, content_filter
|
|
7
|
+
* - Vercel AI SDK: stop, length, tool-calls, content-filter, error, other
|
|
8
|
+
*/
|
|
9
|
+
type StopReason =
|
|
10
|
+
/**
|
|
11
|
+
* Natural completion - model decided to stop
|
|
12
|
+
*/
|
|
13
|
+
"end_turn"
|
|
14
|
+
/**
|
|
15
|
+
* Reached maximum token limit
|
|
16
|
+
*/
|
|
17
|
+
| "max_tokens"
|
|
18
|
+
/**
|
|
19
|
+
* Model requested tool usage
|
|
20
|
+
*/
|
|
21
|
+
| "tool_use"
|
|
22
|
+
/**
|
|
23
|
+
* Encountered a custom stop sequence
|
|
24
|
+
*/
|
|
25
|
+
| "stop_sequence"
|
|
26
|
+
/**
|
|
27
|
+
* Content filter triggered
|
|
28
|
+
*/
|
|
29
|
+
| "content_filter"
|
|
30
|
+
/**
|
|
31
|
+
* Error occurred during generation
|
|
32
|
+
*/
|
|
33
|
+
| "error"
|
|
34
|
+
/**
|
|
35
|
+
* Other/unknown reason
|
|
36
|
+
*/
|
|
37
|
+
| "other";
|
|
38
|
+
|
|
39
|
+
export type { StopReason as S };
|