@agentxjs/core 1.9.5-dev → 1.9.6-dev

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.
Files changed (80) hide show
  1. package/dist/Processor-DT0N1qI6.d.ts +64 -0
  2. package/dist/agent/engine/internal/index.d.ts +223 -0
  3. package/dist/agent/engine/internal/index.js +24 -0
  4. package/dist/agent/engine/internal/index.js.map +1 -0
  5. package/dist/agent/engine/mealy/index.d.ts +157 -0
  6. package/dist/agent/engine/mealy/index.js +26 -0
  7. package/dist/agent/engine/mealy/index.js.map +1 -0
  8. package/dist/agent/index.d.ts +244 -0
  9. package/dist/agent/index.js +66 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/agent/types/index.d.ts +322 -0
  12. package/dist/agent/types/index.js +12 -0
  13. package/dist/agent/types/index.js.map +1 -0
  14. package/dist/base-m40r3Qgu.d.ts +157 -0
  15. package/dist/bus-uF1DM2ox.d.ts +906 -0
  16. package/dist/chunk-7D4SUZUM.js +38 -0
  17. package/dist/chunk-7D4SUZUM.js.map +1 -0
  18. package/dist/chunk-7ZDX3O6I.js +173 -0
  19. package/dist/chunk-7ZDX3O6I.js.map +1 -0
  20. package/dist/chunk-AT5P47YA.js +543 -0
  21. package/dist/chunk-AT5P47YA.js.map +1 -0
  22. package/dist/chunk-E5FPOAPO.js +123 -0
  23. package/dist/chunk-E5FPOAPO.js.map +1 -0
  24. package/dist/chunk-EKHT54KN.js +272 -0
  25. package/dist/chunk-EKHT54KN.js.map +1 -0
  26. package/dist/chunk-I7GYR3MN.js +502 -0
  27. package/dist/chunk-I7GYR3MN.js.map +1 -0
  28. package/dist/chunk-K6WXQ2RW.js +38 -0
  29. package/dist/chunk-K6WXQ2RW.js.map +1 -0
  30. package/dist/chunk-RL3JRNXM.js +3 -0
  31. package/dist/chunk-RL3JRNXM.js.map +1 -0
  32. package/dist/combinators-nEa5dD0T.d.ts +271 -0
  33. package/dist/common/index.d.ts +1 -0
  34. package/dist/common/index.js +2 -0
  35. package/dist/common/index.js.map +1 -0
  36. package/dist/common/logger/index.d.ts +163 -0
  37. package/dist/common/logger/index.js +184 -0
  38. package/dist/common/logger/index.js.map +1 -0
  39. package/dist/container/index.d.ts +110 -0
  40. package/dist/container/index.js +127 -0
  41. package/dist/container/index.js.map +1 -0
  42. package/dist/driver/index.d.ts +266 -0
  43. package/dist/driver/index.js +1 -0
  44. package/dist/driver/index.js.map +1 -0
  45. package/dist/event/index.d.ts +55 -0
  46. package/dist/event/index.js +60 -0
  47. package/dist/event/index.js.map +1 -0
  48. package/dist/event/types/index.d.ts +1149 -0
  49. package/dist/event/types/index.js +56 -0
  50. package/dist/event/types/index.js.map +1 -0
  51. package/dist/event-CDuTzs__.d.ts +296 -0
  52. package/dist/image/index.d.ts +112 -0
  53. package/dist/image/index.js +151 -0
  54. package/dist/image/index.js.map +1 -0
  55. package/dist/index.d.ts +8 -0
  56. package/dist/index.js +67 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/message-BMrMm1pq.d.ts +305 -0
  59. package/dist/mq/index.d.ts +165 -0
  60. package/dist/mq/index.js +37 -0
  61. package/dist/mq/index.js.map +1 -0
  62. package/dist/network/index.d.ts +567 -0
  63. package/dist/network/index.js +435 -0
  64. package/dist/network/index.js.map +1 -0
  65. package/dist/persistence/index.d.ts +155 -0
  66. package/dist/persistence/index.js +1 -0
  67. package/dist/persistence/index.js.map +1 -0
  68. package/dist/runtime/index.d.ts +240 -0
  69. package/dist/runtime/index.js +347 -0
  70. package/dist/runtime/index.js.map +1 -0
  71. package/dist/session/index.d.ts +92 -0
  72. package/dist/session/index.js +56 -0
  73. package/dist/session/index.js.map +1 -0
  74. package/dist/workspace/index.d.ts +111 -0
  75. package/dist/workspace/index.js +1 -0
  76. package/dist/workspace/index.js.map +1 -0
  77. package/dist/wrapper-Y3UTVU2E.js +3635 -0
  78. package/dist/wrapper-Y3UTVU2E.js.map +1 -0
  79. package/package.json +73 -14
  80. package/tsconfig.json +0 -10
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Processor - Core pure function type for stream processing
3
+ *
4
+ * A Processor is a pure function that takes a state and an input,
5
+ * and returns a new state along with outputs.
6
+ *
7
+ * Pattern: (state, input) => [newState, outputs]
8
+ *
9
+ * Key properties:
10
+ * - Pure function (no side effects)
11
+ * - Deterministic (same input → same output)
12
+ * - State is a means (accumulator), outputs are the goal
13
+ *
14
+ * @template TState - The state type (internal accumulator)
15
+ * @template TInput - The input type
16
+ * @template TOutput - The output type (emissions)
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const messageProcessor: Processor<MsgState, StreamEvent, MsgEvent> =
21
+ * (state, input) => {
22
+ * switch (input.type) {
23
+ * case 'text_delta':
24
+ * return [{ ...state, buffer: state.buffer + input.data.text }, []];
25
+ * case 'message_stop':
26
+ * return [{ buffer: '' }, [{ type: 'assistant_message', content: state.buffer }]];
27
+ * default:
28
+ * return [state, []];
29
+ * }
30
+ * };
31
+ * ```
32
+ */
33
+ type Processor<TState, TInput, TOutput> = (state: Readonly<TState>, input: TInput) => [TState, TOutput[]];
34
+ /**
35
+ * ProcessorResult - The return type of a Processor
36
+ *
37
+ * A tuple containing:
38
+ * - [0] newState: The updated state after processing
39
+ * - [1] outputs: Array of outputs to emit
40
+ */
41
+ type ProcessorResult<TState, TOutput> = [TState, TOutput[]];
42
+ /**
43
+ * ProcessorDefinition - Metadata for a Processor
44
+ */
45
+ interface ProcessorDefinition<TState, TInput, TOutput> {
46
+ /**
47
+ * Unique name for this processor
48
+ */
49
+ name: string;
50
+ /**
51
+ * The pure processor function
52
+ */
53
+ processor: Processor<TState, TInput, TOutput>;
54
+ /**
55
+ * Initial state factory
56
+ */
57
+ initialState: () => TState;
58
+ /**
59
+ * Optional description
60
+ */
61
+ description?: string;
62
+ }
63
+
64
+ export type { Processor as P, ProcessorResult as a, ProcessorDefinition as b };
@@ -0,0 +1,223 @@
1
+ import { P as Processor, b as ProcessorDefinition } from '../../../Processor-DT0N1qI6.js';
2
+ import { a2 as AssistantMessageEvent, a3 as ToolCallMessageEvent, a4 as ToolResultMessageEvent, a5 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, aa as TurnRequestEvent, ab as TurnResponseEvent, a6 as AgentMessageEvent } from '../../../event-CDuTzs__.js';
3
+ import '../../../message-BMrMm1pq.js';
4
+
5
+ /**
6
+ * messageAssemblerProcessor
7
+ *
8
+ * Pure Mealy transition function that assembles complete Message Layer events
9
+ * from Stream Layer events.
10
+ *
11
+ * Input Events (Stream Layer):
12
+ * - message_start
13
+ * - text_delta
14
+ * - tool_use_start
15
+ * - input_json_delta
16
+ * - tool_use_stop
17
+ * - tool_result
18
+ * - message_stop
19
+ *
20
+ * Output Events (Message Layer):
21
+ * - tool_call_message (Message - AI's request to call a tool)
22
+ * - tool_result_message (Message - tool execution result)
23
+ * - assistant_message (Message - complete assistant response)
24
+ */
25
+
26
+ /**
27
+ * Pending content accumulator
28
+ */
29
+ interface PendingContent {
30
+ type: "text" | "tool_use";
31
+ index: number;
32
+ textDeltas?: string[];
33
+ toolId?: string;
34
+ toolName?: string;
35
+ toolInputJson?: string;
36
+ }
37
+ /**
38
+ * Pending tool call info (for matching with tool_result)
39
+ */
40
+ interface PendingToolCall {
41
+ id: string;
42
+ name: string;
43
+ }
44
+ /**
45
+ * MessageAssemblerState
46
+ *
47
+ * Tracks the state of message assembly from stream events.
48
+ */
49
+ interface MessageAssemblerState {
50
+ /**
51
+ * Current message ID being assembled
52
+ */
53
+ currentMessageId: string | null;
54
+ /**
55
+ * Timestamp when the current message started
56
+ */
57
+ messageStartTime: number | null;
58
+ /**
59
+ * Pending content blocks being accumulated
60
+ * Key is the content block index
61
+ */
62
+ pendingContents: Record<number, PendingContent>;
63
+ /**
64
+ * Pending tool calls waiting for results
65
+ * Key is the tool call ID
66
+ */
67
+ pendingToolCalls: Record<string, PendingToolCall>;
68
+ }
69
+ /**
70
+ * Initial state factory for MessageAssembler
71
+ */
72
+ declare function createInitialMessageAssemblerState(): MessageAssemblerState;
73
+ /**
74
+ * Output event types from MessageAssembler
75
+ */
76
+ type MessageAssemblerOutput = AssistantMessageEvent | ToolCallMessageEvent | ToolResultMessageEvent | ErrorMessageEvent;
77
+ /**
78
+ * Input event types for MessageAssembler
79
+ */
80
+ type MessageAssemblerInput = StreamEvent;
81
+ /**
82
+ * messageAssemblerProcessor
83
+ *
84
+ * Pure Mealy transition function for message assembly.
85
+ * Pattern: (state, input) => [newState, outputs]
86
+ */
87
+ declare const messageAssemblerProcessor: Processor<MessageAssemblerState, MessageAssemblerInput, MessageAssemblerOutput>;
88
+ /**
89
+ * MessageAssembler Processor Definition
90
+ */
91
+ declare const messageAssemblerProcessorDef: ProcessorDefinition<MessageAssemblerState, MessageAssemblerInput, MessageAssemblerOutput>;
92
+
93
+ /**
94
+ * stateEventProcessor
95
+ *
96
+ * Stateless event transformer: Stream Events → State Events
97
+ *
98
+ * Input Events (Stream Layer):
99
+ * - message_start
100
+ * - message_stop
101
+ * - text_delta (triggers responding state)
102
+ * - tool_use_start
103
+ * - tool_use_stop
104
+ *
105
+ * Output Events (State Layer):
106
+ * - conversation_start
107
+ * - conversation_responding
108
+ * - conversation_end
109
+ * - tool_planned
110
+ * - tool_executing
111
+ */
112
+
113
+ /**
114
+ * StateEventProcessorContext
115
+ *
116
+ * Minimal context needed for event transformation logic.
117
+ * Does NOT track agent state - only auxiliary info for decision-making.
118
+ *
119
+ * Currently empty - no context needed as all information comes from events.
120
+ */
121
+ interface StateEventProcessorContext {
122
+ }
123
+ /**
124
+ * Initial context factory for StateEventProcessor
125
+ */
126
+ declare function createInitialStateEventProcessorContext(): StateEventProcessorContext;
127
+ /**
128
+ * Output event types from StateEventProcessor
129
+ */
130
+ type StateEventProcessorOutput = ConversationStartEvent | ConversationRespondingEvent | ConversationEndEvent | ConversationInterruptedEvent | ToolPlannedEvent | ToolExecutingEvent | ErrorOccurredEvent;
131
+ /**
132
+ * Input event types for StateEventProcessor
133
+ */
134
+ type StateEventProcessorInput = StreamEvent;
135
+ /**
136
+ * stateEventProcessor
137
+ *
138
+ * Stateless event transformer: Stream Events → State Events
139
+ *
140
+ * Design:
141
+ * - Does NOT track agent state (that's StateMachine's job)
142
+ * - Only maintains auxiliary context (timestamps, etc.)
143
+ * - Emits State Events that StateMachine consumes
144
+ *
145
+ * Pattern: (context, input) => [newContext, outputs]
146
+ */
147
+ declare const stateEventProcessor: Processor<StateEventProcessorContext, StateEventProcessorInput, StateEventProcessorOutput>;
148
+ /**
149
+ * StateEvent Processor Definition
150
+ *
151
+ * Stateless event transformer: Stream Events → State Events
152
+ */
153
+ declare const stateEventProcessorDef: ProcessorDefinition<StateEventProcessorContext, StateEventProcessorInput, StateEventProcessorOutput>;
154
+
155
+ /**
156
+ * turnTrackerProcessor
157
+ *
158
+ * Pure Mealy transition function that tracks request-response turn pairs.
159
+ *
160
+ * Input Events:
161
+ * - user_message (Message Layer)
162
+ * - message_stop (Stream Layer - contains stop reason)
163
+ * - assistant_message (Message Layer)
164
+ *
165
+ * Output Events (Turn Layer):
166
+ * - turn_request
167
+ * - turn_response
168
+ */
169
+
170
+ /**
171
+ * Pending turn tracking
172
+ */
173
+ interface PendingTurn {
174
+ turnId: string;
175
+ messageId: string;
176
+ content: string;
177
+ requestedAt: number;
178
+ }
179
+ /**
180
+ * TurnTrackerState
181
+ *
182
+ * Tracks the current turn state.
183
+ */
184
+ interface TurnTrackerState {
185
+ /**
186
+ * Currently pending turn (waiting for response)
187
+ */
188
+ pendingTurn: PendingTurn | null;
189
+ /**
190
+ * Cost per input token (USD)
191
+ */
192
+ costPerInputToken: number;
193
+ /**
194
+ * Cost per output token (USD)
195
+ */
196
+ costPerOutputToken: number;
197
+ }
198
+ /**
199
+ * Initial state factory for TurnTracker
200
+ */
201
+ declare function createInitialTurnTrackerState(): TurnTrackerState;
202
+ /**
203
+ * Output event types from TurnTracker
204
+ */
205
+ type TurnTrackerOutput = TurnRequestEvent | TurnResponseEvent;
206
+ /**
207
+ * Input event types for TurnTracker
208
+ * Accepts both Stream and Message layer events
209
+ */
210
+ type TurnTrackerInput = StreamEvent | AgentMessageEvent;
211
+ /**
212
+ * turnTrackerProcessor
213
+ *
214
+ * Pure Mealy transition function for turn tracking.
215
+ * Pattern: (state, input) => [newState, outputs]
216
+ */
217
+ declare const turnTrackerProcessor: Processor<TurnTrackerState, TurnTrackerInput, TurnTrackerOutput>;
218
+ /**
219
+ * TurnTracker Processor Definition
220
+ */
221
+ declare const turnTrackerProcessorDef: ProcessorDefinition<TurnTrackerState, TurnTrackerInput, TurnTrackerOutput>;
222
+
223
+ export { type MessageAssemblerInput, type MessageAssemblerOutput, type MessageAssemblerState, type PendingContent, type PendingTurn, type StateEventProcessorContext, type StateEventProcessorInput, type StateEventProcessorOutput, type TurnTrackerInput, type TurnTrackerOutput, type TurnTrackerState, createInitialMessageAssemblerState, createInitialStateEventProcessorContext, createInitialTurnTrackerState, messageAssemblerProcessor, messageAssemblerProcessorDef, stateEventProcessor, stateEventProcessorDef, turnTrackerProcessor, turnTrackerProcessorDef };
@@ -0,0 +1,24 @@
1
+ import {
2
+ createInitialMessageAssemblerState,
3
+ createInitialStateEventProcessorContext,
4
+ createInitialTurnTrackerState,
5
+ messageAssemblerProcessor,
6
+ messageAssemblerProcessorDef,
7
+ stateEventProcessor,
8
+ stateEventProcessorDef,
9
+ turnTrackerProcessor,
10
+ turnTrackerProcessorDef
11
+ } from "../../../chunk-I7GYR3MN.js";
12
+ import "../../../chunk-7D4SUZUM.js";
13
+ export {
14
+ createInitialMessageAssemblerState,
15
+ createInitialStateEventProcessorContext,
16
+ createInitialTurnTrackerState,
17
+ messageAssemblerProcessor,
18
+ messageAssemblerProcessorDef,
19
+ stateEventProcessor,
20
+ stateEventProcessorDef,
21
+ turnTrackerProcessor,
22
+ turnTrackerProcessorDef
23
+ };
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,157 @@
1
+ import { S as Store, a as Sink, b as SinkDefinition } from '../../../combinators-nEa5dD0T.js';
2
+ export { M as MemoryStore, c as Source, d as SourceDefinition, g as chainProcessors, f as combineInitialStates, e as combineProcessors, h as filterProcessor, i as identityProcessor, m as mapOutput, w as withLogging } from '../../../combinators-nEa5dD0T.js';
3
+ import { P as Processor } from '../../../Processor-DT0N1qI6.js';
4
+ export { b as ProcessorDefinition, a as ProcessorResult } from '../../../Processor-DT0N1qI6.js';
5
+
6
+ /**
7
+ * Mealy - The Mealy Machine runtime
8
+ *
9
+ * A Mealy Machine is a finite-state machine where outputs depend on
10
+ * both the current state AND the input: (state, input) => (state, output)
11
+ *
12
+ * This runtime orchestrates the complete processing pipeline:
13
+ * 1. Sources receive external input (side effects)
14
+ * 2. Processors process inputs (pure Mealy transition functions)
15
+ * 3. Sinks produce output effects (side effects)
16
+ *
17
+ * Architecture:
18
+ * - Inputs enter through Sources (input adapters)
19
+ * - Processors transform inputs (pure functions, state is means)
20
+ * - Sinks produce actions (output adapters)
21
+ *
22
+ * @template TState - The state type (accumulator, means to an end)
23
+ * @template TInput - The input/output type for Processors
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const mealy = createMealy({
28
+ * processor: messageProcessor,
29
+ * store: new MemoryStore(),
30
+ * initialState: { text: '' },
31
+ * sinks: [sseSink, logSink],
32
+ * });
33
+ *
34
+ * // Process an input
35
+ * mealy.process('agent_123', input);
36
+ * ```
37
+ */
38
+
39
+ /**
40
+ * MealyConfig - Configuration for creating a Mealy instance
41
+ */
42
+ interface MealyConfig<TState, TInput> {
43
+ /**
44
+ * The processor function to execute (pure Mealy transition function)
45
+ */
46
+ processor: Processor<TState, TInput, TInput>;
47
+ /**
48
+ * The store for state persistence
49
+ */
50
+ store: Store<TState>;
51
+ /**
52
+ * Initial state for new IDs
53
+ */
54
+ initialState: TState;
55
+ /**
56
+ * Sinks to receive outputs
57
+ * Can be simple Sink functions or SinkDefinitions with filter/name
58
+ */
59
+ sinks?: (Sink<TInput> | SinkDefinition<TInput>)[];
60
+ /**
61
+ * Whether to recursively process outputs
62
+ * If true, outputs are fed back into the processor
63
+ *
64
+ * @default true
65
+ */
66
+ recursive?: boolean;
67
+ /**
68
+ * Maximum recursion depth to prevent infinite loops
69
+ *
70
+ * @default 100
71
+ */
72
+ maxDepth?: number;
73
+ }
74
+ /**
75
+ * ProcessResult - Result of processing an input
76
+ */
77
+ interface ProcessResult<TState, TOutput> {
78
+ /**
79
+ * The new state after processing
80
+ */
81
+ state: TState;
82
+ /**
83
+ * All outputs produced (including from recursion)
84
+ */
85
+ outputs: TOutput[];
86
+ /**
87
+ * Number of processor invocations (including recursion)
88
+ */
89
+ processCount: number;
90
+ }
91
+ /**
92
+ * Mealy - Mealy Machine runtime
93
+ *
94
+ * Implements the Mealy Machine pattern: (state, input) => (state, output)
95
+ * where output depends on both current state and input.
96
+ */
97
+ declare class Mealy<TState, TInput> {
98
+ private readonly processor;
99
+ private readonly store;
100
+ private readonly initialState;
101
+ private readonly sinks;
102
+ private readonly recursive;
103
+ private readonly maxDepth;
104
+ constructor(config: MealyConfig<TState, TInput>);
105
+ /**
106
+ * Process an input through the Mealy Machine
107
+ *
108
+ * @param id - Unique identifier (e.g., agentId)
109
+ * @param input - The input to process
110
+ * @returns Result containing new state and all outputs
111
+ */
112
+ process(id: string, input: TInput): ProcessResult<TState, TInput>;
113
+ /**
114
+ * Internal process with depth tracking
115
+ */
116
+ private processInternal;
117
+ /**
118
+ * Send outputs to all sinks
119
+ */
120
+ private sendToSinks;
121
+ /**
122
+ * Get current state for an ID (without processing)
123
+ */
124
+ getState(id: string): TState | undefined;
125
+ /**
126
+ * Check if state exists for an ID
127
+ */
128
+ hasState(id: string): boolean;
129
+ /**
130
+ * Delete state for an ID (cleanup)
131
+ */
132
+ cleanup(id: string): void;
133
+ /**
134
+ * Add a sink at runtime
135
+ */
136
+ addSink(sink: Sink<TInput> | SinkDefinition<TInput>): void;
137
+ /**
138
+ * Remove a sink by name (only works for SinkDefinitions)
139
+ */
140
+ removeSink(name: string): boolean;
141
+ }
142
+ /**
143
+ * createMealy - Factory function for creating Mealy Machine instances
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const mealy = createMealy({
148
+ * processor: myProcessor,
149
+ * store: new MemoryStore(),
150
+ * initialState: { count: 0 },
151
+ * sinks: [logSink],
152
+ * });
153
+ * ```
154
+ */
155
+ declare function createMealy<TState, TInput>(config: MealyConfig<TState, TInput>): Mealy<TState, TInput>;
156
+
157
+ export { Mealy, type MealyConfig, type ProcessResult, Processor, Sink, SinkDefinition, Store, createMealy };
@@ -0,0 +1,26 @@
1
+ import {
2
+ Mealy,
3
+ MemoryStore,
4
+ chainProcessors,
5
+ combineInitialStates,
6
+ combineProcessors,
7
+ createMealy,
8
+ filterProcessor,
9
+ identityProcessor,
10
+ mapOutput,
11
+ withLogging
12
+ } from "../../../chunk-EKHT54KN.js";
13
+ import "../../../chunk-7D4SUZUM.js";
14
+ export {
15
+ Mealy,
16
+ MemoryStore,
17
+ chainProcessors,
18
+ combineInitialStates,
19
+ combineProcessors,
20
+ createMealy,
21
+ filterProcessor,
22
+ identityProcessor,
23
+ mapOutput,
24
+ withLogging
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}