@llblab/pi-kit 0.1.12 → 0.2.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/CHANGELOG.md +9 -0
- package/README.md +2 -2
- package/node_modules/@llblab/pi-actors/AGENTS.md +5 -3
- package/node_modules/@llblab/pi-actors/BACKLOG.md +1 -1
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +15 -0
- package/node_modules/@llblab/pi-actors/README.md +5 -3
- package/node_modules/@llblab/pi-actors/dist/index.js +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +2 -2
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +42 -19
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +2 -1
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +7 -2
- package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.js +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +10 -11
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +81 -56
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +31 -0
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +180 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.d.ts +115 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.js +623 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +341 -13
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +5 -3
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +16 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +143 -0
- package/node_modules/@llblab/pi-actors/dist/lib/temp.js +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +3 -1
- package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +5 -19
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +2 -2
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +1 -1
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/SKILL.md +1 -1
- package/node_modules/@llblab/pi-actors/docs/README.md +1 -0
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +8 -4
- package/node_modules/@llblab/pi-actors/docs/coordinator-delivery.md +207 -0
- package/node_modules/@llblab/pi-actors/index.ts +4 -1
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +42 -21
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +8 -3
- package/node_modules/@llblab/pi-actors/lib/limits.ts +9 -0
- package/node_modules/@llblab/pi-actors/lib/observability.ts +97 -78
- package/node_modules/@llblab/pi-actors/lib/pi.ts +210 -0
- package/node_modules/@llblab/pi-actors/lib/run-delivery.ts +800 -0
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +370 -18
- package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +6 -4
- package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +153 -0
- package/node_modules/@llblab/pi-actors/lib/temp.ts +1 -1
- package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +4 -1
- package/node_modules/@llblab/pi-actors/package.json +3 -3
- package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +5 -19
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +2 -2
- package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +1 -1
- package/node_modules/@llblab/pi-actors/skills/swarm/SKILL.md +1 -1
- package/node_modules/@llblab/pi-telegram/AGENTS.md +4 -4
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +19 -0
- package/node_modules/@llblab/pi-telegram/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/activity.md +12 -5
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +7 -6
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +3 -4
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +4 -5
- package/node_modules/@llblab/pi-telegram/docs/voice.md +12 -2
- package/node_modules/@llblab/pi-telegram/index.ts +0 -1
- package/node_modules/@llblab/pi-telegram/lib/activity.ts +32 -5
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +59 -12
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/config.ts +25 -25
- package/node_modules/@llblab/pi-telegram/lib/inbound.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +50 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +10 -73
- package/node_modules/@llblab/pi-telegram/lib/pi.ts +15 -0
- package/node_modules/@llblab/pi-telegram/lib/status.ts +11 -1
- package/node_modules/@llblab/pi-telegram/package.json +4 -4
- package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +5 -3
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-actors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Local Actor Kernel for Pi",
|
|
6
6
|
"keywords": [
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"image": "https://raw.githubusercontent.com/llblab/pi-actors/main/banner.jpg"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@earendil-works/pi-coding-agent": "
|
|
70
|
-
"@earendil-works/pi-tui": "
|
|
69
|
+
"@earendil-works/pi-coding-agent": ">=0.84.4",
|
|
70
|
+
"@earendil-works/pi-tui": ">=0.84.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "latest",
|
|
@@ -284,9 +284,6 @@ export async function runAsyncRunner(stateDir = process.argv[2]) {
|
|
|
284
284
|
complete_allowed: missing.length === 0,
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
function getCommandDoneDelivery(result) {
|
|
288
|
-
return result.code !== 0 || activeSubagents > 0 ? "followup" : "log";
|
|
289
|
-
}
|
|
290
287
|
function progressRunning() {
|
|
291
288
|
progress("running", {
|
|
292
289
|
activeSubagents,
|
|
@@ -433,21 +430,6 @@ export async function runAsyncRunner(stateDir = process.argv[2]) {
|
|
|
433
430
|
...(preflightDiagnostic ? { preflight: preflightDiagnostic } : {}),
|
|
434
431
|
});
|
|
435
432
|
}
|
|
436
|
-
event("command.done", {
|
|
437
|
-
activeSubagents,
|
|
438
|
-
command_id: commandId,
|
|
439
|
-
code: result.code,
|
|
440
|
-
command: commandDetail,
|
|
441
|
-
killed: result.killed,
|
|
442
|
-
...captureDetails(result),
|
|
443
|
-
...(materialized.promptFile ? { prompt_file: materialized.promptFile } : {}),
|
|
444
|
-
...(materialized.promptBytes ? { prompt_bytes: materialized.promptBytes } : {}),
|
|
445
|
-
...(session.sessionDir ? { session_dir: relative(stateDir, session.sessionDir).replaceAll("\\", "/") } : {}),
|
|
446
|
-
...(commandSessionFiles(session.sessionDir).length > 0
|
|
447
|
-
? { session_files: commandSessionFiles(session.sessionDir) }
|
|
448
|
-
: {}),
|
|
449
|
-
...(preflightDiagnostic ? { preflight: preflightDiagnostic } : {}),
|
|
450
|
-
});
|
|
451
433
|
observation(
|
|
452
434
|
"command.done",
|
|
453
435
|
`Command ${summarizeCommandDetail(commandDetail)} completed with code ${result.code}`,
|
|
@@ -462,9 +444,13 @@ export async function runAsyncRunner(stateDir = process.argv[2]) {
|
|
|
462
444
|
...captureDetails(result),
|
|
463
445
|
...(materialized.promptFile ? { prompt_file: materialized.promptFile } : {}),
|
|
464
446
|
...(materialized.promptBytes ? { prompt_bytes: materialized.promptBytes } : {}),
|
|
447
|
+
...(session.sessionDir ? { session_dir: relative(stateDir, session.sessionDir).replaceAll("\\", "/") } : {}),
|
|
448
|
+
...(commandSessionFiles(session.sessionDir).length > 0
|
|
449
|
+
? { session_files: commandSessionFiles(session.sessionDir) }
|
|
450
|
+
: {}),
|
|
465
451
|
...(preflightDiagnostic ? { preflight: preflightDiagnostic } : {}),
|
|
466
452
|
},
|
|
467
|
-
|
|
453
|
+
"log",
|
|
468
454
|
result.code === 0 ? "info" : "error",
|
|
469
455
|
);
|
|
470
456
|
progressRunning();
|
|
@@ -85,7 +85,7 @@ There are two distinct multi-instance shapes:
|
|
|
85
85
|
|
|
86
86
|
In host-coordinator mode, the top-level agent receives declarative outcomes, preserves user authority and global context, delegates bounded concrete execution, and owns integration plus final validation. It is not merely another worker after delegation begins. One bounded implementation worker normally runs with reasoning off; consequential output receives a separate reasoning-enabled review. Several independent participants or reviewers additionally use `swarm`.
|
|
87
87
|
|
|
88
|
-
Delegation is not mandatory for every prompt. Work inline when one short bounded act has one natural validation boundary and spawning would add more coordination than isolation, latency hiding, clean context, or continued coordinator availability can repay. For admitted delegation, prefer
|
|
88
|
+
Delegation is not mandatory for every prompt. Work inline when one short bounded act has one natural validation boundary and spawning would add more coordination than isolation, latency hiding, clean context, or continued coordinator availability can repay. For admitted delegation, prefer the settled completion batch and durable Trace/artifacts; inspect on meaningful attention, operator request, or an evidence-based overdue timer rather than busy polling. Treat `attention: "steer"` as an actor-authored urgent semantic checkpoint at Pi's next safe boundary, never as a status-derived completion signal; the later root terminal still arrives through its ordinary completion batch.
|
|
89
89
|
|
|
90
90
|
## Run workflow
|
|
91
91
|
|
|
@@ -97,7 +97,7 @@ Run = Recipe + Trace + Control
|
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
1. Spawn with the exact logical Recipe identity and caller-owned values.
|
|
100
|
-
2. Retain the returned `run:<id>` and normally wait for
|
|
100
|
+
2. Retain the returned `run:<id>` and normally wait for its settled completion batch instead of polling.
|
|
101
101
|
3. Inspect `view=trace` when retained observations or attention matter.
|
|
102
102
|
4. Inspect `view=control` before diagnosing service readiness, stale work, or saturation.
|
|
103
103
|
5. Send `message` only for an action declared and consumed by that controlled Recipe.
|
|
@@ -14,7 +14,7 @@ A rare Skill Recipe may declare `singleton: true`. Do not pass `as`: the runtime
|
|
|
14
14
|
|
|
15
15
|
## Observe
|
|
16
16
|
|
|
17
|
-
Normally wait for
|
|
17
|
+
Normally wait for the settled completion batch. Inspect only when requested, when meaningful attention arrives, or when the Run is overdue or blocked:
|
|
18
18
|
|
|
19
19
|
```text
|
|
20
20
|
inspect target=run:<id> view=recipe
|
|
@@ -15,7 +15,7 @@ A swarm can be coordinated without an external gateway. In this model the curren
|
|
|
15
15
|
|
|
16
16
|
This resembles gateway orchestration in dependency direction but not in ownership: the coordinator is itself an agent instance with inspectable Runs, not an infrastructure service that implicitly creates sessions. Preserve that distinction in prompts, docs, recovery, and target routing.
|
|
17
17
|
|
|
18
|
-
Once work is delegated, keep the coordinator available for decisions and integration instead of duplicating participant implementation. Wait for
|
|
18
|
+
Once work is delegated, keep the coordinator available for decisions and integration instead of duplicating participant implementation. Wait for the settled completion batch by default; use meaningful attention or evidence-based timers for overdue work rather than a tight inspection loop.
|
|
19
19
|
|
|
20
20
|
## Reasoning allocation
|
|
21
21
|
|
|
@@ -92,9 +92,9 @@ Use the relevant local skill before non-trivial work in its domain. Keep skill o
|
|
|
92
92
|
- Telegram extension side effects must not hold Pi's core lifecycle hostage after semantic completion. Preserve ordering in extension-owned background work, record failures, and fence target/profile/transport/session authority.
|
|
93
93
|
- Complete assistant/guest model answers use Telegram-native Rich Markdown. Harness-owned menus, status, diagnostics, thinking, and tool evidence remain explicit HTML/plain or their documented native surface. Preserve literal code and structurally safe chunking; never split invalid markup.
|
|
94
94
|
- `preview` owns streaming lifecycle only, not assistant rendering. Finalization waits for active preview flushes and must not issue pre/post-final draft-clear calls that create transient Telegram draft UI.
|
|
95
|
-
- Native `sendChatAction(typing)` is the automatic activity signal. Do not invent extra in-chat work indicators or emit activity for startup/connect/reload/recovery alone.
|
|
96
|
-
- Public activity handlers and companion delivery are asynchronous, target-bound, generation-fenced surfaces. Token deltas, hidden reasoning, unknown sources, and stale authority never enter public projection.
|
|
97
|
-
- UI labels, emoji semantics, navigation, settings controls, callback namespaces, voice behavior, command templates, and assistant markup follow the linked `/docs` contracts
|
|
95
|
+
- Native `sendChatAction(typing)` is the automatic activity signal for unsettled agent and compaction work while Telegram transport is authorized. Extension-owned blocking UI prompts pause it and completion resumes it while either work owner remains active. Do not invent extra in-chat work indicators or emit activity for startup/connect/reload/recovery alone.
|
|
96
|
+
- Public activity handlers and connected companion delivery are asynchronous, target-bound, generation-fenced surfaces. Connected companion projection has no independent opt-out: disconnect or authority loss is its boundary. Token deltas, hidden reasoning, unknown sources, and stale authority never enter public projection.
|
|
97
|
+
- UI labels, emoji semantics, navigation, settings controls, callback namespaces, voice behavior, command templates, and assistant markup follow the linked `/docs` contracts. Generated human-readable prompt-button labels use `emoji + space + text`; emoji-free text is only a reasoned no-semantic-marker fallback. Non-spatial generated controls default to top-level vertical cells, with nested rows reserved for unmistakably compact peers. Do not restate other evolving UI details here.
|
|
98
98
|
|
|
99
99
|
## 5. Domain Ownership Index
|
|
100
100
|
|
|
@@ -125,7 +125,7 @@ The detailed map is canonical in [`docs/architecture.md`](./docs/architecture.md
|
|
|
125
125
|
- Keep interfaces consistent with their owning exported contract. Use local structural `*Like`/view types only for deliberate narrow projections, not duplicate source-of-truth models.
|
|
126
126
|
- Remove dead code immediately. Reachability from composition roots, public exports, tests, registered surfaces, and documented APIs—not recent usefulness—determines whether code is live.
|
|
127
127
|
- Treat every meaningful `index.ts` edit as a composition-pressure check, but keep one-off live adapter wiring there when extraction would only hide cross-domain state.
|
|
128
|
-
- Follow [`docs/ui-style.md`](./docs/ui-style.md) for interface copy, emoji, buttons, menus, and dialogs. Update the registry before assigning a new UI emoji meaning. Standalone notices use one fully bold emoji-led
|
|
128
|
+
- Follow [`docs/ui-style.md`](./docs/ui-style.md) for interface copy, emoji, buttons, menus, and dialogs. Update the registry before assigning a new UI emoji meaning. Standalone notices use one fully bold emoji-led sentence with a terminal period; menu or chooser headings use the same hierarchy with a terminal colon. Material names may add nested italic emphasis without breaking the outer bold span. Callback alerts preserve equivalent emoji-led plain text because Telegram does not support rich formatting there.
|
|
129
129
|
- Markdown tables use compact source formatting with `---` separator cells and one surrounding space per cell. Preserve vendored references unchanged.
|
|
130
130
|
- Treat Windows filesystem, named-pipe, lock, heartbeat, and atomic-rename reports as high-signal evidence; reduce them to regressions or explicit platform caveats.
|
|
131
131
|
- Route significant runtime failures through the redacted recent-event recorder. Keep the compact TUI status at generic `error`; details belong in diagnostics.
|
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
> Each release keeps at most 8 outcome records of at most 512 characters.
|
|
4
4
|
|
|
5
|
+
## 0.41.0: Connected Companion Presence
|
|
6
|
+
|
|
7
|
+
- `Always-On Projection`: Treats authorized Telegram connection as the public-output boundary for local, autonomous, and unclassified Pi work, always delivering completed visible blocks in order instead of exposing an independent proactive-push opt-out.
|
|
8
|
+
- `Configuration`: Removes Proactive Push from Telegram Settings and the public config contract, atomically drops retired `assistant.proactivePush` values during normalization, and routes stale pre-upgrade callbacks back to the current Settings surface with an explanatory notice.
|
|
9
|
+
- `Work Presence`: Keeps native Telegram typing aligned with unsettled agent and compaction work, pauses it only while extension-owned local UI prompts await the operator, and resumes it after those prompts even when compaction begins after low-level `agent_end`.
|
|
10
|
+
- `Compaction Notices`: Preserves observed `Compaction started` and terminal notices across Pi 0.84.4's post-`agent_end` automatic-compaction order, flushing them after the final-answer delivery tail at `agent_settled`.
|
|
11
|
+
- `Generated Controls`: Requires semantic emoji-led human-readable labels and defaults non-spatial controls to full-width vertical cells, reserving nested horizontal rows for unmistakably compact peers while retaining reasoned no-marker and genuine spatial-grammar exceptions.
|
|
12
|
+
- `Thread Presence`: Aligns the Threaded Mode instance-connected notice with the common information hierarchy by bolding the complete emoji-led sentence while adding nested bold-italic emphasis to the instance name.
|
|
13
|
+
- `Status Parity`: Renames the ambiguous Usage row to Tokens and mirrors Pi's compact terminal telemetry in one line, including inline `R`/`W` cache tokens and `CH` for the latest request's cache-hit rate rather than a cumulative-session approximation.
|
|
14
|
+
- `Voice Setup`: Links maintained Groq Whisper, Mistral Voxtral, and keyless Edge TTS Skills from the voice guide, documenting their environment requirements and direct `telegram.json` command-template path without a companion extension or local speech model.
|
|
15
|
+
|
|
16
|
+
## 0.40.0: Pi 0.84.4 Lifecycle Alignment
|
|
17
|
+
|
|
18
|
+
- `Pi Compatibility`: Requires `@earendil-works/pi-coding-agent`, `pi-agent-core`, and `pi-ai` 0.84.4 or newer, aligning the bridge and its validation runtime with native compaction-failure, mid-run compaction, message-finalization, and UI-prompt lifecycle contracts.
|
|
19
|
+
- `Compaction Failure`: Handles `session_compact_failed` immediately by clearing compacting state, stopping observer-owned typing, releasing deferred queue work, abandoning stale activity, and reporting automatic failure or cancellation without duplicating manual `/compact` errors.
|
|
20
|
+
- `Compaction Chronology`: Distinguishes terminal assistant output awaiting Telegram delivery from mid-run tool continuation. Post-answer notices remain ordered after the final reply, while tool-result threshold compaction is reported in place before the next assistant response.
|
|
21
|
+
- `Local UI Waiting`: Pauses Telegram typing while Pi waits on extension-owned local select, confirm, input, editor, or custom prompts and emits coalesced `ui-prompt-start` / `ui-prompt-end` Activity boundaries before resuming active-turn typing.
|
|
22
|
+
- `Inbound Context`: Raises successful inbound handler and built-in text attachment output from 12,000 to 24,000 characters while retaining the 1 MB built-in file admission ceiling and explicit truncation evidence.
|
|
23
|
+
|
|
5
24
|
## 0.39.5: Auto-Compaction Notice Chronology Hotfix
|
|
6
25
|
|
|
7
26
|
- `Turn Chronology`: Defers observed automatic-compaction notices while a Telegram turn is still active, preserving the same causal order shown by the terminal: final answer, compaction started, then compaction completed. Abandoned compactions and session shutdown discard deferred notices instead of leaking them into a later turn.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
It is a **runtime adapter**, not a remote terminal. Start or supervise work in the Pi TUI, then continue from Telegram while away from the keyboard. Each Telegram destination follows a running Pi instance and sends prompts into that instance's currently active session; it is not permanently bound to one session file or session identity. The bridge preserves Pi session semantics instead of pretending Telegram is a PTY, shell, process launcher, or session browser. That boundary is the product: Telegram gets safe runtime handles, not raw terminal power.
|
|
10
10
|
|
|
11
|
-
Every completed intermediate commentary block from a Telegram-originated turn is delivered once as its own message before the existing final reply.
|
|
11
|
+
Every completed intermediate commentary block from a Telegram-originated turn is delivered once as its own message before the existing final reply. While Telegram is connected, local, autonomous, and unclassified extension follow-up work also projects visible checkpoints and the final answer to the authorized Telegram target once and in order, preserving assistant-authored `telegram_button` comments as interactive prompt buttons. This connected companion projection is always active rather than configurable. Neither path mirrors local prompts, thinking, tool traffic, token deltas, or stale-generation work. The separate `Activity` setting defaults to `verbose` so new installations discover collapsed provider-exposed thinking and tool evidence immediately; operators can narrow it to one class or choose `quiet`. See [Outbound](docs/outbound.md#public-assistant-output) and the [configuration reference](docs/public-api.md#configuration-api).
|
|
12
12
|
|
|
13
13
|
This repository is an actively maintained fork of [`badlogic/pi-telegram`](https://github.com/badlogic/pi-telegram). It started from upstream commit [`cb34008`](https://github.com/badlogic/pi-telegram/commit/cb34008460b6c1ca036d92322f69d87f626be0fc) and has since diverged substantially.
|
|
14
14
|
|
|
@@ -96,7 +96,7 @@ Source classification follows evidence, not guesses:
|
|
|
96
96
|
|
|
97
97
|
Automatic retries, overflow compaction retries, and tool continuations inherit the current activity identity/source until `agent_settled`. A new unrelated `agent_start` after settlement allocates a new activity id.
|
|
98
98
|
|
|
99
|
-
A standalone compaction owns a temporary activity
|
|
99
|
+
A standalone compaction owns a temporary activity until `session_compact` or `session_compact_failed`. Native failure or cancellation immediately abandons that identity, clears compacting state, releases deferred queue work, and stops observer-owned typing; the five-minute observer timeout remains a compatibility fallback for a host that never emits a terminal compaction event. A late `session_compact` after abandonment is ignored and cannot attach to the next run. Compaction inside an existing agent activity never clears that agent's identity.
|
|
100
100
|
|
|
101
101
|
## Event Contract
|
|
102
102
|
|
|
@@ -151,6 +151,12 @@ export type TelegramActivityEvent = TelegramActivityEnvelope & (
|
|
|
151
151
|
type: "compaction-end";
|
|
152
152
|
reason: "manual" | "threshold" | "overflow" | "unknown";
|
|
153
153
|
}
|
|
154
|
+
| {
|
|
155
|
+
type: "ui-prompt-start";
|
|
156
|
+
kind: "select" | "confirm" | "input" | "editor" | "custom";
|
|
157
|
+
title?: string;
|
|
158
|
+
}
|
|
159
|
+
| { type: "ui-prompt-end" }
|
|
154
160
|
| { type: "agent-end" }
|
|
155
161
|
| { type: "agent-settled" }
|
|
156
162
|
);
|
|
@@ -236,7 +242,7 @@ The Delivery API independently serializes concrete Telegram operations per targe
|
|
|
236
242
|
|
|
237
243
|
### Core assistant-output projection
|
|
238
244
|
|
|
239
|
-
Activity's built-in assistant-output projection uses the same normalized `assistant-segment` boundary exposed to public handlers. For `telegram` activity it always projects complete `intermediate` commentary to the immutable originating target, while final and terminal-partial segments remain with active-turn settlement. For `local`, `autonomous`, or unclassified extension follow-up activity,
|
|
245
|
+
Activity's built-in assistant-output projection uses the same normalized `assistant-segment` boundary exposed to public handlers. For `telegram` activity it always projects complete `intermediate` commentary to the immutable originating target, while final and terminal-partial segments remain with active-turn settlement. For `local`, `autonomous`, or unclassified extension follow-up activity, every completed public block—including intermediate commentary/checkpoints and the final block—is projected whenever this Pi instance retains authorized connected transport. This closes actor-follow-up delivery without reclassifying it as direct user input, and the connected companion contract has no projection opt-out. It never projects text token deltas, reasoning events, tool events or payloads, or empty text.
|
|
240
246
|
|
|
241
247
|
The projection does not delay Activity dispatch or Pi lifecycle. Its ordered admission tail deduplicates normalized event identity, while existing routing and outbound owners revalidate the immutable admission-time target, profile/token transport generation, direct leader epoch or follower registration generation, and session generation immediately before each send. Active-turn final delivery waits for admitted commentary inside its existing background task. A replacement or stale owner drops queued work rather than rerouting it, and an already-started non-idempotent Bot API mutation follows the normal `commit-unknown` no-replay contract.
|
|
242
248
|
|
|
@@ -250,9 +256,10 @@ The bridge maps Pi hooks as follows:
|
|
|
250
256
|
- `agent_start`: allocate or reuse activity identity and emit `agent-start` after Telegram queue consumption establishes active-turn ownership.
|
|
251
257
|
- `message_update.assistantMessageEvent`: normalize text/reasoning/provider boundaries.
|
|
252
258
|
- `tool_execution_start/update/end`: emit executed tool events.
|
|
253
|
-
- `session_before_compact` / `session_compact`: emit compaction boundaries and preserve activity identity across retry compaction
|
|
254
|
-
- `
|
|
255
|
-
- `
|
|
259
|
+
- `session_before_compact` / `session_compact` / `session_compact_failed`: emit successful compaction boundaries, abandon failed or cancelled work immediately, and preserve activity identity across retry compaction. Mid-run threshold compaction stays between tool results and the next assistant response, while terminal assistant output awaiting transport keeps later notices behind its final reply. A missing or unrecognized reason maps to `unknown` rather than guessing.
|
|
260
|
+
- `ui_prompt_start` / `ui_prompt_end`: emit one coalesced waiting span for extension-owned local UI, pause Telegram typing while Pi waits for the operator, and resume typing when the prompt closes if agent or compaction work remains unsettled.
|
|
261
|
+
- `agent_end`: emit low-level run completion but keep identity and connected work presence alive for retry, compaction, or follow-up work.
|
|
262
|
+
- `agent_settled`: emit terminal settlement, flush pending terminal segments, release activity identity, and end agent-owned connected work presence.
|
|
256
263
|
- `session_shutdown`: stop dispatch, clear pending normalization state, and invalidate delivery generation through the existing delivery lifecycle.
|
|
257
264
|
|
|
258
265
|
## Diagnostics
|
|
@@ -79,7 +79,7 @@ The repository uses a **Flat Domain DAG**:
|
|
|
79
79
|
- `keyboard`: shared inline-keyboard reply-markup shape only; feature domains own labels, callback data, and behavior.
|
|
80
80
|
- `preview` / `replies` / `rendering`: throttled native Rich Markdown draft delivery, native final reply delivery, reply parameters, transport-limit chunking, and remaining Telegram HTML rendering for bridge-owned UI/compatibility surfaces.
|
|
81
81
|
- `delivery`: public extension operational-view delivery, active-turn/instance/aggregate/authorized target policy, logical chunk handles, per-target ordering, runtime generation fencing, and the process-local runtime membrane. Its bridge adapter composes the established UI/compat reply renderer with narrow bus-aware Telegram API and ownership ports; it never exposes bot clients or Pi contexts.
|
|
82
|
-
- `activity`: public normalized Pi lifecycle registration, activity/source identity, assistant segment and reasoning normalization, executed-tool events, non-blocking per-handler queues, delivery contexts, compatibility adapters, and shutdown fencing. The same domain extends assistant-output observation for
|
|
82
|
+
- `activity`: public normalized Pi lifecycle registration, activity/source identity, assistant segment and reasoning normalization, executed-tool events, non-blocking per-handler queues, delivery contexts, compatibility adapters, and shutdown fencing. The same domain extends assistant-output observation for connected companion projection: eligible completed local/autonomous public segments retain source order and deduplicate event identity. `bindings` assembles observation, authority, sender, and failure-projection ports; routing owns exact delivery authority, outbound composes established transformations and reply delivery, and Bot API domains implement transport. No separate proactive state-machine domain exists.
|
|
83
83
|
- `outbound-markup`: top-level assistant action comment parsing, attribute parsing, voice reply planning, and preview/delivery stripping.
|
|
84
84
|
- `outbound`: outbound text transformations, voice/button artifact delivery, and generated callback actions.
|
|
85
85
|
- `generative-apps`: managed deterministic application identity, canonical installation and explicit replacement, content-addressed module loading, state timelines, cross-process transition serialization, bounded executable-plus-argv adaptation, `telegram_bind`, and pre-model-queue `app::method` invocation. It does not own Telegram transport, arbitrary shell execution, or the external application adapted by one Generative App.
|
|
@@ -315,14 +315,15 @@ Queue and menu mutations are reachable through Telegram updates handled by the c
|
|
|
315
315
|
|
|
316
316
|
### Compaction And Typing Status
|
|
317
317
|
|
|
318
|
-
Manual `/compact` requires inline confirmation because accidental taps are disruptive. Confirmed manual compaction and auto-compaction both set the bridge compaction flag, block queued prompt dispatch, retain that flag in explicit diagnostics, and clear it on compact completion, timeout fallback, or session shutdown. Pi owns its terminal compaction lifecycle; pi-telegram keeps `Active` scoped to Telegram-owned work and otherwise preserves the stable connected/leader/follower role.
|
|
318
|
+
Manual `/compact` requires inline confirmation because accidental taps are disruptive. Confirmed manual compaction and auto-compaction both set the bridge compaction flag, block queued prompt dispatch, retain that flag in explicit diagnostics, and clear it on native compact completion or failure, timeout fallback, or session shutdown. Pi owns its terminal compaction lifecycle; pi-telegram keeps `Active` scoped to Telegram-owned work and otherwise preserves the stable connected/leader/follower role. Mid-run threshold compaction reports notices in place between tool output and the next assistant response; compaction observed after terminal assistant output waits for final Telegram delivery so transport chronology matches the terminal.
|
|
319
319
|
|
|
320
320
|
Native typing during compaction follows connected-instance activity rather than terminal status:
|
|
321
321
|
|
|
322
322
|
- Confirmed manual `/compact` starts a native `typing` keepalive in the command target and stops it on completion/failure.
|
|
323
323
|
- Automatic/session compaction with an active Telegram turn reuses that turn's target.
|
|
324
324
|
- Automatic/session compaction without an active Telegram turn uses the connected instance's assigned target; an unconnected instance sends nothing.
|
|
325
|
-
- Thread-targeted typing is sent to the concrete thread and mirrored to `All` as the aggregate activity surface; completion, timeout, and shutdown stop the keyed loop.
|
|
325
|
+
- Thread-targeted typing is sent to the concrete thread and mirrored to `All` as the aggregate activity surface; completion, native failure, timeout, and shutdown stop the keyed loop.
|
|
326
|
+
- Pi `ui_prompt_start` pauses typing while an extension-owned local prompt waits for the operator; `ui_prompt_end` emits the matching Activity boundary and resumes typing whenever agent or compaction work remains unsettled.
|
|
326
327
|
|
|
327
328
|
At every connected instance `agent_start`, the lifecycle binding starts Telegram's native `…typing` indicator in that instance's assigned target, whether the run came from Telegram, the local TUI, or an autonomous continuation such as Grow Loop. Terminal `Active` remains Telegram-turn-specific; the native indicator answers the separate question of whether the instance is doing agent work. Each loop keeps one action in flight, while the leader API runtime coalesces identical chat/thread/action calls across local and follower traffic for two seconds; expired gates prune opportunistically and at most 256 currently active keys are retained. A Telegram 429 response opens the exact action's shared `retry_after` suppression window without scheduling delayed retries or projecting expected activity throttling as a terminal status error. Assistant message start/update hooks still re-arm it during Telegram-owned turns so transient provider/model errors do not leave a continuing run without activity feedback, and agent/session completion stops it.
|
|
328
329
|
|
|
@@ -389,13 +390,13 @@ The bridge does not mirror arbitrary `ctx.ui.confirm/input/select/custom` prompt
|
|
|
389
390
|
|
|
390
391
|
## Diagnostics And Operational Behavior
|
|
391
392
|
|
|
392
|
-
Status rendering distinguishes connected, active, dispatching, queued, tool-running, model-switching, and compacting states; the Telegram status menu gives compaction precedence over generic active or pending work. Observed automatic compaction sends the same start and completion notices as the manual command without duplicating notices for command-owned compaction. If a queue mutation removes the last waiting item while Telegram-owned work still has running tools, status remains active instead of degrading to connected.
|
|
393
|
+
Status rendering distinguishes connected, active, dispatching, queued, tool-running, model-switching, and compacting states; the Telegram status menu gives compaction precedence over generic active or pending work. Its Tokens row mirrors Pi's terminal footer, including inline `R` cache-read tokens, `W` cache-write tokens, and `CH` for the latest assistant request's cache-read share of prompt tokens rather than a misleading cumulative-session ratio; the label remains distinct from companion-provided usage limits. Observed automatic compaction sends the same start and completion notices as the manual command without duplicating notices for command-owned compaction. If a queue mutation removes the last waiting item while Telegram-owned work still has running tools, status remains active instead of degrading to connected.
|
|
393
394
|
|
|
394
395
|
Queue reaction behavior, lane-tail transitions, Keep/Skip independence, multi-reaction precedence, and the Bot API reaction-removal limitation are defined in [Priority, Reactions, Keep, and Skip](#priority-reactions-keep-and-skip). Reaction changes first flush a matching delayed text or media group so the governed turn exists before mutation, and dropping marked heads cannot leave status permanently queued.
|
|
395
396
|
|
|
396
397
|
`/telegram-status` records grouped diagnostics for transport/API, polling/update, prompt dispatch, controls, typing, compaction, setup, session lifecycle, attachment queue/delivery, and recent redacted runtime events. Polling diagnostics expose the exact phase, phase start, current update, last successful `getUpdates` response, and stop reason; outbound success never substitutes for inbound progress. Expected preview noise such as unchanged edit responses is filtered out. The compact TUI status renders only `error`; detailed failure text remains in diagnostics and profile-scoped logs instead of expanding the status line.
|
|
397
398
|
|
|
398
|
-
Complete intermediate assistant text blocks from Telegram-originated activity are sent once to the immutable originating target before active-turn final delivery; final and terminal-partial segments stay with settlement so replies are not duplicated.
|
|
399
|
+
Complete intermediate assistant text blocks from Telegram-originated activity are sent once to the immutable originating target before active-turn final delivery; final and terminal-partial segments stay with settlement so replies are not duplicated. While this instance has exact direct or follower transport authority, completed public blocks from local/autonomous work are always sent once and in source order to the instance's authorized target. Connected companion projection is not configurable; disconnect or authority loss is its boundary. Both paths use the configured Rich or HTML renderer and exclude reasoning, tool traffic, token deltas, local prompt text, unknown sources, and stale generations. Each admitted block remains fenced to its exact target, profile/token stamp, leader epoch or follower registration generation, and session generation; non-idempotent acknowledgement ambiguity never authorizes replay.
|
|
399
400
|
|
|
400
401
|
`assistant.activity` is an independent bridge-owned projection over normalized Activity events. Each process reloads the shared file-backed setting at `agent-start` before activity admission, so multi-instance mode cannot continue projecting a stale broader process-local selection. Omitted values resolve to `verbose`, while invalid values fail closed to `quiet`; `thinking` and `tools` select one technical class, while `verbose` enables both. Provider-exposed thinking uses persistent ordinary HTML containing only a standard expandable blockquote with a bounded redacted latest-text window and inline Markdown rendered as Telegram HTML. Completed executed tools use native Rich Messages: each closed `<Tool>: <status>` root details node renders snake-case names as title words while preserving an uppercase two- or three-letter repeated prefix per word, then the native disclosure chevron reveals an open-by-default `arguments` child plus closed retained `update N` and `result`/`error` child details with lowercase monospaced, marker-free summaries and JSON pre blocks; known-safe Rich rejections fall back to the previous HTML disclosure. The projection captures the exact target and transport stamp at activity admission, serializes updates, preserves tool-start order, closes coalescing across assistant/thinking boundaries, bounds retained text/update memory plus edit frames and message/tool size, disables previews and HTTP(S) auto-link recognition inside technical evidence, and never replays a possibly committed send. Session generations own independent queues, so replacement drops queued old work without waiting on an old call. Both proactive prose and active-turn final delivery wait for the admitted activity queue inside their extension-owned delivery tasks, preserving technical-before-semantic ordering without delaying Pi lifecycle completion. Settlement, replacement, disconnect, failure, or stale authority clears only local ownership; already-sent activity messages remain in chat.
|
|
401
402
|
|
|
@@ -418,7 +419,7 @@ This is limited to Telegram-owned runs. If Pi is busy with non-Telegram work, th
|
|
|
418
419
|
|
|
419
420
|
Non-critical timers are `unref()`ed so print/headless processes are not kept alive only by Telegram housekeeping. This includes typing keepalive intervals, bounded typing-idle waits, deferred queue dispatch, media/text-group debounce windows, preview flush timers, and polling retry sleeps. Polling retry sleep is abort-aware, so shutdown does not wait for the normal retry delay after a polling error.
|
|
420
421
|
|
|
421
|
-
Non-interactive `pi -p` runs must remain passive unless Pi provides a live Telegram session lifecycle. Loading the extension with `telegram.json
|
|
422
|
+
Non-interactive `pi -p` runs must remain passive unless Pi provides a live Telegram session lifecycle. Loading the extension with `telegram.json` or existing lock state must not by itself keep the print-mode process alive or let a non-owner send companion Telegram output.
|
|
422
423
|
|
|
423
424
|
## Related
|
|
424
425
|
|
|
@@ -8,9 +8,9 @@ Text handlers use the portable [Command Template Standard](./command-templates.m
|
|
|
8
8
|
|
|
9
9
|
## Public Assistant Output
|
|
10
10
|
|
|
11
|
-
Every completed `assistant-segment` with `placement: "intermediate"` from a Telegram-originated turn is delivered as its own message to the immutable originating target before the ordinary active-turn final reply.
|
|
11
|
+
Every completed `assistant-segment` with `placement: "intermediate"` from a Telegram-originated turn is delivered as its own message to the immutable originating target before the ordinary active-turn final reply. Final and terminal-partial Telegram segments remain owned by active-turn settlement so the final answer, voice, buttons, previews, and artifacts are not duplicated.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
While Telegram is connected, local, autonomous, and unclassified extension follow-up Pi work always projects every completed public block—including visible commentary/checkpoints and the final answer—to the instance's authorized target in source order. There is no projection setting or opt-out: disconnecting Telegram is the boundary that stops this companion surface. Both paths consume normalized complete Activity segments rather than raw token deltas, reasoning, or tool traffic.
|
|
14
14
|
|
|
15
15
|
Projected blocks use `assistant.rendering` independently of voice policy. Rich mode sends native Rich Markdown and HTML mode keeps the established HTML renderer; assistant-authored `telegram_button` comments are planned into prompt buttons before either renderer runs, while projection does not synthesize voice or attach queued files merely because Rich rendering is active. Ordered admission revalidates the exact target, profile/token transport generation, leader epoch or follower registration generation, and session generation before each send. Active-turn final delivery waits for admitted commentary inside its existing background delivery task, preserving commentary-before-final order without blocking Pi lifecycle completion. A `commit-unknown` outcome never permits replay.
|
|
16
16
|
|
|
@@ -94,7 +94,6 @@ interface TelegramConfig {
|
|
|
94
94
|
assistant?: {
|
|
95
95
|
draftPreviews?: boolean;
|
|
96
96
|
rendering?: "rich" | "html";
|
|
97
|
-
proactivePush?: boolean;
|
|
98
97
|
activity?: "quiet" | "thinking" | "tools" | "verbose";
|
|
99
98
|
timeInjection?: "hidden" | "always" | "interval";
|
|
100
99
|
};
|
|
@@ -117,10 +116,10 @@ The file is global across Pi instances and contains configuration only. The per-
|
|
|
117
116
|
Hidden/default semantics are represented by absence:
|
|
118
117
|
|
|
119
118
|
- `threads.automaticCleanup` defaults to `true`; graceful Pi quit deletes the instance's bound Threaded Mode tab without prompting but preserves the owner slot as independent restart intent. Set it to `false`, or use `🧹 Thread cleanup` in Telegram Settings, to preserve the tab too. A confirmed `/telegram-disconnect`, unlike quit, clears restart ownership. Settings views and cleanup reload shared config before evaluating this switch, so another live Pi instance's update takes effect without restarting. Confirmed leader/follower teardown persists an exact target/runtime-generation cleanup intent before Telegram deletion; an interrupted attempt remains retryable by the current or successor leader under current authority and clears only after confirmed deletion. A same-profile replacement leader first adopts any still-active binding and cancels its superseded cleanup, so startup never deletes and recreates a reusable thread. If a follower's graceful envelope is missed, the leader may create the same fenced cleanup only after its heartbeat is stale, the OS confirms the exact registered PID no longer exists, cleanup remains enabled, and no replacement registration can overtake deletion. Heartbeat loss alone, live/unknown process liveness, IPC failure, and auth failure remain non-destructive. Invalid-config recovery makes the setting unresolved and therefore skips destructive cleanup. Manual `/telegram-disconnect` keeps its confirmation and teardown behavior regardless of this setting.
|
|
120
|
-
- Every complete intermediate assistant text block from a Telegram-originated turn is delivered once to its immutable target before the existing final reply
|
|
119
|
+
- Every complete intermediate assistant text block from a Telegram-originated turn is delivered once to its immutable target before the existing final reply; final and terminal-partial segments stay with settlement to prevent duplicate replies. While Telegram transport remains authorized, local/autonomous work also projects every completed public block, including commentary and the final block. This connected companion projection is always active and excludes token deltas, hidden reasoning, tool calls/arguments/results, empty blocks, unknown sources, and stale authority. Projection uses the configured Rich or HTML assistant renderer and binds admitted work to the exact target, profile/token transport generation, direct leader epoch or follower registration generation, and session generation. Retired top-level and `assistant.proactivePush` keys are ignored; the nested key is removed during config normalization.
|
|
121
120
|
- `assistant.activity` accepts exactly `"quiet"`, `"thinking"`, `"tools"`, or `"verbose"`; omitted values default to `"verbose"`, explicit values remain unchanged, and invalid values fail closed to `"quiet"`. Each Pi process reloads the shared file-backed value at `agent-start`, so multi-instance activity isolation never relies on a stale process-local config snapshot. `thinking` shows only provider-exposed thinking, `tools` shows only completed tool activity, and `verbose` shows both. Thinking uses persistent ordinary HTML `sendMessage`/`editMessageText` disclosure with a standard expandable blockquote, a `🧠` header carrying the current Pi thinking level, and bounded redacted text whose inline Markdown renders as Telegram HTML. Tools use native Rich Messages with one header followed by separate closed details and JSON pre blocks for bounded redacted arguments, retained updates, and results/errors. Thinking disables link previews on every HTML send/edit and neutralizes HTTP(S) auto-link detection; Rich tool output disables automatic entity detection, with the same protections retained by its HTML fallback. Consecutive tools coalesce only inside the same ordered activity segment and bounded message. Legacy `assistant.activityVerbosity` is read only when `assistant.activity` is absent and is removed by the next Activity Settings write.
|
|
122
121
|
- Voice Reply `hidden`: no `voice.replyMode` key is persisted; legacy `manual` resolves to this silent default. `mirror` adds `[voice] delivery: automatic voice` only to voice/audio-input turns, while `always` adds the same effective line to every Telegram turn.
|
|
123
|
-
- Agent activity status is not configurable
|
|
122
|
+
- Agent activity status is not configurable. While Telegram transport remains authorized, Telegram uses native `sendChatAction(typing)` / product `...active` status as the automatic in-chat work signal for unsettled agent and compaction work. Extension-owned blocking UI prompts pause it and completion resumes it while either work owner remains active.
|
|
124
123
|
- `assistant.timeInjection` accepts `hidden`, `always`, or `interval` and defaults to `interval` when absent without migrating an explicit stored value. Settings writes the selected value there, including `hidden`; the old `time.injectionMode` key is ignored and is not migrated. `time.interval` remains the optional interval duration in milliseconds.
|
|
125
124
|
|
|
126
125
|
With `assistant.rendering: "rich"` (the default), assistant Markdown delivery is native: final replies are sent as `InputRichMessage.markdown` via `sendRichMessage`, and draft previews use `sendRichMessageDraft` when a structurally closed preview frame is available. Draft-frame failures are recorded and skipped rather than converted into raw plain preview messages, because partial Markdown can be temporarily invalid while the final answer remains valid. Long native replies are split at Telegram Rich Message transport limits, with oversized fenced code, display-math, and fully wrapped inline-formatting blocks rewrapped per chunk so persisted chunks remain structurally valid. Guest replies use `InputRichMessageContent` in `answerGuestQuery` results. Bridge-owned UI surfaces such as menus, status, queue controls, commands, and sections keep explicit Telegram HTML/plain rendering by default because those texts are authored by the bridge or companion extensions for Telegram UI. Companion extension sections may explicitly request `"markdown"`, `"html"`, or `"plain"` per view. `assistant.rendering: "html"` keeps the compatibility path that converts assistant Markdown to Telegram HTML before ordinary message delivery. The bridge sets `skip_entity_detection: true` for assistant and guest Markdown so technical text such as `/commands`, hashtags, URLs, phone numbers, and card-like numbers does not gain unintended automatic entities; explicit Markdown links still belong in the Markdown source.
|
|
@@ -337,7 +336,7 @@ Contract:
|
|
|
337
336
|
- Providers are synchronous because `/start` status text is rendered inline with the menu.
|
|
338
337
|
- Return `undefined` when the line is not relevant for the active model.
|
|
339
338
|
- Provider failures are isolated and skipped so optional companion status cannot break the core Telegram menu.
|
|
340
|
-
- The bridge renders rows as `<Label>: <value>` in the same HTML status block as Status,
|
|
339
|
+
- The bridge renders rows as `<Label>: <value>` in the same HTML status block as Status, Tokens, Cost, and Context, capitalizing the first label character for Telegram UI consistency. Tokens mirrors Pi's footer telemetry: `↑` input, `↓` output, `R` cache-read tokens, `W` cache-write tokens, and `CH` for the latest assistant request's `cacheRead / (input + cacheRead + cacheWrite)`, shown to one decimal place only after the session reports cache activity. The precise Tokens label avoids conflating token telemetry with companion-provided usage-limit rows.
|
|
341
340
|
|
|
342
341
|
## Updates
|
|
343
342
|
|
|
@@ -32,7 +32,6 @@ Use emoji as stable semantic markers, not decoration. Emoji carry transportable
|
|
|
32
32
|
| `🧩` | Extension-provided surface | Extension command examples, extension section examples | Companion extensions may choose their own emoji, but `🧩` means generic extension/plugin. |
|
|
33
33
|
| `👄` | Voice reply policy | Voice reply settings row and detail card | Not a generic audio attachment marker. |
|
|
34
34
|
| `🕒` | Time injection / wall-clock context | Time injection settings row and detail card | Clock-face marker with hands; not a generic duration/progress marker. |
|
|
35
|
-
| `📌` | Proactive push / pinned behavior | Proactive push settings row and detail card | Not generic active/selected state. |
|
|
36
35
|
| `🔬` | Activity / technical detail | Activity settings row and detail card | Chooses quiet, thinking, tools, or verbose bridge activity; not a generic diagnostics marker. |
|
|
37
36
|
| `🧠` | Model thinking controls | Thinking menus and status rows | Thinking activity quotes omit this icon and their header entirely to minimize chat height. |
|
|
38
37
|
| `📎` | Attachment | Attachment summaries, queue rows for attachment-only turns | Not for thread binding. |
|
|
@@ -138,7 +137,6 @@ Rules:
|
|
|
138
137
|
Examples:
|
|
139
138
|
|
|
140
139
|
- `🟢 Active` — model detail, navigates back to model list
|
|
141
|
-
- `📌 Proactive push: On` — settings row, opens the toggle submenu
|
|
142
140
|
- `👄 Voice reply: Mirror` — settings row, opens the option list
|
|
143
141
|
|
|
144
142
|
## Boolean Toggles
|
|
@@ -199,7 +197,7 @@ Examples:
|
|
|
199
197
|
|
|
200
198
|
## Generated Prompt Buttons
|
|
201
199
|
|
|
202
|
-
A button-only assistant reply uses the standard Rich Markdown heading `☑️ **Choose an option:**`: semantic icon first, one space, bold heading text, and a final colon. Assistant-generated prompt buttons use the default app style before selection. After queue admission, edit only the selected button to its agent-configured `selected_style`: `primary` (default/blue), `success` (green), or `danger` (red). Preserve its agent-authored text and emoji, leave other choices at their default style, and always queue the selected prompt regardless of color. The callback acknowledgement remains the compatibility fallback when a client does not render button styles.
|
|
200
|
+
A button-only assistant reply uses the standard Rich Markdown heading `☑️ **Choose an option:**`: semantic icon first, one space, bold heading text, and a final colon. Every generated human-readable action label starts with the most semantically appropriate emoji, one ASCII space, then concise action text. Emoji selection is part of authoring the control, including compact label-equals-prompt forms. Emoji-free text remains a syntax-compatible fallback only when no honest semantic marker exists after considering the action, domain, and state—not merely for convenience or label pressure; genuine coordinate and symbolic spatial controls retain their established grammar. Generated non-spatial controls default to vertical full-width buttons represented as top-level matrix cells. Nested row arrays are a compact-peer exception only when every label is unmistakably short—roughly 15 visible characters or fewer including emoji and space; this is a judgment heuristic rather than a mechanical count, and any plausible ellipsis or wrapping risk returns the controls to vertical rows. Assistant-generated prompt buttons use the default app style before selection. After queue admission, edit only the selected button to its agent-configured `selected_style`: `primary` (default/blue), `success` (green), or `danger` (red). Preserve its agent-authored text and emoji, leave other choices at their default style, and always queue the selected prompt regardless of color. The callback acknowledgement remains the compatibility fallback when a client does not render button styles.
|
|
203
201
|
|
|
204
202
|
## Navigation
|
|
205
203
|
|
|
@@ -225,8 +223,9 @@ Message cards and standalone informational notices sent by the bot should start
|
|
|
225
223
|
Rules:
|
|
226
224
|
|
|
227
225
|
- Start with a bold heading or, for dialogs, a bold question.
|
|
228
|
-
- Format standalone notices as one fully bold line: relevant emoji, one space, concise sentence, and terminal period or colon.
|
|
229
|
-
-
|
|
226
|
+
- Format standalone notices as one fully bold line: relevant emoji, one space, concise sentence, and terminal period. Menu or chooser headings use the same fully bold form but end in a colon when controls or detail follow.
|
|
227
|
+
- Keep the emoji and complete sentence or heading inside the single bold span; do not bold only a fragment. A material name or phrase may receive nested italic emphasis without breaking the outer bold hierarchy—for example `<b>📡 Instance <i>Cedar</i> connected.</b>`.
|
|
228
|
+
- Apply the same hierarchy to success, progress, empty, busy, unavailable, cancellation, and failure notices.
|
|
230
229
|
- Callback alerts remain plain text because Telegram does not support rich text there, but still keep the relevant emoji and concise sentence.
|
|
231
230
|
- Setting detail cards may include an emoji in the heading, then a colon and the current value in `<code>`.
|
|
232
231
|
- Explain what the setting does and what the options mean only as much as needed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Voice Integration
|
|
2
2
|
|
|
3
|
-
Voice messages flow through an **inbound transcription → outbound voice reply** pipeline. This document describes the bridge's role in that pipeline; provider-specific mechanics (TTS/STT backends, voice IDs, languages) are owned by voice provider extensions. This is a first-class extension surface: one companion extension can provide STT fallbacks for inbound voice/audio files and TTS fallbacks for outbound Telegram voice replies without owning a second bot polling loop.
|
|
3
|
+
Voice messages flow through an **inbound transcription → outbound voice reply** pipeline. This document describes the bridge's role in that pipeline; provider-specific mechanics (TTS/STT backends, voice IDs, languages) are owned by configured handler scripts or voice provider extensions. This is a first-class extension surface: one companion extension can provide STT fallbacks for inbound voice/audio files and TTS fallbacks for outbound Telegram voice replies without owning a second bot polling loop.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -18,7 +18,17 @@ Use the smallest path that fits the operator's available capabilities:
|
|
|
18
18
|
2. **Companion extension:** Register programmatic STT/TTS providers when installation, provider-owned settings, lifecycle integration, or zero-config reuse justifies code.
|
|
19
19
|
3. **Hybrid:** Keep explicit operator command templates first and let installed providers supply progressive fallbacks.
|
|
20
20
|
|
|
21
|
-
pi-telegram does not
|
|
21
|
+
pi-telegram does not maintain a built-in or exhaustive speech-provider catalog. Configuration agents should discover applicable Skills or trusted local executables, verify required environment variables by presence without exposing values, preserve unrelated `telegram.json` state, ensure TTS ends as OGG/Opus, and test each stage before the live Telegram path. `hidden` remains the safe and useful default: it disables only automatic voice replies, while explicit `telegram_voice` actions continue to use the configured synthesis pipeline.
|
|
22
|
+
|
|
23
|
+
### Ready-made command-template examples
|
|
24
|
+
|
|
25
|
+
The public [`llblab/skills`](https://github.com/llblab/skills) repository provides three maintained Skills with standalone scripts that can be wired directly into `telegram.json`; no additional Pi extension or local inference engine is required:
|
|
26
|
+
|
|
27
|
+
- [`groq-stt`](https://github.com/llblab/skills/tree/main/groq-stt) — Groq Whisper speech-to-text through `scripts/transcribe.sh`. It outputs plain transcript text and requires `GROQ_API_KEY` in the Pi process environment.
|
|
28
|
+
- [`mistral-stt`](https://github.com/llblab/skills/tree/main/mistral-stt) — Mistral Voxtral speech-to-text through `scripts/transcribe.sh`. It outputs plain transcript text and requires `MISTRAL_API_KEY` in the Pi process environment.
|
|
29
|
+
- [`edge-tts`](https://github.com/llblab/skills/tree/main/edge-tts) — Microsoft Edge neural text-to-speech through `scripts/say.sh`. It requires internet access but no account or API key and can write MP3 output for the outbound pipeline.
|
|
30
|
+
|
|
31
|
+
The two hosted STT options avoid running a local transcription model and offer useful free-tier capacity after provider registration; provider limits and terms may change. Install or clone the Skill repository, verify the required API-key variable by presence without printing its value, and point the matching `inboundHandlers` template at the Skill's transcription script. For Edge TTS, point an `outboundHandlers` voice pipeline at `say.sh --file - --write-media {mp3}`, then convert `{mp3}` to `{ogg}` with ffmpeg as shown in [Outbound Voice Handlers](#outbound-voice-handlers), because Telegram native voice notes require OGG/Opus. Read each linked Skill's current `SKILL.md` for its exact CLI, defaults, dependencies, and optional language/model controls.
|
|
22
32
|
|
|
23
33
|
## Voice Detection
|
|
24
34
|
|
|
@@ -548,7 +548,6 @@ export default function (pi: Pi.ExtensionAPI) {
|
|
|
548
548
|
} = Bindings.createTelegramActivityBindingRuntime({
|
|
549
549
|
generation: deliveryGenerationSeed,
|
|
550
550
|
assistantOutput: {
|
|
551
|
-
isEnabled: configControls.isProactivePushEnabled,
|
|
552
551
|
authority: {
|
|
553
552
|
getPreferredTarget: proactivePushTargetGetter,
|
|
554
553
|
getFallbackChatId: proactivePushChatIdGetter,
|
|
@@ -85,6 +85,12 @@ export type TelegramActivityPayload =
|
|
|
85
85
|
type: "compaction-end";
|
|
86
86
|
reason: "manual" | "threshold" | "overflow" | "unknown";
|
|
87
87
|
}
|
|
88
|
+
| {
|
|
89
|
+
type: "ui-prompt-start";
|
|
90
|
+
kind: "select" | "confirm" | "input" | "editor" | "custom";
|
|
91
|
+
title?: string;
|
|
92
|
+
}
|
|
93
|
+
| { type: "ui-prompt-end" }
|
|
88
94
|
| { type: "agent-end" }
|
|
89
95
|
| { type: "agent-settled" };
|
|
90
96
|
|
|
@@ -440,6 +446,12 @@ export function createTelegramActivityBridgeRuntime(deps: {
|
|
|
440
446
|
onCompactionAbandoned() {
|
|
441
447
|
getRuntime()?.onCompactionAbandoned();
|
|
442
448
|
},
|
|
449
|
+
onUiPromptStart(kind, title) {
|
|
450
|
+
getRuntime()?.onUiPromptStart(kind, title);
|
|
451
|
+
},
|
|
452
|
+
onUiPromptEnd() {
|
|
453
|
+
getRuntime()?.onUiPromptEnd();
|
|
454
|
+
},
|
|
443
455
|
onAgentEnd() {
|
|
444
456
|
getRuntime()?.onAgentEnd();
|
|
445
457
|
},
|
|
@@ -502,6 +514,11 @@ export interface TelegramActivityRuntime {
|
|
|
502
514
|
reason: "manual" | "threshold" | "overflow" | "unknown",
|
|
503
515
|
) => void;
|
|
504
516
|
onCompactionAbandoned: () => void;
|
|
517
|
+
onUiPromptStart: (
|
|
518
|
+
kind: "select" | "confirm" | "input" | "editor" | "custom",
|
|
519
|
+
title?: string,
|
|
520
|
+
) => void;
|
|
521
|
+
onUiPromptEnd: () => void;
|
|
505
522
|
onAgentEnd: () => void;
|
|
506
523
|
onAgentSettled: () => void;
|
|
507
524
|
onSessionShutdown: () => void;
|
|
@@ -533,6 +550,7 @@ export function createTelegramActivityRuntime(deps: {
|
|
|
533
550
|
let pendingAssistantSegment: PendingAssistantSegment | undefined;
|
|
534
551
|
let compactionInProgress = false;
|
|
535
552
|
let compactionOwnedActivity = false;
|
|
553
|
+
let uiPromptInProgress = false;
|
|
536
554
|
const ensureActivity = (
|
|
537
555
|
activeTelegramTarget?: TelegramActivityTarget,
|
|
538
556
|
): string => {
|
|
@@ -592,6 +610,7 @@ export function createTelegramActivityRuntime(deps: {
|
|
|
592
610
|
pendingAssistantSegment = undefined;
|
|
593
611
|
compactionInProgress = false;
|
|
594
612
|
compactionOwnedActivity = false;
|
|
613
|
+
uiPromptInProgress = false;
|
|
595
614
|
};
|
|
596
615
|
const abandonCompaction = (): void => {
|
|
597
616
|
if (!compactionInProgress) return;
|
|
@@ -685,6 +704,16 @@ export function createTelegramActivityRuntime(deps: {
|
|
|
685
704
|
onCompactionAbandoned() {
|
|
686
705
|
abandonCompaction();
|
|
687
706
|
},
|
|
707
|
+
onUiPromptStart(kind, title) {
|
|
708
|
+
if (!activityId || uiPromptInProgress) return;
|
|
709
|
+
uiPromptInProgress = true;
|
|
710
|
+
emit({ type: "ui-prompt-start", kind, title });
|
|
711
|
+
},
|
|
712
|
+
onUiPromptEnd() {
|
|
713
|
+
if (!activityId || !uiPromptInProgress) return;
|
|
714
|
+
uiPromptInProgress = false;
|
|
715
|
+
emit({ type: "ui-prompt-end" });
|
|
716
|
+
},
|
|
688
717
|
onAgentEnd() {
|
|
689
718
|
if (activityId) emit({ type: "agent-end" });
|
|
690
719
|
},
|
|
@@ -712,7 +741,6 @@ export interface TelegramAssistantOutputRuntime {
|
|
|
712
741
|
}
|
|
713
742
|
|
|
714
743
|
export function createTelegramAssistantOutputRuntime<TAuthority = undefined>(deps: {
|
|
715
|
-
isEnabled: () => boolean;
|
|
716
744
|
captureAuthority?: () => TAuthority;
|
|
717
745
|
isAuthorityActive?: (authority: TAuthority) => boolean;
|
|
718
746
|
canDeliver: (event: TelegramAssistantSegmentEvent) => boolean;
|
|
@@ -732,10 +760,9 @@ export function createTelegramAssistantOutputRuntime<TAuthority = undefined>(dep
|
|
|
732
760
|
const admitted = new Set<string>();
|
|
733
761
|
const isEligibleEvent = (event: TelegramAssistantSegmentEvent): boolean =>
|
|
734
762
|
(event.source === "telegram" && event.placement === "intermediate") ||
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
deps.isEnabled());
|
|
763
|
+
event.source === "local" ||
|
|
764
|
+
event.source === "autonomous" ||
|
|
765
|
+
event.source === "unknown";
|
|
739
766
|
|
|
740
767
|
return {
|
|
741
768
|
start() {
|