@forthix/forthic 0.7.2 → 0.8.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/cjs/forthic/decorators/schemaUtils.d.ts +70 -0
- package/dist/cjs/forthic/decorators/schemaUtils.js +77 -0
- package/dist/cjs/forthic/decorators/schemaUtils.js.map +1 -0
- package/dist/cjs/forthic/decorators/stackEffect.d.ts +63 -0
- package/dist/cjs/forthic/decorators/stackEffect.js +179 -0
- package/dist/cjs/forthic/decorators/stackEffect.js.map +1 -0
- package/dist/cjs/forthic/interpreter.d.ts +21 -0
- package/dist/cjs/forthic/interpreter.js +76 -1
- package/dist/cjs/forthic/interpreter.js.map +1 -1
- package/dist/cjs/forthic/module.d.ts +2 -0
- package/dist/cjs/forthic/module.js +4 -0
- package/dist/cjs/forthic/module.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/forthic/decorators/schemaUtils.d.ts +70 -0
- package/dist/esm/forthic/decorators/schemaUtils.js +72 -0
- package/dist/esm/forthic/decorators/schemaUtils.js.map +1 -0
- package/dist/esm/forthic/decorators/stackEffect.d.ts +63 -0
- package/dist/esm/forthic/decorators/stackEffect.js +174 -0
- package/dist/esm/forthic/decorators/stackEffect.js.map +1 -0
- package/dist/esm/forthic/interpreter.d.ts +21 -0
- package/dist/esm/forthic/interpreter.js +74 -1
- package/dist/esm/forthic/interpreter.js.map +1 -1
- package/dist/esm/forthic/module.d.ts +2 -0
- package/dist/esm/forthic/module.js +4 -0
- package/dist/esm/forthic/module.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/grpc/server.test.d.ts +0 -1
- package/dist/cjs/grpc/server.test.js +0 -156
- package/dist/cjs/grpc/server.test.js.map +0 -1
- package/dist/cjs/grpc/temporal_utils.d.ts +0 -36
- package/dist/cjs/grpc/temporal_utils.js +0 -80
- package/dist/cjs/grpc/temporal_utils.js.map +0 -1
- package/dist/cjs/websocket/action_cable_client.d.ts +0 -106
- package/dist/cjs/websocket/action_cable_client.js +0 -269
- package/dist/cjs/websocket/action_cable_client.js.map +0 -1
- package/dist/cjs/websocket/client.d.ts +0 -103
- package/dist/cjs/websocket/client.js +0 -266
- package/dist/cjs/websocket/client.js.map +0 -1
- package/dist/cjs/websocket/remote_module.d.ts +0 -68
- package/dist/cjs/websocket/remote_module.js +0 -107
- package/dist/cjs/websocket/remote_module.js.map +0 -1
- package/dist/cjs/websocket/remote_word.d.ts +0 -53
- package/dist/cjs/websocket/remote_word.js +0 -93
- package/dist/cjs/websocket/remote_word.js.map +0 -1
- package/dist/cjs/websocket/runtime_manager.d.ts +0 -69
- package/dist/cjs/websocket/runtime_manager.js +0 -112
- package/dist/cjs/websocket/runtime_manager.js.map +0 -1
- package/dist/esm/grpc/server.test.d.ts +0 -1
- package/dist/esm/grpc/server.test.js +0 -121
- package/dist/esm/grpc/server.test.js.map +0 -1
- package/dist/esm/grpc/temporal_utils.d.ts +0 -36
- package/dist/esm/grpc/temporal_utils.js +0 -72
- package/dist/esm/grpc/temporal_utils.js.map +0 -1
- package/dist/esm/websocket/action_cable_client.d.ts +0 -106
- package/dist/esm/websocket/action_cable_client.js +0 -265
- package/dist/esm/websocket/action_cable_client.js.map +0 -1
- package/dist/esm/websocket/client.d.ts +0 -103
- package/dist/esm/websocket/client.js +0 -262
- package/dist/esm/websocket/client.js.map +0 -1
- package/dist/esm/websocket/remote_module.d.ts +0 -68
- package/dist/esm/websocket/remote_module.js +0 -103
- package/dist/esm/websocket/remote_module.js.map +0 -1
- package/dist/esm/websocket/remote_word.d.ts +0 -53
- package/dist/esm/websocket/remote_word.js +0 -89
- package/dist/esm/websocket/remote_word.js.map +0 -1
- package/dist/esm/websocket/runtime_manager.d.ts +0 -69
- package/dist/esm/websocket/runtime_manager.js +0 -108
- package/dist/esm/websocket/runtime_manager.js.map +0 -1
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ActionCable Client for Forthic
|
|
3
|
-
* Browser-compatible client that mirrors GrpcClient API
|
|
4
|
-
* Specifically designed for Rails ActionCable WebSocket protocol
|
|
5
|
-
*/
|
|
6
|
-
import { serializeStack, deserializeStack } from './serializer.js';
|
|
7
|
-
import { RemoteRuntimeError } from './errors.js';
|
|
8
|
-
/**
|
|
9
|
-
* ActionCable client for executing words in remote Forthic runtimes
|
|
10
|
-
* Mirrors the GrpcClient API for compatibility
|
|
11
|
-
* Uses Rails ActionCable WebSocket protocol
|
|
12
|
-
*/
|
|
13
|
-
export class ActionCableClient {
|
|
14
|
-
ws;
|
|
15
|
-
config;
|
|
16
|
-
pendingRequests = new Map();
|
|
17
|
-
messageId = 0;
|
|
18
|
-
connected = false;
|
|
19
|
-
connectionPromise;
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.config = {
|
|
22
|
-
url: config.url,
|
|
23
|
-
timezone: config.timezone || 'UTC',
|
|
24
|
-
reconnect: config.reconnect ?? true,
|
|
25
|
-
reconnectDelay: config.reconnectDelay || 3000,
|
|
26
|
-
channel: config.channel || 'ForthicRuntimeChannel',
|
|
27
|
-
};
|
|
28
|
-
this.connect();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Connect to the WebSocket server
|
|
32
|
-
*/
|
|
33
|
-
connect() {
|
|
34
|
-
if (this.connectionPromise) {
|
|
35
|
-
return this.connectionPromise;
|
|
36
|
-
}
|
|
37
|
-
this.connectionPromise = new Promise((resolve, reject) => {
|
|
38
|
-
try {
|
|
39
|
-
this.ws = new WebSocket(this.config.url);
|
|
40
|
-
this.ws.onopen = () => {
|
|
41
|
-
this.connected = true;
|
|
42
|
-
// Subscribe to ActionCable channel
|
|
43
|
-
const subscribeMessage = {
|
|
44
|
-
command: 'subscribe',
|
|
45
|
-
identifier: JSON.stringify({
|
|
46
|
-
channel: this.config.channel,
|
|
47
|
-
timezone: this.config.timezone,
|
|
48
|
-
}),
|
|
49
|
-
};
|
|
50
|
-
this.ws.send(JSON.stringify(subscribeMessage));
|
|
51
|
-
resolve();
|
|
52
|
-
};
|
|
53
|
-
this.ws.onmessage = (event) => {
|
|
54
|
-
this.handleMessage(event);
|
|
55
|
-
};
|
|
56
|
-
this.ws.onerror = (error) => {
|
|
57
|
-
console.error('WebSocket error:', error);
|
|
58
|
-
reject(new Error('WebSocket connection error'));
|
|
59
|
-
};
|
|
60
|
-
this.ws.onclose = () => {
|
|
61
|
-
this.connected = false;
|
|
62
|
-
this.connectionPromise = undefined;
|
|
63
|
-
// Reject all pending requests
|
|
64
|
-
for (const [id, pending] of this.pendingRequests.entries()) {
|
|
65
|
-
pending.reject(new Error('WebSocket connection closed'));
|
|
66
|
-
}
|
|
67
|
-
this.pendingRequests.clear();
|
|
68
|
-
// Attempt reconnect if enabled
|
|
69
|
-
if (this.config.reconnect) {
|
|
70
|
-
setTimeout(() => this.connect(), this.config.reconnectDelay);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
reject(error);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return this.connectionPromise;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Handle incoming WebSocket messages
|
|
82
|
-
*/
|
|
83
|
-
handleMessage(event) {
|
|
84
|
-
try {
|
|
85
|
-
const data = JSON.parse(event.data);
|
|
86
|
-
// Handle ActionCable control messages
|
|
87
|
-
if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// Extract the actual message from ActionCable envelope
|
|
91
|
-
const message = data.message || data;
|
|
92
|
-
if (!message.id) {
|
|
93
|
-
console.warn('Received message without ID:', message);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// Handle streaming progress updates
|
|
97
|
-
if (message.type === 'streaming_progress') {
|
|
98
|
-
const pending = this.pendingRequests.get(message.id);
|
|
99
|
-
if (pending?.onProgress) {
|
|
100
|
-
pending.onProgress(message.progress);
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// Handle final responses
|
|
105
|
-
const pending = this.pendingRequests.get(message.id);
|
|
106
|
-
if (!pending) {
|
|
107
|
-
console.warn('Received response for unknown request:', message.id);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (message.error) {
|
|
111
|
-
pending.reject(new RemoteRuntimeError(message.error));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
pending.resolve(message.result);
|
|
115
|
-
}
|
|
116
|
-
this.pendingRequests.delete(message.id);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
console.error('Error handling WebSocket message:', error);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Generate next message ID
|
|
124
|
-
*/
|
|
125
|
-
nextMessageId() {
|
|
126
|
-
return `msg-${++this.messageId}-${Date.now()}`;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Send a request and wait for response
|
|
130
|
-
* @template T The expected result type (the value of the `result` field)
|
|
131
|
-
*/
|
|
132
|
-
async sendRequest(message) {
|
|
133
|
-
await this.ensureConnected();
|
|
134
|
-
return new Promise((resolve, reject) => {
|
|
135
|
-
this.pendingRequests.set(message.id, { resolve, reject });
|
|
136
|
-
// Wrap message in ActionCable format
|
|
137
|
-
const actionCableMessage = {
|
|
138
|
-
command: 'message',
|
|
139
|
-
identifier: JSON.stringify({
|
|
140
|
-
channel: this.config.channel,
|
|
141
|
-
}),
|
|
142
|
-
data: JSON.stringify(message),
|
|
143
|
-
};
|
|
144
|
-
this.ws.send(JSON.stringify(actionCableMessage));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Send a streaming request with progress callbacks
|
|
149
|
-
* @template T The expected result type (the value of the `result` field)
|
|
150
|
-
*/
|
|
151
|
-
async sendStreamingRequest(message, onProgress) {
|
|
152
|
-
await this.ensureConnected();
|
|
153
|
-
return new Promise((resolve, reject) => {
|
|
154
|
-
this.pendingRequests.set(message.id, { resolve, reject, onProgress });
|
|
155
|
-
// Wrap message in ActionCable format
|
|
156
|
-
const actionCableMessage = {
|
|
157
|
-
command: 'message',
|
|
158
|
-
identifier: JSON.stringify({
|
|
159
|
-
channel: this.config.channel,
|
|
160
|
-
}),
|
|
161
|
-
data: JSON.stringify(message),
|
|
162
|
-
};
|
|
163
|
-
this.ws.send(JSON.stringify(actionCableMessage));
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Ensure WebSocket is connected
|
|
168
|
-
*/
|
|
169
|
-
async ensureConnected() {
|
|
170
|
-
if (!this.connected) {
|
|
171
|
-
await this.connect();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Execute a word in the remote runtime
|
|
176
|
-
* Mirrors GrpcClient.executeWord
|
|
177
|
-
*/
|
|
178
|
-
async executeWord(word, stack) {
|
|
179
|
-
const message = {
|
|
180
|
-
type: 'execute_word',
|
|
181
|
-
id: this.nextMessageId(),
|
|
182
|
-
params: {
|
|
183
|
-
word,
|
|
184
|
-
stack: serializeStack(stack),
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
const result = await this.sendRequest(message);
|
|
188
|
-
return deserializeStack(result.stack);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Execute a sequence of words (batched execution)
|
|
192
|
-
* Mirrors GrpcClient.executeSequence
|
|
193
|
-
*/
|
|
194
|
-
async executeSequence(words, stack) {
|
|
195
|
-
const message = {
|
|
196
|
-
type: 'execute_sequence',
|
|
197
|
-
id: this.nextMessageId(),
|
|
198
|
-
params: {
|
|
199
|
-
words,
|
|
200
|
-
stack: serializeStack(stack),
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
const result = await this.sendRequest(message);
|
|
204
|
-
return deserializeStack(result.stack);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* List available runtime-specific modules
|
|
208
|
-
* Mirrors GrpcClient.listModules
|
|
209
|
-
*/
|
|
210
|
-
async listModules() {
|
|
211
|
-
const message = {
|
|
212
|
-
type: 'list_modules',
|
|
213
|
-
id: this.nextMessageId(),
|
|
214
|
-
};
|
|
215
|
-
const result = await this.sendRequest(message);
|
|
216
|
-
return result.modules || [];
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Get detailed information about a specific module
|
|
220
|
-
* Mirrors GrpcClient.getModuleInfo
|
|
221
|
-
*/
|
|
222
|
-
async getModuleInfo(moduleName) {
|
|
223
|
-
const message = {
|
|
224
|
-
type: 'get_module_info',
|
|
225
|
-
id: this.nextMessageId(),
|
|
226
|
-
params: {
|
|
227
|
-
module_name: moduleName,
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
return await this.sendRequest(message);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Execute code with streaming progress updates (NEW capability)
|
|
234
|
-
*/
|
|
235
|
-
async streamingExecute(code, stack, onProgress) {
|
|
236
|
-
const message = {
|
|
237
|
-
type: 'streaming_execute',
|
|
238
|
-
id: this.nextMessageId(),
|
|
239
|
-
params: {
|
|
240
|
-
code,
|
|
241
|
-
stack: serializeStack(stack),
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
const result = await this.sendStreamingRequest(message, onProgress);
|
|
245
|
-
return deserializeStack(result.stack);
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Close the WebSocket connection
|
|
249
|
-
*/
|
|
250
|
-
close() {
|
|
251
|
-
if (this.ws) {
|
|
252
|
-
this.config.reconnect = false; // Disable auto-reconnect
|
|
253
|
-
this.ws.close();
|
|
254
|
-
this.ws = undefined;
|
|
255
|
-
this.connected = false;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Check if the client is connected
|
|
260
|
-
*/
|
|
261
|
-
isConnected() {
|
|
262
|
-
return this.connected;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
//# sourceMappingURL=action_cable_client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action_cable_client.js","sourceRoot":"","sources":["../../../src/websocket/action_cable_client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoIjD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,EAAE,CAAa;IACf,MAAM,CAAoC;IAC1C,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAW,CAAC,CAAC;IACtB,SAAS,GAAY,KAAK,CAAC;IAC3B,iBAAiB,CAAiB;IAE1C,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;SACnD,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,OAAO;QACb,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,IAAI,CAAC;gBACH,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,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EAAE,IAAI,CAAC,aAAa,EAAE;YACxB,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;aAC7B;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAA0B,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7F,OAAO,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,yBAAyB;YACxD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket Client for Forthic
|
|
3
|
-
* Browser-compatible client that mirrors GrpcClient API
|
|
4
|
-
* Connects to Rails ActionCable server and executes remote words
|
|
5
|
-
*/
|
|
6
|
-
import { StackValue } from './serializer.js';
|
|
7
|
-
export interface ModuleSummary {
|
|
8
|
-
name: string;
|
|
9
|
-
description: string;
|
|
10
|
-
word_count: number;
|
|
11
|
-
}
|
|
12
|
-
export interface WordInfo {
|
|
13
|
-
name: string;
|
|
14
|
-
stack_effect: string;
|
|
15
|
-
description: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ModuleInfo {
|
|
18
|
-
module_name: string;
|
|
19
|
-
words: WordInfo[];
|
|
20
|
-
}
|
|
21
|
-
export interface ProgressUpdate {
|
|
22
|
-
step: number;
|
|
23
|
-
total_steps: number;
|
|
24
|
-
current_word: string;
|
|
25
|
-
message?: string;
|
|
26
|
-
partial_stack?: StackValue[];
|
|
27
|
-
}
|
|
28
|
-
export interface WebSocketClientConfig {
|
|
29
|
-
url: string;
|
|
30
|
-
timezone?: string;
|
|
31
|
-
reconnect?: boolean;
|
|
32
|
-
reconnectDelay?: number;
|
|
33
|
-
channel?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* WebSocket client for executing words in remote Forthic runtimes
|
|
37
|
-
* Mirrors the GrpcClient API for compatibility
|
|
38
|
-
*/
|
|
39
|
-
export declare class WebSocketClient {
|
|
40
|
-
private ws?;
|
|
41
|
-
private config;
|
|
42
|
-
private pendingRequests;
|
|
43
|
-
private messageId;
|
|
44
|
-
private connected;
|
|
45
|
-
private connectionPromise?;
|
|
46
|
-
constructor(config: WebSocketClientConfig);
|
|
47
|
-
/**
|
|
48
|
-
* Connect to the WebSocket server
|
|
49
|
-
*/
|
|
50
|
-
private connect;
|
|
51
|
-
/**
|
|
52
|
-
* Handle incoming WebSocket messages
|
|
53
|
-
*/
|
|
54
|
-
private handleMessage;
|
|
55
|
-
/**
|
|
56
|
-
* Generate next message ID
|
|
57
|
-
*/
|
|
58
|
-
private nextMessageId;
|
|
59
|
-
/**
|
|
60
|
-
* Send a request and wait for response
|
|
61
|
-
*/
|
|
62
|
-
private sendRequest;
|
|
63
|
-
/**
|
|
64
|
-
* Send a streaming request with progress callbacks
|
|
65
|
-
*/
|
|
66
|
-
private sendStreamingRequest;
|
|
67
|
-
/**
|
|
68
|
-
* Ensure WebSocket is connected
|
|
69
|
-
*/
|
|
70
|
-
private ensureConnected;
|
|
71
|
-
/**
|
|
72
|
-
* Execute a word in the remote runtime
|
|
73
|
-
* Mirrors GrpcClient.executeWord
|
|
74
|
-
*/
|
|
75
|
-
executeWord(word: string, stack: any[]): Promise<any[]>;
|
|
76
|
-
/**
|
|
77
|
-
* Execute a sequence of words (batched execution)
|
|
78
|
-
* Mirrors GrpcClient.executeSequence
|
|
79
|
-
*/
|
|
80
|
-
executeSequence(words: string[], stack: any[]): Promise<any[]>;
|
|
81
|
-
/**
|
|
82
|
-
* List available runtime-specific modules
|
|
83
|
-
* Mirrors GrpcClient.listModules
|
|
84
|
-
*/
|
|
85
|
-
listModules(): Promise<ModuleSummary[]>;
|
|
86
|
-
/**
|
|
87
|
-
* Get detailed information about a specific module
|
|
88
|
-
* Mirrors GrpcClient.getModuleInfo
|
|
89
|
-
*/
|
|
90
|
-
getModuleInfo(moduleName: string): Promise<ModuleInfo>;
|
|
91
|
-
/**
|
|
92
|
-
* Execute code with streaming progress updates (NEW capability)
|
|
93
|
-
*/
|
|
94
|
-
streamingExecute(code: string, stack: any[], onProgress?: (progress: ProgressUpdate) => void): Promise<any[]>;
|
|
95
|
-
/**
|
|
96
|
-
* Close the WebSocket connection
|
|
97
|
-
*/
|
|
98
|
-
close(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Check if the client is connected
|
|
101
|
-
*/
|
|
102
|
-
isConnected(): boolean;
|
|
103
|
-
}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket Client for Forthic
|
|
3
|
-
* Browser-compatible client that mirrors GrpcClient API
|
|
4
|
-
* Connects to Rails ActionCable server and executes remote words
|
|
5
|
-
*/
|
|
6
|
-
import { serializeStack, deserializeStack } from './serializer.js';
|
|
7
|
-
import { RemoteRuntimeError } from './errors.js';
|
|
8
|
-
/**
|
|
9
|
-
* WebSocket client for executing words in remote Forthic runtimes
|
|
10
|
-
* Mirrors the GrpcClient API for compatibility
|
|
11
|
-
*/
|
|
12
|
-
export class WebSocketClient {
|
|
13
|
-
ws;
|
|
14
|
-
config;
|
|
15
|
-
pendingRequests = new Map();
|
|
16
|
-
messageId = 0;
|
|
17
|
-
connected = false;
|
|
18
|
-
connectionPromise;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.config = {
|
|
21
|
-
url: config.url,
|
|
22
|
-
timezone: config.timezone || 'UTC',
|
|
23
|
-
reconnect: config.reconnect ?? true,
|
|
24
|
-
reconnectDelay: config.reconnectDelay || 3000,
|
|
25
|
-
channel: config.channel || 'ForthicRuntimeChannel',
|
|
26
|
-
};
|
|
27
|
-
this.connect();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Connect to the WebSocket server
|
|
31
|
-
*/
|
|
32
|
-
connect() {
|
|
33
|
-
if (this.connectionPromise) {
|
|
34
|
-
return this.connectionPromise;
|
|
35
|
-
}
|
|
36
|
-
this.connectionPromise = new Promise((resolve, reject) => {
|
|
37
|
-
try {
|
|
38
|
-
this.ws = new WebSocket(this.config.url);
|
|
39
|
-
this.ws.onopen = () => {
|
|
40
|
-
this.connected = true;
|
|
41
|
-
// Subscribe to ActionCable channel
|
|
42
|
-
const subscribeMessage = {
|
|
43
|
-
command: 'subscribe',
|
|
44
|
-
identifier: JSON.stringify({
|
|
45
|
-
channel: this.config.channel,
|
|
46
|
-
timezone: this.config.timezone,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
this.ws.send(JSON.stringify(subscribeMessage));
|
|
50
|
-
resolve();
|
|
51
|
-
};
|
|
52
|
-
this.ws.onmessage = (event) => {
|
|
53
|
-
this.handleMessage(event);
|
|
54
|
-
};
|
|
55
|
-
this.ws.onerror = (error) => {
|
|
56
|
-
console.error('WebSocket error:', error);
|
|
57
|
-
reject(new Error('WebSocket connection error'));
|
|
58
|
-
};
|
|
59
|
-
this.ws.onclose = () => {
|
|
60
|
-
this.connected = false;
|
|
61
|
-
this.connectionPromise = undefined;
|
|
62
|
-
// Reject all pending requests
|
|
63
|
-
for (const [id, pending] of this.pendingRequests.entries()) {
|
|
64
|
-
pending.reject(new Error('WebSocket connection closed'));
|
|
65
|
-
}
|
|
66
|
-
this.pendingRequests.clear();
|
|
67
|
-
// Attempt reconnect if enabled
|
|
68
|
-
if (this.config.reconnect) {
|
|
69
|
-
setTimeout(() => this.connect(), this.config.reconnectDelay);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
reject(error);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return this.connectionPromise;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Handle incoming WebSocket messages
|
|
81
|
-
*/
|
|
82
|
-
handleMessage(event) {
|
|
83
|
-
try {
|
|
84
|
-
const data = JSON.parse(event.data);
|
|
85
|
-
// Handle ActionCable control messages
|
|
86
|
-
if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// Extract the actual message from ActionCable envelope
|
|
90
|
-
const message = data.message || data;
|
|
91
|
-
if (!message.id) {
|
|
92
|
-
console.warn('Received message without ID:', message);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// Handle streaming progress updates
|
|
96
|
-
if (message.type === 'streaming_progress') {
|
|
97
|
-
const pending = this.pendingRequests.get(message.id);
|
|
98
|
-
if (pending?.onProgress) {
|
|
99
|
-
pending.onProgress(message.progress);
|
|
100
|
-
}
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// Handle final responses
|
|
104
|
-
const pending = this.pendingRequests.get(message.id);
|
|
105
|
-
if (!pending) {
|
|
106
|
-
console.warn('Received response for unknown request:', message.id);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (message.error) {
|
|
110
|
-
pending.reject(new RemoteRuntimeError(message.error));
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
pending.resolve(message.result);
|
|
114
|
-
}
|
|
115
|
-
this.pendingRequests.delete(message.id);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.error('Error handling WebSocket message:', error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Generate next message ID
|
|
123
|
-
*/
|
|
124
|
-
nextMessageId() {
|
|
125
|
-
return `msg-${++this.messageId}-${Date.now()}`;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Send a request and wait for response
|
|
129
|
-
*/
|
|
130
|
-
async sendRequest(message) {
|
|
131
|
-
await this.ensureConnected();
|
|
132
|
-
return new Promise((resolve, reject) => {
|
|
133
|
-
this.pendingRequests.set(message.id, { resolve, reject });
|
|
134
|
-
// Wrap message in ActionCable format
|
|
135
|
-
const actionCableMessage = {
|
|
136
|
-
command: 'message',
|
|
137
|
-
identifier: JSON.stringify({
|
|
138
|
-
channel: this.config.channel,
|
|
139
|
-
}),
|
|
140
|
-
data: JSON.stringify(message),
|
|
141
|
-
};
|
|
142
|
-
this.ws.send(JSON.stringify(actionCableMessage));
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Send a streaming request with progress callbacks
|
|
147
|
-
*/
|
|
148
|
-
async sendStreamingRequest(message, onProgress) {
|
|
149
|
-
await this.ensureConnected();
|
|
150
|
-
return new Promise((resolve, reject) => {
|
|
151
|
-
this.pendingRequests.set(message.id, { resolve, reject, onProgress });
|
|
152
|
-
// Wrap message in ActionCable format
|
|
153
|
-
const actionCableMessage = {
|
|
154
|
-
command: 'message',
|
|
155
|
-
identifier: JSON.stringify({
|
|
156
|
-
channel: this.config.channel,
|
|
157
|
-
}),
|
|
158
|
-
data: JSON.stringify(message),
|
|
159
|
-
};
|
|
160
|
-
this.ws.send(JSON.stringify(actionCableMessage));
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Ensure WebSocket is connected
|
|
165
|
-
*/
|
|
166
|
-
async ensureConnected() {
|
|
167
|
-
if (!this.connected) {
|
|
168
|
-
await this.connect();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Execute a word in the remote runtime
|
|
173
|
-
* Mirrors GrpcClient.executeWord
|
|
174
|
-
*/
|
|
175
|
-
async executeWord(word, stack) {
|
|
176
|
-
const message = {
|
|
177
|
-
type: 'execute_word',
|
|
178
|
-
id: this.nextMessageId(),
|
|
179
|
-
params: {
|
|
180
|
-
word,
|
|
181
|
-
stack: serializeStack(stack),
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
const result = await this.sendRequest(message);
|
|
185
|
-
return deserializeStack(result.stack);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Execute a sequence of words (batched execution)
|
|
189
|
-
* Mirrors GrpcClient.executeSequence
|
|
190
|
-
*/
|
|
191
|
-
async executeSequence(words, stack) {
|
|
192
|
-
const message = {
|
|
193
|
-
type: 'execute_sequence',
|
|
194
|
-
id: this.nextMessageId(),
|
|
195
|
-
params: {
|
|
196
|
-
words,
|
|
197
|
-
stack: serializeStack(stack),
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
const result = await this.sendRequest(message);
|
|
201
|
-
return deserializeStack(result.stack);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* List available runtime-specific modules
|
|
205
|
-
* Mirrors GrpcClient.listModules
|
|
206
|
-
*/
|
|
207
|
-
async listModules() {
|
|
208
|
-
const message = {
|
|
209
|
-
type: 'list_modules',
|
|
210
|
-
id: this.nextMessageId(),
|
|
211
|
-
};
|
|
212
|
-
const result = await this.sendRequest(message);
|
|
213
|
-
return result.modules || [];
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get detailed information about a specific module
|
|
217
|
-
* Mirrors GrpcClient.getModuleInfo
|
|
218
|
-
*/
|
|
219
|
-
async getModuleInfo(moduleName) {
|
|
220
|
-
const message = {
|
|
221
|
-
type: 'get_module_info',
|
|
222
|
-
id: this.nextMessageId(),
|
|
223
|
-
params: {
|
|
224
|
-
module_name: moduleName,
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
return await this.sendRequest(message);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Execute code with streaming progress updates (NEW capability)
|
|
231
|
-
*/
|
|
232
|
-
async streamingExecute(code, stack, onProgress) {
|
|
233
|
-
const message = {
|
|
234
|
-
type: 'streaming_execute',
|
|
235
|
-
id: this.nextMessageId(),
|
|
236
|
-
params: {
|
|
237
|
-
code,
|
|
238
|
-
stack: serializeStack(stack),
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
const result = await this.sendStreamingRequest(message, onProgress);
|
|
242
|
-
return deserializeStack(result.stack);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Close the WebSocket connection
|
|
246
|
-
*/
|
|
247
|
-
close() {
|
|
248
|
-
if (this.ws) {
|
|
249
|
-
this.config.reconnect = false; // Disable auto-reconnect
|
|
250
|
-
this.ws.close();
|
|
251
|
-
this.ws = undefined;
|
|
252
|
-
this.connected = false;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Check if the client is connected
|
|
257
|
-
*/
|
|
258
|
-
isConnected() {
|
|
259
|
-
return this.connected;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/websocket/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoIjD;;;GAGG;AACH,MAAM,OAAO,eAAe;IAClB,EAAE,CAAa;IACf,MAAM,CAAkC;IACxC,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAW,CAAC,CAAC;IACtB,SAAS,GAAY,KAAK,CAAC;IAC3B,iBAAiB,CAAiB;IAE1C,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,cAAc,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