pi-agent-flow 2.0.0 → 2.0.2
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/README.md +126 -489
- package/agents/audit.md +7 -2
- package/agents/build.md +6 -2
- package/agents/craft.md +6 -3
- package/agents/debug.md +7 -3
- package/agents/ideas.md +8 -4
- package/agents/scout.md +8 -1
- package/dist/batch/apply-patch.d.ts +60 -0
- package/dist/batch/apply-patch.d.ts.map +1 -0
- package/dist/batch/apply-patch.js +477 -0
- package/dist/batch/apply-patch.js.map +1 -0
- package/dist/batch/batch-bash.d.ts +0 -6
- package/dist/batch/batch-bash.d.ts.map +1 -1
- package/dist/batch/batch-bash.js +52 -14
- package/dist/batch/batch-bash.js.map +1 -1
- package/dist/batch/constants.d.ts +45 -4
- package/dist/batch/constants.d.ts.map +1 -1
- package/dist/batch/constants.js +72 -4
- package/dist/batch/constants.js.map +1 -1
- package/dist/batch/execute.d.ts +8 -2
- package/dist/batch/execute.d.ts.map +1 -1
- package/dist/batch/execute.js +338 -70
- package/dist/batch/execute.js.map +1 -1
- package/dist/batch/fuzzy-edit.d.ts +4 -1
- package/dist/batch/fuzzy-edit.d.ts.map +1 -1
- package/dist/batch/fuzzy-edit.js +7 -2
- package/dist/batch/fuzzy-edit.js.map +1 -1
- package/dist/batch/index.d.ts +3 -15
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +48 -78
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/render.d.ts.map +1 -1
- package/dist/batch/render.js +30 -7
- package/dist/batch/render.js.map +1 -1
- package/dist/batch/shell-compress.d.ts +25 -0
- package/dist/batch/shell-compress.d.ts.map +1 -0
- package/dist/batch/shell-compress.js +602 -0
- package/dist/batch/shell-compress.js.map +1 -0
- package/dist/batch/summary.d.ts.map +1 -1
- package/dist/batch/summary.js +4 -0
- package/dist/batch/summary.js.map +1 -1
- package/dist/batch/symbols.d.ts.map +1 -1
- package/dist/batch/symbols.js +12 -7
- package/dist/batch/symbols.js.map +1 -1
- package/dist/config/config.d.ts +5 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +63 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/models.d.ts +2 -0
- package/dist/config/models.d.ts.map +1 -0
- package/dist/config/models.js +49 -0
- package/dist/config/models.js.map +1 -0
- package/dist/config/settings-resolver.js +2 -2
- package/dist/config/settings-resolver.js.map +1 -1
- package/dist/core/agents.js +2 -2
- package/dist/core/agents.js.map +1 -1
- package/dist/core/depth.d.ts +3 -3
- package/dist/core/depth.d.ts.map +1 -1
- package/dist/core/depth.js +5 -5
- package/dist/core/depth.js.map +1 -1
- package/dist/core/executor.d.ts +10 -3
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/executor.js +7 -3
- package/dist/core/executor.js.map +1 -1
- package/dist/core/flow.d.ts +19 -3
- package/dist/core/flow.d.ts.map +1 -1
- package/dist/core/flow.js +97 -58
- package/dist/core/flow.js.map +1 -1
- package/dist/core/session-mode.d.ts +1 -1
- package/dist/core/session-mode.d.ts.map +1 -1
- package/dist/core/session-mode.js +2 -1
- package/dist/core/session-mode.js.map +1 -1
- package/dist/core/{delegation.d.ts → transition.d.ts} +9 -9
- package/dist/core/transition.d.ts.map +1 -0
- package/dist/core/{delegation.js → transition.js} +17 -24
- package/dist/core/transition.js.map +1 -0
- package/dist/flow/auto-warp.d.ts +12 -0
- package/dist/flow/auto-warp.d.ts.map +1 -0
- package/dist/flow/auto-warp.js +29 -0
- package/dist/flow/auto-warp.js.map +1 -0
- package/dist/flow/command.d.ts.map +1 -1
- package/dist/flow/command.js +7 -2
- package/dist/flow/command.js.map +1 -1
- package/dist/flow/continuation.d.ts.map +1 -1
- package/dist/flow/continuation.js +52 -15
- package/dist/flow/continuation.js.map +1 -1
- package/dist/flow/index.d.ts +5 -2
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +6 -3
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/loop-command.d.ts +8 -0
- package/dist/flow/loop-command.d.ts.map +1 -0
- package/dist/flow/loop-command.js +102 -0
- package/dist/flow/loop-command.js.map +1 -0
- package/dist/flow/loop-templates.d.ts +7 -0
- package/dist/flow/loop-templates.d.ts.map +1 -0
- package/dist/flow/loop-templates.js +38 -0
- package/dist/flow/loop-templates.js.map +1 -0
- package/dist/flow/loop.d.ts +19 -0
- package/dist/flow/loop.d.ts.map +1 -0
- package/dist/flow/loop.js +95 -0
- package/dist/flow/loop.js.map +1 -0
- package/dist/flow/settings-command.d.ts.map +1 -1
- package/dist/flow/settings-command.js +93 -4
- package/dist/flow/settings-command.js.map +1 -1
- package/dist/flow/store.d.ts +3 -3
- package/dist/flow/store.d.ts.map +1 -1
- package/dist/flow/store.js +24 -16
- package/dist/flow/store.js.map +1 -1
- package/dist/flow/template-shared.d.ts +9 -0
- package/dist/flow/template-shared.d.ts.map +1 -0
- package/dist/flow/template-shared.js +13 -0
- package/dist/flow/template-shared.js.map +1 -0
- package/dist/flow/template-strings.d.ts.map +1 -1
- package/dist/flow/template-strings.js +2 -5
- package/dist/flow/template-strings.js.map +1 -1
- package/dist/flow/types.d.ts +15 -9
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/flow/warp.d.ts +15 -0
- package/dist/flow/warp.d.ts.map +1 -0
- package/dist/flow/warp.js +207 -0
- package/dist/flow/warp.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -28
- package/dist/index.js.map +1 -1
- package/dist/snapshot/cli-args.d.ts +1 -0
- package/dist/snapshot/cli-args.d.ts.map +1 -1
- package/dist/snapshot/cli-args.js +12 -0
- package/dist/snapshot/cli-args.js.map +1 -1
- package/dist/snapshot/runner-events.d.ts +5 -0
- package/dist/snapshot/runner-events.d.ts.map +1 -1
- package/dist/snapshot/runner-events.js +89 -15
- package/dist/snapshot/runner-events.js.map +1 -1
- package/dist/snapshot/snapshot.d.ts +22 -19
- package/dist/snapshot/snapshot.d.ts.map +1 -1
- package/dist/snapshot/snapshot.js +1063 -167
- package/dist/snapshot/snapshot.js.map +1 -1
- package/dist/steering/flow-prompt.d.ts +2 -2
- package/dist/steering/flow-prompt.d.ts.map +1 -1
- package/dist/steering/flow-prompt.js +4 -4
- package/dist/steering/flow-prompt.js.map +1 -1
- package/dist/steering/sliding-prompt.d.ts.map +1 -1
- package/dist/steering/sliding-prompt.js +9 -6
- package/dist/steering/sliding-prompt.js.map +1 -1
- package/dist/steering/tool-utils.d.ts +31 -8
- package/dist/steering/tool-utils.d.ts.map +1 -1
- package/dist/steering/tool-utils.js +63 -30
- package/dist/steering/tool-utils.js.map +1 -1
- package/dist/tools/ask-user.d.ts +0 -17
- package/dist/tools/ask-user.d.ts.map +1 -1
- package/dist/tools/ask-user.js +13 -37
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/timed-bash.d.ts +1 -1
- package/dist/tools/timed-bash.d.ts.map +1 -1
- package/dist/tools/timed-bash.js +19 -8
- package/dist/tools/timed-bash.js.map +1 -1
- package/dist/tools/web-tool.d.ts.map +1 -1
- package/dist/tools/web-tool.js +11 -13
- package/dist/tools/web-tool.js.map +1 -1
- package/dist/tui/render-utils.d.ts +5 -1
- package/dist/tui/render-utils.d.ts.map +1 -1
- package/dist/tui/render-utils.js +36 -10
- package/dist/tui/render-utils.js.map +1 -1
- package/dist/tui/render.d.ts +9 -0
- package/dist/tui/render.d.ts.map +1 -1
- package/dist/tui/render.js +112 -100
- package/dist/tui/render.js.map +1 -1
- package/dist/tui/scramble/constants.d.ts +8 -8
- package/dist/tui/scramble/constants.d.ts.map +1 -1
- package/dist/tui/scramble/constants.js +7 -7
- package/dist/tui/scramble/constants.js.map +1 -1
- package/dist/tui/scramble/index.d.ts +1 -1
- package/dist/tui/scramble/index.d.ts.map +1 -1
- package/dist/tui/scramble/index.js +1 -1
- package/dist/tui/scramble/index.js.map +1 -1
- package/dist/tui/scramble/manager.d.ts +1 -5
- package/dist/tui/scramble/manager.d.ts.map +1 -1
- package/dist/tui/scramble/manager.js +16 -64
- package/dist/tui/scramble/manager.js.map +1 -1
- package/dist/tui/scramble/utils.js +1 -1
- package/dist/tui/scramble/utils.js.map +1 -1
- package/dist/types/flow.d.ts +2 -0
- package/dist/types/flow.d.ts.map +1 -1
- package/dist/types/flow.js +11 -2
- package/dist/types/flow.js.map +1 -1
- package/dist/types/output.d.ts +6 -0
- package/dist/types/output.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/core/delegation.d.ts.map +0 -1
- package/dist/core/delegation.js.map +0 -1
- package/dist/flow/warp-command.d.ts +0 -9
- package/dist/flow/warp-command.d.ts.map +0 -1
- package/dist/flow/warp-command.js +0 -405
- package/dist/flow/warp-command.js.map +0 -1
package/dist/tui/render-utils.js
CHANGED
|
@@ -34,23 +34,20 @@ export function formatFlowTypeName(type) {
|
|
|
34
34
|
return lower.slice(0, targetWidth);
|
|
35
35
|
return lower.padEnd(targetWidth, " ");
|
|
36
36
|
}
|
|
37
|
-
/** Format tokens-per-second to a
|
|
38
|
-
function formatTps(value) {
|
|
37
|
+
/** Format tokens-per-second to a display string. */
|
|
38
|
+
export function formatTps(value) {
|
|
39
39
|
if (!value || value <= 0)
|
|
40
|
-
return "
|
|
41
|
-
return value.toFixed(1).padStart(5)
|
|
40
|
+
return "-----";
|
|
41
|
+
return `${value.toFixed(1).padStart(5)} t/s`;
|
|
42
42
|
}
|
|
43
43
|
export function italic(text) {
|
|
44
44
|
return `\x1b[3m${text}\x1b[23m`;
|
|
45
45
|
}
|
|
46
|
-
export function formatCompactTokenPair(usage) {
|
|
47
|
-
return `▲ ${formatFixedTokens(usage.input || 0)} ·`;
|
|
48
|
-
}
|
|
49
46
|
export function formatCompactStats(usage, model, maxWidth, options = {}) {
|
|
50
47
|
const tokenParts = [`▲ ${formatFixedTokens(usage.input || 0)}`];
|
|
51
|
-
let runtimeParts = [
|
|
48
|
+
let runtimeParts = [formatTps(usage.smoothedTps)];
|
|
52
49
|
if (!options.skipContext) {
|
|
53
|
-
runtimeParts.push(
|
|
50
|
+
runtimeParts.push(formatFixedTokens(usage.contextTokens || 0));
|
|
54
51
|
}
|
|
55
52
|
const parts = options.skipTokens ? runtimeParts : [...tokenParts, ...runtimeParts];
|
|
56
53
|
const displayModel = options.hideModel ? undefined : (model ? model.replace(/^[^/]+\//, "").toLowerCase() : undefined);
|
|
@@ -61,7 +58,8 @@ export function formatCompactStats(usage, model, maxWidth, options = {}) {
|
|
|
61
58
|
if (visibleLength(narrow) <= maxWidth)
|
|
62
59
|
return narrow;
|
|
63
60
|
// Drop context tokens next.
|
|
64
|
-
const
|
|
61
|
+
const tpsOnly = [formatTps(usage.smoothedTps)];
|
|
62
|
+
const withoutContext = options.skipTokens ? tpsOnly : [...tokenParts, ...tpsOnly];
|
|
65
63
|
narrow = withoutContext.join(" - ");
|
|
66
64
|
if (visibleLength(narrow) <= maxWidth)
|
|
67
65
|
return narrow;
|
|
@@ -86,6 +84,34 @@ export function formatCountdown(ms) {
|
|
|
86
84
|
const seconds = totalSeconds % 60;
|
|
87
85
|
return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
|
88
86
|
}
|
|
87
|
+
export function formatModelLabel(model, maxTail = 10) {
|
|
88
|
+
if (!model)
|
|
89
|
+
return "";
|
|
90
|
+
const parts = model.split("/");
|
|
91
|
+
if (parts.length < 2)
|
|
92
|
+
return model.toLowerCase();
|
|
93
|
+
const provider = parts[0];
|
|
94
|
+
const modelPath = parts.slice(1).join("/").toLowerCase();
|
|
95
|
+
const shortened = modelPath.length > maxTail ? "..." + modelPath.slice(-maxTail) : modelPath;
|
|
96
|
+
return `${provider}/${shortened}`;
|
|
97
|
+
}
|
|
98
|
+
export function formatCountdownRemaining(deadlineAtMs) {
|
|
99
|
+
if (typeof deadlineAtMs !== "number")
|
|
100
|
+
return undefined;
|
|
101
|
+
const remaining = deadlineAtMs - Date.now();
|
|
102
|
+
if (remaining < 0)
|
|
103
|
+
return undefined;
|
|
104
|
+
return formatCountdown(remaining);
|
|
105
|
+
}
|
|
106
|
+
export function formatContextLabel(ctxTokens, maxCtxTokens) {
|
|
107
|
+
if (maxCtxTokens === undefined) {
|
|
108
|
+
return formatFixedTokens(ctxTokens).trim();
|
|
109
|
+
}
|
|
110
|
+
if (ctxTokens === 0) {
|
|
111
|
+
return `-----/${formatFixedTokens(maxCtxTokens).trim()}`;
|
|
112
|
+
}
|
|
113
|
+
return `${formatFixedTokens(ctxTokens).trim()}/${formatFixedTokens(maxCtxTokens).trim()}`;
|
|
114
|
+
}
|
|
89
115
|
/** Regex matching ANSI escape sequences. */
|
|
90
116
|
const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
91
117
|
/** Return the visible (ANSI-stripped) character count. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-utils.js","sourceRoot":"","sources":["../../src/tui/render-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC9C,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;IACvB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACP,MAAM,CAAC,GAAG,KAAK,GAAG,O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AED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAW;IACjD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IAE5C,kDAAkD;IAClD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACxB,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,GAAG,GAAG,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC9C,IAAI,QAAQ,KAAK,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBACxC,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClC,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;oBACjB,SAAS;gBACV,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,EAAE,CAAC;QACV,CAAC,EAAE,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/tui/render.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ import type { SingleResult } from "../types/flow.js";
|
|
|
9
9
|
/** Reset the anonymous counter — call in tests for deterministic ids. */
|
|
10
10
|
export declare function resetAnonymousFlowIdCounter(): void;
|
|
11
11
|
import { type FlowColorConfig, type FlowTheme } from "./flow-colors.js";
|
|
12
|
+
/** Single segment of a multi-part header with its original plain length and style. */
|
|
13
|
+
export interface HeaderSegment {
|
|
14
|
+
text: string;
|
|
15
|
+
style: (text: string) => string;
|
|
16
|
+
}
|
|
17
|
+
/** Reconstruct multi-segment ANSI styles on a flat string by splitting at
|
|
18
|
+
* original segment boundaries and re-applying each segment's style function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reconstructHeader(content: string, segments: HeaderSegment[]): string;
|
|
12
21
|
export declare function renderFlowCall(args: Record<string, any>, theme: FlowTheme, config?: FlowColorConfig): Container | Text;
|
|
13
22
|
export declare function renderFlowResult(result: {
|
|
14
23
|
content: Array<{
|
package/dist/tui/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/tui/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,SAAS,EAAoB,IAAI,EAAiB,MAAM,sBAAsB,CAAC;AAExF,OAAO,KAAK,EACX,YAAY,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/tui/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,SAAS,EAAoB,IAAI,EAAiB,MAAM,sBAAsB,CAAC;AAExF,OAAO,KAAK,EACX,YAAY,EAEZ,MAAM,kBAAkB,CAAC;AAyB1B,yEAAyE;AACzE,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAeD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,SAAS,EAGf,MAAM,kBAAkB,CAAC;AAkG1B,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAapF;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAsBtH;AAMD,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,EAC9E,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,SAAS,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,MAAM,CAAC,EAAE,eAAe,GACtB,SAAS,GAAG,IAAI,CAyGlB;AAMD,wBAAgB,sBAAsB,CACrC,CAAC,EAAE,YAAY,EACf,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,SAAS,EAChB,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,eAAe,GACtB,SAAS,GAAG,IAAI,CAalB"}
|
package/dist/tui/render.js
CHANGED
|
@@ -31,7 +31,7 @@ function getLiveTextWithFallback(id) {
|
|
|
31
31
|
const fallbackId = id.includes("#") ? "collapsed" + id.slice(id.indexOf("#")) : "collapsed";
|
|
32
32
|
return getLiveText(fallbackId);
|
|
33
33
|
}
|
|
34
|
-
import { formatCompactStats,
|
|
34
|
+
import { formatCompactStats, formatFlowTypeName, lowerFirstWord, truncateChars, tailText, getTruncationBudget, visibleLength, stripAnsi, formatModelLabel, formatContextLabel, formatTps } from "./render-utils.js";
|
|
35
35
|
function shortenPath(p) {
|
|
36
36
|
const home = os.homedir();
|
|
37
37
|
return p.startsWith(home) ? `~${p.slice(home.length)}` : p;
|
|
@@ -118,10 +118,23 @@ function sectionHeader(label) {
|
|
|
118
118
|
const right = "─".repeat(Math.ceil(side));
|
|
119
119
|
return `${left} ${label} ${right}`;
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
/** Reconstruct multi-segment ANSI styles on a flat string by splitting at
|
|
122
|
+
* original segment boundaries and re-applying each segment's style function.
|
|
123
|
+
*/
|
|
124
|
+
export function reconstructHeader(content, segments) {
|
|
125
|
+
let offset = 0;
|
|
126
|
+
const parts = [];
|
|
127
|
+
for (const seg of segments) {
|
|
128
|
+
const len = seg.text.length;
|
|
129
|
+
if (offset >= content.length)
|
|
130
|
+
break;
|
|
131
|
+
parts.push(seg.style(content.slice(offset, offset + len)));
|
|
132
|
+
offset += len;
|
|
133
|
+
}
|
|
134
|
+
if (offset < content.length) {
|
|
135
|
+
parts.push(content.slice(offset));
|
|
136
|
+
}
|
|
137
|
+
return parts.join("");
|
|
125
138
|
}
|
|
126
139
|
// ---------------------------------------------------------------------------
|
|
127
140
|
// renderFlowCall — shown while the flow is being invoked
|
|
@@ -280,15 +293,21 @@ export function renderSingleFlowResult(r, expanded, theme, streamingText, toolCa
|
|
|
280
293
|
function renderFlowExpanded(r, icon, error, displayItems, flowOutput, theme, id, now, isComplete, streamingText, config) {
|
|
281
294
|
const mdTheme = getMarkdownTheme();
|
|
282
295
|
const container = new Container();
|
|
283
|
-
// Header: uppercase type name with dots, no icon, no source
|
|
284
296
|
const typeName = formatFlowTypeName(r.type);
|
|
285
297
|
let header = applyRole("flowName", typeName, theme, config);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
298
|
+
const errorSegment = error && r.stopReason ? ` [${r.stopReason}]` : "";
|
|
299
|
+
if (errorSegment)
|
|
300
|
+
header += ` ${theme.fg("error", errorSegment)}`;
|
|
301
|
+
const plainHeader = typeName + errorSegment;
|
|
302
|
+
const headerSegments = [
|
|
303
|
+
{ text: typeName, style: (s) => applyRole("flowName", s, theme, config) },
|
|
304
|
+
];
|
|
305
|
+
if (errorSegment) {
|
|
306
|
+
headerSegments.push({ text: errorSegment, style: (s) => theme.fg("error", s) });
|
|
307
|
+
}
|
|
289
308
|
container.addChild(new DynamicScrambleText(header, () => {
|
|
290
309
|
const result = scrambleManager.updateText(id, 'header', plainHeader, Date.now(), isComplete);
|
|
291
|
-
return result.isAnimating ?
|
|
310
|
+
return result.isAnimating ? reconstructHeader(result.content, headerSegments) : header;
|
|
292
311
|
}));
|
|
293
312
|
if (error && r.errorMessage) {
|
|
294
313
|
container.addChild(new Text(scrambleManager.renderStatic(theme.fg("error", `Error: ${r.errorMessage}`)), 0, 0));
|
|
@@ -431,44 +450,55 @@ function renderFlowCollapsed(r, icon, error, flowOutput, theme, streamingText, t
|
|
|
431
450
|
const container = new Container();
|
|
432
451
|
const maxWidth = process.stdout.columns ?? 80;
|
|
433
452
|
const typeName = formatCollapsedFlowHeaderTypeName(r.type);
|
|
434
|
-
const modelLabel = r.model
|
|
453
|
+
const modelLabel = formatModelLabel(r.model);
|
|
435
454
|
const headerPrefixLen = visibleLength(typeName) + visibleLength(modelLabel ? ` ${modelLabel} · ` : " ");
|
|
436
|
-
const stats = formatCompactStats(r.usage, r.model, Math.max(maxWidth - headerPrefixLen, 20), { skipTokens: true, skipContext: true, hideModel: true });
|
|
437
455
|
const isComplete = r.exitCode !== -1;
|
|
456
|
+
// Build header stats: ctxLabel · t/s
|
|
457
|
+
const statsParts = [];
|
|
458
|
+
if (r.maxContextTokens !== undefined || r.usage.contextTokens > 0) {
|
|
459
|
+
const ctxLabel = formatContextLabel(r.usage.contextTokens, r.maxContextTokens);
|
|
460
|
+
statsParts.push(ctxLabel);
|
|
461
|
+
}
|
|
462
|
+
const tpsFormatted = formatTps(r.usage.smoothedTps);
|
|
463
|
+
statsParts.push(tpsFormatted);
|
|
464
|
+
let displayStats = statsParts.join(" · ");
|
|
438
465
|
// Flash TPS value when it changes
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
466
|
+
const tpsNum = tpsFormatted.slice(0, -4); // remove " t/s" suffix
|
|
467
|
+
if (r.usage.smoothedTps && r.usage.smoothedTps > 0) {
|
|
468
|
+
const scrambledTps = scrambleManager.updateTps(id, tpsNum, now, isComplete, true);
|
|
469
|
+
if (scrambledTps !== tpsNum) {
|
|
470
|
+
displayStats = displayStats.replace(`${tpsNum} t/s`, `${scrambledTps} t/s`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const modelSegment = modelLabel ? ` ${modelLabel} · ` : " ";
|
|
474
|
+
const statsSegment = stripAnsi(displayStats);
|
|
475
|
+
const errorSegment = error && r.stopReason ? ` [${r.stopReason}]` : "";
|
|
476
|
+
let header = `${applyRole("flowName", typeName, theme, config)}${applyRole("modelName", modelSegment, theme, config)}${applyRole("stats", displayStats, theme, config)}`;
|
|
477
|
+
if (errorSegment)
|
|
478
|
+
header += ` ${theme.fg("error", errorSegment)}`;
|
|
479
|
+
const plainHeader = typeName + modelSegment + statsSegment + errorSegment;
|
|
480
|
+
const headerSegments = [
|
|
481
|
+
{ text: typeName, style: (s) => applyRole("flowName", s, theme, config) },
|
|
482
|
+
{ text: modelSegment, style: (s) => applyRole("modelName", s, theme, config) },
|
|
483
|
+
{ text: statsSegment, style: (s) => applyRole("stats", s, theme, config) },
|
|
484
|
+
];
|
|
485
|
+
if (errorSegment) {
|
|
486
|
+
headerSegments.push({ text: errorSegment, style: (s) => theme.fg("error", s) });
|
|
487
|
+
}
|
|
452
488
|
container.addChild(new DynamicScrambleText(header, () => {
|
|
453
489
|
const result = scrambleManager.updateText(id, 'header', plainHeader, Date.now(), isComplete, true);
|
|
454
|
-
return result.isAnimating ?
|
|
490
|
+
return result.isAnimating ? reconstructHeader(result.content, headerSegments) : header;
|
|
455
491
|
}, true));
|
|
456
492
|
// aim: line — glitch on text change
|
|
457
493
|
if (r.aim) {
|
|
458
|
-
const countdown = getLiveCountdown(r);
|
|
459
494
|
const aimTree = "├─";
|
|
460
|
-
const aimLabel =
|
|
461
|
-
? ` aim ▸ ${countdown} · `
|
|
462
|
-
: ` aim ▸ `;
|
|
495
|
+
const aimLabel = ` aim ▸ `;
|
|
463
496
|
const aimPrefix = `${aimTree}${aimLabel}`;
|
|
464
497
|
const budget = getTruncationBudget(visibleLength(aimPrefix));
|
|
465
498
|
const displayAim = truncateChars(lowerFirstWord(r.aim), budget);
|
|
466
499
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", aimTree, theme, config)}${applyRole("prefixLabel", aimLabel, theme, config)}${applyRole("aimContent", displayAim, theme, config)}`, () => {
|
|
467
500
|
const now = Date.now();
|
|
468
|
-
const
|
|
469
|
-
const freshAimLabel = freshCountdown
|
|
470
|
-
? ` aim ▸ ${freshCountdown} · `
|
|
471
|
-
: ` aim ▸ `;
|
|
501
|
+
const freshAimLabel = ` aim ▸ `;
|
|
472
502
|
const freshAimPrefix = `${aimTree}${freshAimLabel}`;
|
|
473
503
|
const freshBudget = getTruncationBudget(visibleLength(freshAimPrefix));
|
|
474
504
|
const freshText = truncateChars(lowerFirstWord(r.aim), freshBudget);
|
|
@@ -480,31 +510,21 @@ function renderFlowCollapsed(r, icon, error, flowOutput, theme, streamingText, t
|
|
|
480
510
|
const lastTool = getLastToolCall(r.messages);
|
|
481
511
|
const actStr = lastTool ? formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme)) : "[n/a]";
|
|
482
512
|
const actTree = "├─";
|
|
483
|
-
const actLabel = `
|
|
513
|
+
const actLabel = ` cmd ▸ `;
|
|
484
514
|
const prefixStub = `${actTree}${actLabel}`;
|
|
485
515
|
const budget = getTruncationBudget(visibleLength(prefixStub));
|
|
486
516
|
const actFullText = stripAnsi(lowerFirstWord(actStr));
|
|
487
|
-
const initialActContent = actFullText.length > budget ? actFullText
|
|
517
|
+
const initialActContent = actFullText.length > budget ? tailText(actFullText, budget) : actFullText;
|
|
488
518
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", actTree, theme, config)}${applyRole("prefixLabel", actLabel, theme, config)}${applyRole("actContent", initialActContent, theme, config)}`, () => {
|
|
489
519
|
const now = Date.now();
|
|
490
|
-
const displayAct =
|
|
520
|
+
const displayAct = tailText(actFullText, budget);
|
|
491
521
|
const actContent = scrambleManager.updateAct(id, displayAct, now, isComplete, true).content;
|
|
492
|
-
|
|
493
|
-
const scrambledActKpi = scrambleManager.updateActKpi(id, actKpi, now, isComplete, true);
|
|
494
|
-
if (scrambledActKpi !== actKpi) {
|
|
495
|
-
actKpi = scrambledActKpi;
|
|
496
|
-
}
|
|
497
|
-
const actLabel = ` act ▸ ${actKpi} · `;
|
|
522
|
+
const actLabel = ` cmd ▸ `;
|
|
498
523
|
const actPrefix = `${actTree}${actLabel}`;
|
|
499
524
|
return `${applyRole("treeChars", actTree, theme, config)}${applyRole("prefixLabel", actLabel, theme, config)}${applyRole("actContent", actContent, theme, config)}`;
|
|
500
525
|
}, true));
|
|
501
526
|
// msg: line (last assistant text or streaming)
|
|
502
|
-
|
|
503
|
-
const scrambledMsgKpi = scrambleManager.updateMsgKpi(id, msgKpi, now, isComplete, false);
|
|
504
|
-
if (scrambledMsgKpi !== msgKpi) {
|
|
505
|
-
msgKpi = scrambledMsgKpi;
|
|
506
|
-
}
|
|
507
|
-
const msgPrefixStub = `└─ msg ▸ ${msgKpi} `;
|
|
527
|
+
const msgPrefixStub = `└─ msg ▸ `;
|
|
508
528
|
const msgBudget = getTruncationBudget(visibleLength(msgPrefixStub));
|
|
509
529
|
let rawMsg;
|
|
510
530
|
let useError = false;
|
|
@@ -534,16 +554,11 @@ function renderFlowCollapsed(r, icon, error, flowOutput, theme, streamingText, t
|
|
|
534
554
|
? tailText(rawMsg, msgBudget)
|
|
535
555
|
: truncateChars(rawMsg, msgBudget);
|
|
536
556
|
const msgTree = "└─";
|
|
537
|
-
const msgLabel = ` msg ▸
|
|
557
|
+
const msgLabel = ` msg ▸ `;
|
|
538
558
|
const initialMsgPrefix = `${msgTree}${msgLabel}`;
|
|
539
559
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", msgTree, theme, config)}${applyRole("prefixLabel", msgLabel, theme, config)}${applyRole(useError ? "msgError" : "msgContent", initialMsgContent, theme, config)}`, () => {
|
|
540
560
|
const now = Date.now();
|
|
541
|
-
|
|
542
|
-
const scrambledMsgKpi = scrambleManager.updateMsgKpi(id, msgKpi, now, isComplete, false);
|
|
543
|
-
if (scrambledMsgKpi !== msgKpi) {
|
|
544
|
-
msgKpi = scrambledMsgKpi;
|
|
545
|
-
}
|
|
546
|
-
const msgLabel = ` msg ▸ ${msgKpi} `;
|
|
561
|
+
const msgLabel = ` msg ▸ `;
|
|
547
562
|
const msgPrefix = `${msgTree}${msgLabel}`;
|
|
548
563
|
const freshRawMsg = (r.exitCode === -1 ? getLiveTextWithFallback(id) : undefined) ?? rawMsg;
|
|
549
564
|
const needsTail = r.exitCode === -1 || streamingText != null;
|
|
@@ -677,49 +692,61 @@ function renderActivityPanel(results, theme, baseId, config) {
|
|
|
677
692
|
const isLast = i === results.length - 1;
|
|
678
693
|
const flowId = `${idPrefix}#${i}`;
|
|
679
694
|
const typeName = formatCollapsedFlowHeaderTypeName(r.type);
|
|
680
|
-
const modelLabel = r.model
|
|
695
|
+
const modelLabel = formatModelLabel(r.model);
|
|
681
696
|
const headerPrefix = isLast ? "└─" : "├─";
|
|
682
697
|
const headerPrefixLen = visibleLength(headerPrefix) + 1 + visibleLength(typeName) + visibleLength(modelLabel ? ` ${modelLabel} · ` : " ");
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
698
|
+
// Build header stats: ctxLabel · t/s
|
|
699
|
+
const statsParts = [];
|
|
700
|
+
if (r.maxContextTokens !== undefined || r.usage.contextTokens > 0) {
|
|
701
|
+
const ctxLabel = formatContextLabel(r.usage.contextTokens, r.maxContextTokens);
|
|
702
|
+
statsParts.push(ctxLabel);
|
|
703
|
+
}
|
|
704
|
+
const tpsFormatted = formatTps(r.usage.smoothedTps);
|
|
705
|
+
statsParts.push(tpsFormatted);
|
|
706
|
+
let displayStats = statsParts.join(" · ");
|
|
686
707
|
const flowComplete = r.exitCode !== -1;
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
708
|
+
// Flash TPS value when it changes
|
|
709
|
+
const tpsNum = tpsFormatted.slice(0, -4); // remove " t/s" suffix
|
|
710
|
+
if (r.usage.smoothedTps && r.usage.smoothedTps > 0) {
|
|
711
|
+
const scrambledTps = scrambleManager.updateTps(flowId, tpsNum, now, flowComplete, true);
|
|
712
|
+
if (scrambledTps !== tpsNum) {
|
|
713
|
+
displayStats = displayStats.replace(`${tpsNum} t/s`, `${scrambledTps} t/s`);
|
|
692
714
|
}
|
|
693
715
|
}
|
|
694
716
|
const error = isFlowError(r);
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
717
|
+
const modelSegment = modelLabel ? ` ${modelLabel} · ` : " ";
|
|
718
|
+
const statsSegment = stripAnsi(displayStats);
|
|
719
|
+
const errorSegment = error && r.stopReason ? ` [${r.stopReason}]` : "";
|
|
720
|
+
let headerLine = `${applyRole("treeChars", headerPrefix, theme, config)} ${applyRole("flowName", typeName, theme, config)}${applyRole("modelName", modelSegment, theme, config)}${applyRole("stats", displayStats, theme, config)}`;
|
|
721
|
+
if (errorSegment) {
|
|
722
|
+
headerLine += ` ${theme.fg("error", errorSegment)}`;
|
|
723
|
+
}
|
|
724
|
+
const plainHeader = headerPrefix + " " + typeName + modelSegment + statsSegment + errorSegment;
|
|
725
|
+
const headerSegments = [
|
|
726
|
+
{ text: headerPrefix + " ", style: (s) => applyRole("treeChars", s, theme, config) },
|
|
727
|
+
{ text: typeName, style: (s) => applyRole("flowName", s, theme, config) },
|
|
728
|
+
{ text: modelSegment, style: (s) => applyRole("modelName", s, theme, config) },
|
|
729
|
+
{ text: statsSegment, style: (s) => applyRole("stats", s, theme, config) },
|
|
730
|
+
];
|
|
731
|
+
if (errorSegment) {
|
|
732
|
+
headerSegments.push({ text: errorSegment, style: (s) => theme.fg("error", s) });
|
|
699
733
|
}
|
|
700
|
-
const plainHeader = headerPrefix + " " + typeName + (modelLabel ? ` ${modelLabel} · ` : " ") + stripAnsi(displayStats) + (error && r.stopReason ? ` [${r.stopReason}]` : "");
|
|
701
734
|
container.addChild(new DynamicScrambleText(headerLine, () => {
|
|
702
735
|
const result = scrambleManager.updateText(flowId, 'header', plainHeader, Date.now(), flowComplete, true);
|
|
703
|
-
return result.isAnimating ?
|
|
736
|
+
return result.isAnimating ? reconstructHeader(result.content, headerSegments) : headerLine;
|
|
704
737
|
}, true));
|
|
705
738
|
// Continuation indent for sub-lines
|
|
706
739
|
const indent = isLast ? " " : "│ ";
|
|
707
740
|
// aim: line — glitch on text change
|
|
708
741
|
if (r.aim) {
|
|
709
|
-
const countdown = getLiveCountdown(r);
|
|
710
742
|
const aimTree = indent + "├─";
|
|
711
|
-
const aimLabel =
|
|
712
|
-
? ` aim ▸ ${countdown} · `
|
|
713
|
-
: ` aim ▸ `;
|
|
743
|
+
const aimLabel = ` aim ▸ `;
|
|
714
744
|
const aimPrefix = `${aimTree}${aimLabel}`;
|
|
715
745
|
const budget = getTruncationBudget(visibleLength(aimPrefix));
|
|
716
746
|
const displayAim = truncateChars(lowerFirstWord(r.aim), budget);
|
|
717
747
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", aimTree, theme, config)}${applyRole("prefixLabel", aimLabel, theme, config)}${applyRole("aimContent", displayAim, theme, config)}`, () => {
|
|
718
748
|
const now = Date.now();
|
|
719
|
-
const
|
|
720
|
-
const freshAimLabel = freshCountdown
|
|
721
|
-
? ` aim ▸ ${freshCountdown} · `
|
|
722
|
-
: ` aim ▸ `;
|
|
749
|
+
const freshAimLabel = ` aim ▸ `;
|
|
723
750
|
const freshAimPrefix = `${aimTree}${freshAimLabel}`;
|
|
724
751
|
const freshBudget = getTruncationBudget(visibleLength(freshAimPrefix));
|
|
725
752
|
const freshText = truncateChars(lowerFirstWord(r.aim), freshBudget);
|
|
@@ -731,33 +758,23 @@ function renderActivityPanel(results, theme, baseId, config) {
|
|
|
731
758
|
const lastTool = getLastToolCall(r.messages);
|
|
732
759
|
const actStr = lastTool ? formatFlowToolCall(lastTool.name, lastTool.args, theme.fg.bind(theme)) : "[n/a]";
|
|
733
760
|
const actTree = `${indent}├─`;
|
|
734
|
-
const actLabel = `
|
|
761
|
+
const actLabel = ` cmd ▸ `;
|
|
735
762
|
const prefixStub = `${actTree}${actLabel}`;
|
|
736
763
|
const budget = getTruncationBudget(visibleLength(prefixStub));
|
|
737
764
|
const actFullText = stripAnsi(lowerFirstWord(actStr));
|
|
738
|
-
const initialActContent = actFullText.length > budget ? actFullText
|
|
765
|
+
const initialActContent = actFullText.length > budget ? tailText(actFullText, budget) : actFullText;
|
|
739
766
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", actTree, theme, config)}${applyRole("prefixLabel", actLabel, theme, config)}${applyRole("actContent", initialActContent, theme, config)}`, () => {
|
|
740
767
|
const now = Date.now();
|
|
741
|
-
|
|
742
|
-
const scrambledActKpi = scrambleManager.updateActKpi(flowId, actKpi, now, flowComplete, false);
|
|
743
|
-
if (scrambledActKpi !== actKpi) {
|
|
744
|
-
actKpi = scrambledActKpi;
|
|
745
|
-
}
|
|
746
|
-
const actLabel = ` act ▸ ${actKpi} · `;
|
|
768
|
+
const actLabel = ` cmd ▸ `;
|
|
747
769
|
const actPrefix = `${actTree}${actLabel}`;
|
|
748
770
|
const freshBudget = getTruncationBudget(visibleLength(actPrefix));
|
|
749
|
-
const displayAct =
|
|
771
|
+
const displayAct = tailText(actFullText, freshBudget);
|
|
750
772
|
const actContent = scrambleManager.updateAct(flowId, displayAct, now, flowComplete, true).content;
|
|
751
773
|
return `${applyRole("treeChars", actTree, theme, config)}${applyRole("prefixLabel", actLabel, theme, config)}${applyRole("actContent", actContent, theme, config)}`;
|
|
752
774
|
}, true));
|
|
753
775
|
// msg: line (live streaming text or last assistant text)
|
|
754
|
-
let msgKpi = formatCompactTokenPair(r.usage);
|
|
755
|
-
const scrambledMsgKpi = scrambleManager.updateMsgKpi(flowId, msgKpi, now, flowComplete, false);
|
|
756
|
-
if (scrambledMsgKpi !== msgKpi) {
|
|
757
|
-
msgKpi = scrambledMsgKpi;
|
|
758
|
-
}
|
|
759
776
|
const msgTree = `${indent}└─`;
|
|
760
|
-
const msgLabel = ` msg ▸
|
|
777
|
+
const msgLabel = ` msg ▸ `;
|
|
761
778
|
const msgPrefixStub = `${msgTree}${msgLabel}`;
|
|
762
779
|
const msgBudget = getTruncationBudget(visibleLength(msgPrefixStub));
|
|
763
780
|
const liveText = r.exitCode === -1 ? r.streamingText : undefined;
|
|
@@ -782,12 +799,7 @@ function renderActivityPanel(results, theme, baseId, config) {
|
|
|
782
799
|
const initialDisplayMsg = initialNeedsTail ? tailText(rawMsg, msgBudget) : truncateChars(rawMsg, msgBudget);
|
|
783
800
|
container.addChild(new DynamicScrambleText(`${applyRole("treeChars", msgTree, theme, config)}${applyRole("prefixLabel", msgLabel, theme, config)}${applyRole(useError ? "msgError" : "msgContent", initialDisplayMsg, theme, config)}`, () => {
|
|
784
801
|
const now = Date.now();
|
|
785
|
-
|
|
786
|
-
const scrambledMsgKpi = scrambleManager.updateMsgKpi(flowId, msgKpi, now, flowComplete, false);
|
|
787
|
-
if (scrambledMsgKpi !== msgKpi) {
|
|
788
|
-
msgKpi = scrambledMsgKpi;
|
|
789
|
-
}
|
|
790
|
-
const msgLabel = ` msg ▸ ${msgKpi} `;
|
|
802
|
+
const msgLabel = ` msg ▸ `;
|
|
791
803
|
const msgPrefix = `${msgTree}${msgLabel}`;
|
|
792
804
|
const freshBudget = getTruncationBudget(visibleLength(msgPrefix));
|
|
793
805
|
const freshRawMsg = flowComplete ? rawMsg : (getLiveTextWithFallback(flowId) ?? rawMsg);
|