@agentxjs/core 1.9.9-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 +6 -6
- 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-TBU7FFZT.js → chunk-JTKCV7IS.js} +4 -4
- 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 +6 -6
- 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-E5FPOAPO.js.map +0 -1
- package/dist/chunk-I7GYR3MN.js.map +0 -1
- package/dist/chunk-K6WXQ2RW.js.map +0 -1
- package/dist/chunk-TBU7FFZT.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
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentXRuntime.test.ts - AgentEngine pipeline integration
|
|
3
|
+
*
|
|
4
|
+
* Verifies that the Runtime properly integrates with the
|
|
5
|
+
* AgentEngine pipeline (Source → MealyMachine → Presenter):
|
|
6
|
+
* - Message events (assistant_message, tool_result_message)
|
|
7
|
+
* - State events (conversation_start, conversation_end)
|
|
8
|
+
* - Turn events (turn_request, turn_response)
|
|
9
|
+
* - Message persistence (user + assistant + tool messages)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
|
13
|
+
import { createAgentXRuntime } from "../AgentXRuntime";
|
|
14
|
+
import { EventBusImpl as EventBus } from "../../event/EventBus";
|
|
15
|
+
import type { AgentXPlatform } from "../../platform/types";
|
|
16
|
+
import type { Message } from "../../agent/types";
|
|
17
|
+
import type { BusEvent } from "../../event/types";
|
|
18
|
+
import type { DriverStreamEvent } from "../../driver/types";
|
|
19
|
+
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Mock Helpers
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a mock Driver that yields predefined stream events
|
|
26
|
+
*/
|
|
27
|
+
function createMockDriver(events: DriverStreamEvent[]) {
|
|
28
|
+
return {
|
|
29
|
+
name: "MockDriver",
|
|
30
|
+
initialize: async () => {},
|
|
31
|
+
receive: async function* () {
|
|
32
|
+
for (const event of events) {
|
|
33
|
+
yield event;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
interrupt: () => {},
|
|
37
|
+
dispose: async () => {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Simple text response: message_start → text_delta → message_stop
|
|
43
|
+
*/
|
|
44
|
+
function simpleTextResponse(text: string): DriverStreamEvent[] {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
type: "message_start",
|
|
48
|
+
data: { messageId: "msg_test_1", model: "test-model" },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "text_delta",
|
|
52
|
+
data: { text },
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "message_stop",
|
|
56
|
+
data: { stopReason: "end_turn" },
|
|
57
|
+
},
|
|
58
|
+
] as DriverStreamEvent[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* In-memory SessionRepository
|
|
63
|
+
*/
|
|
64
|
+
function createMockSessionRepository() {
|
|
65
|
+
const sessions = new Map<string, { messages: Message[] }>();
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
saveSession: async (record: { sessionId: string }) => {
|
|
69
|
+
if (!sessions.has(record.sessionId)) {
|
|
70
|
+
sessions.set(record.sessionId, { messages: [] });
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
findSessionById: async (sessionId: string) => {
|
|
74
|
+
return sessions.has(sessionId) ? { sessionId } : null;
|
|
75
|
+
},
|
|
76
|
+
findSessionsByImageId: async () => [],
|
|
77
|
+
findSessionsByContainerId: async () => [],
|
|
78
|
+
deleteSession: async () => {},
|
|
79
|
+
addMessage: async (sessionId: string, message: Message) => {
|
|
80
|
+
if (!sessions.has(sessionId)) {
|
|
81
|
+
sessions.set(sessionId, { messages: [] });
|
|
82
|
+
}
|
|
83
|
+
sessions.get(sessionId)!.messages.push(message);
|
|
84
|
+
},
|
|
85
|
+
getMessages: async (sessionId: string) => {
|
|
86
|
+
return sessions.get(sessionId)?.messages ?? [];
|
|
87
|
+
},
|
|
88
|
+
clearMessages: async () => {},
|
|
89
|
+
|
|
90
|
+
// Helper for test assertions
|
|
91
|
+
_getMessages: (sessionId: string) => sessions.get(sessionId)?.messages ?? [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Minimal mock platform
|
|
97
|
+
*/
|
|
98
|
+
function createMockPlatform(driverEvents: DriverStreamEvent[]) {
|
|
99
|
+
const eventBus = new EventBus();
|
|
100
|
+
const sessionRepo = createMockSessionRepository();
|
|
101
|
+
|
|
102
|
+
const platform: AgentXPlatform = {
|
|
103
|
+
containerRepository: {
|
|
104
|
+
createContainer: async () => {},
|
|
105
|
+
containerExists: async () => true,
|
|
106
|
+
findAllContainers: async () => [],
|
|
107
|
+
deleteContainer: async () => {},
|
|
108
|
+
},
|
|
109
|
+
imageRepository: {
|
|
110
|
+
saveImage: async () => {},
|
|
111
|
+
findImageById: async (imageId: string) => ({
|
|
112
|
+
imageId,
|
|
113
|
+
containerId: "container_1",
|
|
114
|
+
sessionId: "session_1",
|
|
115
|
+
name: "TestBot",
|
|
116
|
+
systemPrompt: "You are a test bot.",
|
|
117
|
+
createdAt: Date.now(),
|
|
118
|
+
}),
|
|
119
|
+
findImagesByContainerId: async () => [],
|
|
120
|
+
deleteImage: async () => {},
|
|
121
|
+
updateMetadata: async () => {},
|
|
122
|
+
},
|
|
123
|
+
sessionRepository: sessionRepo,
|
|
124
|
+
eventBus,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const runtime = createAgentXRuntime(platform, () => createMockDriver(driverEvents));
|
|
128
|
+
|
|
129
|
+
return { platform, runtime, eventBus, sessionRepo };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Tests
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
describe("AgentXRuntime - AgentEngine Pipeline", () => {
|
|
137
|
+
let env: ReturnType<typeof createMockPlatform>;
|
|
138
|
+
|
|
139
|
+
afterEach(async () => {
|
|
140
|
+
await env.runtime.shutdown();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("message event emission", () => {
|
|
144
|
+
it("should emit assistant_message event after text response", async () => {
|
|
145
|
+
env = createMockPlatform(simpleTextResponse("Hello from assistant"));
|
|
146
|
+
|
|
147
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
148
|
+
|
|
149
|
+
const events: BusEvent[] = [];
|
|
150
|
+
env.eventBus.onAny((event) => {
|
|
151
|
+
events.push(event as BusEvent);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
await env.runtime.receive(agent.agentId, "Hi");
|
|
155
|
+
|
|
156
|
+
// Wait for async processing
|
|
157
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
158
|
+
|
|
159
|
+
const messageTypes = events.map((e) => e.type);
|
|
160
|
+
|
|
161
|
+
// Runtime should produce assistant_message via MealyMachine → Presenter
|
|
162
|
+
expect(messageTypes).toContain("assistant_message");
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("should emit assistant_message with tool calls and tool_result_message", async () => {
|
|
166
|
+
const toolEvents: DriverStreamEvent[] = [
|
|
167
|
+
{
|
|
168
|
+
type: "message_start",
|
|
169
|
+
data: { messageId: "msg_tool", model: "test-model" },
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "tool_use_start",
|
|
173
|
+
data: { toolCallId: "tc_1", toolName: "get_weather" },
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "input_json_delta",
|
|
177
|
+
data: { partialJson: '{"city":"Tokyo"}' },
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: "tool_use_stop",
|
|
181
|
+
data: { toolCallId: "tc_1", toolName: "get_weather", input: { city: "Tokyo" } },
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: "message_stop",
|
|
185
|
+
data: { stopReason: "tool_use" },
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
type: "tool_result",
|
|
189
|
+
data: { toolCallId: "tc_1", result: "Sunny, 25°C", isError: false },
|
|
190
|
+
},
|
|
191
|
+
] as DriverStreamEvent[];
|
|
192
|
+
|
|
193
|
+
env = createMockPlatform(toolEvents);
|
|
194
|
+
|
|
195
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
196
|
+
|
|
197
|
+
const events: BusEvent[] = [];
|
|
198
|
+
env.eventBus.onAny((event) => {
|
|
199
|
+
events.push(event as BusEvent);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
await env.runtime.receive(agent.agentId, "What's the weather?");
|
|
203
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
204
|
+
|
|
205
|
+
const messageTypes = events.map((e) => e.type);
|
|
206
|
+
// Tool calls are now part of assistant_message, not separate tool_call_message
|
|
207
|
+
expect(messageTypes).toContain("assistant_message");
|
|
208
|
+
expect(messageTypes).toContain("tool_result_message");
|
|
209
|
+
expect(messageTypes).not.toContain("tool_call_message");
|
|
210
|
+
|
|
211
|
+
// Verify assistant message contains tool call in content
|
|
212
|
+
const assistantEvent = events.find((e) => e.type === "assistant_message");
|
|
213
|
+
const content = (assistantEvent?.data as { content: unknown[] })?.content;
|
|
214
|
+
expect(content).toBeDefined();
|
|
215
|
+
const toolCallPart = content?.find(
|
|
216
|
+
(p: unknown) => (p as { type: string }).type === "tool-call"
|
|
217
|
+
);
|
|
218
|
+
expect(toolCallPart).toBeDefined();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("state event emission", () => {
|
|
223
|
+
it("should emit conversation lifecycle events", async () => {
|
|
224
|
+
env = createMockPlatform(simpleTextResponse("Hello"));
|
|
225
|
+
|
|
226
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
227
|
+
|
|
228
|
+
const events: BusEvent[] = [];
|
|
229
|
+
env.eventBus.onAny((event) => {
|
|
230
|
+
events.push(event as BusEvent);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await env.runtime.receive(agent.agentId, "Hi");
|
|
234
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
235
|
+
|
|
236
|
+
const types = events.map((e) => e.type);
|
|
237
|
+
|
|
238
|
+
// MealyMachine should produce state events
|
|
239
|
+
expect(types).toContain("conversation_start");
|
|
240
|
+
expect(types).toContain("conversation_end");
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
describe("message persistence", () => {
|
|
245
|
+
it("should persist user message to session", async () => {
|
|
246
|
+
env = createMockPlatform(simpleTextResponse("Hello"));
|
|
247
|
+
|
|
248
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
249
|
+
await env.runtime.receive(agent.agentId, "Hi");
|
|
250
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
251
|
+
|
|
252
|
+
const messages = env.sessionRepo._getMessages("session_1");
|
|
253
|
+
const userMessages = messages.filter((m) => m.subtype === "user");
|
|
254
|
+
|
|
255
|
+
expect(userMessages.length).toBe(1);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("should persist assistant message to session", async () => {
|
|
259
|
+
env = createMockPlatform(simpleTextResponse("Hello from assistant"));
|
|
260
|
+
|
|
261
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
262
|
+
await env.runtime.receive(agent.agentId, "Hi");
|
|
263
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
264
|
+
|
|
265
|
+
const messages = env.sessionRepo._getMessages("session_1");
|
|
266
|
+
const assistantMessages = messages.filter((m) => m.subtype === "assistant");
|
|
267
|
+
|
|
268
|
+
expect(assistantMessages.length).toBe(1);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("should persist tool_call and tool_result messages to session", async () => {
|
|
272
|
+
const toolEvents: DriverStreamEvent[] = [
|
|
273
|
+
{
|
|
274
|
+
type: "message_start",
|
|
275
|
+
data: { messageId: "msg_tool", model: "test-model" },
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
type: "tool_use_start",
|
|
279
|
+
data: { toolCallId: "tc_1", toolName: "bash" },
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
type: "input_json_delta",
|
|
283
|
+
data: { partialJson: '{"cmd":"ls"}' },
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: "tool_use_stop",
|
|
287
|
+
data: { toolCallId: "tc_1", toolName: "bash", input: { cmd: "ls" } },
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
type: "tool_result",
|
|
291
|
+
data: { toolCallId: "tc_1", result: "file.txt", isError: false },
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
type: "message_stop",
|
|
295
|
+
data: { stopReason: "end_turn" },
|
|
296
|
+
},
|
|
297
|
+
] as DriverStreamEvent[];
|
|
298
|
+
|
|
299
|
+
env = createMockPlatform(toolEvents);
|
|
300
|
+
|
|
301
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
302
|
+
await env.runtime.receive(agent.agentId, "List files");
|
|
303
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
304
|
+
|
|
305
|
+
const messages = env.sessionRepo._getMessages("session_1");
|
|
306
|
+
// Tool calls are inside assistant message content, not separate messages
|
|
307
|
+
const assistantMessages = messages.filter((m) => m.subtype === "assistant");
|
|
308
|
+
const toolResultMessages = messages.filter((m) => m.subtype === "tool-result");
|
|
309
|
+
|
|
310
|
+
expect(assistantMessages.length).toBeGreaterThanOrEqual(1);
|
|
311
|
+
// Verify at least one assistant message has a tool-call part
|
|
312
|
+
const hasToolCall = assistantMessages.some((m) => {
|
|
313
|
+
const content = (m as { content: unknown }).content;
|
|
314
|
+
return (
|
|
315
|
+
Array.isArray(content) &&
|
|
316
|
+
content.some((p: unknown) => (p as { type: string }).type === "tool-call")
|
|
317
|
+
);
|
|
318
|
+
});
|
|
319
|
+
expect(hasToolCall).toBe(true);
|
|
320
|
+
expect(toolResultMessages.length).toBe(1);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
describe("turn tracking", () => {
|
|
325
|
+
it("should emit turn_request and turn_response events", async () => {
|
|
326
|
+
env = createMockPlatform(simpleTextResponse("Hello"));
|
|
327
|
+
|
|
328
|
+
const agent = await env.runtime.createAgent({ imageId: "img_1" });
|
|
329
|
+
|
|
330
|
+
const events: BusEvent[] = [];
|
|
331
|
+
env.eventBus.onAny((event) => {
|
|
332
|
+
events.push(event as BusEvent);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
await env.runtime.receive(agent.agentId, "Hi");
|
|
336
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
337
|
+
|
|
338
|
+
const types = events.map((e) => e.type);
|
|
339
|
+
expect(types).toContain("turn_request");
|
|
340
|
+
expect(types).toContain("turn_response");
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
package/src/runtime/index.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* AgentXRuntime interface and implementation.
|
|
5
|
+
* AgentXPlatform is re-exported here for backward compatibility,
|
|
6
|
+
* but its canonical home is @agentxjs/core/platform.
|
|
6
7
|
*
|
|
7
8
|
* Usage:
|
|
8
9
|
* ```typescript
|
|
9
|
-
* import type {
|
|
10
|
-
*
|
|
11
|
-
* AgentXRuntime,
|
|
12
|
-
* RuntimeAgent,
|
|
13
|
-
* } from "@agentxjs/core/runtime";
|
|
10
|
+
* import type { AgentXPlatform } from "@agentxjs/core/platform";
|
|
11
|
+
* import type { AgentXRuntime, RuntimeAgent } from "@agentxjs/core/runtime";
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
* const provider: AgentXProvider = {
|
|
17
|
-
* containerRepository,
|
|
18
|
-
* imageRepository,
|
|
19
|
-
* sessionRepository,
|
|
20
|
-
* workspaceProvider,
|
|
21
|
-
* driver,
|
|
22
|
-
* eventBus,
|
|
23
|
-
* };
|
|
24
|
-
*
|
|
25
|
-
* const runtime: AgentXRuntime = createRuntime({ provider });
|
|
13
|
+
* const runtime = createAgentXRuntime(platform, createDriver);
|
|
26
14
|
*
|
|
27
15
|
* // Create agent from image
|
|
28
16
|
* const agent = await runtime.createAgent({ imageId: "img_xxx" });
|
|
@@ -44,7 +32,7 @@
|
|
|
44
32
|
export type {
|
|
45
33
|
AgentLifecycle,
|
|
46
34
|
RuntimeAgent,
|
|
47
|
-
|
|
35
|
+
AgentXPlatform,
|
|
48
36
|
CreateAgentOptions,
|
|
49
37
|
AgentEventHandler,
|
|
50
38
|
Subscription,
|
package/src/runtime/types.ts
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime Types
|
|
3
3
|
*
|
|
4
|
-
* AgentXProvider - Dependency injection container
|
|
5
4
|
* AgentXRuntime - Runtime integration layer
|
|
6
5
|
*
|
|
7
6
|
* Architecture:
|
|
8
7
|
* ```
|
|
9
8
|
* ┌─────────────────────────────────────────────────────────────┐
|
|
10
|
-
* │
|
|
11
|
-
* │
|
|
12
|
-
* │ │
|
|
13
|
-
* │ ┌─────────────┐ ┌─────────────┐ ┌───────────────┐ │
|
|
14
|
-
* │ │ Repositories│ │ Workspace │ │ DriverFactory │ │
|
|
15
|
-
* │ │ Container │ │ Provider │ │ (per-Agent) │ │
|
|
16
|
-
* │ │ Image │ │ │ │ │ │
|
|
17
|
-
* │ │ Session │ │ │ │ │ │
|
|
18
|
-
* │ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
9
|
+
* │ AgentXPlatform │
|
|
10
|
+
* │ (see @agentxjs/core/platform) │
|
|
19
11
|
* └─────────────────────────────────────────────────────────────┘
|
|
20
12
|
* │
|
|
21
13
|
* ▼
|
|
22
14
|
* ┌─────────────────────────────────────────────────────────────┐
|
|
23
15
|
* │ AgentXRuntime │
|
|
24
|
-
* │ (Integration - Uses
|
|
16
|
+
* │ (Integration - Uses Platform dependencies) │
|
|
25
17
|
* │ │
|
|
26
18
|
* │ ┌─────────────────────────────────────────────────────┐ │
|
|
27
19
|
* │ │ Agent Lifecycle: create / get / destroy │ │
|
|
@@ -32,15 +24,13 @@
|
|
|
32
24
|
* ```
|
|
33
25
|
*/
|
|
34
26
|
|
|
35
|
-
import type {
|
|
36
|
-
import type { ImageRepository } from "../image/types";
|
|
37
|
-
import type { SessionRepository } from "../session/types";
|
|
38
|
-
import type { WorkspaceProvider } from "../workspace/types";
|
|
39
|
-
import type { CreateDriver } from "../driver/types";
|
|
40
|
-
import type { EventBus } from "../event/types";
|
|
27
|
+
import type { AgentXPlatform } from "../platform/types";
|
|
41
28
|
import type { UserContentPart } from "../agent/types";
|
|
42
29
|
import type { BusEvent } from "../event/types";
|
|
43
30
|
|
|
31
|
+
// Re-export AgentXPlatform for backward compatibility
|
|
32
|
+
export type { AgentXPlatform } from "../platform/types";
|
|
33
|
+
|
|
44
34
|
// ============================================================================
|
|
45
35
|
// Agent Runtime State
|
|
46
36
|
// ============================================================================
|
|
@@ -63,48 +53,6 @@ export interface RuntimeAgent {
|
|
|
63
53
|
readonly createdAt: number;
|
|
64
54
|
}
|
|
65
55
|
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// AgentXProvider - Dependency Injection
|
|
68
|
-
// ============================================================================
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* AgentXProvider - Collects all dependencies for runtime
|
|
72
|
-
*
|
|
73
|
-
* Platform packages provide implementations of these interfaces.
|
|
74
|
-
* The provider is passed to AgentXRuntime for integration.
|
|
75
|
-
*/
|
|
76
|
-
export interface AgentXProvider {
|
|
77
|
-
/**
|
|
78
|
-
* Container repository for persistence
|
|
79
|
-
*/
|
|
80
|
-
readonly containerRepository: ContainerRepository;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Image repository for persistence
|
|
84
|
-
*/
|
|
85
|
-
readonly imageRepository: ImageRepository;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Session repository for persistence
|
|
89
|
-
*/
|
|
90
|
-
readonly sessionRepository: SessionRepository;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Workspace provider for isolated environments
|
|
94
|
-
*/
|
|
95
|
-
readonly workspaceProvider: WorkspaceProvider;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* LLM Driver factory function - creates Driver per Agent
|
|
99
|
-
*/
|
|
100
|
-
readonly createDriver: CreateDriver;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Event bus for pub/sub
|
|
104
|
-
*/
|
|
105
|
-
readonly eventBus: EventBus;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
56
|
// ============================================================================
|
|
109
57
|
// AgentXRuntime - Integration Layer
|
|
110
58
|
// ============================================================================
|
|
@@ -144,9 +92,9 @@ export interface Subscription {
|
|
|
144
92
|
*/
|
|
145
93
|
export interface AgentXRuntime {
|
|
146
94
|
/**
|
|
147
|
-
* The
|
|
95
|
+
* The platform containing all dependencies
|
|
148
96
|
*/
|
|
149
|
-
readonly
|
|
97
|
+
readonly platform: AgentXPlatform;
|
|
150
98
|
|
|
151
99
|
// ==================== Agent Lifecycle ====================
|
|
152
100
|
|
|
@@ -227,7 +175,7 @@ export interface AgentXRuntime {
|
|
|
227
175
|
* Configuration for creating AgentXRuntime
|
|
228
176
|
*/
|
|
229
177
|
export interface AgentXRuntimeConfig {
|
|
230
|
-
|
|
178
|
+
platform: AgentXPlatform;
|
|
231
179
|
}
|
|
232
180
|
|
|
233
181
|
/**
|
package/dist/chunk-7D4SUZUM.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
__require,
|
|
35
|
-
__commonJS,
|
|
36
|
-
__toESM
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=chunk-7D4SUZUM.js.map
|