shellpuppet 0.2.0 → 0.3.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/README.md +83 -18
- package/dist/agents/agy/index.d.ts +2 -0
- package/dist/agents/agy/index.js +11 -0
- package/dist/agents/agy/index.js.map +1 -0
- package/dist/agents/agy/nudge.d.ts +2 -0
- package/dist/agents/agy/nudge.js +29 -0
- package/dist/agents/agy/nudge.js.map +1 -0
- package/dist/agents/agy/reading.d.ts +2 -0
- package/dist/agents/agy/reading.js +28 -0
- package/dist/agents/agy/reading.js.map +1 -0
- package/dist/agents/barNudge.d.ts +9 -0
- package/dist/agents/barNudge.js +21 -0
- package/dist/agents/barNudge.js.map +1 -0
- package/dist/agents/claude/index.d.ts +2 -0
- package/dist/agents/claude/index.js +31 -0
- package/dist/agents/claude/index.js.map +1 -0
- package/dist/agents/claude/nudge.d.ts +2 -0
- package/dist/agents/claude/nudge.js +38 -0
- package/dist/agents/claude/nudge.js.map +1 -0
- package/dist/agents/claude/prompts.d.ts +9 -0
- package/dist/agents/claude/prompts.js +16 -0
- package/dist/agents/claude/prompts.js.map +1 -0
- package/dist/agents/claude/reading.d.ts +2 -0
- package/dist/agents/claude/reading.js +25 -0
- package/dist/agents/claude/reading.js.map +1 -0
- package/dist/agents/codex/index.d.ts +2 -0
- package/dist/agents/codex/index.js +28 -0
- package/dist/agents/codex/index.js.map +1 -0
- package/dist/agents/codex/nudge.d.ts +2 -0
- package/dist/agents/codex/nudge.js +35 -0
- package/dist/agents/codex/nudge.js.map +1 -0
- package/dist/agents/codex/prompts.d.ts +9 -0
- package/dist/agents/codex/prompts.js +14 -0
- package/dist/agents/codex/prompts.js.map +1 -0
- package/dist/agents/codex/reading.d.ts +2 -0
- package/dist/agents/codex/reading.js +22 -0
- package/dist/agents/codex/reading.js.map +1 -0
- package/dist/agents/generic/index.d.ts +3 -0
- package/dist/agents/generic/index.js +9 -0
- package/dist/agents/generic/index.js.map +1 -0
- package/dist/agents/generic/prompts.d.ts +2 -0
- package/dist/agents/generic/prompts.js +10 -0
- package/dist/agents/generic/prompts.js.map +1 -0
- package/dist/agents/grok/actionBox.d.ts +13 -0
- package/dist/agents/grok/actionBox.js +127 -0
- package/dist/agents/grok/actionBox.js.map +1 -0
- package/dist/agents/grok/index.d.ts +2 -0
- package/dist/agents/grok/index.js +20 -0
- package/dist/agents/grok/index.js.map +1 -0
- package/dist/agents/grok/nudge.d.ts +2 -0
- package/dist/agents/grok/nudge.js +76 -0
- package/dist/agents/grok/nudge.js.map +1 -0
- package/dist/agents/grok/prompts.d.ts +4 -0
- package/dist/agents/grok/prompts.js +89 -0
- package/dist/agents/grok/prompts.js.map +1 -0
- package/dist/agents/grok/reading.d.ts +2 -0
- package/dist/agents/grok/reading.js +49 -0
- package/dist/agents/grok/reading.js.map +1 -0
- package/dist/agents/grok/readingRules.d.ts +2 -0
- package/dist/agents/grok/readingRules.js +44 -0
- package/dist/agents/grok/readingRules.js.map +1 -0
- package/dist/agents/index.d.ts +28 -0
- package/dist/agents/index.js +46 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/input.d.ts +2 -0
- package/dist/agents/input.js +9 -0
- package/dist/agents/input.js.map +1 -0
- package/dist/agents/mimo/index.d.ts +2 -0
- package/dist/agents/mimo/index.js +13 -0
- package/dist/agents/mimo/index.js.map +1 -0
- package/dist/agents/mimo/nudge.d.ts +3 -0
- package/dist/agents/mimo/nudge.js +59 -0
- package/dist/agents/mimo/nudge.js.map +1 -0
- package/dist/agents/mimo/prompts.d.ts +2 -0
- package/dist/agents/mimo/prompts.js +40 -0
- package/dist/agents/mimo/prompts.js.map +1 -0
- package/dist/agents/mimo/reading.d.ts +2 -0
- package/dist/agents/mimo/reading.js +31 -0
- package/dist/agents/mimo/reading.js.map +1 -0
- package/dist/agents/mimo/readingRules.d.ts +2 -0
- package/dist/agents/mimo/readingRules.js +79 -0
- package/dist/agents/mimo/readingRules.js.map +1 -0
- package/dist/agents/mimo/stalls.d.ts +2 -0
- package/dist/agents/mimo/stalls.js +81 -0
- package/dist/agents/mimo/stalls.js.map +1 -0
- package/dist/agents/muse/index.d.ts +2 -0
- package/dist/agents/muse/index.js +20 -0
- package/dist/agents/muse/index.js.map +1 -0
- package/dist/agents/muse/input.d.ts +3 -0
- package/dist/agents/muse/input.js +7 -0
- package/dist/agents/muse/input.js.map +1 -0
- package/dist/agents/muse/nudge.d.ts +2 -0
- package/dist/agents/muse/nudge.js +33 -0
- package/dist/agents/muse/nudge.js.map +1 -0
- package/dist/agents/muse/prompts.d.ts +14 -0
- package/dist/agents/muse/prompts.js +132 -0
- package/dist/agents/muse/prompts.js.map +1 -0
- package/dist/agents/muse/reading.d.ts +2 -0
- package/dist/agents/muse/reading.js +33 -0
- package/dist/agents/muse/reading.js.map +1 -0
- package/dist/agents/muse/readingRules.d.ts +2 -0
- package/dist/agents/muse/readingRules.js +49 -0
- package/dist/agents/muse/readingRules.js.map +1 -0
- package/dist/agents/nudgeReading.d.ts +74 -0
- package/dist/agents/nudgeReading.js +262 -0
- package/dist/agents/nudgeReading.js.map +1 -0
- package/dist/agents/opencode/index.d.ts +2 -0
- package/dist/agents/opencode/index.js +21 -0
- package/dist/agents/opencode/index.js.map +1 -0
- package/dist/agents/opencode/nudge.d.ts +6 -0
- package/dist/agents/opencode/nudge.js +187 -0
- package/dist/agents/opencode/nudge.js.map +1 -0
- package/dist/agents/opencode/prompts.d.ts +6 -0
- package/dist/agents/opencode/prompts.js +198 -0
- package/dist/agents/opencode/prompts.js.map +1 -0
- package/dist/agents/opencode/reading.d.ts +2 -0
- package/dist/agents/opencode/reading.js +29 -0
- package/dist/agents/opencode/reading.js.map +1 -0
- package/dist/agents/opencode/stalls.d.ts +3 -0
- package/dist/agents/opencode/stalls.js +14 -0
- package/dist/agents/opencode/stalls.js.map +1 -0
- package/dist/agents/qoder/index.d.ts +2 -0
- package/dist/agents/qoder/index.js +12 -0
- package/dist/agents/qoder/index.js.map +1 -0
- package/dist/agents/qoder/nudge.d.ts +2 -0
- package/dist/agents/qoder/nudge.js +16 -0
- package/dist/agents/qoder/nudge.js.map +1 -0
- package/dist/agents/qoder/prompts.d.ts +2 -0
- package/dist/agents/qoder/prompts.js +6 -0
- package/dist/agents/qoder/prompts.js.map +1 -0
- package/dist/agents/qoder/reading.d.ts +2 -0
- package/dist/agents/qoder/reading.js +41 -0
- package/dist/agents/qoder/reading.js.map +1 -0
- package/dist/agents/types.d.ts +187 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/index.js +255 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +17 -3
- package/dist/client/http.js +232 -35
- package/dist/client/http.js.map +1 -1
- package/dist/core/dialogs.d.ts +2 -4
- package/dist/core/dialogs.js +6 -12
- package/dist/core/dialogs.js.map +1 -1
- package/dist/core/mailbox.d.ts +222 -0
- package/dist/core/mailbox.js +545 -0
- package/dist/core/mailbox.js.map +1 -0
- package/dist/core/manager.d.ts +3 -0
- package/dist/core/manager.js +37 -2
- package/dist/core/manager.js.map +1 -1
- package/dist/core/messageText.d.ts +2 -0
- package/dist/core/messageText.js +6 -0
- package/dist/core/messageText.js.map +1 -0
- package/dist/core/nudge.d.ts +37 -0
- package/dist/core/nudge.js +57 -0
- package/dist/core/nudge.js.map +1 -0
- package/dist/core/promptDetector.d.ts +14 -12
- package/dist/core/promptDetector.js +113 -363
- package/dist/core/promptDetector.js.map +1 -1
- package/dist/core/promptText.d.ts +1 -0
- package/dist/core/promptText.js +4 -0
- package/dist/core/promptText.js.map +1 -0
- package/dist/core/readiness.d.ts +14 -0
- package/dist/core/readiness.js +95 -0
- package/dist/core/readiness.js.map +1 -0
- package/dist/core/reasoning.d.ts +68 -7
- package/dist/core/reasoning.js +572 -325
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/renderer.d.ts +63 -3
- package/dist/core/renderer.js +368 -42
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/selection.d.ts +1 -1
- package/dist/core/selection.js +3 -3
- package/dist/core/selection.js.map +1 -1
- package/dist/core/session.d.ts +166 -14
- package/dist/core/session.js +1000 -86
- package/dist/core/session.js.map +1 -1
- package/dist/core/types.d.ts +60 -4
- package/dist/core/types.js +41 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/waiter.d.ts +9 -2
- package/dist/core/waiter.js +35 -10
- package/dist/core/waiter.js.map +1 -1
- package/dist/daemon/audit.d.ts +1 -1
- package/dist/daemon/audit.js +2 -1
- package/dist/daemon/audit.js.map +1 -1
- package/dist/daemon/config.d.ts +42 -0
- package/dist/daemon/config.js +159 -4
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/folderPicker.js +21 -2
- package/dist/daemon/folderPicker.js.map +1 -1
- package/dist/daemon/homeOwner.d.ts +15 -0
- package/dist/daemon/homeOwner.js +106 -0
- package/dist/daemon/homeOwner.js.map +1 -0
- package/dist/daemon/index.js +10 -6
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/launchProfiles.d.ts +5 -0
- package/dist/daemon/launchProfiles.js +42 -40
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/liveness.d.ts +1 -1
- package/dist/daemon/liveness.js +2 -2
- package/dist/daemon/liveness.js.map +1 -1
- package/dist/daemon/nudgeScheduler.d.ts +21 -0
- package/dist/daemon/nudgeScheduler.js +61 -0
- package/dist/daemon/nudgeScheduler.js.map +1 -0
- package/dist/daemon/paths.d.ts +22 -16
- package/dist/daemon/paths.js +137 -49
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/restartHold.d.ts +16 -0
- package/dist/daemon/restartHold.js +126 -0
- package/dist/daemon/restartHold.js.map +1 -0
- package/dist/daemon/restartSource.d.ts +7 -0
- package/dist/daemon/restartSource.js +89 -0
- package/dist/daemon/restartSource.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +4 -1
- package/dist/daemon/screenshot.js +45 -7
- package/dist/daemon/screenshot.js.map +1 -1
- package/dist/daemon/server.d.ts +71 -13
- package/dist/daemon/server.js +1601 -296
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/sessionFeed.js +4 -1
- package/dist/daemon/sessionFeed.js.map +1 -1
- package/dist/mcp/config.js +2 -1
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.js +12 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +21 -1
- package/dist/mcp/tools.js +213 -28
- package/dist/mcp/tools.js.map +1 -1
- package/dist/viewer/dashboard-folders.js +7 -1
- package/dist/viewer/dashboard-layout.js +6 -52
- package/dist/viewer/dashboard.css +20 -4
- package/dist/viewer/dashboard.html +12 -3
- package/dist/viewer/dashboard.js +550 -378
- package/dist/viewer/pane.js +744 -136
- package/dist/viewer/viewer.css +1 -1
- package/dist/viewer/viewer.js +3 -1
- package/package.json +1 -1
package/dist/core/reasoning.js
CHANGED
|
@@ -37,262 +37,10 @@
|
|
|
37
37
|
* The prompt detector times its dialog signatures the same way; its own
|
|
38
38
|
* patterns are not timed.
|
|
39
39
|
*/
|
|
40
|
+
import { BUILT_IN_SIGNATURES, claimsProgram, moduleFor, programName, resolveAgent } from '../agents/index.js';
|
|
40
41
|
import { RegexBudgetError, SET_ASIDE_MS, withRegexBudget } from './regexBudget.js';
|
|
41
42
|
import { detectPrompt } from './promptDetector.js';
|
|
42
|
-
|
|
43
|
-
const RULE = '^[─━]{10,}$';
|
|
44
|
-
const RULE_INDENTED = '^\\s*[─━]{10,}';
|
|
45
|
-
/**
|
|
46
|
-
* Grok draws its permission box behind the same bar as its reasoning: a
|
|
47
|
-
* question row (`> `), a command's rows (`│` starts one, `:` continues it)
|
|
48
|
-
* and option rows (`1 (○)`). No Grok reasoning rule starts or continues on
|
|
49
|
-
* them, so a permission box keeps every row of its own, whatever wording
|
|
50
|
-
* its question is asked in.
|
|
51
|
-
*/
|
|
52
|
-
const GROK_BOX_ROW = ' {2}(?:> |\\d+ \\([○•●]\\) |[│:])';
|
|
53
|
-
/**
|
|
54
|
-
* Built-in signatures. Each comment names the screens its fixtures come from.
|
|
55
|
-
*/
|
|
56
|
-
export const BUILT_IN_SIGNATURES = [
|
|
57
|
-
{
|
|
58
|
-
// Claude Code 2.1.312, default view and the ctrl+o transcript: no
|
|
59
|
-
// reasoning text is drawn in either, only a spinner line while the model
|
|
60
|
-
// thinks ("✻ Pondering… (2s · thinking with xhigh effort)"). The answer
|
|
61
|
-
// is a `●` in the text colour; tool calls get a grey or coloured `●`.
|
|
62
|
-
name: 'claude',
|
|
63
|
-
programs: ['claude'],
|
|
64
|
-
measured: 'Claude Code 2.1.312',
|
|
65
|
-
// The composer's prompt glyph is followed by a non-breaking space once
|
|
66
|
-
// something is typed; the echo of a sent prompt by an ordinary one.
|
|
67
|
-
composer: { text: '^❯( |\\xa0|$)' },
|
|
68
|
-
typed: { text: '^❯[ \\xa0]\\S', word: { dim: false } },
|
|
69
|
-
chrome: [{ text: RULE }, { text: '/effort\\s*$' }],
|
|
70
|
-
frame: { text: RULE },
|
|
71
|
-
busy: [{ text: '^[✻✽✶✢✳·*] \\S+…' }],
|
|
72
|
-
turn: { text: '^❯ \\S' },
|
|
73
|
-
answer: {
|
|
74
|
-
start: { text: '^● ', lead: { fg: ['default', '#ffffff', '#000000'] } },
|
|
75
|
-
continues: { text: '^ {2}' },
|
|
76
|
-
},
|
|
77
|
-
trailer: { text: '^✻ \\S' },
|
|
78
|
-
requireTrailer: true,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
// Codex CLI 0.165.0 (GPT-6-Sol, high effort), default view. The answer is
|
|
82
|
-
// a dim "•" with plain text after it; a tool group is a dim "•" with a
|
|
83
|
-
// bold heading ("Explored"), a command a bold green "•" ("Ran"). While a
|
|
84
|
-
// turn runs, "Working (Ns • esc to interrupt)" sits above the composer.
|
|
85
|
-
name: 'codex',
|
|
86
|
-
programs: ['codex'],
|
|
87
|
-
measured: 'Codex CLI 0.165.0',
|
|
88
|
-
composer: { text: '^› ' },
|
|
89
|
-
// The placeholder ("Ask Codex to do anything") is dim; typed text is not.
|
|
90
|
-
typed: { text: '^› \\S', word: { dim: false } },
|
|
91
|
-
chrome: [{ text: 'esc to interrupt' }],
|
|
92
|
-
busy: [{ text: 'esc to interrupt' }],
|
|
93
|
-
turn: { text: '^› \\S' },
|
|
94
|
-
answer: {
|
|
95
|
-
start: { text: '^• ', lead: { dim: true }, word: { bold: false, italic: false } },
|
|
96
|
-
continues: { text: '^ {2}(?!Worked for )[^\\s└]' },
|
|
97
|
-
},
|
|
98
|
-
trailer: { text: '^ {2}Worked for ' },
|
|
99
|
-
requireTrailer: true,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
// Antigravity CLI 1.4.10 (Gemini 3.8 Flash, high effort). A summary of
|
|
103
|
-
// the model's reasoning stays on screen as one line, "○ Thought for 4.2s
|
|
104
|
-
// (Create the file, then…)"; while it works, the spinner's label is the
|
|
105
|
-
// subject of what it is thinking about. "▸ Thought for 5s, 228 tokens"
|
|
106
|
-
// carries no text. Tool calls are a green "●"; the answer is plain text
|
|
107
|
-
// indented two spaces. While a turn runs, "esc to cancel" is under the
|
|
108
|
-
// composer.
|
|
109
|
-
name: 'agy',
|
|
110
|
-
programs: ['agy', 'antigravity'],
|
|
111
|
-
measured: 'Antigravity CLI 1.4.10',
|
|
112
|
-
composer: { text: '^>' },
|
|
113
|
-
chrome: [{ text: RULE_INDENTED }, { text: '^[⠀-⣿] {2}' }, { text: '^└ ' }],
|
|
114
|
-
frame: { text: RULE_INDENTED },
|
|
115
|
-
busy: [{ text: '^[⠀-⣿] {2}\\S' }, { text: '^esc to cancel' }],
|
|
116
|
-
turn: { text: '^> \\S' },
|
|
117
|
-
reasoning: [
|
|
118
|
-
{ start: { text: '^○ Thought for ' } },
|
|
119
|
-
{ start: { text: '^[⠀-⣿] {2}\\S' } },
|
|
120
|
-
],
|
|
121
|
-
answer: {
|
|
122
|
-
start: { text: '^ {2}\\S', lead: { fg: ['default', '#ffffff', '#000000', 'p7', 'p15'] } },
|
|
123
|
-
continues: { text: '^ {2}\\S', lead: { fg: ['default', '#ffffff', '#000000', 'p7', 'p15'] } },
|
|
124
|
-
upward: true,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
// Grok Build 1.0.70 (grok-4.7, xhigh effort). While the model thinks, its
|
|
129
|
-
// reasoning streams into a block behind a fading "│" bar, headed
|
|
130
|
-
// "♦ Thinking…"; once it is done the block collapses to "♦ Thought for
|
|
131
|
-
// Ns" with nothing under it. Messages and the answer are plain text
|
|
132
|
-
// indented five spaces; tool work is a "♦" line ("♦ Edited primes.py, ran
|
|
133
|
-
// 1 command"); "Worked for Ns" closes the turn. While a turn runs, a
|
|
134
|
-
// spinner line ("| Thinking… 3.1s") sits above the composer's box.
|
|
135
|
-
name: 'grok',
|
|
136
|
-
programs: ['grok'],
|
|
137
|
-
measured: 'Grok Build 1.0.70',
|
|
138
|
-
composer: { text: '^ {2}│ >' },
|
|
139
|
-
chrome: [{ text: '^ {2}╭' }, { text: '^ {3}[|/\\\\-] \\S' }, { text: '^ {3}\\S.*shift\\+tab', }],
|
|
140
|
-
frame: { text: '^ {2}[╭╰]' },
|
|
141
|
-
busy: [{ text: '^ {3}[|/\\\\-] .* \\d+(?:\\.\\d+)?s\\s*$' }, { text: '♦ Thinking…' }],
|
|
142
|
-
turn: { text: '^ {5}> \\S' },
|
|
143
|
-
reasoning: [
|
|
144
|
-
{
|
|
145
|
-
start: { text: '^ {2}│ {2}♦ Thinking' },
|
|
146
|
-
continues: { text: `^ {2}│(?!${GROK_BOX_ROW})` },
|
|
147
|
-
},
|
|
148
|
-
// The spinner's label can be the model's own words about what it is
|
|
149
|
-
// doing; it goes too, and the busy state still shows in the result.
|
|
150
|
-
{ start: { text: '^ {3}[|/\\\\-] \\S' } },
|
|
151
|
-
// The bar on its own: the heading may have scrolled away.
|
|
152
|
-
{
|
|
153
|
-
start: { text: `^ {2}│(?!${GROK_BOX_ROW}) {2}\\S` },
|
|
154
|
-
continues: { text: `^ {2}│(?!${GROK_BOX_ROW})` },
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
answer: {
|
|
158
|
-
start: { text: '^ {5}(?!Worked for )[^\\s♦>]', lead: { fg: ['default', '#c8c8c8', '#ffffff', '#000000'] } },
|
|
159
|
-
continues: { text: '^ {5}(?!Worked for )[^\\s♦>]', lead: { fg: ['default', '#c8c8c8', '#ffffff', '#000000'] } },
|
|
160
|
-
upward: true,
|
|
161
|
-
},
|
|
162
|
-
trailer: { text: '^ {5}Worked for ' },
|
|
163
|
-
requireTrailer: true,
|
|
164
|
-
// A right-aligned time on each message row.
|
|
165
|
-
tidy: ' {2,}\\d{1,2}:\\d{2}(?: ?[A-Za-z]{2})?\\s*$',
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
// OpenCode 2.0.26 (GLM-5.3): no reasoning text is drawn. While the model
|
|
169
|
-
// thinks it shows "⠇ Thinking"; afterwards a collapsed "+ Thought · Ns"
|
|
170
|
-
// with nothing under it. The answer is plain paragraphs, in the same
|
|
171
|
-
// colour and indent as any other text, closed by a footer naming the
|
|
172
|
-
// agent, the model and the time ("Build · GLM-5.3 · 7.0s"). A sidebar
|
|
173
|
-
// can share the rows on the right.
|
|
174
|
-
name: 'opencode',
|
|
175
|
-
programs: ['opencode'],
|
|
176
|
-
measured: 'OpenCode 2.0.26',
|
|
177
|
-
composer: { text: '^ {2}[┃╹]' },
|
|
178
|
-
chrome: [{ text: '^ {2}┃' }, { text: '^\\s{60,}\\S' }],
|
|
179
|
-
busy: [
|
|
180
|
-
{ text: '\\besc interrupt\\b' },
|
|
181
|
-
{ text: '^ {3,}[⠀-⣿] ' },
|
|
182
|
-
{ text: '^ {3,}\\+ Thought\\s*$' },
|
|
183
|
-
],
|
|
184
|
-
turn: { text: '^ {2}┃ {2}\\S' },
|
|
185
|
-
answer: {
|
|
186
|
-
start: { text: '^ {5}[^\\s→+⠀-⣿]', lead: { fg: ['default', '#eeeeee', '#ffffff', '#000000'] } },
|
|
187
|
-
continues: { text: '^ {5}[^\\s→+⠀-⣿]', lead: { fg: ['default', '#eeeeee', '#ffffff', '#000000'] } },
|
|
188
|
-
upward: true,
|
|
189
|
-
},
|
|
190
|
-
trailer: { text: '^ {5}\\S+ · [^·]+ · \\d[\\d.]*m?s\\b' },
|
|
191
|
-
requireTrailer: true,
|
|
192
|
-
// The sidebar, on the same rows to the right.
|
|
193
|
-
tidy: ' {20,}\\S.*$',
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
// MiMoCode 0.1.16 (MiMo-V2.6-Pro), built from OpenCode: no reasoning text
|
|
197
|
-
// is drawn. A collapsed "+ Thought: Ns" sits before each tool group and
|
|
198
|
-
// before the answer; tool calls are boxes behind a bar drawn in the
|
|
199
|
-
// background colour, the person's prompt and the composer behind one in
|
|
200
|
-
// the agent's colour. The answer is plain paragraphs closed by "▣ Build ·
|
|
201
|
-
// MiMo-V2.6-Pro · Ns", which carries no time while the turn runs. A side
|
|
202
|
-
// panel on the right shares the rows (the session's title, context and
|
|
203
|
-
// cost). The composer can hold a suggestion of its own after a turn.
|
|
204
|
-
name: 'mimo',
|
|
205
|
-
programs: ['mimo', 'mimocode', 'mimo-code'],
|
|
206
|
-
measured: 'MiMoCode 0.1.16',
|
|
207
|
-
composer: { text: '^ {2}[┃╹]' },
|
|
208
|
-
chrome: [{ text: '^ {2}┃' }, { text: '^\\s{60,}\\S' }],
|
|
209
|
-
busy: [
|
|
210
|
-
{ text: '\\besc (?:to )?interrupt\\b' },
|
|
211
|
-
{ text: '^ {5}▣ {2}\\S+ · [^·]+?\\s*(?:[⎘█].*)?$' },
|
|
212
|
-
{ text: '^ {3,}[⠀-⣿] ' },
|
|
213
|
-
],
|
|
214
|
-
turn: { text: '^ {2}┃ {2}\\S', lead: { notFg: ['#0a0a0a'] } },
|
|
215
|
-
answer: {
|
|
216
|
-
start: { text: '^ {5}[^\\s→+⠀-⣿▣]' },
|
|
217
|
-
continues: { text: '^ {5}[^\\s→+⠀-⣿▣]' },
|
|
218
|
-
upward: true,
|
|
219
|
-
},
|
|
220
|
-
trailer: { text: '^ {5}▣ {2}\\S+ · [^·]+ · \\d' },
|
|
221
|
-
requireTrailer: true,
|
|
222
|
-
// The scrollbar, the side panel and the copy button, on the same rows.
|
|
223
|
-
tidy: '\\s+[⎘█].*$',
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
// Qoder CLI 1.1.80 (GLM-5.3), default thinking: a "Thinking" heading in
|
|
227
|
-
// italics, then the reasoning behind a grey "│" bar in grey italics, as
|
|
228
|
-
// the model works and after it has answered. Messages start with a "▪"
|
|
229
|
-
// in the text colour, tool calls with a green one. While a turn runs, a
|
|
230
|
-
// braille spinner line says "(esc to cancel, Ns)".
|
|
231
|
-
name: 'qoder',
|
|
232
|
-
programs: ['qodercli', 'qoder'],
|
|
233
|
-
measured: 'Qoder CLI 1.1.80',
|
|
234
|
-
composer: { text: '^ > ' },
|
|
235
|
-
// The placeholder ("Type your message or @path/to/file") is grey; typed text is not.
|
|
236
|
-
typed: { text: '^ > ', word: { notFg: ['#95958f'] } },
|
|
237
|
-
chrome: [
|
|
238
|
-
{ text: RULE_INDENTED },
|
|
239
|
-
{ text: 'Shift\\+Tab' },
|
|
240
|
-
{ text: '\\? for shortcuts\\s*$' },
|
|
241
|
-
{ text: '\\(esc to cancel' },
|
|
242
|
-
],
|
|
243
|
-
frame: { text: RULE_INDENTED },
|
|
244
|
-
busy: [{ text: '\\(esc to cancel' }],
|
|
245
|
-
turn: { text: '^ > \\S' },
|
|
246
|
-
reasoning: [
|
|
247
|
-
// The bar by its text alone: a code span or a table inside the
|
|
248
|
-
// reasoning is drawn upright, and an upright line is still reasoning.
|
|
249
|
-
{
|
|
250
|
-
start: { text: '^ Thinking\\s*$', lead: { italic: true } },
|
|
251
|
-
continues: { text: '^ │( |$)' },
|
|
252
|
-
},
|
|
253
|
-
// The same bar on its own: the heading may have scrolled away.
|
|
254
|
-
{
|
|
255
|
-
start: { text: '^ │ ' },
|
|
256
|
-
continues: { text: '^ │( |$)' },
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
answer: {
|
|
260
|
-
start: { text: '^ ▪ ', lead: { fg: ['default', '#eeeeeb', '#ffffff', '#000000'] } },
|
|
261
|
-
continues: { text: '^ {3}[^\\s└│]' },
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
// Muse Code 1.4.14. A completed answer is a bold ◆ block. Tool calls
|
|
266
|
-
// use a green ◆, and the live reasoning summary uses a grey ◆. The
|
|
267
|
-
// composer is the last ❯ row followed only by chrome, with or without
|
|
268
|
-
// typed text. Submitted turns sit above it. The Muse Code banner
|
|
269
|
-
// sits above the transcript, and the status line ending in Launch overrides
|
|
270
|
-
// sits below the composer. A
|
|
271
|
-
// finished turn may have no Worked for line.
|
|
272
|
-
name: 'muse',
|
|
273
|
-
programs: ['muse', 'muse-bin-*'],
|
|
274
|
-
measured: 'Muse Code 1.4.14',
|
|
275
|
-
composer: { text: '^❯(?:\\s*$| \\S)' },
|
|
276
|
-
typed: { text: '^❯ \\S', body: { dim: false, fg: ['#ccd3db'] } },
|
|
277
|
-
chrome: [{ text: '^── Voice input \\(Alt\\+V to start\\)' }, { text: RULE }],
|
|
278
|
-
frame: { text: RULE },
|
|
279
|
-
busy: [
|
|
280
|
-
{ text: '^[◇◈◆] .*esc to interrupt\\)' },
|
|
281
|
-
{ text: '^└ (?:Hooks running|last event|Meta Model )' },
|
|
282
|
-
],
|
|
283
|
-
turn: { text: '^❯ \\S' },
|
|
284
|
-
reasoning: [{
|
|
285
|
-
start: { text: '^◆ (?!Worked for )', lead: { fg: ['#676c74'] } },
|
|
286
|
-
continues: { text: '^ {2}(?![◆◇◈❯])\\S', lead: { fg: ['#676c74', '#8a9098'] } },
|
|
287
|
-
}],
|
|
288
|
-
answer: {
|
|
289
|
-
start: { text: '^◆ (?!Worked for |(?:Wrote|Ran command|Write)\\b)', lead: { bold: true, fg: ['#ccd3db'] } },
|
|
290
|
-
continues: { text: '^ {2}\\S', lead: { fg: ['#ccd3db'] } },
|
|
291
|
-
upward: true,
|
|
292
|
-
},
|
|
293
|
-
trailer: { text: '^◆ Worked for ' },
|
|
294
|
-
},
|
|
295
|
-
];
|
|
43
|
+
export { BUILT_IN_SIGNATURES } from '../agents/index.js';
|
|
296
44
|
export { SET_ASIDE_MS };
|
|
297
45
|
/** Whether a signature is set aside for running past its time budget just now. */
|
|
298
46
|
export function setAside(signature, now = Date.now()) {
|
|
@@ -472,20 +220,15 @@ export function useAgentSignatures(extra, onOverBudget = () => undefined) {
|
|
|
472
220
|
reportOverBudget = onOverBudget;
|
|
473
221
|
return problems;
|
|
474
222
|
}
|
|
223
|
+
/** Resolve identity once, independently of a reading pattern's temporary time budget. */
|
|
224
|
+
export function resolveSessionAgent(agent, command) {
|
|
225
|
+
return resolveAgent(agent, command, active);
|
|
226
|
+
}
|
|
475
227
|
/** The names `terminal_start`'s `agent` accepts. */
|
|
476
228
|
export function agentNames() {
|
|
477
229
|
return active.map((s) => s.name).sort();
|
|
478
230
|
}
|
|
479
|
-
|
|
480
|
-
export function programName(command) {
|
|
481
|
-
const base = command.split(/[\\/]/).pop() ?? command;
|
|
482
|
-
return base.replace(/\.(exe|cmd|bat|ps1|com)$/i, '').toLowerCase();
|
|
483
|
-
}
|
|
484
|
-
/** A versioned Muse executable has a changing suffix after muse-bin-. */
|
|
485
|
-
function claimsProgram(signature, program) {
|
|
486
|
-
return signature.programs.includes(program) ||
|
|
487
|
-
(signature.programs.includes('muse-bin-*') && /^muse-bin-\d+(?:\.\d+)*(?:[-+][a-z0-9]+(?:[.-][a-z0-9]+)*)?$/.test(program));
|
|
488
|
-
}
|
|
231
|
+
export { programName } from '../agents/index.js';
|
|
489
232
|
/**
|
|
490
233
|
* The agent a session runs as, by name: the one it was started as, or the one
|
|
491
234
|
* whose programs include its start command. The signatures are compiled and
|
|
@@ -511,12 +254,16 @@ export function agentNameFor(agent, command, extra = []) {
|
|
|
511
254
|
* The signature for a session: the agent it was started as, or the one whose
|
|
512
255
|
* programs include its start command. Null when neither names one.
|
|
513
256
|
*/
|
|
514
|
-
export function signatureFor(agent, command) {
|
|
257
|
+
export function signatureFor(agent, command = '') {
|
|
515
258
|
if (agent !== undefined)
|
|
516
259
|
return active.find((s) => s.name === agent && !setAside(s)) ?? null;
|
|
517
260
|
const program = programName(command);
|
|
518
261
|
return active.find((s) => !setAside(s) && claimsProgram(s, program)) ?? null;
|
|
519
262
|
}
|
|
263
|
+
/** A fallback identity must not select a configured reading named generic. */
|
|
264
|
+
export function signatureForSession(session) {
|
|
265
|
+
return session.agentSource === 'fallback' ? null : signatureFor(session.agent);
|
|
266
|
+
}
|
|
520
267
|
// ---------------------------------------------------------------- matching
|
|
521
268
|
/** A row that holds nothing but whitespace and box drawing: border, not text. */
|
|
522
269
|
const BORDER_ROW = /^[\s─-╿-]*$/u;
|
|
@@ -556,6 +303,11 @@ function lineFits(line, test) {
|
|
|
556
303
|
return false;
|
|
557
304
|
if (test.lead === undefined && test.body === undefined && test.word === undefined)
|
|
558
305
|
return true;
|
|
306
|
+
if (test.lead !== undefined && test.body === undefined && test.word === undefined) {
|
|
307
|
+
const first = line.text.search(/\S/u);
|
|
308
|
+
const style = line.spans.find(span => span.from <= first && span.to > first);
|
|
309
|
+
return style !== undefined && styleFits(style, test.lead);
|
|
310
|
+
}
|
|
559
311
|
const ink = inkStyles(line);
|
|
560
312
|
if (ink.length === 0)
|
|
561
313
|
return false;
|
|
@@ -631,32 +383,10 @@ function guarded(signature, body) {
|
|
|
631
383
|
function composerAt(lines, signature) {
|
|
632
384
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
633
385
|
const candidate = lines[i];
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
signature.composer.text?.test(candidate.text) === true &&
|
|
638
|
-
lines.slice(Math.max(0, i - 2), i).some((line) => /^── Voice input \(Alt\+V to start\)/.test(line.text));
|
|
639
|
-
if (!lineFits(candidate, signature.composer) && !wrappedMuseComposer)
|
|
386
|
+
const composerRule = moduleFor(signature.name)?.readingRules?.composer;
|
|
387
|
+
if (!(composerRule === undefined ? lineFits(candidate, signature.composer) :
|
|
388
|
+
composerRule(lines, i, signature, readingContext)))
|
|
640
389
|
continue;
|
|
641
|
-
if (signature.name === 'muse') {
|
|
642
|
-
let inComposerBody = true;
|
|
643
|
-
const tailIsChrome = lines.slice(i + 1).every((line) => {
|
|
644
|
-
if (line.text.trim() === '')
|
|
645
|
-
return true;
|
|
646
|
-
if (/^[─━]{10,}$/.test(line.text)) {
|
|
647
|
-
inComposerBody = false;
|
|
648
|
-
return true;
|
|
649
|
-
}
|
|
650
|
-
if (/· Launch overrides\s*$/.test(line.text))
|
|
651
|
-
return true;
|
|
652
|
-
// Muse indents later rows of a typed composer. Their text keeps the
|
|
653
|
-
// ordinary foreground, unlike the grey hint or status line.
|
|
654
|
-
return inComposerBody && /^ {2}\S/.test(line.text) &&
|
|
655
|
-
inkStyles(line).every((style) => style.fg === '#ccd3db');
|
|
656
|
-
});
|
|
657
|
-
if (!tailIsChrome)
|
|
658
|
-
continue;
|
|
659
|
-
}
|
|
660
390
|
// Reasoning is never drawn below the composer. A line with reasoning under
|
|
661
391
|
// it is the echo of the person's prompt, taken for the composer while a
|
|
662
392
|
// dialog stands in its place: no composer is found, so the filter reads
|
|
@@ -702,17 +432,20 @@ function enclosedByReasoning(lines, signature, first, last) {
|
|
|
702
432
|
* stays reasoning too.
|
|
703
433
|
*/
|
|
704
434
|
function claimedRows(lines, signature, prompt) {
|
|
705
|
-
if (prompt ===
|
|
435
|
+
if (prompt?.basis === 'question' && enclosedByReasoning(lines, signature, ...prompt.rows))
|
|
706
436
|
return null;
|
|
707
|
-
const
|
|
708
|
-
|
|
437
|
+
const claim = moduleFor(signature.name)?.readingRules?.claimPromptRows?.(lines, prompt);
|
|
438
|
+
const bounds = prompt?.rows ?? claim;
|
|
439
|
+
if (!bounds)
|
|
709
440
|
return null;
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
bottom
|
|
441
|
+
const [first, last] = bounds;
|
|
442
|
+
let [top, bottom] = claim ?? bounds;
|
|
443
|
+
if (!claim) {
|
|
444
|
+
while (top > 0 && BORDER_ROW.test(lines[top - 1].text))
|
|
445
|
+
top--;
|
|
446
|
+
while (bottom + 1 < lines.length && BORDER_ROW.test(lines[bottom + 1].text))
|
|
447
|
+
bottom++;
|
|
448
|
+
}
|
|
716
449
|
const rows = new Set();
|
|
717
450
|
for (let i = top; i <= bottom; i++) {
|
|
718
451
|
// A one-line reasoning summary drawn between the question and the last
|
|
@@ -778,7 +511,7 @@ export function hideReasoning(lines, signature, firstVisible = 0) {
|
|
|
778
511
|
// no reasoning rules can hide nothing, so the detector is not run. Dialog
|
|
779
512
|
// signatures are the only patterns the detector times (`dialogs.ts`); its
|
|
780
513
|
// own patterns are not.
|
|
781
|
-
const detected = signature.reasoning.length === 0 ? null : detectPrompt(lines.map((line) => line.wrapped ? '' : line.text).join('\n'));
|
|
514
|
+
const detected = signature.reasoning.length === 0 ? null : detectPrompt(lines.map((line) => line.wrapped ? '' : line.text).join('\n'), signature.name);
|
|
782
515
|
return guarded(signature, () => {
|
|
783
516
|
const claimed = claimedRows(lines, signature, detected);
|
|
784
517
|
// Everything above the composer's own line, the chrome over it included:
|
|
@@ -838,11 +571,12 @@ export function resultRefusal(reason) {
|
|
|
838
571
|
* reasoning block; nothing else is ever returned in its place.
|
|
839
572
|
*/
|
|
840
573
|
export function latestResult(lines, signature) {
|
|
574
|
+
lines = moduleFor(signature.name)?.readingRules?.contentRegion?.(lines) ?? lines;
|
|
841
575
|
const result = guarded(signature, () => {
|
|
842
576
|
const composer = composerAt(lines, signature);
|
|
843
577
|
if (composer === null) {
|
|
844
|
-
const
|
|
845
|
-
return { found: false, reason:
|
|
578
|
+
const busy = moduleFor(signature.name)?.readingRules?.busyWithoutComposer === true && lines.some((line) => signature.busy.some((test) => lineFits(line, test)));
|
|
579
|
+
return { found: false, reason: busy ? 'busy' : 'no-composer', status: [] };
|
|
846
580
|
}
|
|
847
581
|
const status = lines
|
|
848
582
|
.slice(composer.line + 1)
|
|
@@ -861,30 +595,8 @@ export function latestResult(lines, signature) {
|
|
|
861
595
|
}
|
|
862
596
|
// A spinner can be drawn in the latest turn or the chrome under it;
|
|
863
597
|
// a stale copy in the scrollback above says nothing.
|
|
864
|
-
|
|
865
|
-
if (signature.name !== 'muse' && signature.busy.some((test) => current.some((line) => lineFits(line, test)))) {
|
|
866
|
-
return { found: false, reason: 'busy', status };
|
|
867
|
-
}
|
|
868
|
-
let lastBusy = -1;
|
|
869
|
-
if (signature.name === 'muse') {
|
|
870
|
-
for (let i = lines.length - 1; i >= turnStart; i--) {
|
|
871
|
-
if (signature.busy.some((test) => lineFits(lines[i], test))) {
|
|
872
|
-
lastBusy = i;
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
// Muse can retain an activity row above a finished answer. Only a later
|
|
878
|
-
// answer before the composer makes that row historical.
|
|
879
|
-
let museAnswerAfterBusy = false;
|
|
880
|
-
if (signature.name === 'muse' && lastBusy >= 0) {
|
|
881
|
-
const ranges = reasoningRanges(lines, signature, composer.chrome);
|
|
882
|
-
const inReasoning = (i) => ranges.some(([from, to]) => i >= from && i < to);
|
|
883
|
-
museAnswerAfterBusy = lines.slice(lastBusy + 1, composer.chrome).some((line, offset) => !inReasoning(lastBusy + 1 + offset) && lineFits(line, signature.answer.start));
|
|
884
|
-
}
|
|
885
|
-
if (lastBusy >= 0 && !museAnswerAfterBusy) {
|
|
598
|
+
if (turnBusy(lines, signature, turnStart, composer.chrome))
|
|
886
599
|
return { found: false, reason: 'busy', status };
|
|
887
|
-
}
|
|
888
600
|
if (signature.typed !== undefined) {
|
|
889
601
|
for (let i = composer.chrome; i <= composer.line; i++) {
|
|
890
602
|
if (lineFits(lines[i], signature.typed))
|
|
@@ -930,4 +642,539 @@ export function latestResult(lines, signature) {
|
|
|
930
642
|
});
|
|
931
643
|
return result ?? { found: false, reason: 'over-budget', status: [] };
|
|
932
644
|
}
|
|
645
|
+
const readingContext = { matches: lineFits, ink: inkStyles, ranges: reasoningRanges };
|
|
646
|
+
/** Shared turn boundary and busy rules for result reading and stall detection. */
|
|
647
|
+
function turnBusy(lines, signature, turnStart, chrome) {
|
|
648
|
+
const rule = moduleFor(signature.name)?.readingRules?.busy;
|
|
649
|
+
return rule === undefined
|
|
650
|
+
? signature.busy.some(test => lines.slice(turnStart).some(line => lineFits(line, test)))
|
|
651
|
+
: rule(lines, turnStart, chrome, signature, readingContext);
|
|
652
|
+
}
|
|
653
|
+
export const STALL_SETTLE_MS = 1000;
|
|
654
|
+
/** The same candidate must survive settling; input suppresses old refusal screens. */
|
|
655
|
+
export class StallTracker {
|
|
656
|
+
candidate = null;
|
|
657
|
+
since = 0;
|
|
658
|
+
suppressed = null;
|
|
659
|
+
state;
|
|
660
|
+
/** A candidate has been recognised and may still be settling. */
|
|
661
|
+
get tracking() { return this.candidate !== null; }
|
|
662
|
+
/** Includes a recognised candidate that has not yet settled. */
|
|
663
|
+
get reason() { return this.candidate?.reason ?? this.state?.reason; }
|
|
664
|
+
matchesBlock(candidate) {
|
|
665
|
+
return candidate !== null && this.candidate?.blockIdentity === candidate.blockIdentity;
|
|
666
|
+
}
|
|
667
|
+
/** Changed rendered content ends this observation, without undoing input suppression. */
|
|
668
|
+
invalidate() {
|
|
669
|
+
this.candidate = null;
|
|
670
|
+
this.state = undefined;
|
|
671
|
+
}
|
|
672
|
+
noteInput() {
|
|
673
|
+
if (this.reason === 'server-lost')
|
|
674
|
+
return;
|
|
675
|
+
this.suppressed = this.candidate?.blockIdentity ?? this.suppressed;
|
|
676
|
+
this.candidate = null;
|
|
677
|
+
this.state = undefined;
|
|
678
|
+
}
|
|
679
|
+
observe(candidate, now = Date.now()) {
|
|
680
|
+
// Discovery needs the complete user turn. Once established, its text is
|
|
681
|
+
// layout-sensitive: only the validated refusal and footer identify it.
|
|
682
|
+
// Input suppression uses that same block across user-text redraws.
|
|
683
|
+
if (this.state !== undefined && this.matchesBlock(candidate))
|
|
684
|
+
return this.state;
|
|
685
|
+
if (candidate !== null && 'inconclusive' in candidate) {
|
|
686
|
+
// Missing context cannot discover or finish settling a new refusal.
|
|
687
|
+
this.invalidate();
|
|
688
|
+
return undefined;
|
|
689
|
+
}
|
|
690
|
+
if (candidate === null)
|
|
691
|
+
this.suppressed = null;
|
|
692
|
+
if (candidate === null || candidate.blockIdentity === this.suppressed) {
|
|
693
|
+
this.candidate = null;
|
|
694
|
+
this.state = undefined;
|
|
695
|
+
return undefined;
|
|
696
|
+
}
|
|
697
|
+
if (this.candidate?.identity !== candidate.identity) {
|
|
698
|
+
this.candidate = candidate;
|
|
699
|
+
this.since = now;
|
|
700
|
+
this.state = undefined;
|
|
701
|
+
}
|
|
702
|
+
if (now - this.since >= STALL_SETTLE_MS) {
|
|
703
|
+
this.state ??= { reason: candidate.reason, description: candidate.description, since: new Date(this.since).toISOString() };
|
|
704
|
+
}
|
|
705
|
+
return this.state;
|
|
706
|
+
}
|
|
707
|
+
remaining(now = Date.now()) {
|
|
708
|
+
return this.candidate === null || this.state !== undefined ? null : Math.max(1, this.since + STALL_SETTLE_MS - now);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const compiledStalls = new WeakMap();
|
|
712
|
+
function stallTests(shape) {
|
|
713
|
+
let tests = compiledStalls.get(shape);
|
|
714
|
+
if (tests === undefined) {
|
|
715
|
+
tests = {
|
|
716
|
+
before: compileLine(shape.before, 'stall.before'),
|
|
717
|
+
rows: shape.rows.map(row => compileLine(row, 'stall.rows')),
|
|
718
|
+
footer: compileLine(shape.footer, 'stall.footer'),
|
|
719
|
+
composer: compileLine(shape.composer, 'stall.composer'),
|
|
720
|
+
composerStatus: shape.composerStatus === undefined ? undefined : compileLine(shape.composerStatus, 'stall.composerStatus'),
|
|
721
|
+
chrome: shape.chrome.map(row => compileLine(row, 'stall.chrome')),
|
|
722
|
+
idle: shape.idle.map(row => compileLine(row, 'stall.idle')),
|
|
723
|
+
idleClipped: shape.idleClipped === undefined ? undefined : compileLine(shape.idleClipped.row, 'stall.idleClipped'),
|
|
724
|
+
bottom: shape.bottom.map(row => compileLine(row, 'stall.bottom')),
|
|
725
|
+
};
|
|
726
|
+
compiledStalls.set(shape, tests);
|
|
727
|
+
}
|
|
728
|
+
return tests;
|
|
729
|
+
}
|
|
730
|
+
/** Cheap viewport comparison; cursor, styles and known controls are not output. */
|
|
731
|
+
function stallScreenFrame(lines, shapes) {
|
|
732
|
+
const framed = stallRegion(lines, shapes);
|
|
733
|
+
const composer = stallComposer(framed, shapes);
|
|
734
|
+
let footer = (composer?.chrome ?? 0) - 1;
|
|
735
|
+
while (footer >= 0 && blank(framed[footer]))
|
|
736
|
+
footer--;
|
|
737
|
+
const content = framed.map((row, index) => {
|
|
738
|
+
let line = row.text;
|
|
739
|
+
for (const shape of shapes) {
|
|
740
|
+
if (index === footer && shape.cosmetic !== undefined)
|
|
741
|
+
line = line.replace(shape.cosmetic, '$1');
|
|
742
|
+
}
|
|
743
|
+
return line.trimEnd();
|
|
744
|
+
}).join('\n').trimEnd();
|
|
745
|
+
return { content, footer: framed.length === lines.length ? footer : -1 };
|
|
746
|
+
}
|
|
747
|
+
export function stallScreenContent(lines, shapes) {
|
|
748
|
+
return stallScreenFrame(lines, shapes).content;
|
|
749
|
+
}
|
|
750
|
+
/** Cache physical semantic rows; a repaint usually changes only a control. */
|
|
751
|
+
export class StallScreenCache {
|
|
752
|
+
lines = [];
|
|
753
|
+
shapes;
|
|
754
|
+
footer = -1;
|
|
755
|
+
semantic = '';
|
|
756
|
+
content(lines, shapes) {
|
|
757
|
+
if (shapes === this.shapes && lines.length === this.lines.length) {
|
|
758
|
+
let changed = -1;
|
|
759
|
+
for (let i = 0; i < lines.length; i++) {
|
|
760
|
+
if (lines[i] === this.lines[i])
|
|
761
|
+
continue;
|
|
762
|
+
if (changed !== -1) {
|
|
763
|
+
changed = -2;
|
|
764
|
+
break;
|
|
765
|
+
}
|
|
766
|
+
changed = i;
|
|
767
|
+
}
|
|
768
|
+
if (changed === -1)
|
|
769
|
+
return this.semantic;
|
|
770
|
+
if (changed >= 0 && changed === this.footer) {
|
|
771
|
+
const normalise = (line) => {
|
|
772
|
+
for (const shape of shapes)
|
|
773
|
+
line = line.replace(shape.cosmetic ?? /$^/u, '$1');
|
|
774
|
+
return line.trimEnd();
|
|
775
|
+
};
|
|
776
|
+
// The composer, its gutter run and any panel dividers are unchanged.
|
|
777
|
+
// Only a control on the already framed footer may skip that walk.
|
|
778
|
+
// All other row changes, including a moved footer, re-establish it.
|
|
779
|
+
if (normalise(lines[changed]) === normalise(this.lines[changed])) {
|
|
780
|
+
this.lines[changed] = lines[changed];
|
|
781
|
+
return this.semantic;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
const frame = stallScreenFrame(lines, shapes);
|
|
786
|
+
this.lines = [...lines];
|
|
787
|
+
this.shapes = shapes;
|
|
788
|
+
this.footer = frame.footer;
|
|
789
|
+
this.semantic = frame.content;
|
|
790
|
+
return this.semantic;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function stallRegion(lines, shapes) {
|
|
794
|
+
let rows = lines.map(line => typeof line === 'string' ? { text: line, spans: [] } : line);
|
|
795
|
+
const applied = new Set();
|
|
796
|
+
for (const shape of shapes) {
|
|
797
|
+
if (shape.contentRegion !== undefined && !applied.has(shape.contentRegion)) {
|
|
798
|
+
rows = shape.contentRegion(rows);
|
|
799
|
+
applied.add(shape.contentRegion);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return rows;
|
|
803
|
+
}
|
|
804
|
+
function stallComposer(lines, shapes, partial = false) {
|
|
805
|
+
for (let line = lines.length - 1; line >= 0; line--) {
|
|
806
|
+
const complete = shapes.some(shape => shape.overlay === undefined && lineFits(lines[line], stallTests(shape).composer));
|
|
807
|
+
// A native redraw may replace the closing edge with one gutter row. The
|
|
808
|
+
// independently styled mode row and preceding input gutter still establish
|
|
809
|
+
// ownership, but never prove a complete composer for discovery.
|
|
810
|
+
if (!complete && !(partial && line > 1 && shapes.some(shape => {
|
|
811
|
+
if (shape.overlay !== undefined)
|
|
812
|
+
return false;
|
|
813
|
+
const tests = stallTests(shape);
|
|
814
|
+
return tests.composerStatus !== undefined && lineFits(lines[line - 1], tests.composerStatus) &&
|
|
815
|
+
tests.chrome.some(test => lineFits(lines[line - 2], test)) &&
|
|
816
|
+
(blank(lines[line]) || tests.chrome.some(test => lineFits(lines[line], test)));
|
|
817
|
+
})))
|
|
818
|
+
continue;
|
|
819
|
+
let chrome = line;
|
|
820
|
+
// Use the owning module's reading walk, with no broad tidy expression.
|
|
821
|
+
while (chrome > 0 && (blank(lines[chrome - 1]) ||
|
|
822
|
+
shapes.some(shape => shape.overlay === undefined && stallTests(shape).chrome.some(test => {
|
|
823
|
+
const above = lines[chrome - 1];
|
|
824
|
+
// Unstyled rows serve only the cosmetic cache and suggestion hint.
|
|
825
|
+
// Validation and transcript ownership always supply gutter ink.
|
|
826
|
+
return lineFits(above, above.spans.length === 0 ? { text: test.text } : test);
|
|
827
|
+
}))))
|
|
828
|
+
chrome--;
|
|
829
|
+
return { line, chrome };
|
|
830
|
+
}
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Cheap evidence of new transcript text, using the module's presentation rules.
|
|
835
|
+
* Text that could be idle chrome is left for styled validation, never accepted
|
|
836
|
+
* as proof of an idle composer here. The caller supplies joined terminal wraps.
|
|
837
|
+
*/
|
|
838
|
+
export function stallTranscriptContent(lines, shapes, signature) {
|
|
839
|
+
const content = stallRegion(lines, shapes);
|
|
840
|
+
// The modal owns the busy screen beneath it. Its animated title is not new
|
|
841
|
+
// transcript output; loss of the modal is checked on the next frame.
|
|
842
|
+
if (shapes.some(shape => shape.overlay !== undefined && content.some(line => stallMarker(line.text, shape))))
|
|
843
|
+
return '';
|
|
844
|
+
const composer = stallComposer(content, shapes, true);
|
|
845
|
+
const omitted = new Set();
|
|
846
|
+
const limit = composer?.chrome ?? content.length;
|
|
847
|
+
let turnStart = 0;
|
|
848
|
+
if (signature?.turn !== undefined)
|
|
849
|
+
for (let i = limit - 1; i >= 0; i--) {
|
|
850
|
+
if (lineFits(content[i], signature.turn)) {
|
|
851
|
+
turnStart = i + 1;
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
for (const shape of shapes) {
|
|
856
|
+
if (shape.overlay !== undefined)
|
|
857
|
+
continue;
|
|
858
|
+
const tests = stallTests(shape);
|
|
859
|
+
// Only the error-ink gutter run immediately before the completed footer
|
|
860
|
+
// owns these rows. The same words elsewhere remain transcript output.
|
|
861
|
+
let footer = limit - 1;
|
|
862
|
+
while (footer >= turnStart && blank(content[footer]))
|
|
863
|
+
footer--;
|
|
864
|
+
let end = footer;
|
|
865
|
+
let completed = false;
|
|
866
|
+
if (footer >= turnStart) {
|
|
867
|
+
const text = content[footer].text.replace(shape.cosmetic ?? /$^/u, '$1');
|
|
868
|
+
if (tests.footer.text?.test(text)) {
|
|
869
|
+
completed = true;
|
|
870
|
+
omitted.add(footer);
|
|
871
|
+
end--;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
while (end >= turnStart && blank(content[end]))
|
|
875
|
+
end--;
|
|
876
|
+
let start = end;
|
|
877
|
+
const lead = tests.rows[0]?.lead;
|
|
878
|
+
while (start >= turnStart) {
|
|
879
|
+
const row = content[start];
|
|
880
|
+
if (row.text.trim() !== '' && !(lead !== undefined && lineFits(row, { text: signature?.chrome[0]?.text, lead })))
|
|
881
|
+
break;
|
|
882
|
+
start--;
|
|
883
|
+
}
|
|
884
|
+
if (start < end) {
|
|
885
|
+
for (let i = start + 1; i <= end; i++)
|
|
886
|
+
omitted.add(i);
|
|
887
|
+
// The gutter still owns its block when the footer is temporarily gone.
|
|
888
|
+
// Its introduction is the preceding paragraph, not a phrase elsewhere.
|
|
889
|
+
if (start >= turnStart)
|
|
890
|
+
omitted.add(start);
|
|
891
|
+
}
|
|
892
|
+
else if (completed && end >= turnStart && footer - end - 1 >= tests.rows.length &&
|
|
893
|
+
lineFits(content[end], tests.before)) {
|
|
894
|
+
// Erasure can leave the introduction above the now-empty error slots.
|
|
895
|
+
// The completed footer and those module-sized slots retain ownership;
|
|
896
|
+
// full validation still confirms the missing ink. A new paragraph after
|
|
897
|
+
// a surviving error block leaves that block in the comparison and clears.
|
|
898
|
+
omitted.add(end);
|
|
899
|
+
}
|
|
900
|
+
if (composer !== null) {
|
|
901
|
+
for (let i = composer.chrome; i <= composer.line; i++) {
|
|
902
|
+
const row = content[i];
|
|
903
|
+
// Suggestion ink belongs to the framed input row, including its
|
|
904
|
+
// terminal wraps. Physical-row text equality cannot establish that.
|
|
905
|
+
const presentation = tests.idle.some(test => test.body !== undefined &&
|
|
906
|
+
lineFits(row, { lead: test.lead, body: test.body }));
|
|
907
|
+
if (tests.idle.some(test => test.text?.test(row.text)) || presentation || blank(row))
|
|
908
|
+
omitted.add(i);
|
|
909
|
+
}
|
|
910
|
+
for (let n = 0; n < tests.bottom.length; n++) {
|
|
911
|
+
const i = composer.line + 1 + n;
|
|
912
|
+
if (content[i] !== undefined && lineFits(content[i], tests.bottom[n]))
|
|
913
|
+
omitted.add(i);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return content.slice(turnStart).filter((_, index) => !omitted.has(index + turnStart))
|
|
918
|
+
.map(line => line.text.trimEnd()).filter(text => text !== '').join('\n');
|
|
919
|
+
}
|
|
920
|
+
/** A clipped viewport cannot prove that a changed transcript is new output. */
|
|
921
|
+
export function stallTurnVisible(lines, shapes, signature) {
|
|
922
|
+
if (signature.turn === undefined)
|
|
923
|
+
return true;
|
|
924
|
+
const content = stallRegion(lines, shapes);
|
|
925
|
+
const limit = stallComposer(content, shapes, true)?.chrome ?? content.length;
|
|
926
|
+
return content.slice(0, limit).some(line => lineFits(line, signature.turn));
|
|
927
|
+
}
|
|
928
|
+
/** Reject ordinary screens before styled context and prompt detection. */
|
|
929
|
+
export function possibleStall(lines, signature) {
|
|
930
|
+
if (setAside(signature))
|
|
931
|
+
return false;
|
|
932
|
+
const shapes = moduleFor(signature.name)?.stalls;
|
|
933
|
+
// This hint uses only module-owned marker and closing-edge rules. No
|
|
934
|
+
// configured pattern runs here; full validation retains its regex budget.
|
|
935
|
+
if (!shapes?.some(shape => lines.some(line => stallMarker(line, shape))))
|
|
936
|
+
return false;
|
|
937
|
+
if (shapes.some(shape => shape.overlay !== undefined && lines.some(line => stallMarker(line, shape))))
|
|
938
|
+
return true;
|
|
939
|
+
// Busy rules run within the turn during validation. Testing the entire
|
|
940
|
+
// viewport here would also reject an ordinary user echo quoting a rule.
|
|
941
|
+
return shapes.some(shape => {
|
|
942
|
+
if (!lines.some(line => stallMarker(line, shape)))
|
|
943
|
+
return false;
|
|
944
|
+
// Stall closing edges are narrower than the reading composer's rule.
|
|
945
|
+
const test = stallTests(shape).composer;
|
|
946
|
+
return test.text !== undefined && lines.some(line => test.text.test(line));
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
function stallMarker(line, shape) {
|
|
950
|
+
const text = line.trimEnd();
|
|
951
|
+
return typeof shape.marker.text === 'string' ? text === shape.marker.text : shape.marker.text.test(text);
|
|
952
|
+
}
|
|
953
|
+
/** Keep the physical origin for visibility, but match soft wraps as one line. */
|
|
954
|
+
function logicalStallLines(physical, shapes) {
|
|
955
|
+
const lines = [];
|
|
956
|
+
const starts = [];
|
|
957
|
+
for (let i = 0; i < physical.length; i++) {
|
|
958
|
+
const row = physical[i];
|
|
959
|
+
const previous = lines.at(-1);
|
|
960
|
+
// A captured full-width MiMo footer makes xterm mark subsequent, separately
|
|
961
|
+
// painted interface rows as wraps. Their own styled anchors restore the
|
|
962
|
+
// boundaries; ordinary wrapped transcript text is still joined.
|
|
963
|
+
const frameAnchor = /^ {2}[┃╹]/u.test(row.text);
|
|
964
|
+
const footerAnchor = /^ {5}▣ {2}Build · /u.test(row.text);
|
|
965
|
+
const first = frameAnchor ? 2 : footerAnchor ? 5 : -1;
|
|
966
|
+
const firstInk = first < 0 ? undefined : row.spans.find(span => span.from <= first && span.to > first)?.fg;
|
|
967
|
+
const framed = frameAnchor && (firstInk === '#fb8147' || firstInk === '#ff8040');
|
|
968
|
+
const footer = footerAnchor && firstInk === '#fb8147';
|
|
969
|
+
const belowEdge = previous !== undefined &&
|
|
970
|
+
(/^ {2}╹▀+/u.test(previous.text) || shapes.some(shape => stallTests(shape).bottom.some(test => test.text?.test(previous.text)))) &&
|
|
971
|
+
shapes.some(shape => stallTests(shape).bottom.some(test => test.text?.test(row.text)));
|
|
972
|
+
const busyBelowFooter = previous !== undefined && /^ {5}▣ {2}Build · /u.test(previous.text) &&
|
|
973
|
+
/^ {3}esc (?:to )?interrupt\s*$/u.test(row.text);
|
|
974
|
+
const ownRow = shapes.length > 0 && (framed || footer || belowEdge || busyBelowFooter);
|
|
975
|
+
if (row.wrapped && previous !== undefined && !ownRow) {
|
|
976
|
+
const offset = previous.text.length + (physical[i - 1].wrapPadding ?? 0);
|
|
977
|
+
previous.text = previous.text.padEnd(offset) + row.text;
|
|
978
|
+
previous.spans.push(...row.spans.map(span => ({ ...span, from: span.from + offset, to: span.to + offset })));
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
lines.push({ ...row, ...(ownRow ? { wrapped: false } : {}), spans: [...row.spans] });
|
|
982
|
+
starts.push(i);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return { lines, starts };
|
|
986
|
+
}
|
|
987
|
+
/** Discovery requires the complete live-turn context. */
|
|
988
|
+
export function detectStall(physical, signature, prompt, firstVisible = 0) {
|
|
989
|
+
const result = validateStall(physical, signature, prompt, firstVisible);
|
|
990
|
+
return result === null || 'inconclusive' in result ? null : result;
|
|
991
|
+
}
|
|
992
|
+
/** Validate the visible shape independently of whether the turn boundary is available. */
|
|
993
|
+
export function validateStall(physical, signature, prompt, firstVisible = 0) {
|
|
994
|
+
const signatures = moduleFor(signature.name)?.stalls;
|
|
995
|
+
if (signatures === undefined || setAside(signature))
|
|
996
|
+
return null;
|
|
997
|
+
return guarded(signature, () => {
|
|
998
|
+
for (const shape of signatures) {
|
|
999
|
+
if (shape.overlay === undefined)
|
|
1000
|
+
continue;
|
|
1001
|
+
const candidate = validateOverlayStall(physical, shape, firstVisible);
|
|
1002
|
+
if (candidate !== null && (!prompt || candidate.reason === 'server-lost'))
|
|
1003
|
+
return candidate;
|
|
1004
|
+
}
|
|
1005
|
+
if (prompt)
|
|
1006
|
+
return null;
|
|
1007
|
+
if (signatures.every(shape => shape.overlay !== undefined))
|
|
1008
|
+
return null;
|
|
1009
|
+
const logical = logicalStallLines(physical, signatures);
|
|
1010
|
+
const lines = stallRegion(logical.lines, signatures);
|
|
1011
|
+
const starts = logical.starts;
|
|
1012
|
+
const composer = stallComposer(lines, signatures);
|
|
1013
|
+
if (composer === null || starts[composer.line] < firstVisible)
|
|
1014
|
+
return null;
|
|
1015
|
+
let turnStart = 0;
|
|
1016
|
+
for (let i = composer.chrome - 1; i >= 0; i--) {
|
|
1017
|
+
if (signature.turn !== undefined && lineFits(lines[i], signature.turn)) {
|
|
1018
|
+
turnStart = i + 1;
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
let lastOutput = composer.chrome - 1;
|
|
1023
|
+
while (lastOutput >= turnStart && blank(lines[lastOutput]))
|
|
1024
|
+
lastOutput--;
|
|
1025
|
+
const completedFooter = lastOutput >= turnStart && signatures.some(shape => {
|
|
1026
|
+
const row = lines[lastOutput];
|
|
1027
|
+
return lineFits({ ...row, text: row.text.replace(shape.cosmetic ?? /$^/u, '$1') }, stallTests(shape).footer);
|
|
1028
|
+
});
|
|
1029
|
+
const busyInComposer = lines.slice(composer.chrome).some(line => signature.busy.some(test => lineFits(line, test)));
|
|
1030
|
+
if (turnBusy(lines, signature, turnStart, composer.chrome) && (!completedFooter || busyInComposer))
|
|
1031
|
+
return null;
|
|
1032
|
+
for (const shape of signatures) {
|
|
1033
|
+
if (shape.overlay !== undefined)
|
|
1034
|
+
continue;
|
|
1035
|
+
const tests = stallTests(shape);
|
|
1036
|
+
if (!lineFits(lines[composer.line], tests.composer))
|
|
1037
|
+
continue;
|
|
1038
|
+
if (lines.slice(composer.line + 1).some((line, index) => !blank(line) && (tests.bottom[index] === undefined || !lineFits(line, tests.bottom[index]))))
|
|
1039
|
+
continue;
|
|
1040
|
+
const rules = moduleFor(signature.name)?.readingRules;
|
|
1041
|
+
const rawInput = lines.slice(composer.chrome, composer.line + 1);
|
|
1042
|
+
const input = rules?.inputRegion?.(rawInput, rawInput.length - 1) ?? rawInput;
|
|
1043
|
+
const clipped = shape.idleClipped;
|
|
1044
|
+
const rightEdge = lines[composer.line].text.length - (clipped?.rightInset ?? 0);
|
|
1045
|
+
// A row cut off at the edge after a space renders without that space,
|
|
1046
|
+
// one cell short; it counts when the restored space completes the rule.
|
|
1047
|
+
const clippedAtEdge = (line) => tests.idleClipped !== undefined && ((line.text.length === rightEdge && lineFits(line, tests.idleClipped)) ||
|
|
1048
|
+
(line.text.length === rightEdge - 1 && lineFits({ ...line, text: `${line.text} ` }, tests.idleClipped)));
|
|
1049
|
+
if (input.some(line => !blank(line) && !tests.idle.some(test => lineFits(line, test)) && !clippedAtEdge(line)))
|
|
1050
|
+
continue;
|
|
1051
|
+
let end = composer.chrome - 1;
|
|
1052
|
+
while (end >= turnStart && blank(lines[end]))
|
|
1053
|
+
end--;
|
|
1054
|
+
const footer = end < turnStart ? undefined : { ...lines[end],
|
|
1055
|
+
text: lines[end].text.replace(shape.cosmetic ?? /$^/u, '$1') };
|
|
1056
|
+
if (footer === undefined || !lineFits(footer, tests.footer))
|
|
1057
|
+
continue;
|
|
1058
|
+
if (shape.clippedBody) {
|
|
1059
|
+
// A marker that has scrolled away cannot establish a new turn boundary.
|
|
1060
|
+
// Require the red block to run from the top of the available history
|
|
1061
|
+
// straight to the completed recovery footer.
|
|
1062
|
+
if (turnStart !== 0 || !lines[end].text.includes('↻ /recover'))
|
|
1063
|
+
continue;
|
|
1064
|
+
let top = end - 1;
|
|
1065
|
+
while (top >= 0 && blank(lines[top]))
|
|
1066
|
+
top--;
|
|
1067
|
+
let messages = 0;
|
|
1068
|
+
while (top >= 0 && /^ {2}┃(?: {3,}.*)?$/u.test(lines[top].text) &&
|
|
1069
|
+
lines[top].spans.some(span => span.from <= 2 && span.to > 2 && span.fg === '#fb7185' && span.bg === '#141414')) {
|
|
1070
|
+
if (lines[top].text.length > 3)
|
|
1071
|
+
messages++;
|
|
1072
|
+
top--;
|
|
1073
|
+
}
|
|
1074
|
+
if (top >= 0 || messages < 2 || !/^ {2}┃ {3,}.+/u.test(lines[0].text))
|
|
1075
|
+
continue;
|
|
1076
|
+
const block = lines.slice(0, end).map(line => line.text.trim().replace(/\s+/gu, ' ')).filter(Boolean);
|
|
1077
|
+
const blockIdentity = JSON.stringify([shape.reason, block, footer.text.trim()]);
|
|
1078
|
+
return { reason: shape.reason, description: shape.description, blockIdentity, identity: blockIdentity };
|
|
1079
|
+
}
|
|
1080
|
+
let row = end - 1;
|
|
1081
|
+
while (row >= turnStart && blank(lines[row]))
|
|
1082
|
+
row--;
|
|
1083
|
+
let matches = true;
|
|
1084
|
+
if (shape.flexibleMessage) {
|
|
1085
|
+
if (row < turnStart || !lineFits(lines[row], tests.rows[4]))
|
|
1086
|
+
matches = false;
|
|
1087
|
+
else {
|
|
1088
|
+
row--;
|
|
1089
|
+
let messages = 0;
|
|
1090
|
+
let startFound = false;
|
|
1091
|
+
for (let checked = 0; row >= turnStart && checked < 32; checked++, row--) {
|
|
1092
|
+
if (row >= turnStart + 2 && lineFits(lines[row], tests.rows[2]) &&
|
|
1093
|
+
lineFits(lines[row - 1], tests.rows[1]) && lineFits(lines[row - 2], tests.rows[0])) {
|
|
1094
|
+
row -= 3;
|
|
1095
|
+
startFound = true;
|
|
1096
|
+
break;
|
|
1097
|
+
}
|
|
1098
|
+
if (lineFits(lines[row], tests.rows[3])) {
|
|
1099
|
+
messages++;
|
|
1100
|
+
continue;
|
|
1101
|
+
}
|
|
1102
|
+
if (!lineFits(lines[row], tests.rows[2]))
|
|
1103
|
+
break;
|
|
1104
|
+
}
|
|
1105
|
+
if (!startFound || messages === 0)
|
|
1106
|
+
matches = false;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
else
|
|
1110
|
+
for (let n = tests.rows.length - 1; n >= 0; n--, row--) {
|
|
1111
|
+
if (row < turnStart || !lineFits(lines[row], tests.rows[n])) {
|
|
1112
|
+
matches = false;
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
if (!matches)
|
|
1117
|
+
continue;
|
|
1118
|
+
const errorStart = row + 1;
|
|
1119
|
+
while (row >= turnStart && blank(lines[row]))
|
|
1120
|
+
row--;
|
|
1121
|
+
const hasBefore = row >= turnStart && lineFits(lines[row], tests.before);
|
|
1122
|
+
if (!hasBefore && !shape.beforeOptional)
|
|
1123
|
+
continue;
|
|
1124
|
+
const blockStart = hasBefore ? row : errorStart;
|
|
1125
|
+
const live = rules?.liveContent?.(lines, turnStart, blockStart, readingContext);
|
|
1126
|
+
if (live !== true && live !== 'inconclusive')
|
|
1127
|
+
continue;
|
|
1128
|
+
// The same semantic identity drives both settlement and suppression.
|
|
1129
|
+
// Styles prove the shape above, but do not identify an occurrence.
|
|
1130
|
+
const semantic = (line) => {
|
|
1131
|
+
const text = line.text;
|
|
1132
|
+
return (line === lines[end] ? footer.text : text).trim().replace(/\s+/gu, ' ');
|
|
1133
|
+
};
|
|
1134
|
+
const block = lines.slice(blockStart, end + 1).map(semantic).filter(Boolean);
|
|
1135
|
+
const blockIdentity = JSON.stringify([shape.reason, block]);
|
|
1136
|
+
if (live === 'inconclusive' && !(firstVisible === 0 && lines[0]?.text.startsWith(' ┃') &&
|
|
1137
|
+
inkStyles(lines[0])[0]?.fg === '#0a0a0a'))
|
|
1138
|
+
return { inconclusive: true, blockIdentity };
|
|
1139
|
+
return { reason: shape.reason, description: shape.description, blockIdentity,
|
|
1140
|
+
identity: JSON.stringify([shape.reason, turnStart > 0 ? semantic(lines[turnStart - 1]) : '',
|
|
1141
|
+
block]) };
|
|
1142
|
+
}
|
|
1143
|
+
return null;
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
function validateOverlayStall(lines, shape, firstVisible) {
|
|
1147
|
+
const overlay = shape.overlay;
|
|
1148
|
+
if (overlay === undefined || !(shape.marker.text instanceof RegExp))
|
|
1149
|
+
return null;
|
|
1150
|
+
const message = compileLine(overlay.message, 'stall.overlay.message').text;
|
|
1151
|
+
const styleAt = (line, column) => line.spans.find(span => span.from <= column && span.to > column);
|
|
1152
|
+
const visibleRows = lines.length - firstVisible;
|
|
1153
|
+
const visibleWidth = Math.max(...lines.slice(firstVisible).map(line => line.text.length));
|
|
1154
|
+
for (let i = firstVisible; i + 3 < lines.length; i++) {
|
|
1155
|
+
const title = lines[i];
|
|
1156
|
+
if (!shape.marker.text.test(title.text))
|
|
1157
|
+
continue;
|
|
1158
|
+
if (Math.abs(i - firstVisible - (Math.floor((visibleRows + 1) / 2) + overlay.centreOffset)) > 1)
|
|
1159
|
+
continue;
|
|
1160
|
+
const column = title.text.indexOf('Connection lost…') - 2;
|
|
1161
|
+
if (column < 18 || title.text[column - 2] !== ' ' || title.text[column - 1] !== ' ')
|
|
1162
|
+
continue;
|
|
1163
|
+
if (Math.abs(column - 2 - (Math.floor((visibleWidth + 1) / 2) - 24)) > 2)
|
|
1164
|
+
continue;
|
|
1165
|
+
const detail = lines[i + 2];
|
|
1166
|
+
// The dialog gutter can remain in the blank modal row; blank background
|
|
1167
|
+
// cells themselves have no spans after the renderer trims the row.
|
|
1168
|
+
if (!/^\s*(?:┃)?$/u.test(lines[i + 1].text) || !message?.test(detail.text.slice(column)))
|
|
1169
|
+
continue;
|
|
1170
|
+
const background = overlay.background;
|
|
1171
|
+
if (styleAt(title, column - 2)?.bg !== background || styleAt(title, column)?.fg !== shape.marker.fg[0] ||
|
|
1172
|
+
styleAt(title, column)?.bg !== background || styleAt(detail, column - 2)?.bg !== background ||
|
|
1173
|
+
styleAt(detail, column)?.fg !== '#808080' || styleAt(detail, column)?.bg !== background)
|
|
1174
|
+
continue;
|
|
1175
|
+
const identity = JSON.stringify([shape.reason, 'live-overlay']);
|
|
1176
|
+
return { reason: shape.reason, description: shape.description, identity, blockIdentity: identity };
|
|
1177
|
+
}
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
933
1180
|
//# sourceMappingURL=reasoning.js.map
|