@ykurilov/agent-chat-flows 0.63.2 → 0.64.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/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FACT_PREFIX,
3
3
  fieldValueText
4
- } from "./chunk-KGWXTWBZ.js";
4
+ } from "./chunk-22FWN7NU.js";
5
5
  import {
6
6
  ANY_STATE_LAYOUT_KEY,
7
7
  DEFAULT_LATE_START_HOURS,
@@ -23,12 +23,13 @@ import {
23
23
  noteAgentAnswer,
24
24
  noteHumanMessage,
25
25
  noteSideQuestion,
26
+ parseDuration,
26
27
  parseFlow,
27
28
  sideQuestion,
28
29
  startRun,
29
30
  stateById,
30
31
  timerDueAt
31
- } from "./chunk-LT4QELAZ.js";
32
+ } from "./chunk-5RDY7QBA.js";
32
33
 
33
34
  // src/react/flow-labels.ts
34
35
  import { createContext, createElement, useContext } from "react";
@@ -610,6 +611,11 @@ var russianFlowTestChatLabels = {
610
611
  close: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C",
611
612
  failed: "\u041D\u0435 \u043F\u043E\u043B\u0443\u0447\u0438\u043B\u043E\u0441\u044C \u2014 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437",
612
613
  nextDay: "\u041A \u043D\u0430\u0447\u0430\u043B\u0443 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E \u0434\u043D\u044F",
614
+ nextFirstMessage: "\u041A \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C\u0443 \u043D\u0430\u043F\u043E\u043C\u0438\u043D\u0430\u043D\u0438\u044E",
615
+ nothingScheduled: "\u0412\u043F\u0435\u0440\u0435\u0434\u0438 \u0441\u0446\u0435\u043D\u0430\u0440\u0438\u0439 \u0441\u0430\u043C \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u043F\u0438\u0448\u0435\u0442",
616
+ customTime: "\u0421\u0432\u043E\u0451 \u0432\u0440\u0435\u043C\u044F",
617
+ customTimePlaceholder: "15 \u043C\u0438\u043D, 1 \u0447 30 \u043C\u0438\u043D, 2 \u0434\u043D\u044F",
618
+ customTimeInvalid: "\u041D\u0435 \u043F\u043E\u043D\u044F\u043B \u0432\u0440\u0435\u043C\u044F \u2014 \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, \xAB1 \u0447 30 \u043C\u0438\u043D\xBB \u0438\u043B\u0438 \xAB2 \u0434\u043D\u044F\xBB",
613
619
  day: (day, totalDays) => totalDays === void 0 ? `\u0414\u0435\u043D\u044C ${day}` : `\u0414\u0435\u043D\u044C ${day} \u0438\u0437 ${totalDays}`,
614
620
  beforeFirstDay: "\u0414\u043E \u043F\u0435\u0440\u0432\u043E\u0433\u043E \u0434\u043D\u044F"
615
621
  };
@@ -624,6 +630,11 @@ var englishFlowTestChatLabels = {
624
630
  close: "Close",
625
631
  failed: "Something went wrong \u2014 try again",
626
632
  nextDay: "To the start of the next day",
633
+ nextFirstMessage: "To the next reminder",
634
+ nothingScheduled: "The flow won't write first from here on",
635
+ customTime: "Custom time",
636
+ customTimePlaceholder: "15 min, 1h 30m, 2 days",
637
+ customTimeInvalid: "Couldn't read the time \u2014 try \u201C1h 30m\u201D or \u201C2 days\u201D",
627
638
  day: (day, totalDays) => totalDays === void 0 ? `Day ${day}` : `Day ${day} of ${totalDays}`,
628
639
  beforeFirstDay: "Before day one"
629
640
  };
@@ -2503,6 +2514,7 @@ function useFlowTestChat(connection, flow) {
2503
2514
  const [timeOffset, setTimeOffset] = useState6(0);
2504
2515
  const [busy, setBusy] = useState6(false);
2505
2516
  const [failed, setFailed] = useState6(false);
2517
+ const [nothingScheduled, setNothingScheduled] = useState6(false);
2506
2518
  const [run, setRun] = useState6(null);
2507
2519
  const latest = useRef4({ connection, flow, chatId });
2508
2520
  latest.current = { connection, flow, chatId };
@@ -2523,9 +2535,14 @@ function useFlowTestChat(connection, flow) {
2523
2535
  const work = useCallback5(async (job) => {
2524
2536
  setBusy(true);
2525
2537
  setFailed(false);
2538
+ setNothingScheduled(false);
2526
2539
  try {
2527
2540
  await job();
2528
2541
  } catch (error) {
2542
+ if (error?.code === "nothing_scheduled") {
2543
+ setNothingScheduled(true);
2544
+ return;
2545
+ }
2529
2546
  console.error("[flow] test chat:", error);
2530
2547
  setFailed(true);
2531
2548
  } finally {
@@ -2556,6 +2573,7 @@ function useFlowTestChat(connection, flow) {
2556
2573
  timeOffset,
2557
2574
  busy,
2558
2575
  failed,
2576
+ nothingScheduled,
2559
2577
  stateId: chatId === null ? null : run?.state ?? flow.start,
2560
2578
  visited: run?.visited ?? NOTHING_VISITED,
2561
2579
  day: chatId === null ? null : run?.day ?? null,
@@ -2566,7 +2584,8 @@ function useFlowTestChat(connection, flow) {
2566
2584
  close: () => setOpened(false),
2567
2585
  reset: () => void start(),
2568
2586
  advance: (ms) => shift2((id) => latest.current.connection.advance(id, ms)),
2569
- nextDay: connection.advanceToNextDay ? () => shift2((id) => latest.current.connection.advanceToNextDay(id)) : null
2587
+ nextDay: connection.advanceToNextDay ? () => shift2((id) => latest.current.connection.advanceToNextDay(id)) : null,
2588
+ nextFirstMessage: connection.advanceToNextFirstMessage ? () => shift2((id) => latest.current.connection.advanceToNextFirstMessage(id)) : null
2570
2589
  };
2571
2590
  }
2572
2591
 
@@ -2633,6 +2652,12 @@ function FlowTestChat({ testChat, advanceSteps = DEFAULT_ADVANCE_STEPS, skin, ..
2633
2652
  onAdvance: controller.advance,
2634
2653
  day: formatDayLine(controller.day, (editor.now?.() ?? Date.now()) + controller.timeOffset, editor.timeZone ?? browserTimeZone2(), labels),
2635
2654
  ...controller.nextDay && editor.value.schedule ? { onNextDay: controller.nextDay } : {},
2655
+ ...controller.nextFirstMessage && { onNextFirstMessage: controller.nextFirstMessage, nothingScheduled: controller.nothingScheduled },
2656
+ onAdvanceText: (text) => {
2657
+ const ms = parseDuration(text);
2658
+ if (ms !== void 0) controller.advance(ms);
2659
+ return ms !== void 0;
2660
+ },
2636
2661
  busy: controller.busy,
2637
2662
  failed: controller.failed,
2638
2663
  onReset: controller.reset,