@adecore/agents 0.46.3 → 0.47.0
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/chat/chat-core.d.ts +2 -2
- package/dist/chat/chat-core.js +2 -2
- package/dist/chat/chat-session.d.ts +2 -2
- package/dist/chat/chat-session.js +12 -2
- package/dist/messages/deliver-notice.d.ts +3 -2
- package/dist/messages/deliver-notice.js +5 -1
- package/dist/messages/notice-notes.d.ts +6 -2
- package/dist/messages/notice-notes.js +2 -1
- package/package.json +3 -3
- package/src/chat/chat-core.ts +3 -2
- package/src/chat/chat-session.ts +13 -2
- package/src/messages/deliver-notice.ts +8 -3
- package/src/messages/notice-notes.ts +8 -3
package/dist/chat/chat-core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentKind, type ChatAttachment, type ChatAttachResult, type ChatAttachmentUpload, type ChatBookmark, type ChatCheckpointDiff, type ChatConfigurePayload, type ChatCreatePayload, type ChatEvent, type ChatHistoryResult, type ChatGoalAction, type ChatInfo, type ChatItem, type ChatQueuedMessage, type ChatUiChoicePayload, type ChatUiQueryPayload, type ChatUiLinkPayload, type ChatSkill, type ChatSubagentPayload, type ChatSubagentResult, type ChatTurnItem, type ChatVisual, type ModelSelection, type RuntimeMode } from '@adecore/agent-contracts';
|
|
1
|
+
import { type AgentKind, type ChatAttachment, type ChatAttachResult, type ChatAttachmentUpload, type ChatBookmark, type ChatCheckpointDiff, type ChatConfigurePayload, type ChatCreatePayload, type ChatEvent, type ChatHistoryResult, type ChatGoalAction, type ChatInfo, type ChatItem, type ChatNoteMessage, type ChatQueuedMessage, type ChatUiChoicePayload, type ChatUiQueryPayload, type ChatUiLinkPayload, type ChatSkill, type ChatSubagentPayload, type ChatSubagentResult, type ChatTurnItem, type ChatVisual, type ModelSelection, type RuntimeMode } from '@adecore/agent-contracts';
|
|
2
2
|
import type { AgentEvent, AgentSink } from '../events.ts';
|
|
3
3
|
import type { OutboxOutcome } from '../outbox/outbox-worker.ts';
|
|
4
4
|
import { type AccountLaunches } from '../providers/accounts/launch.ts';
|
|
@@ -180,7 +180,7 @@ export declare class ChatCore {
|
|
|
180
180
|
writeRecord(chatId: string, info: ChatInfo, items: ChatItem[], preambles?: string[]): Promise<void>;
|
|
181
181
|
deleteRecord(chatId: string): Promise<boolean>;
|
|
182
182
|
lastTurn(chatId: string): Promise<ChatTurnItem | null>;
|
|
183
|
-
addNote(chatId: string, level: 'info' | 'warning' | 'error', text: string): Promise<void>;
|
|
183
|
+
addNote(chatId: string, level: 'info' | 'warning' | 'error', text: string, message?: ChatNoteMessage): Promise<void>;
|
|
184
184
|
deliverNote(chatId: string, delivery: {
|
|
185
185
|
noteId: string;
|
|
186
186
|
note: string;
|
package/dist/chat/chat-core.js
CHANGED
|
@@ -643,7 +643,7 @@ export class ChatCore {
|
|
|
643
643
|
return stored?.items.findLast((item) => item.kind === 'turn') ?? null;
|
|
644
644
|
}
|
|
645
645
|
/* A line from the host in a chat's thread, loading the chat when nobody has; nothing for a chat that is gone. */
|
|
646
|
-
async addNote(chatId, level, text) {
|
|
646
|
+
async addNote(chatId, level, text, message) {
|
|
647
647
|
await this.loaded(chatId);
|
|
648
648
|
if (!(await this.hasStored(chatId))) {
|
|
649
649
|
return;
|
|
@@ -651,7 +651,7 @@ export class ChatCore {
|
|
|
651
651
|
if (!this.chats.has(chatId)) {
|
|
652
652
|
await this.create({ chatId });
|
|
653
653
|
}
|
|
654
|
-
this.chats.get(chatId)?.addNote(level, text);
|
|
654
|
+
this.chats.get(chatId)?.addNote(level, text, message);
|
|
655
655
|
}
|
|
656
656
|
/*
|
|
657
657
|
* Leaves a note and its preamble in a chat, loading that chat when nobody has; false when it was
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatAttachment, ChatCheckpointDiff, ChatEvent, ChatGoalAction, ChatInfo, ChatItem, ChatQueuedMessage, ChatQuoteSource, ChatSkill, ChatUiChoiceOrigin, ChatUiChoicePayload, ChatUiQueryState, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
|
|
1
|
+
import type { ChatAttachment, ChatCheckpointDiff, ChatEvent, ChatGoalAction, ChatInfo, ChatItem, ChatNoteMessage, ChatQueuedMessage, ChatQuoteSource, ChatSkill, ChatUiChoiceOrigin, ChatUiChoicePayload, ChatUiQueryState, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
|
|
2
2
|
import type { ChatProvider } from '../providers/provider.ts';
|
|
3
3
|
import type { LimitsUpdate } from '../usage/limits/normalize.ts';
|
|
4
4
|
import type { BackendLaunch } from './backend.ts';
|
|
@@ -211,7 +211,7 @@ export declare class ChatSession {
|
|
|
211
211
|
preamble: string;
|
|
212
212
|
}): boolean;
|
|
213
213
|
upsertItems(items: readonly ChatItem[]): void;
|
|
214
|
-
addNote(level: 'info' | 'warning' | 'error', text: string): void;
|
|
214
|
+
addNote(level: 'info' | 'warning' | 'error', text: string, message?: ChatNoteMessage): void;
|
|
215
215
|
end(reason: string): void;
|
|
216
216
|
restart(): Promise<void>;
|
|
217
217
|
dropProcess(): Promise<void>;
|
|
@@ -1057,8 +1057,18 @@ export class ChatSession {
|
|
|
1057
1057
|
this.options.persistSoon();
|
|
1058
1058
|
}
|
|
1059
1059
|
/* A line in the thread outside any turn, for something the host has to say about work it gave up on. */
|
|
1060
|
-
addNote(level, text) {
|
|
1061
|
-
this.emit([
|
|
1060
|
+
addNote(level, text, message) {
|
|
1061
|
+
this.emit([
|
|
1062
|
+
this.thread.upsert({
|
|
1063
|
+
id: newId('note'),
|
|
1064
|
+
kind: 'note',
|
|
1065
|
+
createdAt: Date.now(),
|
|
1066
|
+
turnId: null,
|
|
1067
|
+
level,
|
|
1068
|
+
text,
|
|
1069
|
+
...(message === undefined ? {} : { message })
|
|
1070
|
+
})
|
|
1071
|
+
]);
|
|
1062
1072
|
this.options.persist();
|
|
1063
1073
|
}
|
|
1064
1074
|
/*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatItem } from '@adecore/agent-contracts';
|
|
1
|
+
import type { ChatItem, ChatNoteMessage } from '@adecore/agent-contracts';
|
|
2
2
|
import type { ChatCore } from '../chat/chat-core.ts';
|
|
3
3
|
import type { Notice, NoticeStore } from './notice-store.ts';
|
|
4
4
|
export interface MessageWords {
|
|
@@ -20,6 +20,7 @@ export declare function chatNoticeTargets(chats: Pick<ChatCore, 'get' | 'hasStor
|
|
|
20
20
|
export declare function deliverToChat(store: Pick<NoticeStore, 'put'>, targets: ChatNoticeTargets, notice: Omit<Notice, 'createdAt'>): Promise<ChatDelivery>;
|
|
21
21
|
export interface NoticeChat {
|
|
22
22
|
has(id: string): Promise<boolean>;
|
|
23
|
-
note(id: string, text: string): Promise<void>;
|
|
23
|
+
note(id: string, text: string, message: ChatNoteMessage): Promise<void>;
|
|
24
24
|
}
|
|
25
|
+
export declare function noticeMessage(notice: Notice): ChatNoteMessage;
|
|
25
26
|
export declare function showNotices(store: Pick<NoticeStore, 'show'>, chat: NoticeChat, words: Pick<MessageWords, 'shown'>, targetId: string): Promise<void>;
|
|
@@ -57,6 +57,10 @@ export async function deliverToChat(store, targets, notice) {
|
|
|
57
57
|
}
|
|
58
58
|
return { outcome: 'wake', waiting };
|
|
59
59
|
}
|
|
60
|
+
/* The message itself on the line in the thread, so a client can draw it as said to the chat. */
|
|
61
|
+
export function noticeMessage(notice) {
|
|
62
|
+
return { from: notice.from, title: notice.fromTitle, text: notice.text };
|
|
63
|
+
}
|
|
60
64
|
/*
|
|
61
65
|
* Shows a person the message in the chat's thread the moment it lands, not when the model gets round
|
|
62
66
|
* to it. An id no chat holds shows and marks nothing, so a chat that opens on it later still has all of it.
|
|
@@ -66,6 +70,6 @@ export async function showNotices(store, chat, words, targetId) {
|
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
for (const notice of await store.show(targetId)) {
|
|
69
|
-
await chat.note(targetId, words.shown(notice));
|
|
73
|
+
await chat.note(targetId, words.shown(notice), noticeMessage(notice));
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ChatNoteMessage } from '@adecore/agent-contracts';
|
|
1
2
|
import type { PromptNotes } from '../chat/chat-session.ts';
|
|
2
|
-
import type
|
|
3
|
+
import { type MessageWords } from './deliver-notice.ts';
|
|
3
4
|
import type { NoticeStore } from './notice-store.ts';
|
|
4
5
|
export declare class NoticeNotes implements PromptNotes {
|
|
5
6
|
private readonly store;
|
|
@@ -12,4 +13,7 @@ export declare class NoticeNotes implements PromptNotes {
|
|
|
12
13
|
};
|
|
13
14
|
reset(): void;
|
|
14
15
|
}
|
|
15
|
-
export declare function unshownNotes(store: Pick<NoticeStore, 'show'>, chatId: string, words: Pick<MessageWords, 'shown'>): Promise<
|
|
16
|
+
export declare function unshownNotes(store: Pick<NoticeStore, 'show'>, chatId: string, words: Pick<MessageWords, 'shown'>): Promise<{
|
|
17
|
+
text: string;
|
|
18
|
+
message: ChatNoteMessage;
|
|
19
|
+
}[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noticeMessage } from './deliver-notice.js';
|
|
1
2
|
/*
|
|
2
3
|
* What another node left for a chat, taken from the queue in front of its next prompt so the model
|
|
3
4
|
* hears it once. Nothing of it is shown: a person read each message in the thread as it landed
|
|
@@ -22,5 +23,5 @@ export class NoticeNotes {
|
|
|
22
23
|
* reload writes none again. The model still hears the messages themselves from the queue.
|
|
23
24
|
*/
|
|
24
25
|
export async function unshownNotes(store, chatId, words) {
|
|
25
|
-
return (await store.show(chatId)).map((notice) => words.shown(notice));
|
|
26
|
+
return (await store.show(chatId)).map((notice) => ({ text: words.shown(notice), message: noticeMessage(notice) }));
|
|
26
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Node-compatible agent chat hosts, providers, accounts, usage and durable task coordination.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"test": "bun --conditions=source test"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@adecore/agent-contracts": "0.
|
|
97
|
-
"@adecore/intelligent-ui": "0.
|
|
96
|
+
"@adecore/agent-contracts": "0.47.0",
|
|
97
|
+
"@adecore/intelligent-ui": "0.47.0",
|
|
98
98
|
"zod": "^4.6.7"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
package/src/chat/chat-core.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type ChatGoalAction,
|
|
18
18
|
type ChatInfo,
|
|
19
19
|
type ChatItem,
|
|
20
|
+
type ChatNoteMessage,
|
|
20
21
|
type ChatQueuedMessage,
|
|
21
22
|
type ChatUiChoicePayload,
|
|
22
23
|
type ChatUiQueryPayload,
|
|
@@ -974,7 +975,7 @@ export class ChatCore {
|
|
|
974
975
|
}
|
|
975
976
|
|
|
976
977
|
/* A line from the host in a chat's thread, loading the chat when nobody has; nothing for a chat that is gone. */
|
|
977
|
-
async addNote(chatId: string, level: 'info' | 'warning' | 'error', text: string): Promise<void> {
|
|
978
|
+
async addNote(chatId: string, level: 'info' | 'warning' | 'error', text: string, message?: ChatNoteMessage): Promise<void> {
|
|
978
979
|
await this.loaded(chatId);
|
|
979
980
|
|
|
980
981
|
if (!(await this.hasStored(chatId))) {
|
|
@@ -985,7 +986,7 @@ export class ChatCore {
|
|
|
985
986
|
await this.create({ chatId });
|
|
986
987
|
}
|
|
987
988
|
|
|
988
|
-
this.chats.get(chatId)?.addNote(level, text);
|
|
989
|
+
this.chats.get(chatId)?.addNote(level, text, message);
|
|
989
990
|
}
|
|
990
991
|
|
|
991
992
|
/*
|
package/src/chat/chat-session.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ChatGoalAction,
|
|
7
7
|
ChatInfo,
|
|
8
8
|
ChatItem,
|
|
9
|
+
ChatNoteMessage,
|
|
9
10
|
ChatQueuedMessage,
|
|
10
11
|
ChatQuoteSource,
|
|
11
12
|
ChatSkill,
|
|
@@ -1470,8 +1471,18 @@ export class ChatSession {
|
|
|
1470
1471
|
}
|
|
1471
1472
|
|
|
1472
1473
|
/* A line in the thread outside any turn, for something the host has to say about work it gave up on. */
|
|
1473
|
-
addNote(level: 'info' | 'warning' | 'error', text: string): void {
|
|
1474
|
-
this.emit([
|
|
1474
|
+
addNote(level: 'info' | 'warning' | 'error', text: string, message?: ChatNoteMessage): void {
|
|
1475
|
+
this.emit([
|
|
1476
|
+
this.thread.upsert({
|
|
1477
|
+
id: newId('note'),
|
|
1478
|
+
kind: 'note',
|
|
1479
|
+
createdAt: Date.now(),
|
|
1480
|
+
turnId: null,
|
|
1481
|
+
level,
|
|
1482
|
+
text,
|
|
1483
|
+
...(message === undefined ? {} : { message })
|
|
1484
|
+
})
|
|
1485
|
+
]);
|
|
1475
1486
|
this.options.persist();
|
|
1476
1487
|
}
|
|
1477
1488
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatItem } from '@adecore/agent-contracts';
|
|
1
|
+
import type { ChatItem, ChatNoteMessage } from '@adecore/agent-contracts';
|
|
2
2
|
import type { ChatCore } from '../chat/chat-core.ts';
|
|
3
3
|
import type { Notice, NoticeStore } from './notice-store.ts';
|
|
4
4
|
|
|
@@ -111,7 +111,12 @@ export interface NoticeChat {
|
|
|
111
111
|
/* Whether the host holds a chat under the id, running or on disk. */
|
|
112
112
|
has(id: string): Promise<boolean>;
|
|
113
113
|
/* Puts a line in that chat's thread, loading the chat when nobody has. */
|
|
114
|
-
note(id: string, text: string): Promise<void>;
|
|
114
|
+
note(id: string, text: string, message: ChatNoteMessage): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* The message itself on the line in the thread, so a client can draw it as said to the chat. */
|
|
118
|
+
export function noticeMessage(notice: Notice): ChatNoteMessage {
|
|
119
|
+
return { from: notice.from, title: notice.fromTitle, text: notice.text };
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
/*
|
|
@@ -124,6 +129,6 @@ export async function showNotices(store: Pick<NoticeStore, 'show'>, chat: Notice
|
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
for (const notice of await store.show(targetId)) {
|
|
127
|
-
await chat.note(targetId, words.shown(notice));
|
|
132
|
+
await chat.note(targetId, words.shown(notice), noticeMessage(notice));
|
|
128
133
|
}
|
|
129
134
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ChatNoteMessage } from '@adecore/agent-contracts';
|
|
1
2
|
import type { PromptNotes } from '../chat/chat-session.ts';
|
|
2
|
-
import type
|
|
3
|
+
import { noticeMessage, type MessageWords } from './deliver-notice.ts';
|
|
3
4
|
import type { NoticeStore } from './notice-store.ts';
|
|
4
5
|
|
|
5
6
|
/*
|
|
@@ -29,6 +30,10 @@ export class NoticeNotes implements PromptNotes {
|
|
|
29
30
|
* The lines a chat that just loaded owes a person for what landed while nobody held it, marked so a
|
|
30
31
|
* reload writes none again. The model still hears the messages themselves from the queue.
|
|
31
32
|
*/
|
|
32
|
-
export async function unshownNotes(
|
|
33
|
-
|
|
33
|
+
export async function unshownNotes(
|
|
34
|
+
store: Pick<NoticeStore, 'show'>,
|
|
35
|
+
chatId: string,
|
|
36
|
+
words: Pick<MessageWords, 'shown'>
|
|
37
|
+
): Promise<{ text: string; message: ChatNoteMessage }[]> {
|
|
38
|
+
return (await store.show(chatId)).map((notice) => ({ text: words.shown(notice), message: noticeMessage(notice) }));
|
|
34
39
|
}
|