@ykurilov/agent-chat-core 0.89.1 → 0.91.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/CHANGELOG.md +18 -0
- package/dist/{chunk-MXJ2YLCP.js → chunk-LH6CTSB7.js} +37 -5
- package/dist/chunk-LH6CTSB7.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/storage-contract.js +1 -1
- package/dist/types/agent-run/run-agent-turn.d.ts +3 -0
- package/dist/types/chat-service.d.ts +4 -0
- package/dist/types/frozen-context/frozen-context-messages.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-MXJ2YLCP.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ykurilov/agent-chat-core
|
|
2
2
|
|
|
3
|
+
## 0.91.0
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 0.90.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 302ab32: Карточки для модели: `agent.contextBlocksHistory: { latest: ["flow:state"] }` оставляет только последнее выданное обновление выбранных app-блоков. Исходные snapshots, raw история и серверное хранилище сохраняются; дата, память, место, notices и обычные сообщения не удаляются. Опция выключена по умолчанию. Изменение выбранной карточки может сбрасывать кэш старого префикса; настройка не мигрирует закреплённую версию сценария.
|
|
12
|
+
|
|
13
|
+
Тестовый разговор: `flow.reopen({ ownerId, chatId, allowFinal: true })` снимает только запрет `final` по явному серверному решению приложения. Нода и история сохраняются; владелец, `deadline`, `blocked`, истёкший срок программы и атомарность проверяются как прежде.
|
|
14
|
+
|
|
15
|
+
Вложения: `unsentRetentionMs` у `createAttachments` и `createExternalAttachments` задаёт срок неотправленных файлов. Без настройки — сутки, `null` отключает очистку/отказ по возрасту. Квоты, владелец, чат и подтверждение сохраняются. PDF resolver больше не использует `import.meta.resolve`: webpack не выдаёт его critical warning, весь пакет не требуется выносить из Next-сборки вместе с клиентскими hooks.
|
|
16
|
+
|
|
17
|
+
### Как обновить приложение
|
|
18
|
+
|
|
19
|
+
Обновить все пакеты SDK одной версией. Для старых карточек убрать обёртку `listMessages/getMessage` и включить `agent.contextBlocksHistory.latest` с нужными ключами; не переписывать сохранённую историю. В тестовом чате заменить прямое открытие через FlowStore на `flow.reopen` с `allowFinal:true`, сохранив авторизацию эксперта и собственное очищение итогов приложения. Для очередей фото задать срок или `null` через `unsentRetentionMs` у всех обработчиков общего storage. Убрать вынесение всего attachments-пакета из Next-сборки, если оно было добавлено только ради предупреждения PDF. Подробности — docs/context-blocks-refresh.md, docs/flows.md и README пакета вложений. Без этих opt-in настроек политика прежняя; миграций БД и файлов нет.
|
|
20
|
+
|
|
3
21
|
## 0.89.1
|
|
4
22
|
|
|
5
23
|
No changes in this release.
|
|
@@ -4691,6 +4691,34 @@ function withFrozenContext(history, options2) {
|
|
|
4691
4691
|
const anchorHistory = options2.anchorHistory && options2.anchorHistory[0]?.id === root?.id ? options2.anchorHistory : history;
|
|
4692
4692
|
const allowed = options2.includeKey ?? (() => true);
|
|
4693
4693
|
const anchor = root?.parts.some(isSummaryPart) ? anchorHistory.flatMap((message) => message.role === "assistant" ? [dataOf(message), ...message.parts.filter((p) => p.type === FROZEN_CONTEXT_PART_TYPE).slice(1).map((p) => p.data)] : []).concat(current?.data).find((data) => data?.appContextFrom === root.id) : void 0;
|
|
4694
|
+
const latestKeys = new Set((options2.latestKeys ?? []).filter((key) => !isReservedKey(key)));
|
|
4695
|
+
const lastUpdates = /* @__PURE__ */ new Map();
|
|
4696
|
+
if (anchor) {
|
|
4697
|
+
for (const block of anchor.blocks) if (latestKeys.has(block.key)) lastUpdates.set(block.key, anchor);
|
|
4698
|
+
}
|
|
4699
|
+
if (latestKeys.size) {
|
|
4700
|
+
const bases = /* @__PURE__ */ new Map();
|
|
4701
|
+
const noteUpdate = (data, base) => {
|
|
4702
|
+
const keys = data.sent === "all" || !base ? [...latestKeys] : [...data.sent.changed, ...data.sent.removed, ...data.sent.hidden ?? []];
|
|
4703
|
+
for (const key of keys) if (latestKeys.has(key)) lastUpdates.set(key, data);
|
|
4704
|
+
};
|
|
4705
|
+
let currentSeen = false;
|
|
4706
|
+
for (const message of history) {
|
|
4707
|
+
const data = dataOf(message);
|
|
4708
|
+
if (data) {
|
|
4709
|
+
noteUpdate(data, data.base === null ? void 0 : bases.get(data.base));
|
|
4710
|
+
bases.set(message.id, data);
|
|
4711
|
+
if (message.id === current?.answerId) currentSeen = true;
|
|
4712
|
+
}
|
|
4713
|
+
for (const part of message.role === "assistant" ? message.parts.filter((part2) => part2.type === FROZEN_CONTEXT_PART_TYPE).slice(1) : []) {
|
|
4714
|
+
const note = part.data;
|
|
4715
|
+
noteUpdate(note, bases.get(message.id));
|
|
4716
|
+
bases.set(message.id, note);
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
if (current && !currentSeen) noteUpdate(current.data, current.data.base === null ? void 0 : bases.get(current.data.base));
|
|
4720
|
+
}
|
|
4721
|
+
const keptUpdate = (key, data) => !latestKeys.has(key) || lastUpdates.get(key) === data;
|
|
4694
4722
|
let anchored = false;
|
|
4695
4723
|
const seen = /* @__PURE__ */ new Map();
|
|
4696
4724
|
const output = [];
|
|
@@ -4702,8 +4730,8 @@ function withFrozenContext(history, options2) {
|
|
|
4702
4730
|
else output.push({ id: `frozen-context-${output.length}`, role: "user", parts: output.length === 0 ? [{ type: "text", text: GREETING_LEAD }, ...parts] : parts });
|
|
4703
4731
|
};
|
|
4704
4732
|
const textsOf = (data, base) => {
|
|
4705
|
-
const include = (key) => allowed(key) && (!anchor || anchored || isReservedKey(key));
|
|
4706
|
-
const texts = blockTexts(data, base, group, anchor || options2.includeKey ? include : void 0);
|
|
4733
|
+
const include = (key) => allowed(key) && keptUpdate(key, data) && (!anchor || anchored || isReservedKey(key));
|
|
4734
|
+
const texts = blockTexts(data, base, group, anchor || options2.includeKey || latestKeys.size ? include : void 0);
|
|
4707
4735
|
if (data === anchor) anchored = true;
|
|
4708
4736
|
return texts;
|
|
4709
4737
|
};
|
|
@@ -4715,7 +4743,7 @@ function withFrozenContext(history, options2) {
|
|
|
4715
4743
|
seen.set(message.id, data);
|
|
4716
4744
|
if (message.id === current?.answerId) currentPlaced = true;
|
|
4717
4745
|
}
|
|
4718
|
-
const placed = anchor && message === root ? { ...message, parts: message.parts.flatMap((part) => isSummaryPart(part) ? [part, ...anchor.blocks.filter((block) => !isReservedKey(block.key) && allowed(block.key) && !(group && block.private)).map((block) => ({ type: "text", text: block.text }))] : [part]) } : message;
|
|
4746
|
+
const placed = anchor && message === root ? { ...message, parts: message.parts.flatMap((part) => isSummaryPart(part) ? [part, ...anchor.blocks.filter((block) => !isReservedKey(block.key) && allowed(block.key) && keptUpdate(block.key, anchor) && !(group && block.private)).map((block) => ({ type: "text", text: block.text }))] : [part]) } : message;
|
|
4719
4747
|
output.push(...withResumeNotes(placed, (note) => {
|
|
4720
4748
|
const texts = textsOf(note, seen.get(message.id));
|
|
4721
4749
|
seen.set(message.id, note);
|
|
@@ -7940,6 +7968,7 @@ async function openAttempt(input, attempt, attemptSignal) {
|
|
|
7940
7968
|
stepContextTimeoutMs,
|
|
7941
7969
|
contextBlocks: _contextBlocks,
|
|
7942
7970
|
contextBlocksRefresh: _contextBlocksRefresh,
|
|
7971
|
+
contextBlocksHistory: _contextBlocksHistory,
|
|
7943
7972
|
contextBlocksTimeoutMs: _contextBlocksTimeoutMs,
|
|
7944
7973
|
...requestInput
|
|
7945
7974
|
} = input;
|
|
@@ -7948,7 +7977,7 @@ async function openAttempt(input, attempt, attemptSignal) {
|
|
|
7948
7977
|
serviceBlocks: input.serviceBlocks ?? CORE_SERVICE_BLOCKS,
|
|
7949
7978
|
providerId,
|
|
7950
7979
|
history: attempt.history,
|
|
7951
|
-
frozenContext: { current: { answerId: input.messageId, data: attempt.frozenContext }, group: Boolean(input.group) },
|
|
7980
|
+
frozenContext: { current: { answerId: input.messageId, data: attempt.frozenContext }, group: Boolean(input.group), latestKeys: input.contextBlocksHistory?.latest },
|
|
7952
7981
|
...attempt.tailMessages && { tailMessages: attempt.tailMessages },
|
|
7953
7982
|
logError,
|
|
7954
7983
|
repeatSilence: attempt.repeatSilence,
|
|
@@ -13148,6 +13177,9 @@ function createChatService(input) {
|
|
|
13148
13177
|
throw new TypeError('agent.contextBlocksRefresh: \u0436\u0434\u0451\u043C "turn" \u0438\u043B\u0438 "history-start"');
|
|
13149
13178
|
}
|
|
13150
13179
|
const stepContextTimeoutMs = resolveTimeoutMs(stepContextTimeoutSetting, DEFAULT_STEP_CONTEXT_TIMEOUT_MS, "agent.stepContextTimeoutMs");
|
|
13180
|
+
if (agentSettings.contextBlocksHistory !== void 0 && (agentSettings.contextBlocksHistory === null || !Array.isArray(agentSettings.contextBlocksHistory.latest) || agentSettings.contextBlocksHistory.latest.some((key) => typeof key !== "string" || !key.trim()))) {
|
|
13181
|
+
throw new TypeError("agent.contextBlocksHistory.latest: \u043D\u0443\u0436\u0435\u043D \u0441\u043F\u0438\u0441\u043E\u043A \u043D\u0435\u043F\u0443\u0441\u0442\u044B\u0445 \u043A\u043B\u044E\u0447\u0435\u0439 \u0431\u043B\u043E\u043A\u043E\u0432");
|
|
13182
|
+
}
|
|
13151
13183
|
const contextBlocksTimeoutMs = resolveTimeoutMs(contextBlocksTimeoutSetting, DEFAULT_CONTEXT_BLOCKS_TIMEOUT_MS, "agent.contextBlocksTimeoutMs");
|
|
13152
13184
|
const turnLimits = resolveTurnLimits({ turnTimeoutMs, maxOutputTokens }, options2.catalog);
|
|
13153
13185
|
const liveTurns = createLiveTurns();
|
|
@@ -15615,4 +15647,4 @@ export {
|
|
|
15615
15647
|
InvalidWidgetAnswerError,
|
|
15616
15648
|
createChatService
|
|
15617
15649
|
};
|
|
15618
|
-
//# sourceMappingURL=chunk-
|
|
15650
|
+
//# sourceMappingURL=chunk-LH6CTSB7.js.map
|