@agentxjs/types 0.0.6 → 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 @@
|
|
|
1
|
+
//# sourceMappingURL=runtime-internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/runtime.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/runtime/index.ts
|
|
17
|
+
var runtime_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
19
|
+
//# sourceMappingURL=runtime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/index.ts"],"sourcesContent":["/**\n * Runtime Module - Execution environment for AI Agents\n *\n * Runtime manages the complete system: Container lifecycle, Session persistence,\n * Sandbox isolation, and event-driven communication via SystemBus.\n *\n * ## Architecture\n *\n * ```\n * Runtime (extends SystemBus)\n * │\n * ├── Container 1\n * │ ├── Agent A ─── Sandbox A ─── Session A\n * │ └── Agent B ─── Sandbox B ─── Session B\n * │\n * └── Container 2\n * └── Agent C ─── Sandbox C ─── Session C\n *\n * Environment (LLM connection)\n * └── Receptor → DriveableEvent → SystemBus → Agent\n * ```\n *\n * ## Two-Domain Relationship\n *\n * ```\n * Runtime Domain AgentEngine Domain\n * ─────────────────────────────────────────────────────────\n * Agent (complete entity) AgentEngine (processing unit)\n * - lifecycle: stop/resume - receive/on/react\n * - LLM + Sandbox + Session - Driver + MealyMachine + Presenter\n *\n * SystemEvent (full context) AgentEvent (lightweight)\n * - source, category, intent - type, timestamp, data\n *\n * DriveableEvent StreamEvent\n * - from Environment - simplified for Engine\n * │ ▲\n * └──────── Driver converts ───────────┘\n * ```\n *\n * ## Core Components\n *\n * | Component | Responsibility |\n * |-----------|----------------|\n * | Runtime | Event-driven API, extends SystemBus |\n * | Container | Agent lifecycle, isolation boundary |\n * | Agent | Complete runtime entity (LLM + Sandbox + Session) |\n * | AgentImage| Snapshot for stop/resume capability |\n * | Session | Message persistence per Agent |\n * | Sandbox | Isolated environment (Workdir, MCP tools) |\n *\n * ## Usage\n *\n * ```typescript\n * // Create runtime\n * const runtime = createRuntime({ persistence });\n *\n * // Create container and run agent\n * const containerRes = await runtime.request(\"container_create_request\", {\n * containerId: \"my-container\"\n * });\n * const agentRes = await runtime.request(\"agent_run_request\", {\n * containerId: \"my-container\",\n * config: { name: \"Assistant\", systemPrompt: \"You are helpful.\" }\n * });\n *\n * // Subscribe to events\n * runtime.on(\"text_delta\", (e) => console.log(e.data.text));\n *\n * // Send message\n * await runtime.request(\"agent_receive_request\", {\n * agentId: agentRes.data.agentId,\n * content: \"Hello!\"\n * });\n * ```\n *\n * For internal implementation types (Container, LLM, Sandbox, Session, etc.),\n * use `@agentxjs/types/runtime/internal`.\n *\n * @packageDocumentation\n */\n\n// ============================================================================\n// Runtime Entry\n// ============================================================================\n\nexport type { Runtime, Unsubscribe, BusEventHandler } from \"./Runtime\";\n\nexport type { Container } from \"./internal/container/Container\";\n\nexport type { AgentImage, ImageMessage } from \"./AgentImage\";\n\nexport type { LLMProvider, ClaudeLLMConfig, ClaudeLLMProvider } from \"./LLMProvider\";\n\n// ============================================================================\n// Agent Runtime\n// ============================================================================\n\nexport type { Agent } from \"./Agent\";\nexport type { AgentConfig } from \"./AgentConfig\";\nexport type { AgentLifecycle } from \"./AgentLifecycle\";\n\n// ============================================================================\n// Events (Re-exported from @agentxjs/types/event)\n// ============================================================================\n\nexport type {\n SystemEvent,\n EventSource,\n EventIntent,\n EventCategory,\n EventContext,\n} from \"~/event/base/SystemEvent\";\n\nexport type {\n DriveableEvent,\n DriveableEventType,\n MessageStartEvent,\n MessageDeltaEvent,\n MessageStopEvent,\n TextContentBlockStartEvent,\n TextDeltaEvent,\n TextContentBlockStopEvent,\n ToolUseContentBlockStartEvent,\n InputJsonDeltaEvent,\n ToolUseContentBlockStopEvent,\n ToolCallEvent,\n ToolResultEvent,\n InterruptedEvent,\n ErrorReceivedEvent,\n} from \"~/event/environment\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { S as SystemBus, A as Agent } from './Container-dBDOcjhk.cjs';
|
|
2
|
+
export { a as AgentLifecycle, B as BusEventHandler, C as Container, U as Unsubscribe } from './Container-dBDOcjhk.cjs';
|
|
3
|
+
import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage } from './ToolResultMessage-CRKMSf5d.cjs';
|
|
4
|
+
export { b as EventCategory, c as EventContext, a as EventIntent, E as EventSource, S as SystemEvent } from './SystemEvent-CPvvxdMQ.cjs';
|
|
5
|
+
export { D as DriveableEvent, a as DriveableEventType, E as ErrorReceivedEvent, I as InputJsonDeltaEvent, j as InterruptedEvent, b as MessageDeltaEvent, M as MessageStartEvent, c as MessageStopEvent, T as TextContentBlockStartEvent, e as TextContentBlockStopEvent, d as TextDeltaEvent, h as ToolCallEvent, i as ToolResultEvent, f as ToolUseContentBlockStartEvent, g as ToolUseContentBlockStopEvent } from './DriveableEvent-CCMC1h_C.cjs';
|
|
6
|
+
import './CommandEvent-DCdk7lzX.cjs';
|
|
7
|
+
import './ImageRecord-Cn0VcJWk.cjs';
|
|
8
|
+
import './StopReason-D4DthB1h.cjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Runtime - Event-driven API for managing Containers and Agents
|
|
12
|
+
*
|
|
13
|
+
* All operations are performed through command events.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const runtime = createRuntime({ persistence });
|
|
18
|
+
*
|
|
19
|
+
* // Using request() - convenient async/await
|
|
20
|
+
* const containerRes = await runtime.request("container_create_request", {
|
|
21
|
+
* containerId: "my-container"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const agentRes = await runtime.request("agent_run_request", {
|
|
25
|
+
* containerId: "my-container",
|
|
26
|
+
* config: { name: "Assistant" }
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Using emitCommand/onCommand - fine-grained control
|
|
30
|
+
* runtime.emitCommand("agent_receive_request", {
|
|
31
|
+
* requestId: "req_123",
|
|
32
|
+
* agentId: agentRes.data.agentId,
|
|
33
|
+
* content: "Hello!"
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Subscribe to stream events
|
|
37
|
+
* runtime.on("text_delta", (e) => console.log(e.data.text));
|
|
38
|
+
*
|
|
39
|
+
* // Cleanup
|
|
40
|
+
* await runtime.dispose();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Runtime interface - event-driven API for AI Agents
|
|
46
|
+
*
|
|
47
|
+
* Extends SystemBus to provide all event operations.
|
|
48
|
+
*/
|
|
49
|
+
interface Runtime extends SystemBus {
|
|
50
|
+
/**
|
|
51
|
+
* Dispose runtime and all resources
|
|
52
|
+
*/
|
|
53
|
+
dispose(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* AgentImage - Agent runtime snapshot (persisted state)
|
|
58
|
+
*
|
|
59
|
+
* AgentImage is a complete snapshot of an Agent's state at a point in time.
|
|
60
|
+
* It contains all information needed to fully restore an Agent:
|
|
61
|
+
* - Runtime context (containerId, agentId)
|
|
62
|
+
* - Configuration (name, systemPrompt)
|
|
63
|
+
* - Conversation history (messages)
|
|
64
|
+
*
|
|
65
|
+
* AgentImage is an object with behavior - it can restore itself to a running Agent.
|
|
66
|
+
*
|
|
67
|
+
* Workflow:
|
|
68
|
+
* ```
|
|
69
|
+
* Agent → runtime.images.snapshot(agent) → AgentImage
|
|
70
|
+
* ↓
|
|
71
|
+
* image.resume()
|
|
72
|
+
* ↓
|
|
73
|
+
* New Agent (restored)
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // Create and use agent
|
|
79
|
+
* const agent = await runtime.agents.run(containerId, config);
|
|
80
|
+
* await agent.receive("Hello!");
|
|
81
|
+
*
|
|
82
|
+
* // Snapshot
|
|
83
|
+
* const image = await runtime.images.snapshot(agent);
|
|
84
|
+
*
|
|
85
|
+
* // Later: restore from image
|
|
86
|
+
* const restoredAgent = await image.resume();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Union type of all message types that can be stored in an Image
|
|
92
|
+
*/
|
|
93
|
+
type ImageMessage = UserMessage | AssistantMessage | ToolCallMessage | ToolResultMessage;
|
|
94
|
+
/**
|
|
95
|
+
* AgentImage - Complete snapshot of Agent state with behavior
|
|
96
|
+
*/
|
|
97
|
+
interface AgentImage {
|
|
98
|
+
/**
|
|
99
|
+
* Unique image identifier
|
|
100
|
+
* Pattern: `img_${nanoid()}`
|
|
101
|
+
*/
|
|
102
|
+
readonly imageId: string;
|
|
103
|
+
/**
|
|
104
|
+
* Container ID where this agent was running
|
|
105
|
+
*/
|
|
106
|
+
readonly containerId: string;
|
|
107
|
+
/**
|
|
108
|
+
* Original agent ID (for traceability)
|
|
109
|
+
*/
|
|
110
|
+
readonly agentId: string;
|
|
111
|
+
/**
|
|
112
|
+
* Agent name
|
|
113
|
+
*/
|
|
114
|
+
readonly name: string;
|
|
115
|
+
/**
|
|
116
|
+
* Agent description (optional)
|
|
117
|
+
*/
|
|
118
|
+
readonly description?: string;
|
|
119
|
+
/**
|
|
120
|
+
* System prompt - controls agent behavior
|
|
121
|
+
*/
|
|
122
|
+
readonly systemPrompt?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Conversation history snapshot
|
|
125
|
+
*/
|
|
126
|
+
readonly messages: ImageMessage[];
|
|
127
|
+
/**
|
|
128
|
+
* Parent image ID (if this image was derived from another)
|
|
129
|
+
*/
|
|
130
|
+
readonly parentImageId?: string;
|
|
131
|
+
/**
|
|
132
|
+
* When this image was created (Unix milliseconds)
|
|
133
|
+
*/
|
|
134
|
+
readonly createdAt: number;
|
|
135
|
+
/**
|
|
136
|
+
* Resume an agent from this image
|
|
137
|
+
*
|
|
138
|
+
* Creates a new Agent instance with the saved configuration
|
|
139
|
+
* and conversation history restored.
|
|
140
|
+
*
|
|
141
|
+
* @throws Error if container not found
|
|
142
|
+
* @returns New Agent instance
|
|
143
|
+
*/
|
|
144
|
+
resume(): Promise<Agent>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* LLMProvider - Large Language Model Supply Service
|
|
149
|
+
*
|
|
150
|
+
* Provides LLM configuration at Runtime level.
|
|
151
|
+
* All Agents in the Runtime share the same LLMProvider.
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* LLMProvider - Large Language Model supply service
|
|
155
|
+
*
|
|
156
|
+
* @typeParam TSupply - Supply type (config, client, token, etc.)
|
|
157
|
+
*/
|
|
158
|
+
interface LLMProvider<TSupply = unknown> {
|
|
159
|
+
/**
|
|
160
|
+
* Provider identifier (e.g., "claude", "openai")
|
|
161
|
+
*/
|
|
162
|
+
readonly name: string;
|
|
163
|
+
/**
|
|
164
|
+
* Provide LLM configuration
|
|
165
|
+
*/
|
|
166
|
+
provide(): TSupply;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* ClaudeLLMConfig - Configuration for Claude LLM
|
|
170
|
+
*/
|
|
171
|
+
interface ClaudeLLMConfig {
|
|
172
|
+
/**
|
|
173
|
+
* Anthropic API key
|
|
174
|
+
*/
|
|
175
|
+
apiKey: string;
|
|
176
|
+
/**
|
|
177
|
+
* API base URL (optional, for custom endpoints)
|
|
178
|
+
*/
|
|
179
|
+
baseUrl?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Model name (e.g., "claude-sonnet-4-20250514")
|
|
182
|
+
*/
|
|
183
|
+
model?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Type alias for Claude LLM Provider
|
|
187
|
+
*/
|
|
188
|
+
type ClaudeLLMProvider = LLMProvider<ClaudeLLMConfig>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* AgentConfig - Runtime configuration for Agent instance
|
|
192
|
+
*
|
|
193
|
+
* Contains the configuration needed to run an Agent.
|
|
194
|
+
* Copied from AgentDefinition when Agent is created.
|
|
195
|
+
*
|
|
196
|
+
* Separation of concerns:
|
|
197
|
+
* - AgentDefinition (application layer) = static template
|
|
198
|
+
* - AgentConfig (runtime layer) = runtime configuration
|
|
199
|
+
*
|
|
200
|
+
* This keeps runtime layer independent of application layer.
|
|
201
|
+
*/
|
|
202
|
+
interface AgentConfig {
|
|
203
|
+
/**
|
|
204
|
+
* Agent name
|
|
205
|
+
*/
|
|
206
|
+
name: string;
|
|
207
|
+
/**
|
|
208
|
+
* Agent description (optional)
|
|
209
|
+
*/
|
|
210
|
+
description?: string;
|
|
211
|
+
/**
|
|
212
|
+
* System prompt - controls agent behavior
|
|
213
|
+
*/
|
|
214
|
+
systemPrompt?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { Agent, type AgentConfig, type AgentImage, type ClaudeLLMConfig, type ClaudeLLMProvider, type ImageMessage, type LLMProvider, type Runtime };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { S as SystemBus, A as Agent } from './Container-DR-1g44i.js';
|
|
2
|
+
export { a as AgentLifecycle, B as BusEventHandler, C as Container, U as Unsubscribe } from './Container-DR-1g44i.js';
|
|
3
|
+
import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage } from './ToolResultMessage-CDG2L7Zv.js';
|
|
4
|
+
export { b as EventCategory, c as EventContext, a as EventIntent, E as EventSource, S as SystemEvent } from './SystemEvent-CPvvxdMQ.js';
|
|
5
|
+
export { D as DriveableEvent, a as DriveableEventType, E as ErrorReceivedEvent, I as InputJsonDeltaEvent, j as InterruptedEvent, b as MessageDeltaEvent, M as MessageStartEvent, c as MessageStopEvent, T as TextContentBlockStartEvent, e as TextContentBlockStopEvent, d as TextDeltaEvent, h as ToolCallEvent, i as ToolResultEvent, f as ToolUseContentBlockStartEvent, g as ToolUseContentBlockStopEvent } from './DriveableEvent-Bj7nn-Uk.js';
|
|
6
|
+
import './CommandEvent-CbXzPolX.js';
|
|
7
|
+
import './ImageRecord-Cn0VcJWk.js';
|
|
8
|
+
import './StopReason-D4DthB1h.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Runtime - Event-driven API for managing Containers and Agents
|
|
12
|
+
*
|
|
13
|
+
* All operations are performed through command events.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const runtime = createRuntime({ persistence });
|
|
18
|
+
*
|
|
19
|
+
* // Using request() - convenient async/await
|
|
20
|
+
* const containerRes = await runtime.request("container_create_request", {
|
|
21
|
+
* containerId: "my-container"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const agentRes = await runtime.request("agent_run_request", {
|
|
25
|
+
* containerId: "my-container",
|
|
26
|
+
* config: { name: "Assistant" }
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Using emitCommand/onCommand - fine-grained control
|
|
30
|
+
* runtime.emitCommand("agent_receive_request", {
|
|
31
|
+
* requestId: "req_123",
|
|
32
|
+
* agentId: agentRes.data.agentId,
|
|
33
|
+
* content: "Hello!"
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Subscribe to stream events
|
|
37
|
+
* runtime.on("text_delta", (e) => console.log(e.data.text));
|
|
38
|
+
*
|
|
39
|
+
* // Cleanup
|
|
40
|
+
* await runtime.dispose();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Runtime interface - event-driven API for AI Agents
|
|
46
|
+
*
|
|
47
|
+
* Extends SystemBus to provide all event operations.
|
|
48
|
+
*/
|
|
49
|
+
interface Runtime extends SystemBus {
|
|
50
|
+
/**
|
|
51
|
+
* Dispose runtime and all resources
|
|
52
|
+
*/
|
|
53
|
+
dispose(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* AgentImage - Agent runtime snapshot (persisted state)
|
|
58
|
+
*
|
|
59
|
+
* AgentImage is a complete snapshot of an Agent's state at a point in time.
|
|
60
|
+
* It contains all information needed to fully restore an Agent:
|
|
61
|
+
* - Runtime context (containerId, agentId)
|
|
62
|
+
* - Configuration (name, systemPrompt)
|
|
63
|
+
* - Conversation history (messages)
|
|
64
|
+
*
|
|
65
|
+
* AgentImage is an object with behavior - it can restore itself to a running Agent.
|
|
66
|
+
*
|
|
67
|
+
* Workflow:
|
|
68
|
+
* ```
|
|
69
|
+
* Agent → runtime.images.snapshot(agent) → AgentImage
|
|
70
|
+
* ↓
|
|
71
|
+
* image.resume()
|
|
72
|
+
* ↓
|
|
73
|
+
* New Agent (restored)
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // Create and use agent
|
|
79
|
+
* const agent = await runtime.agents.run(containerId, config);
|
|
80
|
+
* await agent.receive("Hello!");
|
|
81
|
+
*
|
|
82
|
+
* // Snapshot
|
|
83
|
+
* const image = await runtime.images.snapshot(agent);
|
|
84
|
+
*
|
|
85
|
+
* // Later: restore from image
|
|
86
|
+
* const restoredAgent = await image.resume();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Union type of all message types that can be stored in an Image
|
|
92
|
+
*/
|
|
93
|
+
type ImageMessage = UserMessage | AssistantMessage | ToolCallMessage | ToolResultMessage;
|
|
94
|
+
/**
|
|
95
|
+
* AgentImage - Complete snapshot of Agent state with behavior
|
|
96
|
+
*/
|
|
97
|
+
interface AgentImage {
|
|
98
|
+
/**
|
|
99
|
+
* Unique image identifier
|
|
100
|
+
* Pattern: `img_${nanoid()}`
|
|
101
|
+
*/
|
|
102
|
+
readonly imageId: string;
|
|
103
|
+
/**
|
|
104
|
+
* Container ID where this agent was running
|
|
105
|
+
*/
|
|
106
|
+
readonly containerId: string;
|
|
107
|
+
/**
|
|
108
|
+
* Original agent ID (for traceability)
|
|
109
|
+
*/
|
|
110
|
+
readonly agentId: string;
|
|
111
|
+
/**
|
|
112
|
+
* Agent name
|
|
113
|
+
*/
|
|
114
|
+
readonly name: string;
|
|
115
|
+
/**
|
|
116
|
+
* Agent description (optional)
|
|
117
|
+
*/
|
|
118
|
+
readonly description?: string;
|
|
119
|
+
/**
|
|
120
|
+
* System prompt - controls agent behavior
|
|
121
|
+
*/
|
|
122
|
+
readonly systemPrompt?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Conversation history snapshot
|
|
125
|
+
*/
|
|
126
|
+
readonly messages: ImageMessage[];
|
|
127
|
+
/**
|
|
128
|
+
* Parent image ID (if this image was derived from another)
|
|
129
|
+
*/
|
|
130
|
+
readonly parentImageId?: string;
|
|
131
|
+
/**
|
|
132
|
+
* When this image was created (Unix milliseconds)
|
|
133
|
+
*/
|
|
134
|
+
readonly createdAt: number;
|
|
135
|
+
/**
|
|
136
|
+
* Resume an agent from this image
|
|
137
|
+
*
|
|
138
|
+
* Creates a new Agent instance with the saved configuration
|
|
139
|
+
* and conversation history restored.
|
|
140
|
+
*
|
|
141
|
+
* @throws Error if container not found
|
|
142
|
+
* @returns New Agent instance
|
|
143
|
+
*/
|
|
144
|
+
resume(): Promise<Agent>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* LLMProvider - Large Language Model Supply Service
|
|
149
|
+
*
|
|
150
|
+
* Provides LLM configuration at Runtime level.
|
|
151
|
+
* All Agents in the Runtime share the same LLMProvider.
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* LLMProvider - Large Language Model supply service
|
|
155
|
+
*
|
|
156
|
+
* @typeParam TSupply - Supply type (config, client, token, etc.)
|
|
157
|
+
*/
|
|
158
|
+
interface LLMProvider<TSupply = unknown> {
|
|
159
|
+
/**
|
|
160
|
+
* Provider identifier (e.g., "claude", "openai")
|
|
161
|
+
*/
|
|
162
|
+
readonly name: string;
|
|
163
|
+
/**
|
|
164
|
+
* Provide LLM configuration
|
|
165
|
+
*/
|
|
166
|
+
provide(): TSupply;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* ClaudeLLMConfig - Configuration for Claude LLM
|
|
170
|
+
*/
|
|
171
|
+
interface ClaudeLLMConfig {
|
|
172
|
+
/**
|
|
173
|
+
* Anthropic API key
|
|
174
|
+
*/
|
|
175
|
+
apiKey: string;
|
|
176
|
+
/**
|
|
177
|
+
* API base URL (optional, for custom endpoints)
|
|
178
|
+
*/
|
|
179
|
+
baseUrl?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Model name (e.g., "claude-sonnet-4-20250514")
|
|
182
|
+
*/
|
|
183
|
+
model?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Type alias for Claude LLM Provider
|
|
187
|
+
*/
|
|
188
|
+
type ClaudeLLMProvider = LLMProvider<ClaudeLLMConfig>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* AgentConfig - Runtime configuration for Agent instance
|
|
192
|
+
*
|
|
193
|
+
* Contains the configuration needed to run an Agent.
|
|
194
|
+
* Copied from AgentDefinition when Agent is created.
|
|
195
|
+
*
|
|
196
|
+
* Separation of concerns:
|
|
197
|
+
* - AgentDefinition (application layer) = static template
|
|
198
|
+
* - AgentConfig (runtime layer) = runtime configuration
|
|
199
|
+
*
|
|
200
|
+
* This keeps runtime layer independent of application layer.
|
|
201
|
+
*/
|
|
202
|
+
interface AgentConfig {
|
|
203
|
+
/**
|
|
204
|
+
* Agent name
|
|
205
|
+
*/
|
|
206
|
+
name: string;
|
|
207
|
+
/**
|
|
208
|
+
* Agent description (optional)
|
|
209
|
+
*/
|
|
210
|
+
description?: string;
|
|
211
|
+
/**
|
|
212
|
+
* System prompt - controls agent behavior
|
|
213
|
+
*/
|
|
214
|
+
systemPrompt?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { Agent, type AgentConfig, type AgentImage, type ClaudeLLMConfig, type ClaudeLLMProvider, type ImageMessage, type LLMProvider, type Runtime };
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentxjs/types",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Type definitions for AgentX ecosystem",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,11 +17,89 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"import": "./dist/index.js",
|
|
19
19
|
"require": "./dist/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./agent": {
|
|
22
|
+
"types": "./dist/agent.d.ts",
|
|
23
|
+
"import": "./dist/agent.js",
|
|
24
|
+
"require": "./dist/agent.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./agent/internal": {
|
|
27
|
+
"types": "./dist/agent-internal.d.ts",
|
|
28
|
+
"import": "./dist/agent-internal.js",
|
|
29
|
+
"require": "./dist/agent-internal.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./runtime": {
|
|
32
|
+
"types": "./dist/runtime.d.ts",
|
|
33
|
+
"import": "./dist/runtime.js",
|
|
34
|
+
"require": "./dist/runtime.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./runtime/internal": {
|
|
37
|
+
"types": "./dist/runtime-internal.d.ts",
|
|
38
|
+
"import": "./dist/runtime-internal.js",
|
|
39
|
+
"require": "./dist/runtime-internal.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./event": {
|
|
42
|
+
"types": "./dist/event.d.ts",
|
|
43
|
+
"import": "./dist/event.js",
|
|
44
|
+
"require": "./dist/event.cjs"
|
|
45
|
+
},
|
|
46
|
+
"./common": {
|
|
47
|
+
"types": "./dist/common.d.ts",
|
|
48
|
+
"import": "./dist/common.js",
|
|
49
|
+
"require": "./dist/common.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./agentx": {
|
|
52
|
+
"types": "./dist/agentx.d.ts",
|
|
53
|
+
"import": "./dist/agentx.js",
|
|
54
|
+
"require": "./dist/agentx.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./network": {
|
|
57
|
+
"types": "./dist/network.d.ts",
|
|
58
|
+
"import": "./dist/network.js",
|
|
59
|
+
"require": "./dist/network.cjs"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"typesVersions": {
|
|
63
|
+
"*": {
|
|
64
|
+
"agent": [
|
|
65
|
+
"./dist/agent.d.ts"
|
|
66
|
+
],
|
|
67
|
+
"agent/internal": [
|
|
68
|
+
"./dist/agent-internal.d.ts"
|
|
69
|
+
],
|
|
70
|
+
"runtime": [
|
|
71
|
+
"./dist/runtime.d.ts"
|
|
72
|
+
],
|
|
73
|
+
"runtime/internal": [
|
|
74
|
+
"./dist/runtime-internal.d.ts"
|
|
75
|
+
],
|
|
76
|
+
"event": [
|
|
77
|
+
"./dist/event.d.ts"
|
|
78
|
+
],
|
|
79
|
+
"common": [
|
|
80
|
+
"./dist/common.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"agentx": [
|
|
83
|
+
"./dist/agentx.d.ts"
|
|
84
|
+
],
|
|
85
|
+
"network": [
|
|
86
|
+
"./dist/network.d.ts"
|
|
87
|
+
]
|
|
20
88
|
}
|
|
21
89
|
},
|
|
22
90
|
"files": [
|
|
23
91
|
"dist"
|
|
24
92
|
],
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsup",
|
|
95
|
+
"clean": "rm -rf dist",
|
|
96
|
+
"lint": "eslint .",
|
|
97
|
+
"typecheck": "tsc --noEmit",
|
|
98
|
+
"dev": "tsup --watch",
|
|
99
|
+
"test": "vitest run",
|
|
100
|
+
"test:watch": "vitest",
|
|
101
|
+
"test:update": "vitest run --update"
|
|
102
|
+
},
|
|
25
103
|
"keywords": [
|
|
26
104
|
"agentx",
|
|
27
105
|
"agent",
|
|
@@ -32,16 +110,10 @@
|
|
|
32
110
|
"author": "Deepractice AI",
|
|
33
111
|
"devDependencies": {
|
|
34
112
|
"tsup": "^8.0.1",
|
|
35
|
-
"typescript": "^5.3.3"
|
|
113
|
+
"typescript": "^5.3.3",
|
|
114
|
+
"vitest": "^3.2.4"
|
|
36
115
|
},
|
|
37
116
|
"publishConfig": {
|
|
38
117
|
"access": "public"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsup",
|
|
42
|
-
"clean": "rm -rf dist",
|
|
43
|
-
"lint": "eslint .",
|
|
44
|
-
"typecheck": "tsc --noEmit",
|
|
45
|
-
"dev": "tsup --watch"
|
|
46
118
|
}
|
|
47
|
-
}
|
|
119
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Deepractice
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|