@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,161 @@
|
|
|
1
|
+
import { S as SystemEvent } from './SystemEvent-CPvvxdMQ.js';
|
|
2
|
+
import { S as StopReason } from './StopReason-D4DthB1h.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DriveableEvent - Events from LLM that can drive Agent
|
|
6
|
+
*
|
|
7
|
+
* These are environment events with:
|
|
8
|
+
* - source: "environment"
|
|
9
|
+
* - category: "stream"
|
|
10
|
+
* - intent: "notification"
|
|
11
|
+
*
|
|
12
|
+
* Flow:
|
|
13
|
+
* 1. Receptor receives from Claude SDK
|
|
14
|
+
* 2. Receptor emits DriveableEvent to SystemBus
|
|
15
|
+
* 3. BusDriver listens and forwards to Agent
|
|
16
|
+
* 4. Agent Engine processes the event
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base interface for all LLM stream events
|
|
21
|
+
*
|
|
22
|
+
* All DriveableEvents have:
|
|
23
|
+
* - source: "environment" (from external LLM)
|
|
24
|
+
* - category: "stream" (streaming output)
|
|
25
|
+
* - intent: "notification" (informational, no action needed)
|
|
26
|
+
* - requestId: correlation with the original request
|
|
27
|
+
* - context: agent/image/session scope (inherited from SystemEvent)
|
|
28
|
+
*/
|
|
29
|
+
interface BaseStreamEvent<T extends string, D = unknown> extends SystemEvent<T, D, "environment", "stream", "notification"> {
|
|
30
|
+
/**
|
|
31
|
+
* Content block index (for multi-block responses)
|
|
32
|
+
*/
|
|
33
|
+
index?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Request ID for correlating events with the original message_send_request
|
|
36
|
+
*/
|
|
37
|
+
requestId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* MessageStartEvent - Emitted when streaming message begins
|
|
41
|
+
*/
|
|
42
|
+
interface MessageStartEvent extends BaseStreamEvent<"message_start", {
|
|
43
|
+
message: {
|
|
44
|
+
id: string;
|
|
45
|
+
model: string;
|
|
46
|
+
};
|
|
47
|
+
}> {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MessageDeltaEvent - Emitted with message-level updates
|
|
51
|
+
*/
|
|
52
|
+
interface MessageDeltaEvent extends BaseStreamEvent<"message_delta", {
|
|
53
|
+
usage?: {
|
|
54
|
+
inputTokens: number;
|
|
55
|
+
outputTokens: number;
|
|
56
|
+
};
|
|
57
|
+
}> {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* MessageStopEvent - Emitted when streaming message completes
|
|
61
|
+
*/
|
|
62
|
+
interface MessageStopEvent extends BaseStreamEvent<"message_stop", {
|
|
63
|
+
stopReason?: StopReason;
|
|
64
|
+
stopSequence?: string;
|
|
65
|
+
}> {
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* TextContentBlockStartEvent - Text block started
|
|
69
|
+
*/
|
|
70
|
+
interface TextContentBlockStartEvent extends BaseStreamEvent<"text_content_block_start", Record<string, never>> {
|
|
71
|
+
index: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* TextDeltaEvent - Incremental text output
|
|
75
|
+
*/
|
|
76
|
+
interface TextDeltaEvent extends BaseStreamEvent<"text_delta", {
|
|
77
|
+
text: string;
|
|
78
|
+
}> {
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* TextContentBlockStopEvent - Text block completed
|
|
82
|
+
*/
|
|
83
|
+
interface TextContentBlockStopEvent extends BaseStreamEvent<"text_content_block_stop", Record<string, never>> {
|
|
84
|
+
index: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* ToolUseContentBlockStartEvent - Tool use block started
|
|
88
|
+
*/
|
|
89
|
+
interface ToolUseContentBlockStartEvent extends BaseStreamEvent<"tool_use_content_block_start", {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
}> {
|
|
93
|
+
index: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* InputJsonDeltaEvent - Incremental tool input JSON
|
|
97
|
+
*/
|
|
98
|
+
interface InputJsonDeltaEvent extends BaseStreamEvent<"input_json_delta", {
|
|
99
|
+
partialJson: string;
|
|
100
|
+
}> {
|
|
101
|
+
index: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* ToolUseContentBlockStopEvent - Tool use block completed
|
|
105
|
+
*/
|
|
106
|
+
interface ToolUseContentBlockStopEvent extends BaseStreamEvent<"tool_use_content_block_stop", Record<string, never>> {
|
|
107
|
+
index: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ToolCallEvent - Tool call ready for execution
|
|
111
|
+
*/
|
|
112
|
+
interface ToolCallEvent extends BaseStreamEvent<"tool_call", {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
input: Record<string, unknown>;
|
|
116
|
+
}> {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* ToolResultEvent - Tool execution result
|
|
120
|
+
*/
|
|
121
|
+
interface ToolResultEvent extends BaseStreamEvent<"tool_result", {
|
|
122
|
+
toolUseId: string;
|
|
123
|
+
result: unknown;
|
|
124
|
+
isError?: boolean;
|
|
125
|
+
}> {
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* InterruptedEvent - Stream interrupted
|
|
129
|
+
*/
|
|
130
|
+
interface InterruptedEvent extends BaseStreamEvent<"interrupted", {
|
|
131
|
+
reason: "user_interrupt" | "timeout" | "error" | "system";
|
|
132
|
+
}> {
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* ErrorReceivedEvent - Error received from environment (e.g., Claude API error)
|
|
136
|
+
*
|
|
137
|
+
* This event drives the MealyMachine to produce:
|
|
138
|
+
* - error_occurred (StateEvent) → state transitions to "error"
|
|
139
|
+
* - error_message (MessageEvent) → displayed in chat
|
|
140
|
+
*/
|
|
141
|
+
interface ErrorReceivedEvent extends BaseStreamEvent<"error_received", {
|
|
142
|
+
/** Error message (human-readable) */
|
|
143
|
+
message: string;
|
|
144
|
+
/** Error code (e.g., "rate_limit_error", "api_error", "overloaded_error") */
|
|
145
|
+
errorCode?: string;
|
|
146
|
+
}> {
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* DriveableEvent - All events that can drive Agent
|
|
150
|
+
*/
|
|
151
|
+
type DriveableEvent = MessageStartEvent | MessageDeltaEvent | MessageStopEvent | TextContentBlockStartEvent | TextDeltaEvent | TextContentBlockStopEvent | ToolUseContentBlockStartEvent | InputJsonDeltaEvent | ToolUseContentBlockStopEvent | ToolCallEvent | ToolResultEvent | InterruptedEvent | ErrorReceivedEvent;
|
|
152
|
+
/**
|
|
153
|
+
* DriveableEventType - String literal union of all driveable event types
|
|
154
|
+
*/
|
|
155
|
+
type DriveableEventType = DriveableEvent["type"];
|
|
156
|
+
/**
|
|
157
|
+
* Type guard: is this a DriveableEvent?
|
|
158
|
+
*/
|
|
159
|
+
declare function isDriveableEvent(event: SystemEvent): event is DriveableEvent;
|
|
160
|
+
|
|
161
|
+
export { type DriveableEvent as D, type ErrorReceivedEvent as E, type InputJsonDeltaEvent as I, type MessageStartEvent as M, type TextContentBlockStartEvent as T, type DriveableEventType as a, type MessageDeltaEvent as b, type MessageStopEvent as c, type TextDeltaEvent as d, type TextContentBlockStopEvent as e, type ToolUseContentBlockStartEvent as f, type ToolUseContentBlockStopEvent as g, type ToolCallEvent as h, type ToolResultEvent as i, type InterruptedEvent as j, isDriveableEvent as k };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { S as SystemEvent } from './SystemEvent-CPvvxdMQ.cjs';
|
|
2
|
+
import { S as StopReason } from './StopReason-D4DthB1h.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DriveableEvent - Events from LLM that can drive Agent
|
|
6
|
+
*
|
|
7
|
+
* These are environment events with:
|
|
8
|
+
* - source: "environment"
|
|
9
|
+
* - category: "stream"
|
|
10
|
+
* - intent: "notification"
|
|
11
|
+
*
|
|
12
|
+
* Flow:
|
|
13
|
+
* 1. Receptor receives from Claude SDK
|
|
14
|
+
* 2. Receptor emits DriveableEvent to SystemBus
|
|
15
|
+
* 3. BusDriver listens and forwards to Agent
|
|
16
|
+
* 4. Agent Engine processes the event
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base interface for all LLM stream events
|
|
21
|
+
*
|
|
22
|
+
* All DriveableEvents have:
|
|
23
|
+
* - source: "environment" (from external LLM)
|
|
24
|
+
* - category: "stream" (streaming output)
|
|
25
|
+
* - intent: "notification" (informational, no action needed)
|
|
26
|
+
* - requestId: correlation with the original request
|
|
27
|
+
* - context: agent/image/session scope (inherited from SystemEvent)
|
|
28
|
+
*/
|
|
29
|
+
interface BaseStreamEvent<T extends string, D = unknown> extends SystemEvent<T, D, "environment", "stream", "notification"> {
|
|
30
|
+
/**
|
|
31
|
+
* Content block index (for multi-block responses)
|
|
32
|
+
*/
|
|
33
|
+
index?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Request ID for correlating events with the original message_send_request
|
|
36
|
+
*/
|
|
37
|
+
requestId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* MessageStartEvent - Emitted when streaming message begins
|
|
41
|
+
*/
|
|
42
|
+
interface MessageStartEvent extends BaseStreamEvent<"message_start", {
|
|
43
|
+
message: {
|
|
44
|
+
id: string;
|
|
45
|
+
model: string;
|
|
46
|
+
};
|
|
47
|
+
}> {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MessageDeltaEvent - Emitted with message-level updates
|
|
51
|
+
*/
|
|
52
|
+
interface MessageDeltaEvent extends BaseStreamEvent<"message_delta", {
|
|
53
|
+
usage?: {
|
|
54
|
+
inputTokens: number;
|
|
55
|
+
outputTokens: number;
|
|
56
|
+
};
|
|
57
|
+
}> {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* MessageStopEvent - Emitted when streaming message completes
|
|
61
|
+
*/
|
|
62
|
+
interface MessageStopEvent extends BaseStreamEvent<"message_stop", {
|
|
63
|
+
stopReason?: StopReason;
|
|
64
|
+
stopSequence?: string;
|
|
65
|
+
}> {
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* TextContentBlockStartEvent - Text block started
|
|
69
|
+
*/
|
|
70
|
+
interface TextContentBlockStartEvent extends BaseStreamEvent<"text_content_block_start", Record<string, never>> {
|
|
71
|
+
index: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* TextDeltaEvent - Incremental text output
|
|
75
|
+
*/
|
|
76
|
+
interface TextDeltaEvent extends BaseStreamEvent<"text_delta", {
|
|
77
|
+
text: string;
|
|
78
|
+
}> {
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* TextContentBlockStopEvent - Text block completed
|
|
82
|
+
*/
|
|
83
|
+
interface TextContentBlockStopEvent extends BaseStreamEvent<"text_content_block_stop", Record<string, never>> {
|
|
84
|
+
index: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* ToolUseContentBlockStartEvent - Tool use block started
|
|
88
|
+
*/
|
|
89
|
+
interface ToolUseContentBlockStartEvent extends BaseStreamEvent<"tool_use_content_block_start", {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
}> {
|
|
93
|
+
index: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* InputJsonDeltaEvent - Incremental tool input JSON
|
|
97
|
+
*/
|
|
98
|
+
interface InputJsonDeltaEvent extends BaseStreamEvent<"input_json_delta", {
|
|
99
|
+
partialJson: string;
|
|
100
|
+
}> {
|
|
101
|
+
index: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* ToolUseContentBlockStopEvent - Tool use block completed
|
|
105
|
+
*/
|
|
106
|
+
interface ToolUseContentBlockStopEvent extends BaseStreamEvent<"tool_use_content_block_stop", Record<string, never>> {
|
|
107
|
+
index: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ToolCallEvent - Tool call ready for execution
|
|
111
|
+
*/
|
|
112
|
+
interface ToolCallEvent extends BaseStreamEvent<"tool_call", {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
input: Record<string, unknown>;
|
|
116
|
+
}> {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* ToolResultEvent - Tool execution result
|
|
120
|
+
*/
|
|
121
|
+
interface ToolResultEvent extends BaseStreamEvent<"tool_result", {
|
|
122
|
+
toolUseId: string;
|
|
123
|
+
result: unknown;
|
|
124
|
+
isError?: boolean;
|
|
125
|
+
}> {
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* InterruptedEvent - Stream interrupted
|
|
129
|
+
*/
|
|
130
|
+
interface InterruptedEvent extends BaseStreamEvent<"interrupted", {
|
|
131
|
+
reason: "user_interrupt" | "timeout" | "error" | "system";
|
|
132
|
+
}> {
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* ErrorReceivedEvent - Error received from environment (e.g., Claude API error)
|
|
136
|
+
*
|
|
137
|
+
* This event drives the MealyMachine to produce:
|
|
138
|
+
* - error_occurred (StateEvent) → state transitions to "error"
|
|
139
|
+
* - error_message (MessageEvent) → displayed in chat
|
|
140
|
+
*/
|
|
141
|
+
interface ErrorReceivedEvent extends BaseStreamEvent<"error_received", {
|
|
142
|
+
/** Error message (human-readable) */
|
|
143
|
+
message: string;
|
|
144
|
+
/** Error code (e.g., "rate_limit_error", "api_error", "overloaded_error") */
|
|
145
|
+
errorCode?: string;
|
|
146
|
+
}> {
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* DriveableEvent - All events that can drive Agent
|
|
150
|
+
*/
|
|
151
|
+
type DriveableEvent = MessageStartEvent | MessageDeltaEvent | MessageStopEvent | TextContentBlockStartEvent | TextDeltaEvent | TextContentBlockStopEvent | ToolUseContentBlockStartEvent | InputJsonDeltaEvent | ToolUseContentBlockStopEvent | ToolCallEvent | ToolResultEvent | InterruptedEvent | ErrorReceivedEvent;
|
|
152
|
+
/**
|
|
153
|
+
* DriveableEventType - String literal union of all driveable event types
|
|
154
|
+
*/
|
|
155
|
+
type DriveableEventType = DriveableEvent["type"];
|
|
156
|
+
/**
|
|
157
|
+
* Type guard: is this a DriveableEvent?
|
|
158
|
+
*/
|
|
159
|
+
declare function isDriveableEvent(event: SystemEvent): event is DriveableEvent;
|
|
160
|
+
|
|
161
|
+
export { type DriveableEvent as D, type ErrorReceivedEvent as E, type InputJsonDeltaEvent as I, type MessageStartEvent as M, type TextContentBlockStartEvent as T, type DriveableEventType as a, type MessageDeltaEvent as b, type MessageStopEvent as c, type TextDeltaEvent as d, type TextContentBlockStopEvent as e, type ToolUseContentBlockStartEvent as f, type ToolUseContentBlockStopEvent as g, type ToolCallEvent as h, type ToolResultEvent as i, type InterruptedEvent as j, isDriveableEvent as k };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Message
|
|
3
|
+
*
|
|
4
|
+
* Message representing an error that occurred during conversation.
|
|
5
|
+
* Displayed in the chat history so users can see what went wrong.
|
|
6
|
+
*/
|
|
7
|
+
interface ErrorMessage {
|
|
8
|
+
/** Unique identifier */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Message role */
|
|
11
|
+
role: "error";
|
|
12
|
+
/** Message subtype for serialization */
|
|
13
|
+
subtype: "error";
|
|
14
|
+
/** Error message content (human-readable) */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Error code (e.g., "rate_limit_error", "api_error") */
|
|
17
|
+
errorCode?: string;
|
|
18
|
+
/** When this error occurred (Unix timestamp in milliseconds) */
|
|
19
|
+
timestamp: number;
|
|
20
|
+
/** Parent message ID for threading (optional) */
|
|
21
|
+
parentId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type { ErrorMessage as E };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Message
|
|
3
|
+
*
|
|
4
|
+
* Message representing an error that occurred during conversation.
|
|
5
|
+
* Displayed in the chat history so users can see what went wrong.
|
|
6
|
+
*/
|
|
7
|
+
interface ErrorMessage {
|
|
8
|
+
/** Unique identifier */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Message role */
|
|
11
|
+
role: "error";
|
|
12
|
+
/** Message subtype for serialization */
|
|
13
|
+
subtype: "error";
|
|
14
|
+
/** Error message content (human-readable) */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Error code (e.g., "rate_limit_error", "api_error") */
|
|
17
|
+
errorCode?: string;
|
|
18
|
+
/** When this error occurred (Unix timestamp in milliseconds) */
|
|
19
|
+
timestamp: number;
|
|
20
|
+
/** Parent message ID for threading (optional) */
|
|
21
|
+
parentId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type { ErrorMessage as E };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageRecord - Persistent representation of a conversation
|
|
3
|
+
*
|
|
4
|
+
* Image is the primary entity users interact with (displayed as "conversation").
|
|
5
|
+
* Agent is a transient runtime instance created from Image.
|
|
6
|
+
*
|
|
7
|
+
* Lifecycle:
|
|
8
|
+
* - image_create → ImageRecord (persistent)
|
|
9
|
+
* - image_run → Agent (runtime, in-memory)
|
|
10
|
+
* - image_stop / server restart → Agent destroyed, Image remains
|
|
11
|
+
*
|
|
12
|
+
* Messages are stored separately in Session (via sessionId).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Image metadata for storing provider-specific data
|
|
16
|
+
*/
|
|
17
|
+
interface ImageMetadata {
|
|
18
|
+
/** Claude SDK session ID for conversation resume */
|
|
19
|
+
claudeSdkSessionId?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Image storage record
|
|
23
|
+
*
|
|
24
|
+
* Represents a conversation that persists across server restarts.
|
|
25
|
+
*/
|
|
26
|
+
interface ImageRecord {
|
|
27
|
+
/**
|
|
28
|
+
* Unique image identifier
|
|
29
|
+
* Pattern: `img_${nanoid()}`
|
|
30
|
+
*/
|
|
31
|
+
imageId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Container ID (user isolation boundary)
|
|
34
|
+
*/
|
|
35
|
+
containerId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Session ID for message storage
|
|
38
|
+
* Messages are stored in Session, not duplicated here
|
|
39
|
+
*/
|
|
40
|
+
sessionId: string;
|
|
41
|
+
/**
|
|
42
|
+
* Conversation name (displayed to user)
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
/**
|
|
46
|
+
* Conversation description (optional)
|
|
47
|
+
*/
|
|
48
|
+
description?: string;
|
|
49
|
+
/**
|
|
50
|
+
* System prompt - controls agent behavior
|
|
51
|
+
*/
|
|
52
|
+
systemPrompt?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Parent image ID (for fork/branch feature)
|
|
55
|
+
*/
|
|
56
|
+
parentImageId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Provider-specific metadata (e.g., Claude SDK session ID)
|
|
59
|
+
*/
|
|
60
|
+
metadata?: ImageMetadata;
|
|
61
|
+
/**
|
|
62
|
+
* Creation timestamp (Unix milliseconds)
|
|
63
|
+
*/
|
|
64
|
+
createdAt: number;
|
|
65
|
+
/**
|
|
66
|
+
* Last update timestamp (Unix milliseconds)
|
|
67
|
+
*/
|
|
68
|
+
updatedAt: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { ImageRecord as I, ImageMetadata as a };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageRecord - Persistent representation of a conversation
|
|
3
|
+
*
|
|
4
|
+
* Image is the primary entity users interact with (displayed as "conversation").
|
|
5
|
+
* Agent is a transient runtime instance created from Image.
|
|
6
|
+
*
|
|
7
|
+
* Lifecycle:
|
|
8
|
+
* - image_create → ImageRecord (persistent)
|
|
9
|
+
* - image_run → Agent (runtime, in-memory)
|
|
10
|
+
* - image_stop / server restart → Agent destroyed, Image remains
|
|
11
|
+
*
|
|
12
|
+
* Messages are stored separately in Session (via sessionId).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Image metadata for storing provider-specific data
|
|
16
|
+
*/
|
|
17
|
+
interface ImageMetadata {
|
|
18
|
+
/** Claude SDK session ID for conversation resume */
|
|
19
|
+
claudeSdkSessionId?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Image storage record
|
|
23
|
+
*
|
|
24
|
+
* Represents a conversation that persists across server restarts.
|
|
25
|
+
*/
|
|
26
|
+
interface ImageRecord {
|
|
27
|
+
/**
|
|
28
|
+
* Unique image identifier
|
|
29
|
+
* Pattern: `img_${nanoid()}`
|
|
30
|
+
*/
|
|
31
|
+
imageId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Container ID (user isolation boundary)
|
|
34
|
+
*/
|
|
35
|
+
containerId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Session ID for message storage
|
|
38
|
+
* Messages are stored in Session, not duplicated here
|
|
39
|
+
*/
|
|
40
|
+
sessionId: string;
|
|
41
|
+
/**
|
|
42
|
+
* Conversation name (displayed to user)
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
/**
|
|
46
|
+
* Conversation description (optional)
|
|
47
|
+
*/
|
|
48
|
+
description?: string;
|
|
49
|
+
/**
|
|
50
|
+
* System prompt - controls agent behavior
|
|
51
|
+
*/
|
|
52
|
+
systemPrompt?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Parent image ID (for fork/branch feature)
|
|
55
|
+
*/
|
|
56
|
+
parentImageId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Provider-specific metadata (e.g., Claude SDK session ID)
|
|
59
|
+
*/
|
|
60
|
+
metadata?: ImageMetadata;
|
|
61
|
+
/**
|
|
62
|
+
* Creation timestamp (Unix milliseconds)
|
|
63
|
+
*/
|
|
64
|
+
createdAt: number;
|
|
65
|
+
/**
|
|
66
|
+
* Last update timestamp (Unix milliseconds)
|
|
67
|
+
*/
|
|
68
|
+
updatedAt: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { ImageRecord as I, ImageMetadata as a };
|
|
@@ -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 };
|