@agentxjs/types 0.0.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Agent-BXUYGlWZ.d.cts +510 -0
- package/dist/Agent-CaSxMF_E.d.ts +510 -0
- package/dist/CommandEvent-CbXzPolX.d.ts +495 -0
- package/dist/CommandEvent-DCdk7lzX.d.cts +495 -0
- package/dist/Container-DR-1g44i.d.ts +641 -0
- package/dist/Container-dBDOcjhk.d.cts +641 -0
- package/dist/ContentPart-CqOh-rI1.d.ts +19 -0
- package/dist/ContentPart-DEFnYXCU.d.cts +19 -0
- package/dist/DriveableEvent-Bj7nn-Uk.d.ts +161 -0
- package/dist/DriveableEvent-CCMC1h_C.d.cts +161 -0
- package/dist/ErrorMessage-BoIh3MIO.d.cts +24 -0
- package/dist/ErrorMessage-BoIh3MIO.d.ts +24 -0
- package/dist/ImageRecord-Cn0VcJWk.d.cts +71 -0
- package/dist/ImageRecord-Cn0VcJWk.d.ts +71 -0
- package/dist/LoggerFactory-DZtw0M7U.d.cts +129 -0
- package/dist/LoggerFactory-DZtw0M7U.d.ts +129 -0
- package/dist/Message-Crh81uLL.d.cts +45 -0
- package/dist/Message-DWQUt647.d.ts +45 -0
- package/dist/Persistence-BQkdKomV.d.ts +230 -0
- package/dist/Persistence-Dr70FEBh.d.cts +230 -0
- package/dist/StopReason-D4DthB1h.d.cts +39 -0
- package/dist/StopReason-D4DthB1h.d.ts +39 -0
- package/dist/SystemEvent-CPvvxdMQ.d.cts +159 -0
- package/dist/SystemEvent-CPvvxdMQ.d.ts +159 -0
- package/dist/ToolResultMessage-CDG2L7Zv.d.ts +332 -0
- package/dist/ToolResultMessage-CRKMSf5d.d.cts +332 -0
- package/dist/agent-internal.cjs +19 -0
- package/dist/agent-internal.cjs.map +1 -0
- package/dist/agent-internal.d.cts +52 -0
- package/dist/agent-internal.d.ts +52 -0
- package/dist/agent-internal.js +1 -0
- package/dist/agent-internal.js.map +1 -0
- package/dist/agent.cjs +70 -0
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.cts +229 -0
- package/dist/agent.d.ts +229 -0
- package/dist/agent.js +41 -0
- package/dist/agent.js.map +1 -0
- package/dist/agentx.cjs +38 -0
- package/dist/agentx.cjs.map +1 -0
- package/dist/agentx.d.cts +311 -0
- package/dist/agentx.d.ts +311 -0
- package/dist/agentx.js +12 -0
- package/dist/agentx.js.map +1 -0
- package/dist/chunk-2QHAIM3V.js +1 -0
- package/dist/chunk-2QHAIM3V.js.map +1 -0
- package/dist/common.cjs +19 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +43 -0
- package/dist/common.d.ts +43 -0
- package/dist/common.js +2 -0
- package/dist/common.js.map +1 -0
- package/dist/event.cjs +184 -0
- package/dist/event.cjs.map +1 -0
- package/dist/event.d.cts +769 -0
- package/dist/event.d.ts +769 -0
- package/dist/event.js +134 -0
- package/dist/event.js.map +1 -0
- package/dist/index-CjFNcCxR.d.cts +299 -0
- package/dist/index-usKuk41S.d.ts +299 -0
- package/dist/index.cjs +2 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5267
- package/dist/index.d.ts +8 -5267
- package/dist/index.js +1 -150
- package/dist/index.js.map +1 -1
- package/dist/network.cjs +19 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.d.cts +168 -0
- package/dist/network.d.ts +168 -0
- package/dist/network.js +1 -0
- package/dist/network.js.map +1 -0
- package/dist/runtime-internal.cjs +19 -0
- package/dist/runtime-internal.cjs.map +1 -0
- package/dist/runtime-internal.d.cts +943 -0
- package/dist/runtime-internal.d.ts +943 -0
- package/dist/runtime-internal.js +1 -0
- package/dist/runtime-internal.js.map +1 -0
- package/dist/runtime.cjs +19 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +217 -0
- package/dist/runtime.d.ts +217 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +82 -10
- package/LICENSE +0 -21
package/dist/index.js
CHANGED
|
@@ -1,151 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
3
|
-
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
4
|
-
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
5
|
-
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
6
|
-
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
7
|
-
LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
|
|
8
|
-
return LogLevel2;
|
|
9
|
-
})(LogLevel || {});
|
|
10
|
-
|
|
11
|
-
// src/llm/StopReason.ts
|
|
12
|
-
function isStopReason(value) {
|
|
13
|
-
return [
|
|
14
|
-
"end_turn",
|
|
15
|
-
"max_tokens",
|
|
16
|
-
"tool_use",
|
|
17
|
-
"stop_sequence",
|
|
18
|
-
"content_filter",
|
|
19
|
-
"error",
|
|
20
|
-
"other"
|
|
21
|
-
].includes(value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/mcp/McpProtocol.ts
|
|
25
|
-
var LATEST_PROTOCOL_VERSION = "2025-06-18";
|
|
26
|
-
var SUPPORTED_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
27
|
-
|
|
28
|
-
// src/guards/MessageGuards.ts
|
|
29
|
-
function isUserMessage(message) {
|
|
30
|
-
return message.subtype === "user";
|
|
31
|
-
}
|
|
32
|
-
function isAssistantMessage(message) {
|
|
33
|
-
return message.subtype === "assistant";
|
|
34
|
-
}
|
|
35
|
-
function isSystemMessage(message) {
|
|
36
|
-
return message.subtype === "system";
|
|
37
|
-
}
|
|
38
|
-
function isToolCallMessage(message) {
|
|
39
|
-
return message.subtype === "tool-call";
|
|
40
|
-
}
|
|
41
|
-
function isToolResultMessage(message) {
|
|
42
|
-
return message.subtype === "tool-result";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/guards/ContentPartGuards.ts
|
|
46
|
-
function isTextPart(part) {
|
|
47
|
-
return part.type === "text";
|
|
48
|
-
}
|
|
49
|
-
function isThinkingPart(part) {
|
|
50
|
-
return part.type === "thinking";
|
|
51
|
-
}
|
|
52
|
-
function isImagePart(part) {
|
|
53
|
-
return part.type === "image";
|
|
54
|
-
}
|
|
55
|
-
function isFilePart(part) {
|
|
56
|
-
return part.type === "file";
|
|
57
|
-
}
|
|
58
|
-
function isToolCallPart(part) {
|
|
59
|
-
return part.type === "tool-call";
|
|
60
|
-
}
|
|
61
|
-
function isToolResultPart(part) {
|
|
62
|
-
return part.type === "tool-result";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/guards/EventGuards.ts
|
|
66
|
-
var STATE_EVENT_TYPE_NAMES = [
|
|
67
|
-
"agent_initializing",
|
|
68
|
-
"agent_ready",
|
|
69
|
-
"agent_destroyed",
|
|
70
|
-
"conversation_queued",
|
|
71
|
-
"conversation_start",
|
|
72
|
-
"conversation_thinking",
|
|
73
|
-
"conversation_responding",
|
|
74
|
-
"conversation_end",
|
|
75
|
-
"conversation_interrupted",
|
|
76
|
-
"tool_planned",
|
|
77
|
-
"tool_executing",
|
|
78
|
-
"tool_completed",
|
|
79
|
-
"tool_failed",
|
|
80
|
-
"error_occurred"
|
|
81
|
-
];
|
|
82
|
-
var STATE_EVENT_TYPES = new Set(STATE_EVENT_TYPE_NAMES);
|
|
83
|
-
var MESSAGE_EVENT_TYPE_NAMES = [
|
|
84
|
-
"user_message",
|
|
85
|
-
"assistant_message",
|
|
86
|
-
"tool_call_message",
|
|
87
|
-
"tool_result_message"
|
|
88
|
-
];
|
|
89
|
-
var MESSAGE_EVENT_TYPES = new Set(MESSAGE_EVENT_TYPE_NAMES);
|
|
90
|
-
var ERROR_EVENT_TYPE_NAMES = ["error"];
|
|
91
|
-
var ERROR_EVENT_TYPES = new Set(ERROR_EVENT_TYPE_NAMES);
|
|
92
|
-
var TURN_EVENT_TYPE_NAMES = ["turn_request", "turn_response"];
|
|
93
|
-
var TURN_EVENT_TYPES = new Set(TURN_EVENT_TYPE_NAMES);
|
|
94
|
-
var STREAM_EVENT_TYPE_NAMES = [
|
|
95
|
-
"message_start",
|
|
96
|
-
"message_delta",
|
|
97
|
-
"message_stop",
|
|
98
|
-
"text_content_block_start",
|
|
99
|
-
"text_delta",
|
|
100
|
-
"text_content_block_stop",
|
|
101
|
-
"tool_use_content_block_start",
|
|
102
|
-
"input_json_delta",
|
|
103
|
-
"tool_use_content_block_stop",
|
|
104
|
-
"tool_call",
|
|
105
|
-
"tool_result",
|
|
106
|
-
"interrupted"
|
|
107
|
-
];
|
|
108
|
-
var STREAM_EVENT_TYPES = new Set(STREAM_EVENT_TYPE_NAMES);
|
|
109
|
-
function isStateEvent(event) {
|
|
110
|
-
return "type" in event && STATE_EVENT_TYPES.has(event.type);
|
|
111
|
-
}
|
|
112
|
-
function isMessageEvent(event) {
|
|
113
|
-
return "type" in event && MESSAGE_EVENT_TYPES.has(event.type);
|
|
114
|
-
}
|
|
115
|
-
function isTurnEvent(event) {
|
|
116
|
-
return "type" in event && TURN_EVENT_TYPES.has(event.type);
|
|
117
|
-
}
|
|
118
|
-
function isStreamEvent(event) {
|
|
119
|
-
return "type" in event && STREAM_EVENT_TYPES.has(event.type);
|
|
120
|
-
}
|
|
121
|
-
function isErrorEvent(event) {
|
|
122
|
-
return "type" in event && ERROR_EVENT_TYPES.has(event.type);
|
|
123
|
-
}
|
|
124
|
-
export {
|
|
125
|
-
ERROR_EVENT_TYPE_NAMES,
|
|
126
|
-
LATEST_PROTOCOL_VERSION,
|
|
127
|
-
LogLevel,
|
|
128
|
-
MESSAGE_EVENT_TYPE_NAMES,
|
|
129
|
-
STATE_EVENT_TYPE_NAMES,
|
|
130
|
-
STREAM_EVENT_TYPE_NAMES,
|
|
131
|
-
SUPPORTED_PROTOCOL_VERSIONS,
|
|
132
|
-
TURN_EVENT_TYPE_NAMES,
|
|
133
|
-
isAssistantMessage,
|
|
134
|
-
isErrorEvent,
|
|
135
|
-
isFilePart,
|
|
136
|
-
isImagePart,
|
|
137
|
-
isMessageEvent,
|
|
138
|
-
isStateEvent,
|
|
139
|
-
isStopReason,
|
|
140
|
-
isStreamEvent,
|
|
141
|
-
isSystemMessage,
|
|
142
|
-
isTextPart,
|
|
143
|
-
isThinkingPart,
|
|
144
|
-
isToolCallMessage,
|
|
145
|
-
isToolCallPart,
|
|
146
|
-
isToolResultMessage,
|
|
147
|
-
isToolResultPart,
|
|
148
|
-
isTurnEvent,
|
|
149
|
-
isUserMessage
|
|
150
|
-
};
|
|
1
|
+
import "./chunk-2QHAIM3V.js";
|
|
151
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/network.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/network/index.ts
|
|
17
|
+
var network_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(network_exports);
|
|
19
|
+
//# sourceMappingURL=network.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/network/index.ts"],"sourcesContent":["/**\n * Network types\n */\n\nexport type {\n Unsubscribe,\n MinimalHTTPServer,\n ChannelConnection,\n ChannelServer,\n ChannelClient,\n ChannelClientOptions,\n ChannelServerOptions,\n} from \"./Channel\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Channel Abstraction
|
|
3
|
+
*
|
|
4
|
+
* Provides transport-agnostic interfaces for client-server communication.
|
|
5
|
+
* Can be implemented with WebSocket, HTTP/2, gRPC, etc.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Minimal HTTP server interface for attaching WebSocket
|
|
9
|
+
* Avoids Node.js dependency in types package
|
|
10
|
+
*/
|
|
11
|
+
interface MinimalHTTPServer {
|
|
12
|
+
on(event: "upgrade", listener: (request: any, socket: any, head: any) => void): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Unsubscribe function type
|
|
16
|
+
*/
|
|
17
|
+
type Unsubscribe = () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Channel connection (server-side representation of a client)
|
|
20
|
+
*/
|
|
21
|
+
interface ChannelConnection {
|
|
22
|
+
/**
|
|
23
|
+
* Unique connection ID
|
|
24
|
+
*/
|
|
25
|
+
readonly id: string;
|
|
26
|
+
/**
|
|
27
|
+
* Send message to this client
|
|
28
|
+
*/
|
|
29
|
+
send(message: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Register message handler
|
|
32
|
+
*/
|
|
33
|
+
onMessage(handler: (message: string) => void): Unsubscribe;
|
|
34
|
+
/**
|
|
35
|
+
* Register close handler
|
|
36
|
+
*/
|
|
37
|
+
onClose(handler: () => void): Unsubscribe;
|
|
38
|
+
/**
|
|
39
|
+
* Register error handler
|
|
40
|
+
*/
|
|
41
|
+
onError(handler: (error: Error) => void): Unsubscribe;
|
|
42
|
+
/**
|
|
43
|
+
* Close this connection
|
|
44
|
+
*/
|
|
45
|
+
close(): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Channel server (accepts connections)
|
|
49
|
+
*/
|
|
50
|
+
interface ChannelServer {
|
|
51
|
+
/**
|
|
52
|
+
* Start listening on a port (standalone mode)
|
|
53
|
+
*/
|
|
54
|
+
listen(port: number, host?: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Attach to an existing HTTP server
|
|
57
|
+
*/
|
|
58
|
+
attach(server: MinimalHTTPServer, path?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Register connection handler
|
|
61
|
+
*/
|
|
62
|
+
onConnection(handler: (connection: ChannelConnection) => void): Unsubscribe;
|
|
63
|
+
/**
|
|
64
|
+
* Broadcast message to all connected clients
|
|
65
|
+
*/
|
|
66
|
+
broadcast(message: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Close server and all connections
|
|
69
|
+
*/
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Dispose resources
|
|
73
|
+
*/
|
|
74
|
+
dispose(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Channel client (connects to server)
|
|
78
|
+
*/
|
|
79
|
+
interface ChannelClient {
|
|
80
|
+
/**
|
|
81
|
+
* Connection state
|
|
82
|
+
*/
|
|
83
|
+
readonly readyState: "connecting" | "open" | "closing" | "closed";
|
|
84
|
+
/**
|
|
85
|
+
* Connect to server
|
|
86
|
+
*/
|
|
87
|
+
connect(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Send message to server
|
|
90
|
+
*/
|
|
91
|
+
send(message: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Register message handler
|
|
94
|
+
*/
|
|
95
|
+
onMessage(handler: (message: string) => void): Unsubscribe;
|
|
96
|
+
/**
|
|
97
|
+
* Register open handler
|
|
98
|
+
*/
|
|
99
|
+
onOpen(handler: () => void): Unsubscribe;
|
|
100
|
+
/**
|
|
101
|
+
* Register close handler
|
|
102
|
+
*/
|
|
103
|
+
onClose(handler: () => void): Unsubscribe;
|
|
104
|
+
/**
|
|
105
|
+
* Register error handler
|
|
106
|
+
*/
|
|
107
|
+
onError(handler: (error: Error) => void): Unsubscribe;
|
|
108
|
+
/**
|
|
109
|
+
* Close connection
|
|
110
|
+
*/
|
|
111
|
+
close(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Dispose resources
|
|
114
|
+
*/
|
|
115
|
+
dispose(): void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Channel client factory options
|
|
119
|
+
*/
|
|
120
|
+
interface ChannelClientOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Server URL
|
|
123
|
+
*/
|
|
124
|
+
serverUrl: string;
|
|
125
|
+
/**
|
|
126
|
+
* Enable auto-reconnect (default: true in browser, false in Node.js)
|
|
127
|
+
*/
|
|
128
|
+
autoReconnect?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Min reconnection delay in ms (default: 1000)
|
|
131
|
+
*/
|
|
132
|
+
minReconnectionDelay?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Max reconnection delay in ms (default: 10000)
|
|
135
|
+
*/
|
|
136
|
+
maxReconnectionDelay?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Max retry attempts (default: Infinity)
|
|
139
|
+
*/
|
|
140
|
+
maxRetries?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Connection timeout in ms (default: 4000)
|
|
143
|
+
*/
|
|
144
|
+
connectionTimeout?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Enable debug logging (default: false)
|
|
147
|
+
*/
|
|
148
|
+
debug?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Channel server factory options
|
|
152
|
+
*/
|
|
153
|
+
interface ChannelServerOptions {
|
|
154
|
+
/**
|
|
155
|
+
* Enable heartbeat/ping-pong (default: true)
|
|
156
|
+
*/
|
|
157
|
+
heartbeat?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Heartbeat interval in ms (default: 30000)
|
|
160
|
+
*/
|
|
161
|
+
heartbeatInterval?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Enable debug logging (default: false)
|
|
164
|
+
*/
|
|
165
|
+
debug?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type { ChannelClient, ChannelClientOptions, ChannelConnection, ChannelServer, ChannelServerOptions, MinimalHTTPServer, Unsubscribe };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Channel Abstraction
|
|
3
|
+
*
|
|
4
|
+
* Provides transport-agnostic interfaces for client-server communication.
|
|
5
|
+
* Can be implemented with WebSocket, HTTP/2, gRPC, etc.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Minimal HTTP server interface for attaching WebSocket
|
|
9
|
+
* Avoids Node.js dependency in types package
|
|
10
|
+
*/
|
|
11
|
+
interface MinimalHTTPServer {
|
|
12
|
+
on(event: "upgrade", listener: (request: any, socket: any, head: any) => void): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Unsubscribe function type
|
|
16
|
+
*/
|
|
17
|
+
type Unsubscribe = () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Channel connection (server-side representation of a client)
|
|
20
|
+
*/
|
|
21
|
+
interface ChannelConnection {
|
|
22
|
+
/**
|
|
23
|
+
* Unique connection ID
|
|
24
|
+
*/
|
|
25
|
+
readonly id: string;
|
|
26
|
+
/**
|
|
27
|
+
* Send message to this client
|
|
28
|
+
*/
|
|
29
|
+
send(message: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Register message handler
|
|
32
|
+
*/
|
|
33
|
+
onMessage(handler: (message: string) => void): Unsubscribe;
|
|
34
|
+
/**
|
|
35
|
+
* Register close handler
|
|
36
|
+
*/
|
|
37
|
+
onClose(handler: () => void): Unsubscribe;
|
|
38
|
+
/**
|
|
39
|
+
* Register error handler
|
|
40
|
+
*/
|
|
41
|
+
onError(handler: (error: Error) => void): Unsubscribe;
|
|
42
|
+
/**
|
|
43
|
+
* Close this connection
|
|
44
|
+
*/
|
|
45
|
+
close(): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Channel server (accepts connections)
|
|
49
|
+
*/
|
|
50
|
+
interface ChannelServer {
|
|
51
|
+
/**
|
|
52
|
+
* Start listening on a port (standalone mode)
|
|
53
|
+
*/
|
|
54
|
+
listen(port: number, host?: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Attach to an existing HTTP server
|
|
57
|
+
*/
|
|
58
|
+
attach(server: MinimalHTTPServer, path?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Register connection handler
|
|
61
|
+
*/
|
|
62
|
+
onConnection(handler: (connection: ChannelConnection) => void): Unsubscribe;
|
|
63
|
+
/**
|
|
64
|
+
* Broadcast message to all connected clients
|
|
65
|
+
*/
|
|
66
|
+
broadcast(message: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Close server and all connections
|
|
69
|
+
*/
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Dispose resources
|
|
73
|
+
*/
|
|
74
|
+
dispose(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Channel client (connects to server)
|
|
78
|
+
*/
|
|
79
|
+
interface ChannelClient {
|
|
80
|
+
/**
|
|
81
|
+
* Connection state
|
|
82
|
+
*/
|
|
83
|
+
readonly readyState: "connecting" | "open" | "closing" | "closed";
|
|
84
|
+
/**
|
|
85
|
+
* Connect to server
|
|
86
|
+
*/
|
|
87
|
+
connect(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Send message to server
|
|
90
|
+
*/
|
|
91
|
+
send(message: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Register message handler
|
|
94
|
+
*/
|
|
95
|
+
onMessage(handler: (message: string) => void): Unsubscribe;
|
|
96
|
+
/**
|
|
97
|
+
* Register open handler
|
|
98
|
+
*/
|
|
99
|
+
onOpen(handler: () => void): Unsubscribe;
|
|
100
|
+
/**
|
|
101
|
+
* Register close handler
|
|
102
|
+
*/
|
|
103
|
+
onClose(handler: () => void): Unsubscribe;
|
|
104
|
+
/**
|
|
105
|
+
* Register error handler
|
|
106
|
+
*/
|
|
107
|
+
onError(handler: (error: Error) => void): Unsubscribe;
|
|
108
|
+
/**
|
|
109
|
+
* Close connection
|
|
110
|
+
*/
|
|
111
|
+
close(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Dispose resources
|
|
114
|
+
*/
|
|
115
|
+
dispose(): void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Channel client factory options
|
|
119
|
+
*/
|
|
120
|
+
interface ChannelClientOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Server URL
|
|
123
|
+
*/
|
|
124
|
+
serverUrl: string;
|
|
125
|
+
/**
|
|
126
|
+
* Enable auto-reconnect (default: true in browser, false in Node.js)
|
|
127
|
+
*/
|
|
128
|
+
autoReconnect?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Min reconnection delay in ms (default: 1000)
|
|
131
|
+
*/
|
|
132
|
+
minReconnectionDelay?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Max reconnection delay in ms (default: 10000)
|
|
135
|
+
*/
|
|
136
|
+
maxReconnectionDelay?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Max retry attempts (default: Infinity)
|
|
139
|
+
*/
|
|
140
|
+
maxRetries?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Connection timeout in ms (default: 4000)
|
|
143
|
+
*/
|
|
144
|
+
connectionTimeout?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Enable debug logging (default: false)
|
|
147
|
+
*/
|
|
148
|
+
debug?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Channel server factory options
|
|
152
|
+
*/
|
|
153
|
+
interface ChannelServerOptions {
|
|
154
|
+
/**
|
|
155
|
+
* Enable heartbeat/ping-pong (default: true)
|
|
156
|
+
*/
|
|
157
|
+
heartbeat?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Heartbeat interval in ms (default: 30000)
|
|
160
|
+
*/
|
|
161
|
+
heartbeatInterval?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Enable debug logging (default: false)
|
|
164
|
+
*/
|
|
165
|
+
debug?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type { ChannelClient, ChannelClientOptions, ChannelConnection, ChannelServer, ChannelServerOptions, MinimalHTTPServer, Unsubscribe };
|
package/dist/network.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -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/internal/index.ts
|
|
17
|
+
var internal_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(internal_exports);
|
|
19
|
+
//# sourceMappingURL=runtime-internal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/internal/index.ts"],"sourcesContent":["/**\n * Runtime Internal Types\n *\n * Internal implementation types for runtime layer.\n * These are used by runtime implementers, not end users.\n *\n * ## Structure\n *\n * ```\n * internal/\n * ├── container/\n * │ ├── Container # Agent lifecycle management\n * │ ├── llm/ # LLM connection (LLM, LLMConfig, TokenUsage...)\n * │ └── sandbox/ # Isolated environment\n * │ ├── Sandbox # Workdir + MCP access\n * │ ├── workdir/ # File system operations\n * │ └── mcp/ # MCP tools, resources, prompts\n * │\n * ├── environment/\n * │ ├── Environment # External world abstraction\n * │ ├── Receptor # Event producer (LLM → DriveableEvent)\n * │ └── Effector # Action executor (ToolCall → ToolResult)\n * │\n * ├── session/\n * │ └── Session # Message persistence per Agent\n * │\n * ├── event/\n * │ └── SystemBus # Central event bus\n * │\n * └── persistence/\n * ├── Persistence # Storage facade\n * ├── Repository # Flat storage interface\n * └── record/ # Storage schema types\n * ```\n *\n * @packageDocumentation\n */\n\n// ============================================================================\n// Container\n// ============================================================================\n\nexport type { Container } from \"./container/Container\";\n\n// Sandbox\nexport type { Sandbox } from \"./container/sandbox/Sandbox\";\nexport type { Workdir } from \"./container/sandbox/workdir/Workdir\";\nexport type {\n McpServerInfo,\n McpTool,\n McpResource,\n McpPrompt,\n McpRequest,\n McpTransportConfig,\n McpProtocolVersion,\n} from \"./container/sandbox/mcp\";\n\n// LLM\nexport type {\n LLM,\n LLMConfig,\n LLMProvider,\n LLMRequest,\n LLMResponse,\n StreamChunk,\n StopReason,\n TokenUsage,\n} from \"./container/llm\";\n\n// ============================================================================\n// Environment\n// ============================================================================\n\nexport type { Environment } from \"./environment/Environment\";\nexport type { Receptor } from \"./environment/Receptor\";\nexport type { Effector } from \"./environment/Effector\";\n\n// ============================================================================\n// Session\n// ============================================================================\n\nexport type { Session } from \"./session/Session\";\n\n// ============================================================================\n// Event Bus (Runtime internal)\n// ============================================================================\n\nexport type { SystemBus, BusEventHandler, SubscribeOptions, Unsubscribe } from \"./event/SystemBus\";\nexport type { SystemBusProducer } from \"./event/SystemBusProducer\";\nexport type { SystemBusConsumer } from \"./event/SystemBusConsumer\";\n\n// ============================================================================\n// Event Handler\n// ============================================================================\n\nexport type { ErrorContext } from \"./EventHandler\";\n\n// ============================================================================\n// Persistence\n// ============================================================================\n\nexport * from \"./persistence\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|