@agentshouse/kit 0.2.1-alpha.2 → 0.2.1-alpha.4

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.
@@ -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
- turn.ready = this.deliver(conversation, turn, 'started', {}).then(() => undefined, logged);
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
- const text = turn.text;
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
- void turn.ready.then(() => this.plan(conversation, turn, update.entries));
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, text) {
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, entries) {
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++;
@@ -1,3 +1,4 @@
1
+ import { readEnrolment } from './home.js';
1
2
  const HOUSE_LINE = 'Work with House through the `house` CLI: run `house --help`.';
2
3
  const FILE_LINE = 'To give the User a file, upload it with `house upload_attachment` and link it in your answer.';
3
4
  const HOW_WE_WORK = '/private/library/how-we-work.md';
@@ -24,5 +25,7 @@ async function howWeWork(bridge) {
24
25
  return document.replace(/\n$/, '');
25
26
  }
26
27
  export async function instructions(bridge, base) {
27
- return [`${HOUSE_LINE}\n${FILE_LINE}`, base, await howWeWork(bridge)].filter((part) => part !== '').join('\n\n');
28
+ const app = new URL('/app/new.git', (await readEnrolment()).house).href;
29
+ const appLine = `To show the User a page, upload it or push it to an App instead of starting a server; \`git clone ${app}\` starts a new App.`;
30
+ return [`${HOUSE_LINE}\n${FILE_LINE}\n${appLine}`, base, await howWeWork(bridge)].filter((part) => part !== '').join('\n\n');
28
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-alpha.2",
3
+ "version": "0.2.1-alpha.4",
4
4
  "description": "House Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {