@ykurilov/agent-chat-core 0.58.0 → 0.60.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.
@@ -47,6 +47,7 @@ import type { AfterTurnHandler, AppEvent, BeforeTurnHandler, StaffActor, TurnAct
47
47
  import type { AgentWidgetSettings } from "./widgets/widget-types.js";
48
48
  import type { AgentViewerSource } from "./agent-run/agent-viewer.js";
49
49
  import type { TurnFinishedHandler } from "./agent-run/turn-finished.js";
50
+ import type { ServiceBlockFormat } from "./agent-run/forged-blocks.js";
50
51
  export { DEFAULT_TEXT_MODE_NOTE, DEFAULT_VOICE_MODE_HINT };
51
52
  /**
52
53
  * Голоса приложения для пометок модели (FR-024): чей голос сейчас у человека и какие теги этому голосу идут.
@@ -79,6 +80,12 @@ export interface AgentSettings {
79
80
  */
80
81
  helpers?: Record<string, AgentHelper>;
81
82
  maxSteps?: number;
83
+ /**
84
+ * Служебные форматы приложения и пакетов (`withSkills`, `flow.withChat`): тег `{ tag }` или строка `{ name, line }`.
85
+ * Модель, подделавшая такой блок в ответе, его не покажет: блок вырезается в потоке до экрана и записи, в прошлых
86
+ * ответах — только в запросе. Форматы ядра (`CORE_SERVICE_BLOCKS`), памяти и вложений добавляются сами.
87
+ */
88
+ serviceBlocks?: readonly ServiceBlockFormat[];
82
89
  /**
83
90
  * Пометка модели при входе в голосовой режим: добавляется один раз, отдельной текстовой частью в конец первого
84
91
  * голосового сообщения подряд. В историю чата не пишется: выводится из отметок сообщений, начало запроса от хода
@@ -1,4 +1,5 @@
1
1
  import type { MessageAttachments } from "../attachments/message-attachments.js";
2
+ import type { ServiceBlockFormat } from "../agent-run/forged-blocks.js";
2
3
  import type { AgentToolsSource } from "../agent-run/run-agent-turn.js";
3
4
  import type { AgentViewerSource } from "../agent-run/agent-viewer.js";
4
5
  import type { TurnObserver } from "../agent-run/turn-observer.js";
@@ -100,6 +101,8 @@ export interface CompactionServiceOptions {
100
101
  viewer?: AgentViewerSource;
101
102
  };
102
103
  attachments?: MessageAttachments;
104
+ /** Служебные форматы хода: запрос сжатия чистит прошлые ответы так же, как ход (кэш хода). */
105
+ serviceBlocks?: readonly ServiceBlockFormat[];
103
106
  /** `null` — автосжатие выключено; записи, уже сделанные, всё равно применяются к истории. */
104
107
  settings: ResolvedCompactionSettings | null;
105
108
  logError: (message: string) => void;
@@ -1,6 +1,7 @@
1
1
  import type { ToolSet } from "ai";
2
2
  import type { ModelCallObservation } from "../agent-run/observe-model-calls.js";
3
3
  import type { MessageAttachments } from "../attachments/message-attachments.js";
4
+ import type { ServiceBlockFormat } from "../agent-run/forged-blocks.js";
4
5
  import type { AgentChatMessage, TokenUsage } from "../conversation/types.js";
5
6
  import type { ModelCatalog } from "../models/model-catalog.js";
6
7
  import type { ResolvedCompactionSettings } from "./compaction-settings.js";
@@ -31,6 +32,8 @@ export interface CompactionRunInput {
31
32
  history: readonly AgentChatMessage[];
32
33
  /** Вложения проходят тот же путь, что в обычном ходе: сводка видит текст файлов. */
33
34
  attachments?: MessageAttachments;
35
+ /** Служебные форматы хода: поддельные блоки в прошлых ответах вырезаются так же, как в ходе (кэш хода). */
36
+ serviceBlocks?: readonly ServiceBlockFormat[];
34
37
  settings: ResolvedCompactionSettings;
35
38
  /** Задание последним сообщением; по умолчанию — сводка всей переписки (`compactionTask`). */
36
39
  task?: string;
@@ -96,6 +96,8 @@ export type { MaxOutputTokensSetting, TurnTimeoutSetting } from "./agent-run/tur
96
96
  export type { SequentialToolsSetting } from "./agent-run/sequential-tools.js";
97
97
  export type { ModelCallEvent, ModelCallPurpose, ToolCallEvent, TurnObserver } from "./agent-run/turn-observer.js";
98
98
  export type { TurnFinished, TurnFinishedHandler } from "./agent-run/turn-finished.js";
99
+ export { CORE_SERVICE_BLOCKS, checkServiceBlockFormats, cutForgedBlocks, serviceBlockName } from "./agent-run/forged-blocks.js";
100
+ export type { ServiceBlockFormat } from "./agent-run/forged-blocks.js";
99
101
  export { DEFAULT_MODEL_SILENCE } from "./provider-errors/model-silence.js";
100
102
  export type { ModelSilenceLimits, ModelSilenceSetting } from "./provider-errors/model-silence.js";
101
103
  export { APP_CHANGE_PART_TYPE, BROWSER_CALL_PART_TYPE } from "./page-context/page-context.js";
@@ -1,3 +1,4 @@
1
+ import type { ServiceBlockFormat } from "../agent-run/forged-blocks.js";
1
2
  import type { LanguageModel, ToolSet } from "ai";
2
3
  import type { AgentToolsModel } from "../agent-run/run-agent-turn.js";
3
4
  import type { TokenUsage } from "../conversation/types.js";
@@ -49,6 +50,8 @@ export interface LongTermMemory {
49
50
  * ядро откажет при создании службы. Если инструменты заданы функцией, повтор ловится при сборке набора хода.
50
51
  */
51
52
  toolNames: readonly string[];
53
+ /** Служебные форматы памяти (`<agent_memory>`): поддельный блок в ответе модели вырезается (`ServiceBlockFormat`). */
54
+ serviceBlocks?: readonly ServiceBlockFormat[];
52
55
  /**
53
56
  * Блок памяти для вопроса хода или `null`, если записей нет. Зовётся один раз на чат: в первом ходе и после сжатия
54
57
  * истории; в идущем чате блок берётся из прошлого ответа.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Картинка в ответе инструмента для провайдеров, совместимых с OpenAI (Together, Fireworks). Их пакеты кладут ответ
3
+ * инструмента из частей (`content`) строкой JSON: модель видит буквы base64 вместо картинки и думает без конца (живой
4
+ * ход 2026-10-15). Сами провайдеры картинку видят, если она частью `image_url` (живой замер того же дня) — так её
5
+ * передаёт и пакет DeepSeek. Обёртка `fetch` переписывает такую строку в части `text` и `image_url` перед отправкой.
6
+ * Ответ без картинки, обычный текст и JSON инструмента не трогаются: запрос тот же, кэш цел.
7
+ */
8
+ export declare function withToolResultImages(given?: typeof globalThis.fetch): typeof globalThis.fetch;
@@ -0,0 +1,6 @@
1
+ /** Ограда блока кода в начале строки (``` или ~~~, не дальше трёх пробелов от края) или `null`. */
2
+ export declare function codeFenceOf(line: string): string | null;
3
+ /** Строка закрывает блок кода, открытый оградой `fence`: та же ограда не короче, и больше ничего в строке. */
4
+ export declare function closesCodeFence(line: string, fence: string): boolean;
5
+ /** Строка — код с отступом (4 пробела или табуляция) или цитата (`> …`). */
6
+ export declare function isIndentedCodeOrQuote(line: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ykurilov/agent-chat-core",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,