connectonion 0.0.15 → 0.0.17
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/connect/remote-agent.d.ts +16 -1
- package/dist/connect/remote-agent.d.ts.map +1 -1
- package/dist/connect/remote-agent.js +306 -170
- package/dist/connect/types.d.ts +7 -1
- package/dist/connect/types.d.ts.map +1 -1
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentStatus, ApprovalMode, ChatItem, ConnectOptions, Response, SessionState } from './types';
|
|
1
|
+
import { AgentStatus, ApprovalMode, ChatItem, ConnectionState, ConnectOptions, Response, SessionState } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Proxy to a remote agent with streaming support.
|
|
4
4
|
*
|
|
@@ -28,6 +28,7 @@ export declare class RemoteAgent {
|
|
|
28
28
|
private _endpointResolutionAttempted;
|
|
29
29
|
private _WS;
|
|
30
30
|
private _status;
|
|
31
|
+
private _connectionState;
|
|
31
32
|
private _currentSession;
|
|
32
33
|
private _chatItems;
|
|
33
34
|
private _activeWs;
|
|
@@ -36,8 +37,13 @@ export declare class RemoteAgent {
|
|
|
36
37
|
private _pendingSessionId;
|
|
37
38
|
private _lastPingTime;
|
|
38
39
|
private _healthCheckInterval;
|
|
40
|
+
private _reconnectAttempts;
|
|
41
|
+
private _maxReconnectAttempts;
|
|
42
|
+
private _reconnectBaseDelay;
|
|
43
|
+
private _shouldReconnect;
|
|
39
44
|
constructor(agentAddress: string, options?: ConnectOptions);
|
|
40
45
|
get status(): AgentStatus;
|
|
46
|
+
get connectionState(): ConnectionState;
|
|
41
47
|
get currentSession(): SessionState | null;
|
|
42
48
|
get ui(): ChatItem[];
|
|
43
49
|
get mode(): ApprovalMode;
|
|
@@ -61,15 +67,24 @@ export declare class RemoteAgent {
|
|
|
61
67
|
inviteCode?: string;
|
|
62
68
|
payment?: number;
|
|
63
69
|
}): void;
|
|
70
|
+
respondToPlanReview(message: string): void;
|
|
64
71
|
respondToUlwTurnsReached(action: 'continue' | 'switch_mode', options?: {
|
|
65
72
|
turns?: number;
|
|
66
73
|
mode?: ApprovalMode;
|
|
67
74
|
}): void;
|
|
68
75
|
private _ensureKeys;
|
|
76
|
+
private _deriveWsUrl;
|
|
69
77
|
private _startHealthCheck;
|
|
70
78
|
private _stopHealthCheck;
|
|
79
|
+
private _attemptReconnect;
|
|
80
|
+
private _reconnect;
|
|
71
81
|
private _tryResolveEndpoint;
|
|
72
82
|
private _streamInput;
|
|
83
|
+
/**
|
|
84
|
+
* Attach onmessage/onerror/onclose to a WebSocket.
|
|
85
|
+
* Shared by _streamInput (initial connection) and _reconnect.
|
|
86
|
+
*/
|
|
87
|
+
private _attachMessageHandlers;
|
|
73
88
|
private _removeOptimisticThinking;
|
|
74
89
|
private _handleStreamEvent;
|
|
75
90
|
private _addChatItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-agent.d.ts","sourceRoot":"","sources":["../../src/connect/remote-agent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,EAER,cAAc,EAEd,QAAQ,EACR,YAAY,EAGb,MAAM,SAAS,CAAC;AAUjB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;IACtB,6BAA6B;IAC7B,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,kDAAkD;IAClD,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,OAAO,CAAC,KAAK,CAAC,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAAC,CAAmB;IAC7C,OAAO,CAAC,4BAA4B,CAAS;IAC7C,OAAO,CAAC,GAAG,CAAgB;IAE3B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAA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AAwB,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,YAAY,CAAA;KAAE,GAAG,IAAI;IAgBrH,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,UAAU;YAuDJ,mBAAmB;YAanB,YAAY;IA2E1B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAiP9B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,kBAAkB;IA8M1B,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,YAAY;IAepB,QAAQ,IAAI,MAAM;CAInB"}
|
|
@@ -61,6 +61,7 @@ class RemoteAgent {
|
|
|
61
61
|
constructor(agentAddress, options = {}) {
|
|
62
62
|
this._endpointResolutionAttempted = false;
|
|
63
63
|
this._status = 'idle';
|
|
64
|
+
this._connectionState = 'disconnected';
|
|
64
65
|
this._currentSession = null;
|
|
65
66
|
this._chatItems = [];
|
|
66
67
|
this._activeWs = null;
|
|
@@ -69,6 +70,11 @@ class RemoteAgent {
|
|
|
69
70
|
this._pendingSessionId = null;
|
|
70
71
|
this._lastPingTime = 0;
|
|
71
72
|
this._healthCheckInterval = null;
|
|
73
|
+
// Reconnection state
|
|
74
|
+
this._reconnectAttempts = 0;
|
|
75
|
+
this._maxReconnectAttempts = 3;
|
|
76
|
+
this._reconnectBaseDelay = 1000;
|
|
77
|
+
this._shouldReconnect = false;
|
|
72
78
|
this.address = agentAddress;
|
|
73
79
|
this._relayUrl = (0, endpoint_1.normalizeRelayBase)(options.relayUrl || 'wss://oo.openonion.ai');
|
|
74
80
|
this._directUrl = options.directUrl?.replace(/\/$/, '');
|
|
@@ -83,6 +89,9 @@ class RemoteAgent {
|
|
|
83
89
|
get status() {
|
|
84
90
|
return this._status;
|
|
85
91
|
}
|
|
92
|
+
get connectionState() {
|
|
93
|
+
return this._connectionState;
|
|
94
|
+
}
|
|
86
95
|
get currentSession() {
|
|
87
96
|
return this._currentSession;
|
|
88
97
|
}
|
|
@@ -127,6 +136,9 @@ class RemoteAgent {
|
|
|
127
136
|
this._currentSession = null;
|
|
128
137
|
this._chatItems = [];
|
|
129
138
|
this._status = 'idle';
|
|
139
|
+
this._connectionState = 'disconnected';
|
|
140
|
+
this._shouldReconnect = false;
|
|
141
|
+
this._reconnectAttempts = 0;
|
|
130
142
|
}
|
|
131
143
|
resetConversation() {
|
|
132
144
|
this.reset();
|
|
@@ -178,6 +190,15 @@ class RemoteAgent {
|
|
|
178
190
|
...signed,
|
|
179
191
|
}));
|
|
180
192
|
}
|
|
193
|
+
respondToPlanReview(message) {
|
|
194
|
+
if (!this._activeWs) {
|
|
195
|
+
throw new Error('No active connection to respond to');
|
|
196
|
+
}
|
|
197
|
+
this._activeWs.send(JSON.stringify({
|
|
198
|
+
type: 'PLAN_REVIEW_RESPONSE',
|
|
199
|
+
message,
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
181
202
|
respondToUlwTurnsReached(action, options) {
|
|
182
203
|
if (!this._activeWs) {
|
|
183
204
|
throw new Error('No active connection to respond to ULW');
|
|
@@ -209,6 +230,17 @@ class RemoteAgent {
|
|
|
209
230
|
this._keys = address.generate();
|
|
210
231
|
}
|
|
211
232
|
}
|
|
233
|
+
_deriveWsUrl() {
|
|
234
|
+
if (this._directUrl) {
|
|
235
|
+
const base = this._directUrl.replace(/^https?:\/\//, '');
|
|
236
|
+
const protocol = this._directUrl.startsWith('https') ? 'wss' : 'ws';
|
|
237
|
+
return { wsUrl: `${protocol}://${base}/ws`, isDirect: true };
|
|
238
|
+
}
|
|
239
|
+
if (this._resolvedEndpoint) {
|
|
240
|
+
return { wsUrl: this._resolvedEndpoint.wsUrl, isDirect: true };
|
|
241
|
+
}
|
|
242
|
+
return { wsUrl: `${this._relayUrl}/ws/input`, isDirect: false };
|
|
243
|
+
}
|
|
212
244
|
_startHealthCheck(ws, reject) {
|
|
213
245
|
this._stopHealthCheck();
|
|
214
246
|
this._healthCheckInterval = setInterval(() => {
|
|
@@ -226,6 +258,72 @@ class RemoteAgent {
|
|
|
226
258
|
this._healthCheckInterval = null;
|
|
227
259
|
}
|
|
228
260
|
}
|
|
261
|
+
_attemptReconnect(resolve, reject) {
|
|
262
|
+
if (!this._currentSession?.session_id) {
|
|
263
|
+
reject(new Error('No session to reconnect'));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (this._reconnectAttempts >= this._maxReconnectAttempts) {
|
|
267
|
+
this._reconnectAttempts = 0;
|
|
268
|
+
this._shouldReconnect = false;
|
|
269
|
+
this._connectionState = 'disconnected';
|
|
270
|
+
reject(new Error('Max reconnection attempts reached'));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this._connectionState = 'reconnecting';
|
|
274
|
+
this._reconnectAttempts++;
|
|
275
|
+
const delay = Math.min(this._reconnectBaseDelay * Math.pow(2, this._reconnectAttempts - 1), 30000);
|
|
276
|
+
console.log(`[ConnectOnion] Connection lost. Reconnecting in ${delay}ms (attempt ${this._reconnectAttempts}/${this._maxReconnectAttempts})...`);
|
|
277
|
+
setTimeout(() => {
|
|
278
|
+
this._reconnect(resolve, reject);
|
|
279
|
+
}, delay);
|
|
280
|
+
}
|
|
281
|
+
_reconnect(resolve, reject) {
|
|
282
|
+
const sessionId = this._currentSession?.session_id;
|
|
283
|
+
if (!sessionId) {
|
|
284
|
+
reject(new Error('No session to reconnect'));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const { wsUrl, isDirect } = this._deriveWsUrl();
|
|
288
|
+
const ws = new this._WS(wsUrl);
|
|
289
|
+
this._activeWs = ws;
|
|
290
|
+
this._status = 'working';
|
|
291
|
+
const state = {
|
|
292
|
+
settled: false,
|
|
293
|
+
timer: setTimeout(() => {
|
|
294
|
+
if (!state.settled) {
|
|
295
|
+
state.settled = true;
|
|
296
|
+
this._status = 'idle';
|
|
297
|
+
ws.close();
|
|
298
|
+
this._attemptReconnect(resolve, reject);
|
|
299
|
+
}
|
|
300
|
+
}, 600000),
|
|
301
|
+
};
|
|
302
|
+
ws.onopen = () => {
|
|
303
|
+
console.log('[ConnectOnion] Reconnected successfully');
|
|
304
|
+
this._connectionState = 'connected';
|
|
305
|
+
this._reconnectAttempts = 0;
|
|
306
|
+
this._lastPingTime = Date.now();
|
|
307
|
+
this._startHealthCheck(ws, reject);
|
|
308
|
+
// Send full session for server-side merge (iteration count comparison)
|
|
309
|
+
const payload = {
|
|
310
|
+
prompt: '',
|
|
311
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
312
|
+
};
|
|
313
|
+
if (!isDirect)
|
|
314
|
+
payload.to = this.address;
|
|
315
|
+
const signed = this._signPayload(payload);
|
|
316
|
+
ws.send(JSON.stringify({
|
|
317
|
+
type: 'INPUT',
|
|
318
|
+
input_id: (0, endpoint_1.generateUUID)(),
|
|
319
|
+
prompt: '',
|
|
320
|
+
...signed,
|
|
321
|
+
...(!isDirect && { to: this.address }),
|
|
322
|
+
session: { ...this._currentSession, session_id: sessionId },
|
|
323
|
+
}));
|
|
324
|
+
};
|
|
325
|
+
this._attachMessageHandlers(ws, (0, endpoint_1.generateUUID)(), isDirect, state, resolve, reject);
|
|
326
|
+
}
|
|
229
327
|
async _tryResolveEndpoint() {
|
|
230
328
|
if (this._endpointResolutionAttempted || this._directUrl)
|
|
231
329
|
return;
|
|
@@ -245,34 +343,26 @@ class RemoteAgent {
|
|
|
245
343
|
this._status = 'working';
|
|
246
344
|
const inputId = (0, endpoint_1.generateUUID)();
|
|
247
345
|
const sessionId = this._currentSession?.session_id || (0, endpoint_1.generateUUID)();
|
|
248
|
-
|
|
249
|
-
let isDirect = false;
|
|
250
|
-
if (this._directUrl) {
|
|
251
|
-
const baseUrl = this._directUrl.replace(/^https?:\/\//, '');
|
|
252
|
-
const protocol = this._directUrl.startsWith('https') ? 'wss' : 'ws';
|
|
253
|
-
wsUrl = `${protocol}://${baseUrl}/ws`;
|
|
254
|
-
isDirect = true;
|
|
255
|
-
}
|
|
256
|
-
else if (this._resolvedEndpoint) {
|
|
257
|
-
wsUrl = this._resolvedEndpoint.wsUrl;
|
|
258
|
-
isDirect = true;
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
wsUrl = `${this._relayUrl}/ws/input`;
|
|
262
|
-
}
|
|
346
|
+
const { wsUrl, isDirect } = this._deriveWsUrl();
|
|
263
347
|
const ws = new this._WS(wsUrl);
|
|
264
348
|
this._activeWs = ws;
|
|
349
|
+
this._shouldReconnect = true;
|
|
265
350
|
return new Promise((resolve, reject) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
settled
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
351
|
+
const state = {
|
|
352
|
+
settled: false,
|
|
353
|
+
timer: setTimeout(() => {
|
|
354
|
+
if (!state.settled) {
|
|
355
|
+
state.settled = true;
|
|
356
|
+
this._status = 'idle';
|
|
357
|
+
this._shouldReconnect = false;
|
|
358
|
+
this._connectionState = 'disconnected';
|
|
359
|
+
ws.close();
|
|
360
|
+
reject(new Error('Connection timed out'));
|
|
361
|
+
}
|
|
362
|
+
}, timeoutMs),
|
|
363
|
+
};
|
|
275
364
|
ws.onopen = () => {
|
|
365
|
+
this._connectionState = 'connected';
|
|
276
366
|
this._lastPingTime = Date.now();
|
|
277
367
|
this._startHealthCheck(ws, reject);
|
|
278
368
|
const payload = {
|
|
@@ -303,174 +393,219 @@ class RemoteAgent {
|
|
|
303
393
|
}
|
|
304
394
|
ws.send(JSON.stringify(inputMessage));
|
|
305
395
|
};
|
|
306
|
-
ws
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
396
|
+
this._attachMessageHandlers(ws, inputId, isDirect, state, resolve, reject);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Attach onmessage/onerror/onclose to a WebSocket.
|
|
401
|
+
* Shared by _streamInput (initial connection) and _reconnect.
|
|
402
|
+
*/
|
|
403
|
+
_attachMessageHandlers(ws, inputId, isDirect, state, resolve, reject) {
|
|
404
|
+
ws.onmessage = (evt) => {
|
|
405
|
+
if (state.settled)
|
|
406
|
+
return;
|
|
407
|
+
const raw = typeof evt.data === 'string' ? evt.data : String(evt.data);
|
|
408
|
+
const data = JSON.parse(raw);
|
|
409
|
+
if (data?.type === 'PING') {
|
|
410
|
+
this._lastPingTime = Date.now();
|
|
411
|
+
ws.send(JSON.stringify({ type: 'PONG' }));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (data?.type === 'session_sync' && data.session) {
|
|
415
|
+
this._currentSession = data.session;
|
|
416
|
+
}
|
|
417
|
+
if (data?.type === 'RECONNECTED') {
|
|
418
|
+
console.log('[RemoteAgent] Reconnected to session:', data.session_id);
|
|
419
|
+
}
|
|
420
|
+
if (data?.type === 'SESSION_MERGED' && data.server_newer) {
|
|
421
|
+
console.log('[RemoteAgent] Server had newer session, merged');
|
|
422
|
+
}
|
|
423
|
+
if (data?.type === 'mode_changed' && data.mode) {
|
|
424
|
+
if (!this._currentSession) {
|
|
425
|
+
this._currentSession = { mode: data.mode };
|
|
315
426
|
}
|
|
316
|
-
|
|
317
|
-
this._currentSession = data.
|
|
427
|
+
else {
|
|
428
|
+
this._currentSession.mode = data.mode;
|
|
318
429
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
this._currentSession.mode = data.mode;
|
|
325
|
-
}
|
|
430
|
+
}
|
|
431
|
+
if (data?.type === 'ulw_turns_reached') {
|
|
432
|
+
this._status = 'waiting';
|
|
433
|
+
if (this._currentSession) {
|
|
434
|
+
this._currentSession.ulw_turns_used = data.turns_used;
|
|
326
435
|
}
|
|
327
|
-
|
|
328
|
-
|
|
436
|
+
this._addChatItem({
|
|
437
|
+
type: 'ulw_turns_reached',
|
|
438
|
+
turns_used: data.turns_used,
|
|
439
|
+
max_turns: data.max_turns,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (data?.type === 'llm_call' || data?.type === 'llm_result' ||
|
|
443
|
+
data?.type === 'tool_call' || data?.type === 'tool_result' ||
|
|
444
|
+
data?.type === 'thinking' || data?.type === 'assistant' ||
|
|
445
|
+
data?.type === 'intent' || data?.type === 'eval' || data?.type === 'compact' ||
|
|
446
|
+
data?.type === 'tool_blocked') {
|
|
447
|
+
this._handleStreamEvent(data);
|
|
448
|
+
if (data.session) {
|
|
449
|
+
this._currentSession = data.session;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (data?.type === 'ask_user') {
|
|
453
|
+
this._status = 'waiting';
|
|
454
|
+
this._addChatItem({ type: 'ask_user', text: data.text || '', options: data.options || [], multi_select: data.multi_select || false });
|
|
455
|
+
}
|
|
456
|
+
if (data?.type === 'approval_needed') {
|
|
457
|
+
this._status = 'waiting';
|
|
458
|
+
this._addChatItem({
|
|
459
|
+
type: 'approval_needed',
|
|
460
|
+
tool: data.tool,
|
|
461
|
+
arguments: data.arguments,
|
|
462
|
+
...(data.description && { description: data.description }),
|
|
463
|
+
...(data.batch_remaining && { batch_remaining: data.batch_remaining }),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (data?.type === 'plan_review') {
|
|
467
|
+
this._status = 'waiting';
|
|
468
|
+
this._addChatItem({
|
|
469
|
+
type: 'plan_review',
|
|
470
|
+
plan_content: data.plan_content,
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
if (data?.type === 'ONBOARD_REQUIRED') {
|
|
474
|
+
this._status = 'waiting';
|
|
475
|
+
this._pendingPrompt = data.prompt || '';
|
|
476
|
+
this._pendingInputId = inputId;
|
|
477
|
+
this._pendingSessionId = this._currentSession?.session_id || null;
|
|
478
|
+
this._addChatItem({
|
|
479
|
+
type: 'onboard_required',
|
|
480
|
+
methods: (data.methods || []),
|
|
481
|
+
paymentAmount: data.payment_amount,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (data?.type === 'ONBOARD_SUCCESS') {
|
|
485
|
+
this._addChatItem({
|
|
486
|
+
type: 'onboard_success',
|
|
487
|
+
level: data.level,
|
|
488
|
+
message: data.message,
|
|
489
|
+
});
|
|
490
|
+
if (this._pendingPrompt && this._activeWs) {
|
|
491
|
+
this._status = 'working';
|
|
492
|
+
const retryPrompt = this._pendingPrompt;
|
|
493
|
+
const retryInputId = this._pendingInputId || (0, endpoint_1.generateUUID)();
|
|
494
|
+
this._pendingPrompt = null;
|
|
495
|
+
this._pendingInputId = null;
|
|
496
|
+
const retryPayload = {
|
|
497
|
+
prompt: retryPrompt,
|
|
498
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
499
|
+
};
|
|
500
|
+
if (!isDirect)
|
|
501
|
+
retryPayload.to = this.address;
|
|
502
|
+
const retrySigned = this._signPayload(retryPayload);
|
|
503
|
+
const retryMessage = {
|
|
504
|
+
type: 'INPUT',
|
|
505
|
+
input_id: retryInputId,
|
|
506
|
+
prompt: retryPrompt,
|
|
507
|
+
...retrySigned,
|
|
508
|
+
};
|
|
509
|
+
if (!isDirect)
|
|
510
|
+
retryMessage.to = this.address;
|
|
329
511
|
if (this._currentSession) {
|
|
330
|
-
this._currentSession
|
|
512
|
+
retryMessage.session = { ...this._currentSession, session_id: this._pendingSessionId };
|
|
331
513
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
turns_used: data.turns_used,
|
|
335
|
-
max_turns: data.max_turns,
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
if (data?.type === 'llm_call' || data?.type === 'llm_result' ||
|
|
339
|
-
data?.type === 'tool_call' || data?.type === 'tool_result' ||
|
|
340
|
-
data?.type === 'thinking' || data?.type === 'assistant' ||
|
|
341
|
-
data?.type === 'intent' || data?.type === 'eval' || data?.type === 'compact' ||
|
|
342
|
-
data?.type === 'tool_blocked') {
|
|
343
|
-
this._handleStreamEvent(data);
|
|
344
|
-
if (data.session) {
|
|
345
|
-
this._currentSession = data.session;
|
|
514
|
+
else {
|
|
515
|
+
retryMessage.session = { session_id: this._pendingSessionId };
|
|
346
516
|
}
|
|
517
|
+
this._activeWs.send(JSON.stringify(retryMessage));
|
|
518
|
+
this._pendingSessionId = null;
|
|
347
519
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
520
|
+
}
|
|
521
|
+
const isOutputForUs = isDirect
|
|
522
|
+
? data?.type === 'OUTPUT'
|
|
523
|
+
: data?.type === 'OUTPUT' && data?.input_id === inputId;
|
|
524
|
+
if (isOutputForUs) {
|
|
525
|
+
state.settled = true;
|
|
526
|
+
clearTimeout(state.timer);
|
|
527
|
+
this._stopHealthCheck();
|
|
528
|
+
this._removeOptimisticThinking();
|
|
529
|
+
this._status = 'idle';
|
|
530
|
+
this._shouldReconnect = false;
|
|
531
|
+
this._connectionState = 'disconnected';
|
|
532
|
+
this._reconnectAttempts = 0;
|
|
533
|
+
if (data.session) {
|
|
534
|
+
this._currentSession = data.session;
|
|
361
535
|
}
|
|
362
|
-
if (data
|
|
363
|
-
this.
|
|
364
|
-
|
|
365
|
-
this.
|
|
366
|
-
this._pendingSessionId = sessionId;
|
|
367
|
-
this._addChatItem({
|
|
368
|
-
type: 'onboard_required',
|
|
369
|
-
methods: (data.methods || []),
|
|
370
|
-
paymentAmount: data.payment_amount,
|
|
371
|
-
});
|
|
536
|
+
if (data.chat_items && Array.isArray(data.chat_items)) {
|
|
537
|
+
const userItems = this._chatItems.filter(item => item.type === 'user');
|
|
538
|
+
const serverNonUserItems = data.chat_items.filter(item => item.type !== 'user');
|
|
539
|
+
this._chatItems = [...userItems, ...serverNonUserItems];
|
|
372
540
|
}
|
|
373
|
-
if (data
|
|
374
|
-
|
|
375
|
-
type: 'onboard_success',
|
|
376
|
-
level: data.level,
|
|
377
|
-
message: data.message,
|
|
378
|
-
});
|
|
379
|
-
if (this._pendingPrompt && this._activeWs) {
|
|
380
|
-
this._status = 'working';
|
|
381
|
-
const retryPrompt = this._pendingPrompt;
|
|
382
|
-
const retryInputId = this._pendingInputId || (0, endpoint_1.generateUUID)();
|
|
383
|
-
this._pendingPrompt = null;
|
|
384
|
-
this._pendingInputId = null;
|
|
385
|
-
const retryPayload = {
|
|
386
|
-
prompt: retryPrompt,
|
|
387
|
-
timestamp: Math.floor(Date.now() / 1000),
|
|
388
|
-
};
|
|
389
|
-
if (!isDirect)
|
|
390
|
-
retryPayload.to = this.address;
|
|
391
|
-
const retrySigned = this._signPayload(retryPayload);
|
|
392
|
-
const retryMessage = {
|
|
393
|
-
type: 'INPUT',
|
|
394
|
-
input_id: retryInputId,
|
|
395
|
-
prompt: retryPrompt,
|
|
396
|
-
...retrySigned,
|
|
397
|
-
};
|
|
398
|
-
if (!isDirect)
|
|
399
|
-
retryMessage.to = this.address;
|
|
400
|
-
if (this._currentSession) {
|
|
401
|
-
retryMessage.session = { ...this._currentSession, session_id: this._pendingSessionId };
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
retryMessage.session = { session_id: this._pendingSessionId };
|
|
405
|
-
}
|
|
406
|
-
this._activeWs.send(JSON.stringify(retryMessage));
|
|
407
|
-
this._pendingSessionId = null;
|
|
408
|
-
}
|
|
541
|
+
if (data.server_newer) {
|
|
542
|
+
console.log('[RemoteAgent] Session was merged with newer server state');
|
|
409
543
|
}
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
clearTimeout(timer);
|
|
416
|
-
this._stopHealthCheck();
|
|
417
|
-
this._removeOptimisticThinking();
|
|
418
|
-
this._status = 'idle';
|
|
419
|
-
if (data.session) {
|
|
420
|
-
this._currentSession = data.session;
|
|
421
|
-
}
|
|
422
|
-
const result = data.result || '';
|
|
423
|
-
if (result) {
|
|
424
|
-
const lastAgent = this._chatItems.filter((e) => e.type === 'agent').pop();
|
|
425
|
-
if (!lastAgent || lastAgent.content !== result) {
|
|
426
|
-
this._addChatItem({ type: 'agent', content: result });
|
|
427
|
-
}
|
|
544
|
+
const result = data.result || '';
|
|
545
|
+
if (result) {
|
|
546
|
+
const lastAgent = this._chatItems.filter((e) => e.type === 'agent').pop();
|
|
547
|
+
if (!lastAgent || lastAgent.content !== result) {
|
|
548
|
+
this._addChatItem({ type: 'agent', content: result });
|
|
428
549
|
}
|
|
429
|
-
this._activeWs = null;
|
|
430
|
-
ws.close();
|
|
431
|
-
resolve({ text: result, done: true });
|
|
432
|
-
}
|
|
433
|
-
if (data?.type === 'ERROR') {
|
|
434
|
-
settled = true;
|
|
435
|
-
clearTimeout(timer);
|
|
436
|
-
this._stopHealthCheck();
|
|
437
|
-
this._status = 'idle';
|
|
438
|
-
this._activeWs = null;
|
|
439
|
-
ws.close();
|
|
440
|
-
reject(new Error(`Agent error: ${String(data.message || data.error || 'Unknown error')}`));
|
|
441
550
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
551
|
+
this._activeWs = null;
|
|
552
|
+
ws.close();
|
|
553
|
+
resolve({ text: result, done: true });
|
|
554
|
+
}
|
|
555
|
+
if (data?.type === 'ERROR') {
|
|
556
|
+
state.settled = true;
|
|
557
|
+
clearTimeout(state.timer);
|
|
447
558
|
this._stopHealthCheck();
|
|
448
559
|
this._status = 'idle';
|
|
449
|
-
|
|
560
|
+
this._shouldReconnect = false;
|
|
561
|
+
this._connectionState = 'disconnected';
|
|
562
|
+
this._activeWs = null;
|
|
450
563
|
ws.close();
|
|
451
|
-
|
|
564
|
+
reject(new Error(`Agent error: ${String(data.message || data.error || 'Unknown error')}`));
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
ws.onerror = async (err) => {
|
|
568
|
+
if (state.settled)
|
|
569
|
+
return;
|
|
570
|
+
this._stopHealthCheck();
|
|
571
|
+
clearTimeout(state.timer);
|
|
572
|
+
ws.close();
|
|
573
|
+
if (isDirect && !this._directUrl) {
|
|
574
|
+
this._resolvedEndpoint = undefined;
|
|
575
|
+
this._endpointResolutionAttempted = false;
|
|
576
|
+
}
|
|
577
|
+
if (this._shouldReconnect && this._reconnectAttempts < this._maxReconnectAttempts) {
|
|
578
|
+
this._attemptReconnect(resolve, reject);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
state.settled = true;
|
|
582
|
+
this._status = 'idle';
|
|
583
|
+
this._shouldReconnect = false;
|
|
584
|
+
this._connectionState = 'disconnected';
|
|
585
|
+
reject(new Error(`WebSocket error: ${String(err)}`));
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
ws.onclose = async () => {
|
|
589
|
+
this._activeWs = null;
|
|
590
|
+
this._stopHealthCheck();
|
|
591
|
+
if (!state.settled) {
|
|
592
|
+
clearTimeout(state.timer);
|
|
452
593
|
if (isDirect && !this._directUrl) {
|
|
453
594
|
this._resolvedEndpoint = undefined;
|
|
454
595
|
this._endpointResolutionAttempted = false;
|
|
455
596
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (!settled) {
|
|
462
|
-
settled = true;
|
|
597
|
+
if (this._shouldReconnect && this._reconnectAttempts < this._maxReconnectAttempts) {
|
|
598
|
+
this._attemptReconnect(resolve, reject);
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
state.settled = true;
|
|
463
602
|
this._status = 'idle';
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (isDirect && !this._directUrl) {
|
|
467
|
-
this._resolvedEndpoint = undefined;
|
|
468
|
-
this._endpointResolutionAttempted = false;
|
|
469
|
-
}
|
|
603
|
+
this._shouldReconnect = false;
|
|
604
|
+
this._connectionState = 'disconnected';
|
|
470
605
|
reject(new Error('Connection closed before response'));
|
|
471
606
|
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
474
609
|
}
|
|
475
610
|
// ==========================================================================
|
|
476
611
|
// Private Methods - UI Helpers
|
|
@@ -652,6 +787,7 @@ class RemoteAgent {
|
|
|
652
787
|
tool: event.tool,
|
|
653
788
|
reason: event.reason,
|
|
654
789
|
message: event.message,
|
|
790
|
+
command: event.command,
|
|
655
791
|
});
|
|
656
792
|
break;
|
|
657
793
|
}
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface Response {
|
|
|
4
4
|
text: string;
|
|
5
5
|
done: boolean;
|
|
6
6
|
}
|
|
7
|
-
export type ChatItemType = 'user' | 'agent' | 'thinking' | 'tool_call' | 'ask_user' | 'approval_needed' | 'onboard_required' | 'onboard_success' | 'intent' | 'eval' | 'compact' | 'tool_blocked' | 'ulw_turns_reached';
|
|
7
|
+
export type ChatItemType = 'user' | 'agent' | 'thinking' | 'tool_call' | 'ask_user' | 'approval_needed' | 'onboard_required' | 'onboard_success' | 'intent' | 'eval' | 'compact' | 'tool_blocked' | 'ulw_turns_reached' | 'plan_review';
|
|
8
8
|
export type ChatItem = {
|
|
9
9
|
id: string;
|
|
10
10
|
type: 'user';
|
|
@@ -95,11 +95,16 @@ export type ChatItem = {
|
|
|
95
95
|
tool: string;
|
|
96
96
|
reason: string;
|
|
97
97
|
message: string;
|
|
98
|
+
command?: string;
|
|
98
99
|
} | {
|
|
99
100
|
id: string;
|
|
100
101
|
type: 'ulw_turns_reached';
|
|
101
102
|
turns_used: number;
|
|
102
103
|
max_turns: number;
|
|
104
|
+
} | {
|
|
105
|
+
id: string;
|
|
106
|
+
type: 'plan_review';
|
|
107
|
+
plan_content: string;
|
|
103
108
|
};
|
|
104
109
|
export type WebSocketLike = {
|
|
105
110
|
onopen: ((ev?: unknown) => unknown) | null;
|
|
@@ -159,4 +164,5 @@ export interface SessionState {
|
|
|
159
164
|
}
|
|
160
165
|
export type ApprovalMode = 'safe' | 'plan' | 'accept_edits' | 'ulw';
|
|
161
166
|
export type AgentStatus = 'idle' | 'working' | 'waiting';
|
|
167
|
+
export type ConnectionState = 'disconnected' | 'connected' | 'reconnecting';
|
|
162
168
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/connect/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,CAAC;AAE3C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAMD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/connect/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,CAAC;AAE3C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAMD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,mBAAmB,GAAG,aAAa,CAAC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W,GAAG,cAAc,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import { Response, ChatItem, AgentStatus, ConnectOptions, ApprovalMode } from '../connect';
|
|
21
|
-
export type { Response, ChatItem, ChatItemType, AgentStatus, ConnectOptions, AgentInfo, ApprovalMode, } from '../connect';
|
|
20
|
+
import { Response, ChatItem, AgentStatus, ConnectionState, ConnectOptions, ApprovalMode } from '../connect';
|
|
21
|
+
export type { Response, ChatItem, ChatItemType, AgentStatus, ConnectionState, ConnectOptions, AgentInfo, ApprovalMode, } from '../connect';
|
|
22
22
|
export { fetchAgentInfo } from '../connect';
|
|
23
23
|
/** @deprecated Use ChatItem instead */
|
|
24
24
|
export type UIEvent = ChatItem;
|
|
@@ -45,6 +45,7 @@ export interface Message {
|
|
|
45
45
|
}
|
|
46
46
|
export interface UseAgentReturn {
|
|
47
47
|
status: AgentStatus;
|
|
48
|
+
connectionState: ConnectionState;
|
|
48
49
|
ui: ChatItem[];
|
|
49
50
|
sessionId: string;
|
|
50
51
|
isProcessing: boolean;
|
|
@@ -61,6 +62,7 @@ export interface UseAgentReturn {
|
|
|
61
62
|
}) => Promise<Response>;
|
|
62
63
|
respond: (answer: string | string[]) => void;
|
|
63
64
|
respondToApproval: (approved: boolean, scope?: 'once' | 'session', mode?: 'reject_soft' | 'reject_hard' | 'reject_explain', feedback?: string) => void;
|
|
65
|
+
respondToPlanReview: (message: string) => void;
|
|
64
66
|
respondToUlwTurnsReached: (action: 'continue' | 'switch_mode', options?: {
|
|
65
67
|
turns?: number;
|
|
66
68
|
mode?: ApprovalMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAGL,QAAQ,EACR,QAAQ,EACR,WAAW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zB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,EACX,WAAW,EACX,0BAA0B,EAC1B,KAAK,WAAW,GACjB,MAAM,oBAAoB,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -177,6 +177,9 @@ function useAgent(address, options) {
|
|
|
177
177
|
const respondToApproval = (approved, scope = 'once', mode, feedback) => {
|
|
178
178
|
agent.respondToApproval(approved, scope, mode, feedback);
|
|
179
179
|
};
|
|
180
|
+
const respondToPlanReview = (message) => {
|
|
181
|
+
agent.respondToPlanReview(message);
|
|
182
|
+
};
|
|
180
183
|
const submitOnboard = (options) => {
|
|
181
184
|
agent.submitOnboard(options);
|
|
182
185
|
};
|
|
@@ -200,6 +203,7 @@ function useAgent(address, options) {
|
|
|
200
203
|
};
|
|
201
204
|
return {
|
|
202
205
|
status,
|
|
206
|
+
connectionState: agent.connectionState,
|
|
203
207
|
ui,
|
|
204
208
|
sessionId,
|
|
205
209
|
isProcessing: status !== 'idle',
|
|
@@ -210,6 +214,7 @@ function useAgent(address, options) {
|
|
|
210
214
|
input,
|
|
211
215
|
respond,
|
|
212
216
|
respondToApproval,
|
|
217
|
+
respondToPlanReview,
|
|
213
218
|
respondToUlwTurnsReached,
|
|
214
219
|
submitOnboard,
|
|
215
220
|
setMode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "connectonion",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Connect to Python AI agents from TypeScript apps - Use powerful Python agents in your React, Next.js, Node.js, and Electron applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|