@agentshouse/kit 0.2.1-alpha.2 → 0.2.1-alpha.3
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/conversations.js +19 -9
- package/package.json +1 -1
package/dist/conversations.js
CHANGED
|
@@ -39,11 +39,11 @@ class Turn {
|
|
|
39
39
|
unsentFrom = null;
|
|
40
40
|
draftSequence = 0;
|
|
41
41
|
planSequence = 0;
|
|
42
|
+
entries = null;
|
|
42
43
|
questions = 0;
|
|
43
44
|
secrets = 0;
|
|
44
45
|
prompt = null;
|
|
45
46
|
ended = false;
|
|
46
|
-
ready = Promise.resolve();
|
|
47
47
|
}
|
|
48
48
|
class Conversation {
|
|
49
49
|
id;
|
|
@@ -348,9 +348,19 @@ export class Conversations {
|
|
|
348
348
|
report(conversation) {
|
|
349
349
|
const turn = new Turn();
|
|
350
350
|
conversation.open++;
|
|
351
|
-
|
|
351
|
+
void this.deliver(conversation, turn, 'started', {})
|
|
352
|
+
.then(() => this.admitted(conversation, turn))
|
|
353
|
+
.catch(logged);
|
|
352
354
|
return turn;
|
|
353
355
|
}
|
|
356
|
+
admitted(conversation, turn) {
|
|
357
|
+
if (turn.text !== '') {
|
|
358
|
+
turn.unsentFrom = 0;
|
|
359
|
+
this.draft(conversation, turn);
|
|
360
|
+
}
|
|
361
|
+
if (turn.entries !== null)
|
|
362
|
+
this.plan(conversation, turn);
|
|
363
|
+
}
|
|
354
364
|
begin(conversation) {
|
|
355
365
|
const turn = this.report(conversation);
|
|
356
366
|
conversation.turn = turn;
|
|
@@ -487,12 +497,12 @@ export class Conversations {
|
|
|
487
497
|
if (update.sessionUpdate === 'agent_message_chunk' && update.content.type === 'text') {
|
|
488
498
|
const turn = this.started(conversation);
|
|
489
499
|
turn.text += update.content.text;
|
|
490
|
-
|
|
491
|
-
void turn.ready.then(() => this.draft(conversation, turn, text));
|
|
500
|
+
this.draft(conversation, turn);
|
|
492
501
|
}
|
|
493
502
|
else if (update.sessionUpdate === 'plan') {
|
|
494
503
|
const turn = this.started(conversation);
|
|
495
|
-
|
|
504
|
+
turn.entries = update.entries;
|
|
505
|
+
this.plan(conversation, turn);
|
|
496
506
|
}
|
|
497
507
|
else if (update.sessionUpdate === 'agent_thought_chunk' || update.sessionUpdate === 'tool_call') {
|
|
498
508
|
this.started(conversation);
|
|
@@ -511,8 +521,8 @@ export class Conversations {
|
|
|
511
521
|
conversation.jobs.delete(job.id);
|
|
512
522
|
this.kit.changed();
|
|
513
523
|
}
|
|
514
|
-
draft(conversation, turn
|
|
515
|
-
const blocks = blocksOf(text);
|
|
524
|
+
draft(conversation, turn) {
|
|
525
|
+
const blocks = blocksOf(turn.text);
|
|
516
526
|
const from = Math.min(firstChange(turn.sent, blocks), turn.unsentFrom ?? Infinity);
|
|
517
527
|
const sent = this.kit.send({
|
|
518
528
|
type: 'draft',
|
|
@@ -531,14 +541,14 @@ export class Conversations {
|
|
|
531
541
|
turn.unsentFrom = from;
|
|
532
542
|
}
|
|
533
543
|
}
|
|
534
|
-
plan(conversation, turn
|
|
544
|
+
plan(conversation, turn) {
|
|
535
545
|
const sent = this.kit.send({
|
|
536
546
|
type: 'plan',
|
|
537
547
|
conversation_id: conversation.id,
|
|
538
548
|
turn_id: turn.id,
|
|
539
549
|
sequence: turn.planSequence + 1,
|
|
540
550
|
from: 0,
|
|
541
|
-
steps: entries.map((entry) => ({ label: entry.content, priority: entry.priority, status: entry.status })),
|
|
551
|
+
steps: turn.entries.map((entry) => ({ label: entry.content, priority: entry.priority, status: entry.status })),
|
|
542
552
|
});
|
|
543
553
|
if (sent)
|
|
544
554
|
turn.planSequence++;
|