@adecore/agents 0.26.0 → 0.26.2

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.
@@ -396,12 +396,17 @@ export class ChatCore {
396
396
  if (events !== null) {
397
397
  return { info: session.info, items: [], events: [...events, ...session.uiPreviews], seq: log.seq };
398
398
  }
399
- const page = historyLimit === undefined ? session.thread.snapshot() : session.thread.history(historyLimit);
399
+ if (historyLimit === undefined) {
400
+ const snapshot = session.thread.snapshot();
401
+ return { ...snapshot, info: session.info, items: session.previewItems(snapshot.items), seq: log.seq };
402
+ }
403
+ const page = session.thread.history(historyLimit);
400
404
  return {
401
405
  ...page,
402
406
  info: session.info,
403
407
  items: session.previewItems(page.items),
404
- ...(historyLimit === undefined ? {} : { pending: session.previewItems(session.thread.pending()) }),
408
+ pending: session.previewItems(session.thread.pending()),
409
+ subagents: session.thread.subagentsBefore(page.history.start),
405
410
  seq: log.seq
406
411
  };
407
412
  }
@@ -1,4 +1,4 @@
1
- import type { AgentStatus, ChatApprovalItem, ChatEvent, ChatHistoryResult, ChatInfo, ChatItem, ChatQuestionItem } from '@adecore/agent-contracts';
1
+ import { type AgentStatus, type ChatApprovalItem, type ChatEvent, type ChatHistoryResult, type ChatInfo, type ChatItem, type ChatQuestionItem, type ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  export declare class ChatThread {
3
3
  info: ChatInfo;
4
4
  private readonly items;
@@ -27,6 +27,7 @@ export declare class ChatThread {
27
27
  pending(): Array<ChatApprovalItem | ChatQuestionItem>;
28
28
  private syncRequests;
29
29
  history(limit?: number, cursor?: string): ChatHistoryResult;
30
+ subagentsBefore(start: number): ChatSubagentItem[];
30
31
  snapshot(): {
31
32
  info: ChatInfo;
32
33
  items: ChatItem[];
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { activeSubagents } from '@adecore/agent-contracts';
2
3
  import { appendToolOutput } from '@adecore/agent-contracts/text';
3
4
  import { ChatError } from './errors.js';
4
5
  import { requestSummaries } from './request-summary.js';
@@ -142,7 +143,7 @@ export class ChatThread {
142
143
  const pending = this.pending();
143
144
  this.info = pending.length === 0 ? rest : { ...rest, requests: requestSummaries(pending) };
144
145
  }
145
- history(limit = 60, cursor) {
146
+ history(limit = 90, cursor) {
146
147
  let end = this.order.length;
147
148
  if (cursor) {
148
149
  const [generation, offset] = cursor.split(':');
@@ -167,6 +168,10 @@ export class ChatThread {
167
168
  }
168
169
  return { items, history: { start, cursor: start ? `${this.historyGeneration}:${start}` : null } };
169
170
  }
171
+ /* The active sub-agents a page that begins at `start` leaves out. */
172
+ subagentsBefore(start) {
173
+ return activeSubagents(this.list()).filter((item) => this.indices.get(item.id) < start);
174
+ }
170
175
  snapshot() {
171
176
  return { info: this.info, items: this.list() };
172
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents",
3
- "version": "0.26.0",
3
+ "version": "0.26.2",
4
4
  "description": "Node-compatible agent chat hosts, providers, accounts, usage and durable task coordination.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -81,8 +81,8 @@
81
81
  "test": "bun --conditions=source test"
82
82
  },
83
83
  "dependencies": {
84
- "@adecore/agent-contracts": "0.26.0",
85
- "@adecore/intelligent-ui": "0.26.0",
84
+ "@adecore/agent-contracts": "0.26.2",
85
+ "@adecore/intelligent-ui": "0.26.2",
86
86
  "zod": "^4.6.5"
87
87
  },
88
88
  "devDependencies": {
@@ -597,12 +597,17 @@ export class ChatCore {
597
597
  if (events !== null) {
598
598
  return { info: session.info, items: [], events: [...events, ...session.uiPreviews], seq: log.seq };
599
599
  }
600
- const page = historyLimit === undefined ? session.thread.snapshot() : session.thread.history(historyLimit);
600
+ if (historyLimit === undefined) {
601
+ const snapshot = session.thread.snapshot();
602
+ return { ...snapshot, info: session.info, items: session.previewItems(snapshot.items), seq: log.seq };
603
+ }
604
+ const page = session.thread.history(historyLimit);
601
605
  return {
602
606
  ...page,
603
607
  info: session.info,
604
608
  items: session.previewItems(page.items),
605
- ...(historyLimit === undefined ? {} : { pending: session.previewItems(session.thread.pending()) }),
609
+ pending: session.previewItems(session.thread.pending()),
610
+ subagents: session.thread.subagentsBefore(page.history.start),
606
611
  seq: log.seq
607
612
  };
608
613
  }
@@ -1,5 +1,15 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import type { AgentStatus, ChatApprovalItem, ChatEvent, ChatHistoryResult, ChatInfo, ChatItem, ChatQuestionItem } from '@adecore/agent-contracts';
2
+ import {
3
+ activeSubagents,
4
+ type AgentStatus,
5
+ type ChatApprovalItem,
6
+ type ChatEvent,
7
+ type ChatHistoryResult,
8
+ type ChatInfo,
9
+ type ChatItem,
10
+ type ChatQuestionItem,
11
+ type ChatSubagentItem
12
+ } from '@adecore/agent-contracts';
3
13
  import { appendToolOutput } from '@adecore/agent-contracts/text';
4
14
  import { ChatError } from './errors.ts';
5
15
  import { requestSummaries } from './request-summary.ts';
@@ -164,7 +174,7 @@ export class ChatThread {
164
174
  this.info = pending.length === 0 ? rest : { ...rest, requests: requestSummaries(pending) };
165
175
  }
166
176
 
167
- history(limit = 60, cursor?: string): ChatHistoryResult {
177
+ history(limit = 90, cursor?: string): ChatHistoryResult {
168
178
  let end = this.order.length;
169
179
  if (cursor) {
170
180
  const [generation, offset] = cursor.split(':');
@@ -190,6 +200,11 @@ export class ChatThread {
190
200
  return { items, history: { start, cursor: start ? `${this.historyGeneration}:${start}` : null } };
191
201
  }
192
202
 
203
+ /* The active sub-agents a page that begins at `start` leaves out. */
204
+ subagentsBefore(start: number): ChatSubagentItem[] {
205
+ return activeSubagents(this.list()).filter((item) => this.indices.get(item.id)! < start);
206
+ }
207
+
193
208
  snapshot(): { info: ChatInfo; items: ChatItem[] } {
194
209
  return { info: this.info, items: this.list() };
195
210
  }