@openagents-org/agent-launcher 0.2.127 → 0.2.128
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/package.json +1 -1
- package/src/adapters/base.js +26 -3
package/package.json
CHANGED
package/src/adapters/base.js
CHANGED
|
@@ -330,6 +330,14 @@ class BaseAdapter {
|
|
|
330
330
|
const msgId = msg.id || msg.messageId;
|
|
331
331
|
if (msgId && this._processedIds.has(msgId)) continue;
|
|
332
332
|
if (msg.messageType === 'status') continue;
|
|
333
|
+
// Handle queue cancellation signals from frontend
|
|
334
|
+
if (msg.messageType === 'queue_cancel') {
|
|
335
|
+
if (msgId) this._processedIds.add(msgId);
|
|
336
|
+
const channel = msg.sessionId || this.channelName || 'general';
|
|
337
|
+
const queueId = msg.metadata?.queue_id || (msg.content || '').replace('__queue_cancel:', '');
|
|
338
|
+
if (queueId) this._cancelQueuedMessage(channel, queueId);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
333
341
|
incoming.push(msg);
|
|
334
342
|
}
|
|
335
343
|
|
|
@@ -372,9 +380,14 @@ class BaseAdapter {
|
|
|
372
380
|
|
|
373
381
|
if (this._channelBusy.has(channel)) {
|
|
374
382
|
if (!this._channelQueues[channel]) this._channelQueues[channel] = [];
|
|
383
|
+
const queueId = `q-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
384
|
+
msg._queueId = queueId;
|
|
375
385
|
this._channelQueues[channel].push(msg);
|
|
376
386
|
try {
|
|
377
|
-
await this.sendStatus(channel, 'message queued — will process after current task'
|
|
387
|
+
await this.sendStatus(channel, 'message queued — will process after current task', {
|
|
388
|
+
queued_message: (msg.content || '').slice(0, 200),
|
|
389
|
+
queue_id: queueId,
|
|
390
|
+
});
|
|
378
391
|
} catch {}
|
|
379
392
|
return;
|
|
380
393
|
}
|
|
@@ -384,6 +397,16 @@ class BaseAdapter {
|
|
|
384
397
|
this._wakeControlPoller();
|
|
385
398
|
}
|
|
386
399
|
|
|
400
|
+
_cancelQueuedMessage(channel, queueId) {
|
|
401
|
+
const queue = this._channelQueues[channel];
|
|
402
|
+
if (!queue) return false;
|
|
403
|
+
const idx = queue.findIndex((m) => m._queueId === queueId);
|
|
404
|
+
if (idx === -1) return false;
|
|
405
|
+
queue.splice(idx, 1);
|
|
406
|
+
this._log(`Cancelled queued message ${queueId} in ${channel}`);
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
|
|
387
410
|
async _channelWorker(channel, msg) {
|
|
388
411
|
this._channelBusy.add(channel);
|
|
389
412
|
try {
|
|
@@ -435,13 +458,13 @@ class BaseAdapter {
|
|
|
435
458
|
// Message helpers
|
|
436
459
|
// ------------------------------------------------------------------
|
|
437
460
|
|
|
438
|
-
async sendStatus(channel, content) {
|
|
461
|
+
async sendStatus(channel, content, extraMeta) {
|
|
439
462
|
try {
|
|
440
463
|
await this.client.sendMessage(this.workspaceId, channel, this.token, content, {
|
|
441
464
|
senderType: 'agent',
|
|
442
465
|
senderName: this.agentName,
|
|
443
466
|
messageType: 'status',
|
|
444
|
-
metadata: { agent_mode: this._mode },
|
|
467
|
+
metadata: { agent_mode: this._mode, ...extraMeta },
|
|
445
468
|
sessionId: this._sessionId,
|
|
446
469
|
});
|
|
447
470
|
} catch (e) {
|