@agentxjs/core 1.9.10-dev → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +342 -0
- package/dist/RpcClient-BcJ_zAGu.d.ts +304 -0
- package/dist/agent/engine/internal/index.d.ts +20 -15
- package/dist/agent/engine/internal/index.js +1 -2
- package/dist/agent/engine/mealy/index.js +0 -1
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +15 -15
- package/dist/agent/types/index.d.ts +4 -4
- package/dist/agent/types/index.js +1 -2
- package/dist/bash/index.d.ts +29 -0
- package/dist/bash/index.js +7 -0
- package/dist/{bus-uF1DM2ox.d.ts → bus-C9FLWIu8.d.ts} +3 -1
- package/dist/{chunk-K6WXQ2RW.js → chunk-23UUBQXR.js} +1 -2
- package/dist/chunk-23UUBQXR.js.map +1 -0
- package/dist/chunk-BHOD5PKR.js +55 -0
- package/dist/chunk-BHOD5PKR.js.map +1 -0
- package/dist/{chunk-I7GYR3MN.js → chunk-DEAR6N3O.js} +77 -91
- package/dist/chunk-DEAR6N3O.js.map +1 -0
- package/dist/chunk-FI7WQFGV.js +37 -0
- package/dist/chunk-FI7WQFGV.js.map +1 -0
- package/dist/{chunk-AT5P47YA.js → chunk-JTKCV7IS.js} +9 -9
- package/dist/chunk-JTKCV7IS.js.map +1 -0
- package/dist/{chunk-E5FPOAPO.js → chunk-LTVNPHST.js} +1 -1
- package/dist/chunk-LTVNPHST.js.map +1 -0
- package/dist/chunk-SKS7S2RY.js +1 -0
- package/dist/common/logger/index.js +0 -2
- package/dist/common/logger/index.js.map +1 -1
- package/dist/container/index.d.ts +3 -4
- package/dist/container/index.js +0 -2
- package/dist/container/index.js.map +1 -1
- package/dist/driver/index.d.ts +2 -310
- package/dist/event/index.d.ts +4 -4
- package/dist/event/index.js +1 -2
- package/dist/event/types/index.d.ts +4 -10
- package/dist/event/types/index.js +1 -2
- package/dist/{event-CDuTzs__.d.ts → event-DNWOBSBO.d.ts} +3 -4
- package/dist/image/index.d.ts +9 -5
- package/dist/image/index.js +5 -2
- package/dist/image/index.js.map +1 -1
- package/dist/index-CuS1i5V-.d.ts +609 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -16
- package/dist/{message-BMrMm1pq.d.ts → message-03TJzvIX.d.ts} +10 -33
- package/dist/mq/index.js +0 -2
- package/dist/mq/index.js.map +1 -1
- package/dist/network/index.d.ts +3 -291
- package/dist/network/index.js +3 -14
- package/dist/network/index.js.map +1 -1
- package/dist/persistence/index.d.ts +2 -155
- package/dist/platform/index.d.ts +76 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/runtime/index.d.ts +26 -59
- package/dist/runtime/index.js +117 -33
- package/dist/runtime/index.js.map +1 -1
- package/dist/session/index.d.ts +4 -52
- package/dist/session/index.js +4 -51
- package/dist/session/index.js.map +1 -1
- package/dist/types-aE74Eo6G.d.ts +90 -0
- package/package.json +10 -5
- package/src/agent/__tests__/engine/internal/messageAssemblerProcessor.test.ts +291 -87
- package/src/agent/__tests__/engine/internal/turnTrackerProcessor.test.ts +56 -75
- package/src/agent/engine/MealyMachine.ts +1 -1
- package/src/agent/engine/internal/messageAssemblerProcessor.ts +99 -114
- package/src/agent/engine/internal/turnTrackerProcessor.ts +23 -27
- package/src/agent/types/event.ts +0 -4
- package/src/agent/types/index.ts +1 -3
- package/src/agent/types/message.ts +9 -43
- package/src/bash/index.ts +21 -0
- package/src/bash/tool.ts +57 -0
- package/src/bash/types.ts +108 -0
- package/src/driver/index.ts +1 -0
- package/src/driver/types.ts +122 -4
- package/src/event/__tests__/EventBus.test.ts +1 -1
- package/src/event/types/agent.ts +0 -11
- package/src/event/types/command.ts +3 -1
- package/src/image/Image.ts +11 -1
- package/src/image/types.ts +8 -2
- package/src/network/RpcClient.ts +21 -20
- package/src/network/index.ts +1 -1
- package/src/persistence/types.ts +5 -2
- package/src/platform/index.ts +21 -0
- package/src/platform/types.ts +84 -0
- package/src/runtime/AgentXRuntime.ts +184 -57
- package/src/runtime/__tests__/AgentXRuntime.test.ts +343 -0
- package/src/runtime/index.ts +7 -19
- package/src/runtime/types.ts +10 -62
- package/dist/chunk-7D4SUZUM.js +0 -38
- package/dist/chunk-AT5P47YA.js.map +0 -1
- package/dist/chunk-E5FPOAPO.js.map +0 -1
- package/dist/chunk-I7GYR3MN.js.map +0 -1
- package/dist/chunk-K6WXQ2RW.js.map +0 -1
- package/dist/workspace/index.d.ts +0 -111
- package/dist/wrapper-Y3UTVU2E.js +0 -3635
- package/dist/wrapper-Y3UTVU2E.js.map +0 -1
- package/src/workspace/index.ts +0 -27
- package/src/workspace/types.ts +0 -131
- /package/dist/{workspace → bash}/index.js.map +0 -0
- /package/dist/{chunk-7D4SUZUM.js.map → chunk-SKS7S2RY.js.map} +0 -0
- /package/dist/{workspace → platform}/index.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as Processor, b as ProcessorDefinition } from '../../../Processor-DT0N1qI6.js';
|
|
2
|
-
import { a2 as AssistantMessageEvent, a3 as
|
|
3
|
-
import '../../../message-
|
|
2
|
+
import { a2 as AssistantMessageEvent, a3 as ToolResultMessageEvent, a4 as ErrorMessageEvent, S as StreamEvent, N as ConversationStartEvent, P as ConversationRespondingEvent, Q as ConversationEndEvent, R as ConversationInterruptedEvent, V as ToolPlannedEvent, W as ToolExecutingEvent, Z as ErrorOccurredEvent, a9 as TurnRequestEvent, aa as TurnResponseEvent } from '../../../event-DNWOBSBO.js';
|
|
3
|
+
import '../../../message-03TJzvIX.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* messageAssemblerProcessor
|
|
@@ -18,21 +18,26 @@ import '../../../message-BMrMm1pq.js';
|
|
|
18
18
|
* - message_stop
|
|
19
19
|
*
|
|
20
20
|
* Output Events (Message Layer):
|
|
21
|
-
* -
|
|
21
|
+
* - assistant_message (Message - includes text and tool calls in content)
|
|
22
22
|
* - tool_result_message (Message - tool execution result)
|
|
23
|
-
* - assistant_message (Message - complete assistant response)
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Pending content accumulator
|
|
27
|
+
*
|
|
28
|
+
* Tracks content blocks in the order they appear in the stream.
|
|
29
|
+
* Text and tool_use blocks may be interleaved.
|
|
28
30
|
*/
|
|
29
31
|
interface PendingContent {
|
|
30
32
|
type: "text" | "tool_use";
|
|
31
|
-
index: number;
|
|
32
33
|
textDeltas?: string[];
|
|
33
34
|
toolId?: string;
|
|
34
35
|
toolName?: string;
|
|
35
36
|
toolInputJson?: string;
|
|
37
|
+
/** True when tool_use_stop has been processed and input is fully parsed */
|
|
38
|
+
assembled?: boolean;
|
|
39
|
+
/** Parsed tool input (set at tool_use_stop time) */
|
|
40
|
+
parsedInput?: Record<string, unknown>;
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
* Pending tool call info (for matching with tool_result)
|
|
@@ -56,10 +61,10 @@ interface MessageAssemblerState {
|
|
|
56
61
|
*/
|
|
57
62
|
messageStartTime: number | null;
|
|
58
63
|
/**
|
|
59
|
-
* Pending content blocks
|
|
60
|
-
*
|
|
64
|
+
* Pending content blocks in stream order.
|
|
65
|
+
* Preserves the interleaved order of text and tool_use blocks.
|
|
61
66
|
*/
|
|
62
|
-
pendingContents:
|
|
67
|
+
pendingContents: PendingContent[];
|
|
63
68
|
/**
|
|
64
69
|
* Pending tool calls waiting for results
|
|
65
70
|
* Key is the tool call ID
|
|
@@ -73,7 +78,7 @@ declare function createInitialMessageAssemblerState(): MessageAssemblerState;
|
|
|
73
78
|
/**
|
|
74
79
|
* Output event types from MessageAssembler
|
|
75
80
|
*/
|
|
76
|
-
type MessageAssemblerOutput = AssistantMessageEvent |
|
|
81
|
+
type MessageAssemblerOutput = AssistantMessageEvent | ToolResultMessageEvent | ErrorMessageEvent;
|
|
77
82
|
/**
|
|
78
83
|
* Input event types for MessageAssembler
|
|
79
84
|
*/
|
|
@@ -156,11 +161,11 @@ declare const stateEventProcessorDef: ProcessorDefinition<StateEventProcessorCon
|
|
|
156
161
|
* turnTrackerProcessor
|
|
157
162
|
*
|
|
158
163
|
* Pure Mealy transition function that tracks request-response turn pairs.
|
|
164
|
+
* Derives turn events entirely from stream-layer events (no external injection).
|
|
159
165
|
*
|
|
160
|
-
* Input Events:
|
|
161
|
-
* -
|
|
162
|
-
* - message_stop (
|
|
163
|
-
* - assistant_message (Message Layer)
|
|
166
|
+
* Input Events (Stream Layer):
|
|
167
|
+
* - message_start → emit turn_request (a new turn begins)
|
|
168
|
+
* - message_stop → emit turn_response (turn completes, based on stop reason)
|
|
164
169
|
*
|
|
165
170
|
* Output Events (Turn Layer):
|
|
166
171
|
* - turn_request
|
|
@@ -205,9 +210,9 @@ declare function createInitialTurnTrackerState(): TurnTrackerState;
|
|
|
205
210
|
type TurnTrackerOutput = TurnRequestEvent | TurnResponseEvent;
|
|
206
211
|
/**
|
|
207
212
|
* Input event types for TurnTracker
|
|
208
|
-
*
|
|
213
|
+
* Only stream-layer events — turn events are derived, not injected.
|
|
209
214
|
*/
|
|
210
|
-
type TurnTrackerInput = StreamEvent
|
|
215
|
+
type TurnTrackerInput = StreamEvent;
|
|
211
216
|
/**
|
|
212
217
|
* turnTrackerProcessor
|
|
213
218
|
*
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
stateEventProcessorDef,
|
|
9
9
|
turnTrackerProcessor,
|
|
10
10
|
turnTrackerProcessorDef
|
|
11
|
-
} from "../../../chunk-
|
|
12
|
-
import "../../../chunk-7D4SUZUM.js";
|
|
11
|
+
} from "../../../chunk-DEAR6N3O.js";
|
|
13
12
|
export {
|
|
14
13
|
createInitialMessageAssemblerState,
|
|
15
14
|
createInitialStateEventProcessorContext,
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AssistantMessage, C as ContentPart, E as ErrorMessage, F as FilePart, I as ImagePart, M as Message,
|
|
2
|
-
import { a as AgentState, A as AgentOutput, U as Unsubscribe, S as StreamEvent } from '../event-
|
|
3
|
-
export { e as AgentError, d as AgentErrorCategory, _ as AgentErrorOccurredEvent, c as AgentEvent,
|
|
1
|
+
export { A as AssistantMessage, C as ContentPart, E as ErrorMessage, F as FilePart, I as ImagePart, M as Message, h as MessageRole, i as MessageSubtype, c as TextPart, d as ThinkingPart, a as TokenUsage, e as ToolCallPart, T as ToolResultMessage, f as ToolResultOutput, g as ToolResultPart, b as UserContentPart, U as UserMessage } from '../message-03TJzvIX.js';
|
|
2
|
+
import { a as AgentState, A as AgentOutput, U as Unsubscribe, S as StreamEvent } from '../event-DNWOBSBO.js';
|
|
3
|
+
export { e as AgentError, d as AgentErrorCategory, _ as AgentErrorOccurredEvent, c as AgentEvent, ac as AgentEventHandler, a5 as AgentMessageEvent, b as AgentOutputCallback, $ as AgentStateEvent, ab as AgentTurnEvent, a2 as AssistantMessageEvent, z as ConversationEndData, Q as ConversationEndEvent, B as ConversationInterruptedData, R as ConversationInterruptedEvent, C as ConversationQueuedData, L as ConversationQueuedEvent, y as ConversationRespondingData, P as ConversationRespondingEvent, w as ConversationStartData, N as ConversationStartEvent, x as ConversationThinkingData, O as ConversationThinkingEvent, E as EngineEvent, a4 as ErrorMessageEvent, J as ErrorOccurredData, Z as ErrorOccurredEvent, l as ErrorReceivedData, u as ErrorReceivedEvent, I as InputJsonDeltaData, r as InputJsonDeltaEvent, g as MessageDeltaData, n as MessageDeltaEvent, a0 as MessageEvent, M as MessageStartData, m as MessageStartEvent, h as MessageStopData, o as MessageStopEvent, K as StateEvent, f as StopReason, v as StreamEventType, T as TextDeltaData, p as TextDeltaEvent, G as ToolCompletedData, X as ToolCompletedEvent, F as ToolExecutingData, W as ToolExecutingEvent, H as ToolFailedData, Y as ToolFailedEvent, D as ToolPlannedData, V as ToolPlannedEvent, k as ToolResultData, t as ToolResultEvent, a3 as ToolResultMessageEvent, i as ToolUseStartData, q as ToolUseStartEvent, j as ToolUseStopData, s as ToolUseStopEvent, a8 as TurnEvent, a6 as TurnRequestData, a9 as TurnRequestEvent, a7 as TurnResponseData, aa as TurnResponseEvent, a1 as UserMessageEvent, ae as isMessageEvent, ad as isStateEvent, af as isTurnEvent } from '../event-DNWOBSBO.js';
|
|
4
4
|
import { CreateAgentOptions, AgentEngine, StateChangeHandler } from './types/index.js';
|
|
5
5
|
export { AgentEventBus, AgentInterceptor, AgentInterceptorNext, AgentMiddleware, AgentMiddlewareNext, AgentPresenter, AgentSource, AgentStateMachineInterface, EventHandlerMap, MessageQueue, ReactHandlerMap, StateChange } from './types/index.js';
|
|
6
6
|
import { MessageAssemblerState, StateEventProcessorContext, TurnTrackerState, MessageAssemblerOutput, StateEventProcessorOutput, TurnTrackerOutput } from './engine/internal/index.js';
|
|
@@ -114,7 +114,7 @@ declare class AgentStateMachine {
|
|
|
114
114
|
* AgentOutput (to AgentEngine/Presenter)
|
|
115
115
|
* │
|
|
116
116
|
* ├── StateEvent (conversation_start, conversation_end...)
|
|
117
|
-
* ├── MessageEvent (assistant_message,
|
|
117
|
+
* ├── MessageEvent (assistant_message, tool_result_message...)
|
|
118
118
|
* └── TurnEvent (turn_request, turn_response)
|
|
119
119
|
* ```
|
|
120
120
|
*
|
package/dist/agent/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../chunk-SKS7S2RY.js";
|
|
1
2
|
import {
|
|
2
3
|
AgentStateMachine,
|
|
3
4
|
MealyMachine,
|
|
@@ -5,17 +6,7 @@ import {
|
|
|
5
6
|
createAgent,
|
|
6
7
|
createInitialAgentEngineState,
|
|
7
8
|
createMealyMachine
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import {
|
|
10
|
-
MemoryStore,
|
|
11
|
-
chainProcessors,
|
|
12
|
-
combineInitialStates,
|
|
13
|
-
combineProcessors,
|
|
14
|
-
filterProcessor,
|
|
15
|
-
identityProcessor,
|
|
16
|
-
mapOutput,
|
|
17
|
-
withLogging
|
|
18
|
-
} from "../chunk-EKHT54KN.js";
|
|
9
|
+
} from "../chunk-JTKCV7IS.js";
|
|
19
10
|
import {
|
|
20
11
|
createInitialMessageAssemblerState,
|
|
21
12
|
createInitialStateEventProcessorContext,
|
|
@@ -26,15 +17,24 @@ import {
|
|
|
26
17
|
stateEventProcessorDef,
|
|
27
18
|
turnTrackerProcessor,
|
|
28
19
|
turnTrackerProcessorDef
|
|
29
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-DEAR6N3O.js";
|
|
21
|
+
import {
|
|
22
|
+
MemoryStore,
|
|
23
|
+
chainProcessors,
|
|
24
|
+
combineInitialStates,
|
|
25
|
+
combineProcessors,
|
|
26
|
+
filterProcessor,
|
|
27
|
+
identityProcessor,
|
|
28
|
+
mapOutput,
|
|
29
|
+
withLogging
|
|
30
|
+
} from "../chunk-EKHT54KN.js";
|
|
30
31
|
import {
|
|
31
32
|
isMessageEvent,
|
|
32
33
|
isStateEvent,
|
|
33
34
|
isTurnEvent
|
|
34
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-23UUBQXR.js";
|
|
35
36
|
import "../chunk-7ZDX3O6I.js";
|
|
36
|
-
import "../chunk-
|
|
37
|
-
import "../chunk-7D4SUZUM.js";
|
|
37
|
+
import "../chunk-LTVNPHST.js";
|
|
38
38
|
export {
|
|
39
39
|
AgentStateMachine,
|
|
40
40
|
MealyMachine,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { U as UserMessage } from '../../message-
|
|
2
|
-
export { A as AssistantMessage, C as ContentPart, E as ErrorMessage, F as FilePart, I as ImagePart, M as Message,
|
|
3
|
-
import { S as StreamEvent, A as AgentOutput, a as AgentState, b as AgentOutputCallback, U as Unsubscribe } from '../../event-
|
|
4
|
-
export { e as AgentError, d as AgentErrorCategory, _ as AgentErrorOccurredEvent, c as AgentEvent,
|
|
1
|
+
import { U as UserMessage } from '../../message-03TJzvIX.js';
|
|
2
|
+
export { A as AssistantMessage, C as ContentPart, E as ErrorMessage, F as FilePart, I as ImagePart, M as Message, h as MessageRole, i as MessageSubtype, c as TextPart, d as ThinkingPart, a as TokenUsage, e as ToolCallPart, T as ToolResultMessage, f as ToolResultOutput, g as ToolResultPart, b as UserContentPart } from '../../message-03TJzvIX.js';
|
|
3
|
+
import { S as StreamEvent, A as AgentOutput, a as AgentState, b as AgentOutputCallback, U as Unsubscribe } from '../../event-DNWOBSBO.js';
|
|
4
|
+
export { e as AgentError, d as AgentErrorCategory, _ as AgentErrorOccurredEvent, c as AgentEvent, ac as AgentEventHandler, a5 as AgentMessageEvent, $ as AgentStateEvent, ab as AgentTurnEvent, a2 as AssistantMessageEvent, z as ConversationEndData, Q as ConversationEndEvent, B as ConversationInterruptedData, R as ConversationInterruptedEvent, C as ConversationQueuedData, L as ConversationQueuedEvent, y as ConversationRespondingData, P as ConversationRespondingEvent, w as ConversationStartData, N as ConversationStartEvent, x as ConversationThinkingData, O as ConversationThinkingEvent, E as EngineEvent, a4 as ErrorMessageEvent, J as ErrorOccurredData, Z as ErrorOccurredEvent, l as ErrorReceivedData, u as ErrorReceivedEvent, I as InputJsonDeltaData, r as InputJsonDeltaEvent, g as MessageDeltaData, n as MessageDeltaEvent, a0 as MessageEvent, M as MessageStartData, m as MessageStartEvent, h as MessageStopData, o as MessageStopEvent, K as StateEvent, f as StopReason, v as StreamEventType, T as TextDeltaData, p as TextDeltaEvent, G as ToolCompletedData, X as ToolCompletedEvent, F as ToolExecutingData, W as ToolExecutingEvent, H as ToolFailedData, Y as ToolFailedEvent, D as ToolPlannedData, V as ToolPlannedEvent, k as ToolResultData, t as ToolResultEvent, a3 as ToolResultMessageEvent, i as ToolUseStartData, q as ToolUseStartEvent, j as ToolUseStopData, s as ToolUseStopEvent, a8 as TurnEvent, a6 as TurnRequestData, a9 as TurnRequestEvent, a7 as TurnResponseData, aa as TurnResponseEvent, a1 as UserMessageEvent, ae as isMessageEvent, ad as isStateEvent, af as isTurnEvent } from '../../event-DNWOBSBO.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Engine Types - AgentEngine, Driver, Presenter, and related infrastructure
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { B as BashProvider } from '../types-aE74Eo6G.js';
|
|
2
|
+
export { b as BashOptions, a as BashResult } from '../types-aE74Eo6G.js';
|
|
3
|
+
import { T as ToolDefinition } from '../index-CuS1i5V-.js';
|
|
4
|
+
import '../message-03TJzvIX.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Bash Tool Definition
|
|
8
|
+
*
|
|
9
|
+
* Creates a ToolDefinition that wraps a BashProvider.
|
|
10
|
+
* The tool schema is sent to the LLM, the execute function
|
|
11
|
+
* delegates to the platform-provided BashProvider via closure.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a bash ToolDefinition from a BashProvider
|
|
16
|
+
*
|
|
17
|
+
* @param provider - Platform-provided BashProvider
|
|
18
|
+
* @returns ToolDefinition ready for DriverConfig.tools
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* if (platform.bashProvider) {
|
|
23
|
+
* tools.push(createBashTool(platform.bashProvider));
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function createBashTool(provider: BashProvider): ToolDefinition;
|
|
28
|
+
|
|
29
|
+
export { BashProvider, createBashTool };
|
|
@@ -67,7 +67,7 @@ interface McpServerConfig {
|
|
|
67
67
|
* Image metadata for storing provider-specific data
|
|
68
68
|
*/
|
|
69
69
|
interface ImageMetadata {
|
|
70
|
-
|
|
70
|
+
driverSessionId?: string;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Image storage record
|
|
@@ -273,6 +273,7 @@ interface ImageCreateRequest extends BaseCommandRequest<"image_create_request",
|
|
|
273
273
|
name?: string;
|
|
274
274
|
description?: string;
|
|
275
275
|
systemPrompt?: string;
|
|
276
|
+
customData?: Record<string, unknown>;
|
|
276
277
|
};
|
|
277
278
|
}> {
|
|
278
279
|
}
|
|
@@ -328,6 +329,7 @@ interface ImageUpdateRequest extends BaseCommandRequest<"image_update_request",
|
|
|
328
329
|
updates: {
|
|
329
330
|
name?: string;
|
|
330
331
|
description?: string;
|
|
332
|
+
customData?: Record<string, unknown>;
|
|
331
333
|
};
|
|
332
334
|
}> {
|
|
333
335
|
}
|
|
@@ -19,7 +19,6 @@ function isMessageEvent(event) {
|
|
|
19
19
|
const messageTypes = [
|
|
20
20
|
"user_message",
|
|
21
21
|
"assistant_message",
|
|
22
|
-
"tool_call_message",
|
|
23
22
|
"tool_result_message",
|
|
24
23
|
"error_message"
|
|
25
24
|
];
|
|
@@ -35,4 +34,4 @@ export {
|
|
|
35
34
|
isMessageEvent,
|
|
36
35
|
isTurnEvent
|
|
37
36
|
};
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-23UUBQXR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/types/event.ts"],"sourcesContent":["/**\n * Event Types - Stream, State, Message, and Turn Events\n *\n * This file defines all event types for the AgentEngine:\n * - Base EngineEvent type\n * - Stream Events: message_start, text_delta, tool_use_*, etc.\n * - State Events: conversation_*, tool_*, error_*\n * - Message Events: user_message, assistant_message, etc.\n * - Turn Events: turn_request, turn_response\n * - AgentOutput: Union of all output events\n *\n * @packageDocumentation\n */\n\nimport type {\n UserMessage,\n AssistantMessage,\n ToolResultMessage,\n ErrorMessage,\n TokenUsage,\n} from \"./message\";\n\n// =============================================================================\n// Base Types\n// =============================================================================\n\n/**\n * EngineEvent - Lightweight event base for AgentEngine domain\n *\n * EngineEvent is the simplified event structure used inside AgentEngine.\n * It only contains: type, timestamp, data\n *\n * This is a self-contained type without external dependencies.\n * All specific event types (StreamEvent, StateEvent, etc.) extend this base.\n */\nexport interface EngineEvent<T extends string = string, D = unknown> {\n /**\n * Event type identifier (e.g., \"text_delta\", \"assistant_message\")\n */\n readonly type: T;\n\n /**\n * Event timestamp (Unix milliseconds)\n */\n readonly timestamp: number;\n\n /**\n * Event payload data\n */\n readonly data: D;\n}\n\n/**\n * @deprecated Use EngineEvent instead\n */\nexport type AgentEvent<T extends string = string, D = unknown> = EngineEvent<T, D>;\n\n// =============================================================================\n// Agent State\n// =============================================================================\n\n/**\n * AgentState\n *\n * Agent conversation states for fine-grained monitoring.\n *\n * State transitions:\n * ```\n * idle -> thinking -> responding -> idle\n * |\n * planning_tool -> awaiting_tool_result\n * |\n * thinking -> responding -> idle\n *\n * Any state can transition to error:\n * thinking/responding/planning_tool/awaiting_tool_result -> error -> idle\n * ```\n */\nexport type AgentState =\n | \"idle\" // Waiting for user input\n | \"thinking\" // LLM is thinking\n | \"responding\" // LLM is generating response\n | \"planning_tool\" // Generating tool call parameters\n | \"awaiting_tool_result\" // Waiting for tool execution result\n | \"error\"; // Error occurred during processing\n\n// =============================================================================\n// Agent Error\n// =============================================================================\n\n/**\n * Error category\n */\nexport type AgentErrorCategory =\n | \"network\" // Network/API errors\n | \"validation\" // Input validation errors\n | \"system\" // Internal system errors\n | \"business\"; // Business logic errors\n\n/**\n * AgentError - Standardized error structure\n */\nexport interface AgentError {\n /**\n * Error category\n */\n category: AgentErrorCategory;\n\n /**\n * Error code (e.g., \"NETWORK_TIMEOUT\", \"INVALID_INPUT\")\n */\n code: string;\n\n /**\n * Human-readable error message\n */\n message: string;\n\n /**\n * Whether the error is recoverable\n */\n recoverable: boolean;\n\n /**\n * Original error (if any)\n */\n cause?: Error;\n\n /**\n * Additional context\n */\n context?: Record<string, unknown>;\n}\n\n// =============================================================================\n// Stream Events\n// =============================================================================\n\n/**\n * Stop reason for message completion\n */\nexport type StopReason = \"end_turn\" | \"max_tokens\" | \"stop_sequence\" | \"tool_use\";\n\n// --- Stream Event Data Types ---\n\nexport interface MessageStartData {\n messageId: string;\n model: string;\n}\n\nexport interface MessageDeltaData {\n usage?: {\n inputTokens: number;\n outputTokens: number;\n };\n}\n\nexport interface MessageStopData {\n stopReason?: StopReason;\n}\n\nexport interface TextDeltaData {\n text: string;\n}\n\nexport interface ToolUseStartData {\n toolCallId: string;\n toolName: string;\n}\n\nexport interface InputJsonDeltaData {\n partialJson: string;\n}\n\nexport interface ToolUseStopData {\n toolCallId: string;\n toolName: string;\n input: Record<string, unknown>;\n}\n\nexport interface ToolResultData {\n toolCallId: string;\n result: unknown;\n isError?: boolean;\n}\n\nexport interface ErrorReceivedData {\n message: string;\n errorCode?: string;\n}\n\n// --- Stream Event Types ---\n\nexport type MessageStartEvent = EngineEvent<\"message_start\", MessageStartData>;\nexport type MessageDeltaEvent = EngineEvent<\"message_delta\", MessageDeltaData>;\nexport type MessageStopEvent = EngineEvent<\"message_stop\", MessageStopData>;\nexport type TextDeltaEvent = EngineEvent<\"text_delta\", TextDeltaData>;\nexport type ToolUseStartEvent = EngineEvent<\"tool_use_start\", ToolUseStartData>;\nexport type InputJsonDeltaEvent = EngineEvent<\"input_json_delta\", InputJsonDeltaData>;\nexport type ToolUseStopEvent = EngineEvent<\"tool_use_stop\", ToolUseStopData>;\nexport type ToolResultEvent = EngineEvent<\"tool_result\", ToolResultData>;\nexport type ErrorReceivedEvent = EngineEvent<\"error_received\", ErrorReceivedData>;\n\n/**\n * StreamEvent - All lightweight stream events\n */\nexport type StreamEvent =\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | TextDeltaEvent\n | ToolUseStartEvent\n | InputJsonDeltaEvent\n | ToolUseStopEvent\n | ToolResultEvent\n | ErrorReceivedEvent;\n\n/**\n * StreamEventType - String literal union\n */\nexport type StreamEventType = StreamEvent[\"type\"];\n\n// =============================================================================\n// State Events\n// =============================================================================\n\n// --- State Event Data Types ---\n\nexport interface ConversationQueuedData {\n messageId: string;\n}\n\nexport interface ConversationStartData {\n messageId: string;\n}\n\nexport interface ConversationThinkingData {\n // Empty\n}\n\nexport interface ConversationRespondingData {\n // Empty\n}\n\nexport interface ConversationEndData {\n reason: \"completed\" | \"interrupted\" | \"error\";\n}\n\nexport interface ConversationInterruptedData {\n reason: string;\n}\n\nexport interface ToolPlannedData {\n toolId: string;\n toolName: string;\n}\n\nexport interface ToolExecutingData {\n toolId: string;\n toolName: string;\n input: Record<string, unknown>;\n}\n\nexport interface ToolCompletedData {\n toolId: string;\n toolName: string;\n result: unknown;\n}\n\nexport interface ToolFailedData {\n toolId: string;\n toolName: string;\n error: string;\n}\n\nexport interface ErrorOccurredData {\n code: string;\n message: string;\n recoverable: boolean;\n category?: string;\n}\n\n/**\n * StateEvent - Base type for state events\n * @deprecated Use specific event types instead\n */\nexport interface StateEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// --- State Event Types ---\n\nexport type ConversationQueuedEvent = EngineEvent<\"conversation_queued\", ConversationQueuedData>;\nexport type ConversationStartEvent = EngineEvent<\"conversation_start\", ConversationStartData>;\nexport type ConversationThinkingEvent = EngineEvent<\n \"conversation_thinking\",\n ConversationThinkingData\n>;\nexport type ConversationRespondingEvent = EngineEvent<\n \"conversation_responding\",\n ConversationRespondingData\n>;\nexport type ConversationEndEvent = EngineEvent<\"conversation_end\", ConversationEndData>;\nexport type ConversationInterruptedEvent = EngineEvent<\n \"conversation_interrupted\",\n ConversationInterruptedData\n>;\nexport type ToolPlannedEvent = EngineEvent<\"tool_planned\", ToolPlannedData>;\nexport type ToolExecutingEvent = EngineEvent<\"tool_executing\", ToolExecutingData>;\nexport type ToolCompletedEvent = EngineEvent<\"tool_completed\", ToolCompletedData>;\nexport type ToolFailedEvent = EngineEvent<\"tool_failed\", ToolFailedData>;\nexport type ErrorOccurredEvent = EngineEvent<\"error_occurred\", ErrorOccurredData>;\n\n/**\n * Alias for ErrorOccurredEvent (legacy compatibility)\n */\nexport type AgentErrorOccurredEvent = ErrorOccurredEvent;\n\n/**\n * AgentStateEvent - All lightweight state events\n */\nexport type AgentStateEvent =\n // Conversation\n | ConversationQueuedEvent\n | ConversationStartEvent\n | ConversationThinkingEvent\n | ConversationRespondingEvent\n | ConversationEndEvent\n | ConversationInterruptedEvent\n // Tool\n | ToolPlannedEvent\n | ToolExecutingEvent\n | ToolCompletedEvent\n | ToolFailedEvent\n // Error\n | ErrorOccurredEvent;\n\n/**\n * Type guard: is this a state event?\n */\nexport function isStateEvent(event: EngineEvent): event is AgentStateEvent {\n const stateTypes = [\n \"conversation_queued\",\n \"conversation_start\",\n \"conversation_thinking\",\n \"conversation_responding\",\n \"conversation_end\",\n \"conversation_interrupted\",\n \"tool_planned\",\n \"tool_executing\",\n \"tool_completed\",\n \"tool_failed\",\n \"error_occurred\",\n ];\n return stateTypes.includes(event.type);\n}\n\n// =============================================================================\n// Message Events\n// =============================================================================\n\n/**\n * MessageEvent - Base type for message events\n * @deprecated Use specific event types instead\n */\nexport interface MessageEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// --- Message Event Types ---\n\nexport type UserMessageEvent = EngineEvent<\"user_message\", UserMessage>;\nexport type AssistantMessageEvent = EngineEvent<\"assistant_message\", AssistantMessage>;\nexport type ToolResultMessageEvent = EngineEvent<\"tool_result_message\", ToolResultMessage>;\nexport type ErrorMessageEvent = EngineEvent<\"error_message\", ErrorMessage>;\n\n/**\n * AgentMessageEvent - All lightweight message events\n */\nexport type AgentMessageEvent =\n | UserMessageEvent\n | AssistantMessageEvent\n | ToolResultMessageEvent\n | ErrorMessageEvent;\n\n/**\n * Type guard: is this a message event?\n */\nexport function isMessageEvent(event: EngineEvent): event is AgentMessageEvent {\n const messageTypes = [\n \"user_message\",\n \"assistant_message\",\n \"tool_result_message\",\n \"error_message\",\n ];\n return messageTypes.includes(event.type);\n}\n\n// =============================================================================\n// Turn Events\n// =============================================================================\n\n// --- Turn Event Data Types ---\n\nexport interface TurnRequestData {\n turnId: string;\n messageId: string;\n content: string;\n timestamp: number;\n}\n\nexport interface TurnResponseData {\n turnId: string;\n messageId: string;\n duration: number;\n usage?: TokenUsage;\n model?: string;\n stopReason?: string;\n timestamp: number;\n}\n\n/**\n * TurnEvent - Base type for turn events\n * @deprecated Use specific event types instead\n */\nexport interface TurnEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// --- Turn Event Types ---\n\nexport type TurnRequestEvent = EngineEvent<\"turn_request\", TurnRequestData>;\nexport type TurnResponseEvent = EngineEvent<\"turn_response\", TurnResponseData>;\n\n/**\n * AgentTurnEvent - All lightweight turn events\n */\nexport type AgentTurnEvent = TurnRequestEvent | TurnResponseEvent;\n\n/**\n * Type guard: is this a turn event?\n */\nexport function isTurnEvent(event: EngineEvent): event is AgentTurnEvent {\n const turnTypes = [\"turn_request\", \"turn_response\"];\n return turnTypes.includes(event.type);\n}\n\n// =============================================================================\n// Agent Output\n// =============================================================================\n\n/**\n * AgentOutput - Union of all possible agent output events\n *\n * Includes all event layers:\n * - Stream: Real-time streaming events from Driver\n * - State: State machine transitions\n * - Message: Assembled messages\n * - Turn: Turn analytics\n */\nexport type AgentOutput = StreamEvent | AgentStateEvent | AgentMessageEvent | AgentTurnEvent;\n\n// =============================================================================\n// Event Handling Types\n// =============================================================================\n\n/**\n * Unsubscribe function returned by on()\n */\nexport type Unsubscribe = () => void;\n\n/**\n * Agent output event callback function type\n */\nexport type AgentOutputCallback<T extends AgentOutput = AgentOutput> = (event: T) => void;\n\n/**\n * @deprecated Use AgentOutputCallback instead\n */\nexport type AgentEventHandler<T extends AgentOutput = AgentOutput> = AgentOutputCallback<T>;\n"],"mappings":";AAkVO,SAAS,aAAa,OAA8C;AACzE,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,WAAW,SAAS,MAAM,IAAI;AACvC;AA+BO,SAAS,eAAe,OAAgD;AAC7E,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,aAAa,SAAS,MAAM,IAAI;AACzC;AA4CO,SAAS,YAAY,OAA6C;AACvE,QAAM,YAAY,CAAC,gBAAgB,eAAe;AAClD,SAAO,UAAU,SAAS,MAAM,IAAI;AACtC;","names":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/session/Session.ts
|
|
2
|
+
var SessionImpl = class {
|
|
3
|
+
sessionId;
|
|
4
|
+
imageId;
|
|
5
|
+
containerId;
|
|
6
|
+
createdAt;
|
|
7
|
+
repository;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.sessionId = config.sessionId;
|
|
10
|
+
this.imageId = config.imageId;
|
|
11
|
+
this.containerId = config.containerId;
|
|
12
|
+
this.createdAt = Date.now();
|
|
13
|
+
this.repository = config.repository;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Initialize session in storage
|
|
17
|
+
*/
|
|
18
|
+
async initialize() {
|
|
19
|
+
const record = {
|
|
20
|
+
sessionId: this.sessionId,
|
|
21
|
+
imageId: this.imageId,
|
|
22
|
+
containerId: this.containerId,
|
|
23
|
+
createdAt: this.createdAt,
|
|
24
|
+
updatedAt: this.createdAt
|
|
25
|
+
};
|
|
26
|
+
await this.repository.saveSession(record);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Add a message to the session
|
|
30
|
+
*/
|
|
31
|
+
async addMessage(message) {
|
|
32
|
+
await this.repository.addMessage(this.sessionId, message);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get all messages in the session
|
|
36
|
+
*/
|
|
37
|
+
async getMessages() {
|
|
38
|
+
return this.repository.getMessages(this.sessionId);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Clear all messages in the session
|
|
42
|
+
*/
|
|
43
|
+
async clear() {
|
|
44
|
+
await this.repository.clearMessages(this.sessionId);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function createSession(config) {
|
|
48
|
+
return new SessionImpl(config);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
SessionImpl,
|
|
53
|
+
createSession
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=chunk-BHOD5PKR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session/Session.ts"],"sourcesContent":["/**\n * Session - Manages conversation messages\n *\n * Collects messages and persists to storage via SessionRepository.\n * Pure implementation without EventBus dependency.\n */\n\nimport type { Message } from \"../agent/types\";\nimport type { Session, SessionConfig, SessionRecord, SessionRepository } from \"./types\";\n\n/**\n * SessionImpl - Session implementation\n */\nexport class SessionImpl implements Session {\n readonly sessionId: string;\n readonly imageId: string;\n readonly containerId: string;\n readonly createdAt: number;\n\n private readonly repository: SessionRepository;\n\n constructor(config: SessionConfig) {\n this.sessionId = config.sessionId;\n this.imageId = config.imageId;\n this.containerId = config.containerId;\n this.createdAt = Date.now();\n this.repository = config.repository;\n }\n\n /**\n * Initialize session in storage\n */\n async initialize(): Promise<void> {\n const record: SessionRecord = {\n sessionId: this.sessionId,\n imageId: this.imageId,\n containerId: this.containerId,\n createdAt: this.createdAt,\n updatedAt: this.createdAt,\n };\n await this.repository.saveSession(record);\n }\n\n /**\n * Add a message to the session\n */\n async addMessage(message: Message): Promise<void> {\n await this.repository.addMessage(this.sessionId, message);\n }\n\n /**\n * Get all messages in the session\n */\n async getMessages(): Promise<Message[]> {\n return this.repository.getMessages(this.sessionId);\n }\n\n /**\n * Clear all messages in the session\n */\n async clear(): Promise<void> {\n await this.repository.clearMessages(this.sessionId);\n }\n}\n\n/**\n * Create a new Session instance\n */\nexport function createSession(config: SessionConfig): Session {\n return new SessionImpl(config);\n}\n"],"mappings":";AAaO,IAAM,cAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEQ;AAAA,EAEjB,YAAY,QAAuB;AACjC,SAAK,YAAY,OAAO;AACxB,SAAK,UAAU,OAAO;AACtB,SAAK,cAAc,OAAO;AAC1B,SAAK,YAAY,KAAK,IAAI;AAC1B,SAAK,aAAa,OAAO;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,UAAM,SAAwB;AAAA,MAC5B,WAAW,KAAK;AAAA,MAChB,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB,WAAW,KAAK;AAAA,MAChB,WAAW,KAAK;AAAA,IAClB;AACA,UAAM,KAAK,WAAW,YAAY,MAAM;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,SAAiC;AAChD,UAAM,KAAK,WAAW,WAAW,KAAK,WAAW,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAkC;AACtC,WAAO,KAAK,WAAW,YAAY,KAAK,SAAS;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAuB;AAC3B,UAAM,KAAK,WAAW,cAAc,KAAK,SAAS;AAAA,EACpD;AACF;AAKO,SAAS,cAAc,QAAgC;AAC5D,SAAO,IAAI,YAAY,MAAM;AAC/B;","names":[]}
|