@ykurilov/agent-chat-flows 0.0.0-stage → 0.55.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.
Files changed (151) hide show
  1. package/CHANGELOG.md +252 -0
  2. package/LICENSE +21 -0
  3. package/README.md +124 -2
  4. package/agent-flow.schema.json +1020 -0
  5. package/dist/chunk-3PTJI2XY.js +100 -0
  6. package/dist/chunk-3PTJI2XY.js.map +1 -0
  7. package/dist/chunk-BNMQUNSI.js +9 -0
  8. package/dist/chunk-BNMQUNSI.js.map +1 -0
  9. package/dist/chunk-BOV6FJGU.js +1288 -0
  10. package/dist/chunk-BOV6FJGU.js.map +1 -0
  11. package/dist/chunk-CKY5KG7N.js +165 -0
  12. package/dist/chunk-CKY5KG7N.js.map +1 -0
  13. package/dist/chunk-DCTRMCGV.js +34 -0
  14. package/dist/chunk-DCTRMCGV.js.map +1 -0
  15. package/dist/format.js +147 -0
  16. package/dist/format.js.map +1 -0
  17. package/dist/index.js +3197 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/postgres.js +387 -0
  20. package/dist/postgres.js.map +1 -0
  21. package/dist/react.js +2650 -0
  22. package/dist/react.js.map +1 -0
  23. package/dist/sqlite.js +319 -0
  24. package/dist/sqlite.js.map +1 -0
  25. package/dist/types/check/app-checks.d.ts +16 -0
  26. package/dist/types/check/check-flow.d.ts +8 -0
  27. package/dist/types/check/index.d.ts +2 -0
  28. package/dist/types/engine/data-conditions.d.ts +10 -0
  29. package/dist/types/engine/day-frame.d.ts +17 -0
  30. package/dist/types/engine/first-messages.d.ts +21 -0
  31. package/dist/types/engine/flow-days.d.ts +39 -0
  32. package/dist/types/engine/flow-graph.d.ts +26 -0
  33. package/dist/types/engine/flow-run.d.ts +130 -0
  34. package/dist/types/engine/index.d.ts +14 -0
  35. package/dist/types/engine/migrate-run.d.ts +11 -0
  36. package/dist/types/engine/next-transition.d.ts +40 -0
  37. package/dist/types/engine/nudges.d.ts +78 -0
  38. package/dist/types/engine/run-updates.d.ts +37 -0
  39. package/dist/types/engine/side-questions.d.ts +26 -0
  40. package/dist/types/engine/side-tasks.d.ts +44 -0
  41. package/dist/types/engine/targets.d.ts +9 -0
  42. package/dist/types/engine/timers.d.ts +61 -0
  43. package/dist/types/engine/zoned-time.d.ts +27 -0
  44. package/dist/types/format/catalog-events.d.ts +5 -0
  45. package/dist/types/format/compact-flow.d.ts +8 -0
  46. package/dist/types/format/flow-format.d.ts +286 -0
  47. package/dist/types/format/flow-json-schema.d.ts +2 -0
  48. package/dist/types/format/flow-schema.d.ts +605 -0
  49. package/dist/types/format/index.d.ts +7 -0
  50. package/dist/types/format/migrate-flow.d.ts +4 -0
  51. package/dist/types/format/parse-flow.d.ts +6 -0
  52. package/dist/types/format.d.ts +3 -0
  53. package/dist/types/index.d.ts +4 -0
  54. package/dist/types/labels/client-card.d.ts +20 -0
  55. package/dist/types/labels/editor.d.ts +261 -0
  56. package/dist/types/labels/index.d.ts +14 -0
  57. package/dist/types/labels/migrate.d.ts +19 -0
  58. package/dist/types/labels/test-chat.d.ts +28 -0
  59. package/dist/types/not-yet.d.ts +2 -0
  60. package/dist/types/postgres.d.ts +10 -0
  61. package/dist/types/prompt/client-card-block.d.ts +16 -0
  62. package/dist/types/prompt/flow-rules.d.ts +9 -0
  63. package/dist/types/prompt/rules/after-end.d.ts +3 -0
  64. package/dist/types/prompt/rules/client-facts.d.ts +2 -0
  65. package/dist/types/prompt/rules/day-frame.d.ts +2 -0
  66. package/dist/types/prompt/rules/link-views.d.ts +4 -0
  67. package/dist/types/prompt/rules/rule-part.d.ts +3 -0
  68. package/dist/types/prompt/rules/side-tasks.d.ts +2 -0
  69. package/dist/types/prompt/rules/time-zone.d.ts +2 -0
  70. package/dist/types/prompt/state-card.d.ts +14 -0
  71. package/dist/types/react/client-card/client-card-panel.d.ts +8 -0
  72. package/dist/types/react/client-card/index.d.ts +2 -0
  73. package/dist/types/react/client-card/use-client-card.d.ts +19 -0
  74. package/dist/types/react/client-card-skin.d.ts +27 -0
  75. package/dist/types/react/editor/board-space.d.ts +51 -0
  76. package/dist/types/react/editor/board-styles.d.ts +1 -0
  77. package/dist/types/react/editor/editor-model.d.ts +60 -0
  78. package/dist/types/react/editor/exit-text.d.ts +11 -0
  79. package/dist/types/react/editor/flow-board.d.ts +11 -0
  80. package/dist/types/react/editor/flow-editor.d.ts +13 -0
  81. package/dist/types/react/editor/flow-simulation.d.ts +44 -0
  82. package/dist/types/react/editor/index.d.ts +6 -0
  83. package/dist/types/react/editor/schedule-model.d.ts +47 -0
  84. package/dist/types/react/editor/side-task-model.d.ts +18 -0
  85. package/dist/types/react/editor/use-flow-editor.d.ts +120 -0
  86. package/dist/types/react/flow-editor-skin.d.ts +453 -0
  87. package/dist/types/react/flow-labels.d.ts +8 -0
  88. package/dist/types/react/index.d.ts +6 -0
  89. package/dist/types/react/test-chat/flow-test-chat.d.ts +22 -0
  90. package/dist/types/react/test-chat/index.d.ts +2 -0
  91. package/dist/types/react/test-chat/use-flow-test-chat.d.ts +50 -0
  92. package/dist/types/react.d.ts +3 -0
  93. package/dist/types/runtime/admit.d.ts +15 -0
  94. package/dist/types/runtime/agent-flow.d.ts +20 -0
  95. package/dist/types/runtime/client-card.d.ts +9 -0
  96. package/dist/types/runtime/client-facts.d.ts +22 -0
  97. package/dist/types/runtime/close-day-tool.d.ts +3 -0
  98. package/dist/types/runtime/decisions-client.d.ts +33 -0
  99. package/dist/types/runtime/extra-tool.d.ts +16 -0
  100. package/dist/types/runtime/first-message-retry.d.ts +4 -0
  101. package/dist/types/runtime/first-message-rules.d.ts +55 -0
  102. package/dist/types/runtime/first-reasons-notice.d.ts +9 -0
  103. package/dist/types/runtime/flow-delivery.d.ts +53 -0
  104. package/dist/types/runtime/flow-events.d.ts +126 -0
  105. package/dist/types/runtime/flow-finish.d.ts +68 -0
  106. package/dist/types/runtime/flow-known-texts.d.ts +11 -0
  107. package/dist/types/runtime/flow-signals.d.ts +12 -0
  108. package/dist/types/runtime/flow-timers.d.ts +55 -0
  109. package/dist/types/runtime/flow-tools.d.ts +23 -0
  110. package/dist/types/runtime/flow-types.d.ts +547 -0
  111. package/dist/types/runtime/held-messages.d.ts +25 -0
  112. package/dist/types/runtime/index.d.ts +11 -0
  113. package/dist/types/runtime/judge-context.d.ts +36 -0
  114. package/dist/types/runtime/judge.d.ts +21 -0
  115. package/dist/types/runtime/migrate-chats.d.ts +20 -0
  116. package/dist/types/runtime/note-tools.d.ts +15 -0
  117. package/dist/types/runtime/pause.d.ts +21 -0
  118. package/dist/types/runtime/prepare-turn.d.ts +12 -0
  119. package/dist/types/runtime/side-task-tool.d.ts +5 -0
  120. package/dist/types/runtime/step-tail.d.ts +11 -0
  121. package/dist/types/runtime/tail/day-line.d.ts +2 -0
  122. package/dist/types/runtime/tail/frame-line.d.ts +2 -0
  123. package/dist/types/runtime/tail/side-tasks-line.d.ts +2 -0
  124. package/dist/types/runtime/tail/tail-part.d.ts +21 -0
  125. package/dist/types/runtime/test-clock.d.ts +26 -0
  126. package/dist/types/runtime/time-zone-tool.d.ts +3 -0
  127. package/dist/types/runtime/turn-gate.d.ts +8 -0
  128. package/dist/types/sqlite.d.ts +9 -0
  129. package/dist/types/store/flow-store-shared.d.ts +20 -0
  130. package/dist/types/store/flow-store.d.ts +240 -0
  131. package/dist/types/store/memory.d.ts +3 -0
  132. package/dist/types/store/migration-settings.d.ts +7 -0
  133. package/dist/types/store/postgres-schema.d.ts +775 -0
  134. package/dist/types/store/postgres.d.ts +15 -0
  135. package/dist/types/store/sqlite-schema.d.ts +824 -0
  136. package/dist/types/store/sqlite.d.ts +9 -0
  137. package/drizzle/postgres/0000_init.sql +45 -0
  138. package/drizzle/postgres/0001_days_pause_side_tasks.sql +21 -0
  139. package/drizzle/postgres/0002_chat_placement.sql +1 -0
  140. package/drizzle/postgres/meta/0000_snapshot.json +317 -0
  141. package/drizzle/postgres/meta/0001_snapshot.json +439 -0
  142. package/drizzle/postgres/meta/0002_snapshot.json +445 -0
  143. package/drizzle/postgres/meta/_journal.json +27 -0
  144. package/drizzle/sqlite/0000_init.sql +44 -0
  145. package/drizzle/sqlite/0001_days_pause_side_tasks.sql +21 -0
  146. package/drizzle/sqlite/0002_chat_placement.sql +1 -0
  147. package/drizzle/sqlite/meta/0000_snapshot.json +297 -0
  148. package/drizzle/sqlite/meta/0001_snapshot.json +427 -0
  149. package/drizzle/sqlite/meta/0002_snapshot.json +434 -0
  150. package/drizzle/sqlite/meta/_journal.json +27 -0
  151. package/package.json +98 -3
@@ -0,0 +1,261 @@
1
+ import type { FlowConditionType, FlowDataOp, FlowEventType, FlowFieldType, FlowTimerSpan, FlowTimerUnit } from "../format/flow-format.js";
2
+ /** Надписи редактора сценария: доска, шапка, панели, прогон, окно JSON. */
3
+ export interface FlowEditorLabels {
4
+ conditionKinds: Record<FlowConditionType, string>;
5
+ /** Подсказка к виду условия в легенде. */
6
+ conditionKindHints: Record<FlowConditionType, string>;
7
+ returnKind: string;
8
+ returnTarget: string;
9
+ ops: Record<FlowDataOp, string>;
10
+ events: Record<FlowEventType, string>;
11
+ timerSpans: Record<FlowTimerSpan | "time_of_day", string>;
12
+ units: Record<FlowTimerUnit, string>;
13
+ fieldTypes: Record<FlowFieldType, string>;
14
+ /** Значения поля «да/нет» в условиях и подписях. */
15
+ yes: string;
16
+ no: string;
17
+ /** «1 день», «3 дня», «5 дней». */
18
+ days: (count: number) => string;
19
+ /** Подпись условия «наступил день N программы» на доске: «с дня 3». */
20
+ programDay: (day: number) => string;
21
+ header: {
22
+ state: string;
23
+ card: string;
24
+ check: string;
25
+ run: string;
26
+ json: string;
27
+ save: string;
28
+ saved: string;
29
+ unsaved: string;
30
+ /** Сохранение отклонено: приложение отказало или упало. */
31
+ saveFailed: string;
32
+ saveFailedHint: string;
33
+ /** Плашка «только просмотр»: сценарий сейчас правит не человек. */
34
+ readOnly: string;
35
+ readOnlyHint: string;
36
+ migrate: string;
37
+ };
38
+ board: {
39
+ anyState: string;
40
+ start: string;
41
+ final: string;
42
+ noSideQuestions: string;
43
+ noTarget: string;
44
+ /** Условие словами, у которого ещё нет текста. */
45
+ emptyCondition: string;
46
+ /** Название нового состояния. */
47
+ newState: string;
48
+ zoomIn: string;
49
+ zoomOut: string;
50
+ fit: string;
51
+ /** «2 ошибки», «1 замечание». */
52
+ errors: (count: number) => string;
53
+ warnings: (count: number) => string;
54
+ /** Подпись касаний на карточке ноды: «касания 15 мин · 1 ч». */
55
+ nudges: string;
56
+ noNudges: string;
57
+ /** Срок своих касаний на карточке: «в день входа», «первые 2 дн.». */
58
+ nudgesDays: (days: number) => string;
59
+ /** Кнопки места на доске: легенда, мини-карта, панель «Сценарий», полный экран. */
60
+ space: {
61
+ legend: string;
62
+ showMinimap: string;
63
+ hideMinimap: string;
64
+ showInspector: string;
65
+ hideInspector: string;
66
+ enterFullscreen: string;
67
+ exitFullscreen: string;
68
+ /** Подпись области редактора в полном экране. */
69
+ fullscreenRegion: string;
70
+ };
71
+ };
72
+ overview: {
73
+ title: string;
74
+ common: string;
75
+ commonHint: string;
76
+ states: string;
77
+ exits: string;
78
+ finals: string;
79
+ lists: string;
80
+ help: string;
81
+ /** Находки без места: весь сценарий, «Дни и время». */
82
+ flowIssues: string;
83
+ afterEnd: string;
84
+ afterEndModes: Record<"reply" | "silent", string>;
85
+ afterEndHints: Record<"reply" | "silent", string>;
86
+ };
87
+ schedule: {
88
+ title: string;
89
+ on: string;
90
+ hint: string;
91
+ dayStart: string;
92
+ dayStartHint: string;
93
+ lengthDays: string;
94
+ lengthDaysNone: string;
95
+ nightFrom: string;
96
+ nightFromHint: string;
97
+ lateStart: string;
98
+ lateStartHint: string;
99
+ deadlineState: string;
100
+ deadlineNone: string;
101
+ farewell: string;
102
+ farewellText: string;
103
+ farewellTextHint: string;
104
+ firstMessages: string;
105
+ maxPerDay: string;
106
+ maxPerDayHint: string;
107
+ morning: string;
108
+ skipMorning: string;
109
+ nudges: string;
110
+ nudgesHint: string;
111
+ dayFrame: string;
112
+ dayFrameHint: string;
113
+ softFrom: string;
114
+ hardAt: string;
115
+ hardText: string;
116
+ hardTextHint: string;
117
+ more: string;
118
+ };
119
+ nudges: {
120
+ afterSilence: string;
121
+ addStep: string;
122
+ dailyAt: string;
123
+ addTime: string;
124
+ giveUpAfter: string;
125
+ never: string;
126
+ remove: string;
127
+ on: string;
128
+ };
129
+ sideTasks: {
130
+ title: string;
131
+ hint: string;
132
+ builtIn: string;
133
+ text: string;
134
+ when: string;
135
+ field: string;
136
+ noField: string;
137
+ fromApp: string;
138
+ maxAttempts: string;
139
+ perConversation: string;
140
+ add: string;
141
+ newTask: string;
142
+ delete: string;
143
+ };
144
+ statePanel: {
145
+ title: string;
146
+ name: string;
147
+ instructions: string;
148
+ instructionsHint: string;
149
+ firstMessage: string;
150
+ learn: string;
151
+ tools: string;
152
+ toolsHint: string;
153
+ noTools: string;
154
+ tags: string;
155
+ makeStart: string;
156
+ isStart: string;
157
+ noSideQuestions: string;
158
+ exits: string;
159
+ addExit: string;
160
+ more: string;
161
+ deleteState: string;
162
+ /** «Длится»: выход по времени в ноде. */
163
+ duration: string;
164
+ durationHint: string;
165
+ durationNone: string;
166
+ durationUnits: Record<"h" | "d" | "program_day", string>;
167
+ durationTo: string;
168
+ nudges: string;
169
+ nudgesModes: Record<"inherit" | "own" | "off", string>;
170
+ nudgesHint: string;
171
+ /** Сколько действуют свои касания: всё время в ноде или N дней с дня входа. */
172
+ nudgesDays: string;
173
+ nudgesDaysModes: Record<"always" | "days", string>;
174
+ nudgesDaysHint: string;
175
+ };
176
+ exitCard: {
177
+ when: string;
178
+ field: string;
179
+ op: string;
180
+ value: string;
181
+ event: string;
182
+ eventName: string;
183
+ timer: string;
184
+ amount: string;
185
+ at: string;
186
+ to: string;
187
+ moveUp: string;
188
+ moveDown: string;
189
+ delete: string;
190
+ };
191
+ anyStatePanel: {
192
+ title: string;
193
+ hint: string;
194
+ except: string;
195
+ };
196
+ cardPanel: {
197
+ title: string;
198
+ clientCard: string;
199
+ chatNotes: string;
200
+ chatNotesHint: string;
201
+ empty: string;
202
+ name: string;
203
+ about: string;
204
+ type: string;
205
+ options: string;
206
+ optionsHint: string;
207
+ refreshAfter: string;
208
+ /** «через 6 мес.». */
209
+ refreshAfterMonths: (months: number) => string;
210
+ pace: string;
211
+ /** «раз в 5 сообщений». */
212
+ paceEvery: (messages: number) => string;
213
+ paceHint: string;
214
+ addField: string;
215
+ newField: string;
216
+ /** Добавить поле из словаря приложения (`catalog.fields`). */
217
+ fromApp: string;
218
+ };
219
+ checkPanel: {
220
+ title: string;
221
+ clean: string;
222
+ errors: string;
223
+ warnings: string;
224
+ goTo: string;
225
+ /** Проверки приложения упали. */
226
+ appCheckFailed: string;
227
+ };
228
+ runPanel: {
229
+ title: string;
230
+ hint: string;
231
+ current: string;
232
+ whatHappened: string;
233
+ nothing: string;
234
+ known: string;
235
+ notYet: string;
236
+ nextQuestion: string;
237
+ path: string;
238
+ back: string;
239
+ restart: string;
240
+ finish: string;
241
+ /** «Прогон · шаг 3». */
242
+ step: (step: number) => string;
243
+ /** Цель выбора «ничего из этого». */
244
+ stay: string;
245
+ /** Выбор, который сейчас не сработает: нет цели или «назад» некуда. */
246
+ wontFire: string;
247
+ /** Шаг пути, когда ничего не сработало. */
248
+ nothingHappened: string;
249
+ noStart: string;
250
+ };
251
+ jsonDialog: {
252
+ title: string;
253
+ copy: string;
254
+ copied: string;
255
+ download: string;
256
+ load: string;
257
+ close: string;
258
+ };
259
+ }
260
+ export declare const russianFlowEditorLabels: FlowEditorLabels;
261
+ export declare const englishFlowEditorLabels: FlowEditorLabels;
@@ -0,0 +1,14 @@
1
+ import { type ClientCardLabels } from "./client-card.js";
2
+ import { type FlowEditorLabels } from "./editor.js";
3
+ import { type FlowMigrateLabels } from "./migrate.js";
4
+ import { type FlowTestChatLabels } from "./test-chat.js";
5
+ /** Все надписи экранов сценария: по словарю на экран. */
6
+ export interface FlowLabels {
7
+ editor: FlowEditorLabels;
8
+ clientCard: ClientCardLabels;
9
+ migrate: FlowMigrateLabels;
10
+ testChat: FlowTestChatLabels;
11
+ }
12
+ export declare const russianFlowLabels: FlowLabels;
13
+ export declare const englishFlowLabels: FlowLabels;
14
+ export type { ClientCardLabels, FlowEditorLabels, FlowMigrateLabels, FlowTestChatLabels };
@@ -0,0 +1,19 @@
1
+ /** Надписи окна перевода чатов на новую версию сценария. */
2
+ export interface FlowMigrateLabels {
3
+ title: string;
4
+ hint: string;
5
+ version: string;
6
+ state: string;
7
+ chats: string;
8
+ removed: string;
9
+ target: string;
10
+ chooseTarget: string;
11
+ migrate: string;
12
+ /** «Переведено чатов: 12». */
13
+ moved: (count: number) => string;
14
+ nothingToMigrate: string;
15
+ close: string;
16
+ failed: string;
17
+ }
18
+ export declare const russianFlowMigrateLabels: FlowMigrateLabels;
19
+ export declare const englishFlowMigrateLabels: FlowMigrateLabels;
@@ -0,0 +1,28 @@
1
+ /** Надписи тестового чата редактора: живой разговор по сценарию с перемоткой часов. */
2
+ export interface FlowTestChatLabels {
3
+ title: string;
4
+ state: string;
5
+ /** «+20 мин». */
6
+ advance: (label: string) => string;
7
+ clock: string;
8
+ /** Часы чата не сдвинуты. */
9
+ noOffset: string;
10
+ /** Единицы сдвига: «3 ч 20 мин». */
11
+ units: {
12
+ day: string;
13
+ hour: string;
14
+ minute: string;
15
+ };
16
+ reset: string;
17
+ close: string;
18
+ /** Тестовый чат не открылся или часы не перемотались. */
19
+ failed: string;
20
+ /** Перемотка к началу следующего дня сценария. */
21
+ nextDay: string;
22
+ /** «День 2 из 3», «День 2». */
23
+ day: (day: number, totalDays?: number) => string;
24
+ /** Вечер позднего старта: первый день ещё не начался. */
25
+ beforeFirstDay: string;
26
+ }
27
+ export declare const russianFlowTestChatLabels: FlowTestChatLabels;
28
+ export declare const englishFlowTestChatLabels: FlowTestChatLabels;
@@ -0,0 +1,2 @@
1
+ /** Заглушка модуля, который появится на следующем этапе работ по сценариям. */
2
+ export declare function notYet(stage: number, name: string): never;
@@ -0,0 +1,10 @@
1
+ import type { Pool } from "pg";
2
+ import { type PostgresFlowStore } from "./store/postgres.js";
3
+ export type { PostgresFlowStore } from "./store/postgres.js";
4
+ export { FLOWS_MIGRATIONS_TABLE, FLOWS_MIGRATION_LOCK_KEY } from "./store/migration-settings.js";
5
+ export { flowChats, flowClientCards, flowFirstMessages, flowVersions } from "./store/postgres-schema.js";
6
+ /**
7
+ * Сценарии в PostgreSQL на пуле приложения (схема `agent_chat`, та же база, что у хранилища чатов).
8
+ * Таблицы приводятся к последней миграции при первом обращении. Пул закрывает приложение.
9
+ */
10
+ export declare function postgresFlowStore(pool: Pool): PostgresFlowStore;
@@ -0,0 +1,16 @@
1
+ import type { AgentFlow } from "../format/flow-format.js";
2
+ import type { FlowRun } from "../engine/flow-run.js";
3
+ import type { ClientCardEntry, ClientFact } from "../store/flow-store.js";
4
+ /** Значение поля готовой строкой: для блока модели, ответа `client_card` и экрана. */
5
+ export declare function fieldValueText(value: unknown): string;
6
+ /**
7
+ * Блок `flow:client`: что известно о человеке, что устарело, о чём можно спросить между делом. Известное и заметки идут
8
+ * по порядку полей сценария (порядок = что важнее). Значение не по типу поля считается неизвестным.
9
+ */
10
+ export declare function clientCardBlock(input: {
11
+ flow: AgentFlow;
12
+ run: FlowRun;
13
+ card: ClientCardEntry[];
14
+ facts?: ClientFact[];
15
+ now: number;
16
+ }): string;
@@ -0,0 +1,9 @@
1
+ import type { AgentFlow } from "../format/flow-format.js";
2
+ import type { FlowRulePart } from "./rules/rule-part.js";
3
+ /** Части правил по возможностям сценария, по порядку. Каждую делает свой модуль. */
4
+ export declare const FLOW_RULE_PARTS: readonly FlowRulePart[];
5
+ /**
6
+ * Постоянная часть инструкции: как работает сценарий, правила такта, части по возможностям сценария и «Общее для всех
7
+ * состояний» версии чата. Сценарий без новых полей — текст как в 0.48.
8
+ */
9
+ export declare function flowRules(common: string, flow?: AgentFlow, parts?: readonly FlowRulePart[]): string;
@@ -0,0 +1,3 @@
1
+ import type { AgentFlow } from "../../format/flow-format.js";
2
+ /** Постоянные правила после конца разговора: вместо `flowRules`, когда чат закончен. От дня и места не зависят. */
3
+ export declare function afterEndRules(flow: AgentFlow): string;
@@ -0,0 +1,2 @@
1
+ import type { FlowRulePart } from "./rule-part.js";
2
+ export declare const clientFactsRules: FlowRulePart;
@@ -0,0 +1,2 @@
1
+ import type { FlowRulePart } from "./rule-part.js";
2
+ export declare const dayFrameRules: FlowRulePart;
@@ -0,0 +1,4 @@
1
+ import type { FlowRulePart } from "./rule-part.js";
2
+ /** Имя инструмента `createPersonLinkTool` из `@ykurilov/agent-chat-web-tools`. */
3
+ export declare const PERSON_LINK_TOOL = "person_link_view";
4
+ export declare const linkViewRules: FlowRulePart;
@@ -0,0 +1,3 @@
1
+ import type { AgentFlow } from "../../format/flow-format.js";
2
+ /** Часть постоянных правил сценария; не нужна этому сценарию — `null`. Текст зависит только от версии сценария (кэш). */
3
+ export type FlowRulePart = (flow: AgentFlow) => string | null;
@@ -0,0 +1,2 @@
1
+ import type { FlowRulePart } from "./rule-part.js";
2
+ export declare const sideTaskRules: FlowRulePart;
@@ -0,0 +1,2 @@
1
+ import type { FlowRulePart } from "./rule-part.js";
2
+ export declare const timeZoneRules: FlowRulePart;
@@ -0,0 +1,14 @@
1
+ import type { AgentFlow } from "../format/flow-format.js";
2
+ import type { FlowRun } from "../engine/flow-run.js";
3
+ /** Условия словами состояния по порядку проверки (свои, потом общие): номер в карточке = место в этом списке + 1. */
4
+ export declare function judgeExits(flow: AgentFlow, stateId: string): Array<{
5
+ exitId: string;
6
+ text: string;
7
+ }>;
8
+ /** Цель состояния: первая строка инструкции. */
9
+ export declare function stateGoal(instructions: string): string;
10
+ /**
11
+ * Блок `flow:state`: текущее состояние, цель, условия выхода, что узнать. Зависит только от состояния — пока оно то же,
12
+ * блок не меняется и в новые вопросы не дописывается (→ В9). Первого текста здесь нет: его несёт переход.
13
+ */
14
+ export declare function stateCard(flow: AgentFlow, run: FlowRun): string;
@@ -0,0 +1,8 @@
1
+ import type { ClientCardSkin } from "../client-card-skin.js";
2
+ import { type UseClientCardOptions } from "./use-client-card.js";
3
+ export interface ClientCardScreenProps extends UseClientCardOptions {
4
+ /** Части экрана: `tandemClientCardSkin` из `@ykurilov/agent-chat-skin-tandem/client-card` или свои по договору. */
5
+ skin: ClientCardSkin;
6
+ }
7
+ /** Экран «Что агент знает о вас»: рядом с экраном памяти, если приложение его подключило. Надписи — `useFlowLabels().clientCard`. */
8
+ export declare function ClientCardPanel({ skin, ...options }: ClientCardScreenProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { ClientCardPanel, type ClientCardScreenProps } from "./client-card-panel.js";
2
+ export { useClientCard, type UseClientCardOptions } from "./use-client-card.js";
@@ -0,0 +1,19 @@
1
+ import type { ClientCardField } from "../../format/flow-format.js";
2
+ import type { ClientCardEntry } from "../../store/flow-store.js";
3
+ import type { ClientCardPanelProps } from "../client-card-skin.js";
4
+ export interface UseClientCardOptions {
5
+ /** Поля карточки сценариев приложения: порядок = что важнее, имена видит человек. Чужих полей здесь может не быть — их покажет `id`. */
6
+ fields: Array<Pick<ClientCardField, "id" | "name" | "refreshAfterMonths">>;
7
+ /** Карточка человека с сервера: `flow.readClientCard(ownerId)` за HTTP-ручкой приложения. */
8
+ read(): Promise<ClientCardEntry[]>;
9
+ /** Стереть поле или `"all"`: `flow.forgetClientCard(ownerId, fieldId)`. */
10
+ forget(fieldId: string | "all"): Promise<void>;
11
+ /** Как назвать свободный факт о человеке («ведёт блог») в списке; по умолчанию — `useFlowLabels().clientCard.fact`. */
12
+ factName?: string;
13
+ /** Часы; для тестов. */
14
+ now?: () => number;
15
+ /** Пояс для даты записи; нет — пояс браузера. */
16
+ timeZone?: string;
17
+ }
18
+ /** Слой поведения экрана карточки: грузит, готовит строки для скина, стирает поле или всё. Скин только рисует. */
19
+ export declare function useClientCard(options: UseClientCardOptions): ClientCardPanelProps;
@@ -0,0 +1,27 @@
1
+ import type { ComponentType } from "react";
2
+ export type ClientCardLoadState = "loading" | "ready" | "failed";
3
+ export interface ClientCardFieldView {
4
+ fieldId: string;
5
+ name: string;
6
+ /** Значение готовой строкой. */
7
+ value: string;
8
+ /** Когда записано, готовой строкой («12.10.2026»). */
9
+ updatedAt: string;
10
+ /** Пора уточнить (`refreshAfterMonths` прошёл). */
11
+ stale: boolean;
12
+ /** Идёт стирание этого поля. */
13
+ busy: boolean;
14
+ onForget(): void;
15
+ }
16
+ export interface ClientCardPanelProps {
17
+ state: ClientCardLoadState;
18
+ fields: ClientCardFieldView[];
19
+ /** Идёт «стереть всё». */
20
+ forgettingAll: boolean;
21
+ /** Скин сам спрашивает подтверждение (`labels.forgetAllConfirm`) и только потом зовёт. */
22
+ onForgetAll(): void;
23
+ onRetry(): void;
24
+ }
25
+ export interface ClientCardSkin {
26
+ ClientCardPanel: ComponentType<ClientCardPanelProps>;
27
+ }
@@ -0,0 +1,51 @@
1
+ import type { FlowEditorMode } from "../flow-editor-skin.js";
2
+ import type { FlowSelection } from "./use-flow-editor.js";
3
+ /** Шапка доски: `full` — логотип, название и кнопки; `compact` — одна узкая строка кнопок (название у приложения своё). */
4
+ export type FlowHeaderMode = "full" | "compact";
5
+ /** Легенда «Условия выхода»: свёрнута в кнопку, открыта или убрана совсем. */
6
+ export type FlowLegendMode = "collapsed" | "open" | "hidden";
7
+ /** Мини-карта: открыта, свёрнута в кнопку или убрана совсем. */
8
+ export type FlowMinimapMode = "open" | "collapsed" | "hidden";
9
+ /** Панель «Сценарий»: `open` — открыта, сворачивается кнопкой; `collapsible` — свёрнута, пока ничего не выбрано, выбор раскрывает. */
10
+ export type FlowInspectorMode = "open" | "collapsible";
11
+ export interface FlowBoardSpaceProps {
12
+ header?: FlowHeaderMode;
13
+ legend?: FlowLegendMode;
14
+ minimap?: FlowMinimapMode;
15
+ inspector?: FlowInspectorMode;
16
+ /** Кнопка «На весь экран» в шапке. По умолчанию есть. */
17
+ fullscreen?: boolean;
18
+ /** Ключ в localStorage для запомненного. По умолчанию общий `agent-chat-flow-board`; `null` — не запоминать. */
19
+ storageKey?: string | null;
20
+ }
21
+ export declare const DEFAULT_SPACE_STORAGE_KEY = "agent-chat-flow-board";
22
+ export interface BoardSpace {
23
+ header: FlowHeaderMode;
24
+ legendHidden: boolean;
25
+ legendOpen: boolean;
26
+ toggleLegend(): void;
27
+ minimapHidden: boolean;
28
+ minimapOpen: boolean;
29
+ toggleMinimap(): void;
30
+ inspectorOpen: boolean;
31
+ /** Кнопка сворачивания панели нужна только в обычной правке: проверка и прогон держат панель открытой. */
32
+ inspectorToggleable: boolean;
33
+ toggleInspector(): void;
34
+ fullscreenAllowed: boolean;
35
+ fullscreen: boolean;
36
+ setFullscreen(on: boolean): void;
37
+ }
38
+ export declare function useBoardSpace(props: FlowBoardSpaceProps, editor: {
39
+ selection: FlowSelection;
40
+ mode: FlowEditorMode;
41
+ }): BoardSpace;
42
+ /**
43
+ * Полный экран: Esc выходит (если не открыто окно поверх), страница под редактором не прокручивается, Tab ходит по кругу
44
+ * внутри. Возвращает ссылку-обработчик клавиш для корня.
45
+ */
46
+ export declare function useFullscreenBehavior(active: boolean, onExit: () => void, blocked: boolean, root: HTMLElement | null): (event: {
47
+ key: string;
48
+ shiftKey: boolean;
49
+ target: EventTarget;
50
+ preventDefault(): void;
51
+ }) => void;
@@ -0,0 +1 @@
1
+ export declare const FLOW_BOARD_CSS = "\n.react-flow { direction: ltr; position: relative; width: 100%; height: 100%; overflow: hidden; z-index: 0; }\n.react-flow__container, .react-flow__edgelabel-renderer, .react-flow__viewport-portal {\n position: absolute; width: 100%; height: 100%; top: 0; left: 0;\n}\n.react-flow__pane { z-index: 1; touch-action: none; }\n.react-flow__pane.draggable { cursor: grab; }\n.react-flow__pane.dragging { cursor: grabbing; }\n.react-flow__viewport { transform-origin: 0 0; z-index: 2; pointer-events: none; }\n.react-flow__renderer { z-index: 4; }\n.react-flow__background { pointer-events: none; z-index: -1; }\n.react-flow__background-pattern.dots { fill: var(--flow-board-dots, rgba(128, 128, 128, 0.35)); }\n.react-flow .react-flow__edges { position: absolute; }\n.react-flow .react-flow__edges svg { overflow: visible; position: absolute; pointer-events: none; }\n.react-flow__edge { pointer-events: visibleStroke; }\n.react-flow__edge.inactive { pointer-events: none; }\n.react-flow__edge:focus, .react-flow__edge:focus-visible { outline: none; }\n.react-flow__connection { pointer-events: none; }\n.react-flow__connection-path { stroke: var(--flow-board-connection, currentColor); stroke-width: 2; fill: none; stroke-dasharray: 4 4; }\nsvg.react-flow__connectionline { z-index: 1001; overflow: visible; position: absolute; }\n.react-flow__nodes { pointer-events: none; transform-origin: 0 0; }\n.react-flow__node {\n position: absolute; user-select: none; pointer-events: all; transform-origin: 0 0; box-sizing: border-box; cursor: default;\n}\n.react-flow__node.draggable { cursor: grab; }\n.react-flow__node.draggable.dragging { cursor: grabbing; }\n.react-flow__node:focus, .react-flow__node:focus-visible { outline: none; }\n.react-flow__handle {\n position: absolute; pointer-events: none; width: 10px; height: 10px; min-width: 5px; min-height: 5px; border-radius: 999px;\n background: var(--flow-board-handle-fill, #fff); border: 1.5px solid var(--flow-board-handle, currentColor);\n}\n.react-flow__handle.connectingfrom, .react-flow__handle.connectionindicator { pointer-events: all; cursor: crosshair; }\n.react-flow__handle-left { top: 50%; left: 0; transform: translate(-50%, -50%); }\n.react-flow__handle-right { top: 50%; right: 0; transform: translate(50%, -50%); }\n.react-flow__handle-top { top: 0; left: 50%; transform: translate(-50%, -50%); }\n.react-flow__handle-bottom { top: auto; bottom: 0; left: 50%; transform: translate(-50%, 50%); }\n.react-flow__panel { position: absolute; z-index: 5; margin: 16px; }\n.react-flow__panel.top { top: 0; }\n.react-flow__panel.bottom { bottom: 0; }\n.react-flow__panel.left { left: 0; }\n.react-flow__panel.right { right: 0; }\n.react-flow__panel.top.center, .react-flow__panel.bottom.center { left: 50%; transform: translateX(-16px) translateX(-50%); }\n.react-flow__minimap { background: var(--flow-board-minimap, #fff); border-radius: 12px; overflow: hidden; }\n.react-flow__minimap-svg { display: block; }\n.react-flow__minimap-mask { fill: var(--flow-board-minimap-mask, rgba(128, 128, 128, 0.15)); }\n.react-flow__minimap-node { fill: var(--flow-board-minimap-node, rgba(128, 128, 128, 0.35)); }\n.flow-board__new-exit.react-flow__handle {\n top: auto; bottom: 10px; right: 0; transform: translate(50%, 0); opacity: 0.55;\n}\n.flow-board__new-exit.react-flow__handle:hover { opacity: 1; }\n@media (max-width: 860px) {\n .flow-board__legend, .flow-board__minimap, .flow-board__minimap-toggle { display: none !important; }\n}\n";
@@ -0,0 +1,60 @@
1
+ import { type AgentFlow, type ClientCardField, type FlowCondition, type FlowConditionType, type FlowPoint, type FlowState } from "../../format/flow-format.js";
2
+ /** Чьё условие: id состояния или `null` — общие переходы «Из любого состояния». */
3
+ export type ExitOwner = string | null;
4
+ export type FieldList = "clientCard" | "chatNotes";
5
+ export type StatePatch = Partial<Pick<FlowState, "title" | "instructions" | "firstMessage" | "learn" | "tools" | "tags" | "noSideQuestions">>;
6
+ export declare function addState(flow: AgentFlow, input: {
7
+ title: string;
8
+ at?: FlowPoint;
9
+ }): {
10
+ flow: AgentFlow;
11
+ stateId: string;
12
+ };
13
+ /** Удаляет состояние: ведущие в него условия остаются без цели, из старта и исключений оно уходит. */
14
+ export declare function removeState(flow: AgentFlow, stateId: string): AgentFlow;
15
+ export declare function updateState(flow: AgentFlow, stateId: string, patch: StatePatch): AgentFlow;
16
+ export declare function setStart(flow: AgentFlow, stateId: string): AgentFlow;
17
+ export declare function setExcept(flow: AgentFlow, except: string[]): AgentFlow;
18
+ /** Условие нового вида со значениями по умолчанию; по данным — первое поле карточки или заметок. */
19
+ export declare function defaultCondition(kind: FlowConditionType, flow: AgentFlow): FlowCondition;
20
+ /**
21
+ * Условие после правки в карточке. Скин меняет одно поле, а целым и годным условие делает редактор: другой вид —
22
+ * значения по умолчанию; другое поле — сравнение, подходящее его типу; число из поля ввода — числом; таймер «время
23
+ * суток» ↔ «сколько прошло» — со своими значениями.
24
+ */
25
+ export declare function normalizeCondition(flow: AgentFlow, previous: FlowCondition, next: FlowCondition): FlowCondition;
26
+ export declare function addExit(flow: AgentFlow, owner: ExitOwner, kind: FlowConditionType): {
27
+ flow: AgentFlow;
28
+ exitId: string;
29
+ };
30
+ export declare function updateExit(flow: AgentFlow, owner: ExitOwner, exitId: string, next: {
31
+ when: FlowCondition;
32
+ to: string | null;
33
+ }): AgentFlow;
34
+ /** Стрелка с доски: условие ведёт в `to`. */
35
+ export declare function connectExit(flow: AgentFlow, owner: ExitOwner, exitId: string, to: string): AgentFlow;
36
+ export declare function moveExit(flow: AgentFlow, owner: ExitOwner, exitId: string, delta: number): AgentFlow;
37
+ export declare function removeExit(flow: AgentFlow, owner: ExitOwner, exitId: string): AgentFlow;
38
+ export declare function addField(flow: AgentFlow, list: FieldList, name: string): {
39
+ flow: AgentFlow;
40
+ fieldId: string;
41
+ };
42
+ export declare function updateField(flow: AgentFlow, list: FieldList, fieldId: string, patch: Partial<ClientCardField>): AgentFlow;
43
+ export declare function moveField(flow: AgentFlow, list: FieldList, fieldId: string, delta: number): AgentFlow;
44
+ /** Удаляет поле и его «узнать здесь». Условия по нему остаются: их покажет проверка графа. */
45
+ export declare function removeField(flow: AgentFlow, list: FieldList, fieldId: string): AgentFlow;
46
+ /** Где поставить новое состояние без места: под всеми узлами доски. */
47
+ export declare function freeSpot(flow: AgentFlow): FlowPoint;
48
+ /** Место узла на доске; `ANY_STATE_LAYOUT_KEY` — узел общих переходов. */
49
+ export declare function placeNode(flow: AgentFlow, nodeId: string, at: FlowPoint): AgentFlow;
50
+ /** JSON сценария для окна JSON и скачивания: без значений по умолчанию, как в файлах примеров. */
51
+ export declare function flowToJson(flow: AgentFlow): string;
52
+ export type LoadFlowResult = {
53
+ ok: true;
54
+ flow: AgentFlow;
55
+ } | {
56
+ ok: false;
57
+ errors: string[];
58
+ };
59
+ /** Загрузка JSON в редактор: та же `parseFlow`, что на сервере. Ошибки — строками «место: что не так». */
60
+ export declare function loadFlowJson(text: string): LoadFlowResult;
@@ -0,0 +1,11 @@
1
+ import { type AgentFlow, type FlowCatalog, type FlowCondition, type FlowExit } from "../../format/flow-format.js";
2
+ import type { FlowEditorLabels } from "../../labels/editor.js";
3
+ import type { FlowEdgeKind } from "../flow-editor-skin.js";
4
+ /** Подпись условия для доски, прогона и проверки: «Понятны тема курса и продажи», «Тишина человека 3 ч». С каталогом — подписи событий. */
5
+ export declare function conditionText(flow: AgentFlow, when: FlowCondition, labels: FlowEditorLabels, catalog?: Pick<FlowCatalog, "events">): string;
6
+ /** Вид стрелки: «назад» рисуется отдельно от вида условия. */
7
+ export declare function edgeKind(exit: FlowExit): FlowEdgeKind;
8
+ /** Название цели: состояние, «назад, где был» или `null`, если цель не выбрана или пропала. */
9
+ export declare function targetTitle(flow: AgentFlow, to: string | null, labels: FlowEditorLabels): string | null;
10
+ /** Цель состояния на доске: первая строка инструкции. */
11
+ export declare function stateGoal(instructions: string): string;
@@ -0,0 +1,11 @@
1
+ import type { FlowEditorSkin } from "../flow-editor-skin.js";
2
+ import type { BoardSpace } from "./board-space.js";
3
+ import type { FlowEditorController } from "./use-flow-editor.js";
4
+ /** Ручка «новое условие» у каждого узла: потянуть — появится условие словами. */
5
+ export declare const NEW_EXIT_HANDLE = "@new";
6
+ /** Доска редактора. Свой `ReactFlowProvider`: другой сценарий — доска заново и «весь граф» в экран. */
7
+ export declare function FlowBoard({ editor, skin, space }: {
8
+ editor: FlowEditorController;
9
+ skin: FlowEditorSkin;
10
+ space: BoardSpace;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { type CSSProperties } from "react";
2
+ import type { FlowEditorSkin } from "../flow-editor-skin.js";
3
+ import { type FlowBoardSpaceProps } from "./board-space.js";
4
+ import { type UseFlowEditorOptions } from "./use-flow-editor.js";
5
+ export interface FlowEditorProps extends UseFlowEditorOptions, FlowBoardSpaceProps {
6
+ /** Части экрана: `tandemFlowEditorSkin` из `@ykurilov/agent-chat-skin-tandem/flows` или свои по договору. */
7
+ skin: FlowEditorSkin;
8
+ /** Класс и стиль корня редактора. По умолчанию он занимает высоту родителя, но не меньше разумной (на телефоне тоже). */
9
+ className?: string;
10
+ style?: CSSProperties;
11
+ }
12
+ /** Редактор сценария: доска, панели, проверка, прогон, JSON. Управляемый: сценарий хранит приложение. */
13
+ export declare function FlowEditor({ skin, className, style, header: headerMode, legend, minimap, inspector, fullscreen, storageKey, ...options }: FlowEditorProps): import("react").JSX.Element;