@llblab/pi-state-flow 0.11.0 → 0.11.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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/lib/telegram.ts +20 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.11.2: Single hierarchical Back control
|
|
8
|
+
|
|
9
|
+
- `Telegram inspection navigation`: Removes the chooser-owned `⬅️ Back` button from Show state. The section framework now supplies the only navigation row, `⬆️ Back`, which returns directly to the State Flow section; the four scope choices and read-only Rich state inspection are unchanged.
|
|
10
|
+
|
|
11
|
+
## 0.11.1: Telegram inspection hierarchy
|
|
12
|
+
|
|
13
|
+
- `Telegram inspection`: `👁 Show state` now follows Start/Stop, and its Back, 🌐 Global, 📂 CWD, 💬 Session, and 🧬 Effective controls form one vertical composition axis. A selected scope opens with a fixed emoji-bearing heading followed directly by the four top-level collapsible semantic fields, removing the redundant outer disclosure.
|
|
14
|
+
|
|
7
15
|
## 0.11.0: Telegram state inspection
|
|
8
16
|
|
|
9
17
|
- `Telegram inspection`: The State Flow submenu now offers `👁 Show state` with Global, CWD, Session, and Effective choices. Selecting one scope sends exactly that projected materialized slice as a standalone Telegram Native Rich Message whose semantic fields use collapsible `details` and JSON `pre` blocks; inspection is read-only and the optional adapter remains fail-open without a compatible pi-telegram membrane.
|
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Continue working normally. The agent receives the state protocol and uses `patch
|
|
|
53
53
|
|
|
54
54
|
State Flow is **opt-in**. Starting in an existing conversation keeps its active context for one migration run. To enable genuinely new sessions automatically, set `"autoStart": true` in the optional [configuration](docs/usage.md#configuration).
|
|
55
55
|
|
|
56
|
-
With a compatible `pi-telegram` installed, its main menu
|
|
56
|
+
With a compatible `pi-telegram` installed, its main menu exposes the same Start/Stop controls followed by `👁 Show state`. The chooser uses the transport-owned `⬆️ Back` row to return to State Flow, followed by 🌐 Global, 📂 CWD, 💬 Session, and 🧬 Effective as one vertical composition axis. Selecting a scope sends exactly that materialized slice as a standalone native Rich Message with a fixed scope heading and four top-level collapsible semantic fields; inspection is read-only and does not create a State Flow transition.
|
|
57
57
|
|
|
58
58
|
## What carries forward
|
|
59
59
|
|
package/lib/telegram.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface StateFlowTelegramState {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type StateFlowTelegramRichBlock =
|
|
29
|
+
| { type: "heading"; text: string; size: 2 }
|
|
29
30
|
| { type: "pre"; text: string; language?: string }
|
|
30
31
|
| { type: "details"; summary: string | { type: "bold" | "code"; text: string }; blocks: StateFlowTelegramRichBlock[]; is_open?: true };
|
|
31
32
|
|
|
@@ -124,19 +125,27 @@ export function buildStateFlowSectionView(
|
|
|
124
125
|
text: [formatStateFlowSectionHeader(snapshot), "", STATE_FLOW_SECTION_HELP].join("\n"),
|
|
125
126
|
parseMode: "html",
|
|
126
127
|
replyMarkup: { inline_keyboard: [
|
|
127
|
-
[{ text: "👁 Show state", callback_data: callbackData("show-state") }],
|
|
128
128
|
[action],
|
|
129
|
+
[{ text: "👁 Show state", callback_data: callbackData("show-state") }],
|
|
129
130
|
] },
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
const STATE_FLOW_SCOPE_LABELS: Record<StateFlowTelegramScope, string> = {
|
|
135
|
+
global: "🌐 Global",
|
|
136
|
+
cwd: "📂 CWD",
|
|
137
|
+
session: "💬 Session",
|
|
138
|
+
effective: "🧬 Effective",
|
|
139
|
+
};
|
|
140
|
+
|
|
133
141
|
export function buildStateFlowScopeChooser(callbackData: (action: string, payload?: string) => string): StateFlowTelegramView {
|
|
134
142
|
return {
|
|
135
143
|
text: "<b>👁 Show state:</b>",
|
|
136
144
|
parseMode: "html",
|
|
137
145
|
replyMarkup: { inline_keyboard: [
|
|
138
|
-
["global", "cwd"
|
|
139
|
-
|
|
146
|
+
...(["global", "cwd", "session", "effective"] as const).map((scope) => [
|
|
147
|
+
{ text: STATE_FLOW_SCOPE_LABELS[scope], callback_data: callbackData("inspect", scope) },
|
|
148
|
+
]),
|
|
140
149
|
] },
|
|
141
150
|
};
|
|
142
151
|
}
|
|
@@ -169,18 +178,16 @@ function renderStateFlowTelegramField(value: unknown): string {
|
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
export function renderStateFlowRichState(scope: StateFlowTelegramScope, state: StateFlowTelegramState): StateFlowTelegramRichMessage {
|
|
172
|
-
const title = scope === "cwd" ? "CWD" : `${scope[0].toUpperCase()}${scope.slice(1)}`;
|
|
173
181
|
const fields = ["artifacts", "contract", "working", "response"] as const;
|
|
174
182
|
return {
|
|
175
|
-
blocks: [
|
|
176
|
-
type: "
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
type: "
|
|
180
|
-
|
|
181
|
-
blocks: [{ type: "pre", language: "json", text: renderStateFlowTelegramField(state[field]) }],
|
|
183
|
+
blocks: [
|
|
184
|
+
{ type: "heading", text: STATE_FLOW_SCOPE_LABELS[scope], size: 2 },
|
|
185
|
+
...fields.map((field) => ({
|
|
186
|
+
type: "details" as const,
|
|
187
|
+
summary: { type: "code" as const, text: field },
|
|
188
|
+
blocks: [{ type: "pre" as const, language: "json", text: renderStateFlowTelegramField(state[field]) }],
|
|
182
189
|
})),
|
|
183
|
-
|
|
190
|
+
],
|
|
184
191
|
skip_entity_detection: true,
|
|
185
192
|
};
|
|
186
193
|
}
|
|
@@ -198,7 +205,7 @@ function buildStateFlowTelegramSection(port: StateFlowTelegramPort) {
|
|
|
198
205
|
buildStateFlowSectionView(port.snapshot(), (action) => ctx.callbackData(action)),
|
|
199
206
|
handleCallback: async (ctx: StateFlowTelegramCallbackContext) => {
|
|
200
207
|
// cancel/refresh remain routable for keyboards sent by earlier versions.
|
|
201
|
-
if (ctx.action !== "start" && ctx.action !== "stop" && ctx.action !== "cancel" && ctx.action !== "refresh" && ctx.action !== "show-state" && ctx.action !== "inspect") return "pass" as const;
|
|
208
|
+
if (ctx.action !== "start" && ctx.action !== "stop" && ctx.action !== "cancel" && ctx.action !== "refresh" && ctx.action !== "show-state" && ctx.action !== "inspect" && ctx.action !== "back") return "pass" as const;
|
|
202
209
|
let notice: string | undefined;
|
|
203
210
|
try {
|
|
204
211
|
if (ctx.action === "show-state") {
|