@llblab/pi-kit 0.21.2 → 0.22.1
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 +12 -0
- package/README.md +2 -2
- package/node_modules/@llblab/pi-clean-room/CHANGELOG.md +5 -0
- package/node_modules/@llblab/pi-clean-room/README.md +4 -3
- package/node_modules/@llblab/pi-clean-room/index.ts +45 -1
- package/node_modules/@llblab/pi-clean-room/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/AGENTS.md +2 -1
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +3 -8
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +6 -0
- package/node_modules/@llblab/pi-telegram/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +1 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.d.ts +0 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +0 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +1 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +3 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +17 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +5 -7
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +4 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/model.d.ts +12 -12
- package/node_modules/@llblab/pi-telegram/dist/lib/model.js +49 -35
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +0 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +1 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +0 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/runtime.d.ts +3 -6
- package/node_modules/@llblab/pi-telegram/dist/lib/runtime.js +4 -55
- package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +36 -10
- package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +8 -8
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -2
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +7 -4
- package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +0 -7
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +1 -3
- package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +25 -4
- package/node_modules/@llblab/pi-telegram/lib/menu.ts +14 -9
- package/node_modules/@llblab/pi-telegram/lib/model.ts +77 -44
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +1 -8
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +0 -1
- package/node_modules/@llblab/pi-telegram/lib/runtime.ts +7 -58
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +43 -17
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@llblab/pi-kit` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.22.1 - 2026-09-24
|
|
6
|
+
|
|
7
|
+
- `In-Flight Model Switching`: Advances the exact Telegram pin to `0.51.2`. Telegram model selection can stop, switch, and continue any interruptible run in the current Pi session, including local/TUI work, while preserving the authorized chat, Thread, and reply target and deferring abort until active tools settle.
|
|
8
|
+
- `Typing Continuity`: Native presence refreshes only the assigned Thread, coalesces concurrent chat actions, shares Telegram cooldown across Thread keys, and preserves an existing agent typing loop through compaction. Best-effort typing failures no longer replace healthy leader/follower status with an error.
|
|
9
|
+
- `Package Cohort`: Keeps every other bundled package at its current exact version. Package membership, resource paths, load order, Pi minimum, and bundled Skill ownership remain unchanged.
|
|
10
|
+
|
|
11
|
+
## 0.22.0 - 2026-09-23
|
|
12
|
+
|
|
13
|
+
- `Named npm Extensions`: Advances the exact Clean Room pin to `0.2.0`. `/clean-room <package-name>` now loads installed npm Pi extensions by name, including scoped packages, while preserving explicit resource isolation and project-local precedence.
|
|
14
|
+
- `Model Selection`: Starting an empty clean room from a model registered by an excluded extension no longer fails. When built-in models remain in scope, the child receives only valid entries instead of warnings for stale or excluded-provider patterns; other model providers remain selectable through `/model` when loaded explicitly.
|
|
15
|
+
- `Package Cohort`: Keeps every other bundled package at its current exact version. Package membership, entrypoint order, Skill ownership, and the Pi minimum remain unchanged.
|
|
16
|
+
|
|
5
17
|
## 0.21.2 - 2026-09-23
|
|
6
18
|
|
|
7
19
|
- `Backup Push Reliability`: Advances the exact State Flow pin to `0.18.1`. Backup replication permits one in-flight push per repository; overlapping attempts are skipped until a later accepted turn, while session shutdown waits for the active process to close. Canonical state acceptance remains independent of Git replication.
|
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@ Package links lead to the owning repositories for usage, documentation, issues,
|
|
|
11
11
|
| Package | Version | Purpose |
|
|
12
12
|
| --- | ---: | --- |
|
|
13
13
|
| [`@llblab/pi-actors`](https://github.com/llblab/pi-actors) | `0.53.0` | Inspectable local Runs, reusable Recipes, persistent tools, and delegation Skills |
|
|
14
|
-
| [`@llblab/pi-clean-room`](https://github.com/llblab/pi-clean-room) | `0.
|
|
14
|
+
| [`@llblab/pi-clean-room`](https://github.com/llblab/pi-clean-room) | `0.2.0` | Isolated nested Pi TUI with named npm extensions and compatible model selection |
|
|
15
15
|
| [`@llblab/pi-codex-usage`](https://github.com/llblab/pi-codex-usage) | `0.10.0` | Compact Codex/Spark subscription-limit and Business credit-usage status |
|
|
16
16
|
| [`@llblab/pi-grow-loop`](https://github.com/llblab/pi-grow-loop) | `0.8.1` | Visible continuation scheduling and bounded worker Skills |
|
|
17
17
|
| [`@llblab/pi-state-flow`](https://github.com/llblab/pi-state-flow) | `0.18.1` | Incremental scoped context/memory compiler with independent scope revisions, canonical file persistence, bounded and diagnosable Git backup replication, native working context within each run, and targeted historical reads |
|
|
18
|
-
| [`@llblab/pi-telegram`](https://github.com/llblab/pi-telegram) | `0.51.
|
|
18
|
+
| [`@llblab/pi-telegram`](https://github.com/llblab/pi-telegram) | `0.51.2` | Telegram companion with in-flight model switching, continuous exact-Thread typing, truthful transport status, pressure-safe Workspace rotation, files, voice, controls, and bundled Telegram interaction Skills |
|
|
19
19
|
| [`@llblab/skills`](https://github.com/llblab/skills) | `1.15.0` | Portable workflows for engineering, review, design, context maintenance, and other focused tasks |
|
|
20
20
|
|
|
21
21
|
Versions are exact by design. An upstream release does not change an installed kit until this repository explicitly advances the dependency and publishes a new kit version. Runtime defects and package-specific feature requests belong in the linked repository; package selection and kit installation issues belong here.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0: Named npm extensions and isolated model selection
|
|
4
|
+
|
|
5
|
+
- Launch installed npm extensions by package name, including scoped packages, without exposing their other resources to the clean room.
|
|
6
|
+
- Start clean rooms from extension-backed parent models without failing on excluded providers; when a built-in model scope remains, pass only its valid entries to avoid child startup warnings from stale patterns.
|
|
7
|
+
|
|
3
8
|
## 0.1.1: Isolation and terminal recovery fixes
|
|
4
9
|
|
|
5
10
|
- Keep unselected append-system context excluded when selected global prompt files are missing.
|
|
@@ -6,7 +6,7 @@ Launch a fresh, isolated Pi TUI with only the extensions you explicitly select.
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
Requirements: Pi `0.84.4
|
|
9
|
+
Requirements: Pi `0.84.4` or newer and Node.js `22.19.0` or newer.
|
|
10
10
|
|
|
11
11
|
Install from npm:
|
|
12
12
|
|
|
@@ -32,6 +32,7 @@ Install or load this extension, then run:
|
|
|
32
32
|
/clean-room skills agents system append-system
|
|
33
33
|
/clean-room skills pi-extension-name pi-actors
|
|
34
34
|
/clean-room skills/brain-storm
|
|
35
|
+
/clean-room pi-awesome-extension
|
|
35
36
|
```
|
|
36
37
|
|
|
37
38
|
Arguments may be extension names or resource switches:
|
|
@@ -42,9 +43,9 @@ Arguments may be extension names or resource switches:
|
|
|
42
43
|
- `system` — use `~/.pi/agent/SYSTEM.md`
|
|
43
44
|
- `append-system` — include `~/.pi/agent/APPEND_SYSTEM.md`
|
|
44
45
|
|
|
45
|
-
Extension names are resolved from
|
|
46
|
+
Extension names are resolved from project-local extensions first, then global extensions, then locally installed npm Pi packages (project-local before global). For example, `/clean-room pi-awesome-extension` loads that package's declared extension entries without loading its other resources. Absolute and working-directory-relative extension paths are also accepted. Source-file names resolve consistently across `.ts`, `.js`, `.mts`, `.mjs`, `.cts`, and `.cjs`.
|
|
46
47
|
|
|
47
|
-
The nested Pi starts in the current working directory with the current model
|
|
48
|
+
The nested Pi starts in the current working directory with the current thinking level. It retains the current model unless that model's provider was registered by a parent extension, which may not be loaded in the clean room; in that case Pi selects an available model. Model-cycling scope is inherited from the parent's resolved available models, excluding providers registered by parent-only extensions. When the filtered scope is nonempty, invalid or excluded-provider patterns are not forwarded to the child. `/model` shows all models available in the child; use it to choose a provider loaded by a named extension even when that provider is not in the inherited scope. Built-in model providers remain available without extensions. All optional resources are disabled unless named explicitly. Pi's built-in system prompt and built-in tools remain available. Missing selected global prompt files contribute no content; unselected prompt files remain excluded.
|
|
48
49
|
|
|
49
50
|
Exit the nested TUI normally with `Ctrl+D` to return to the parent session. Launch failures and signal termination are reported after restoring the parent TUI.
|
|
50
51
|
|
|
@@ -12,6 +12,40 @@ import {
|
|
|
12
12
|
const EMPTY_COMPONENT = { render: () => [], invalidate: () => {} };
|
|
13
13
|
const EXTENSION_SUFFIXES = [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"];
|
|
14
14
|
|
|
15
|
+
function npmPackageRoots(cwd: string, agentDir: string): string[] {
|
|
16
|
+
return [join(cwd, CONFIG_DIR_NAME, "npm", "node_modules"), join(agentDir, "npm", "node_modules")];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function installedExtensionPackage(name: string, root: string): string | undefined {
|
|
20
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name) || name === "." || name === "..") return undefined;
|
|
21
|
+
const path = join(root, name);
|
|
22
|
+
try {
|
|
23
|
+
const manifest = JSON.parse(readFileSync(join(path, "package.json"), "utf8"));
|
|
24
|
+
if (manifest.name !== name) return undefined;
|
|
25
|
+
if (Array.isArray(manifest.pi?.extensions) && manifest.pi.extensions.length > 0) return path;
|
|
26
|
+
if (!manifest.pi && existsSync(join(path, "extensions"))) return path;
|
|
27
|
+
} catch {
|
|
28
|
+
// Missing or invalid npm package manifest.
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function discoverInstalledExtensionNames(cwd: string, agentDir: string): string[] {
|
|
34
|
+
const names = new Set<string>();
|
|
35
|
+
for (const root of npmPackageRoots(cwd, agentDir)) {
|
|
36
|
+
if (!existsSync(root)) continue;
|
|
37
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
38
|
+
if (entry.name.startsWith("@") && entry.isDirectory()) {
|
|
39
|
+
for (const child of readdirSync(join(root, entry.name), { withFileTypes: true })) {
|
|
40
|
+
const name = `${entry.name}/${child.name}`;
|
|
41
|
+
if (child.isDirectory() && installedExtensionPackage(name, root)) names.add(name);
|
|
42
|
+
}
|
|
43
|
+
} else if (entry.isDirectory() && installedExtensionPackage(entry.name, root)) names.add(entry.name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [...names];
|
|
47
|
+
}
|
|
48
|
+
|
|
15
49
|
export function discoverExtensionNames(cwd: string, agentDir = getAgentDir()): string[] {
|
|
16
50
|
const roots = [join(agentDir, "extensions"), join(cwd, CONFIG_DIR_NAME, "extensions")];
|
|
17
51
|
const names = new Set<string>();
|
|
@@ -23,6 +57,7 @@ export function discoverExtensionNames(cwd: string, agentDir = getAgentDir()): s
|
|
|
23
57
|
if (entry.isFile() && suffix) names.add(entry.name.slice(0, -suffix.length));
|
|
24
58
|
}
|
|
25
59
|
}
|
|
60
|
+
for (const name of discoverInstalledExtensionNames(cwd, agentDir)) names.add(name);
|
|
26
61
|
return [...names].sort();
|
|
27
62
|
}
|
|
28
63
|
|
|
@@ -36,6 +71,10 @@ export function resolveExtension(source: string, cwd: string, agentDir = getAgen
|
|
|
36
71
|
if (existsSync(candidate)) return candidate;
|
|
37
72
|
}
|
|
38
73
|
}
|
|
74
|
+
for (const root of npmPackageRoots(cwd, agentDir)) {
|
|
75
|
+
const path = installedExtensionPackage(source, root);
|
|
76
|
+
if (path) return path;
|
|
77
|
+
}
|
|
39
78
|
return undefined;
|
|
40
79
|
}
|
|
41
80
|
|
|
@@ -96,7 +135,12 @@ function launchCleanRoom(
|
|
|
96
135
|
resources: ReadonlySet<ResourceArgument>,
|
|
97
136
|
skills: string[],
|
|
98
137
|
) {
|
|
99
|
-
|
|
138
|
+
// Providers registered by parent extensions may not exist in the isolated child.
|
|
139
|
+
const extensionProviders = new Set(ctx.modelRegistry.getRegisteredProviderIds());
|
|
140
|
+
const model = ctx.model && !extensionProviders.has(ctx.model.provider) ? ctx.model : undefined;
|
|
141
|
+
const scopedModels = ctx.scopedModels?.filter(({ model }) => !extensionProviders.has(model.provider));
|
|
142
|
+
const args = buildCleanRoomArgs(extensionPaths, model, ctx.thinkingLevel, resources, getAgentDir(), skills);
|
|
143
|
+
if (scopedModels?.length) args.push("--models", scopedModels.map(({ model }) => `${model.provider}/${model.id}`).join(","));
|
|
100
144
|
const cliEntry = process.argv[1];
|
|
101
145
|
const command = cliEntry && existsSync(cliEntry) ? process.execPath : "pi";
|
|
102
146
|
const commandArgs = cliEntry && existsSync(cliEntry) ? [cliEntry, ...args] : args;
|
|
@@ -96,10 +96,11 @@ Use the relevant local skill before non-trivial work in its domain. Keep skill o
|
|
|
96
96
|
|
|
97
97
|
- Queue lane/kind admission is explicit. Dispatch waits for active-turn, pending-dispatch, control, compaction, `ctx.isIdle()`, and Pi pending-message guards; a dispatched prompt stays queued until `agent_start` consumes it. The terminal `+N` suffix is a yellow count of executable prompts still waiting, excludes the dispatched head immediately, and never counts current agent work from any source. Each prompt is one object with one active lane and no reserved return slot. Normal and Priority are separate FIFO lanes: crossing lanes removes it from the source and appends it at the destination tail, while Keep/Skip and same-category emoji changes preserve lane position. Complete reaction sets independently derive Priority from recognized positive emoji and Skip from recognized negative emoji; both may coexist, suppressed turns retain durable receipts while waiting, and Skip settles them only when the prompt reaches dispatch before dropping it without inference. Suppressed turns remain visible at a struck-through physical ordinal without contributing to executable queue counters, while graceful session shutdown discards all remaining queue authority before clearing memory.
|
|
98
98
|
- `/stop`, `/abort`, `/next`, and `/continue` respectively reset+abort, abort while preserving queue, force the next turn, and enqueue a control-lane continuation. Abort-history folding applies only to Telegram-owned active turns. A busy `/next` marks only its exact active Telegram turn: terminal abort settlement attempts one explicit abort notice before the exact selected queued prompt receives its dispatch notice. Notice failure is diagnostic and cannot block dispatch; a later `/abort` or `/stop` cancels both pending transition notices before taking ownership. Target command adapters must forward these transition ports. A successful dispatch notice keeps the queued prompt's one reply-header claim across agent start, so later messages in that turn never repeat it.
|
|
99
|
+
- A model selection from an authorized Telegram target may stop and continue any interruptible active agent run in that same Pi session, including local/TUI work. Queue the synthetic control-lane continuation before aborting; when no Telegram prompt owns the run, bind continuation and reply ownership to the exact model-menu chat/Thread/message. Delay abort until every active tool execution settles, and clear both selection and fallback target on cancellation, agent start, settlement, or session replacement.
|
|
99
100
|
- 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.
|
|
100
101
|
- 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. Before Telegram preview or final delivery, strip every assistant-authored HTML comment regardless of Markdown position while keeping action activation top-level-only; a comment-only result sends no text message. Preserve literal code outside comments and structurally safe chunking; never split invalid markup.
|
|
101
102
|
- `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. Turns that already answer as one atomic reply (voice replies, Guest Mode queries) never stream previews.
|
|
102
|
-
- 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.
|
|
103
|
+
- 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. Compaction may stop only a typing loop it actually started; it must preserve a pre-existing agent-owned loop. Refresh only the assigned Thread on a conservative three-second cadence; do not mirror typing to aggregate `All` and multiply shared-chat flood pressure. Typing is best-effort presence only: a failed exact-target action remains a structured diagnostic and must not replace a healthy connected/leader/follower status with `error`. Do not invent extra in-chat work indicators or emit activity for startup/connect/reload/recovery alone.
|
|
103
104
|
- 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.
|
|
104
105
|
- Thread display defaults to the profile-scoped Letters strategy, with Names, Directory Snake, and Directory Title as the other automatic choices; Names projects the generated dictionary name for the slot. Unsupported retained display keys resolve to Letters without rewriting persisted configuration. A durable manual Thread display name retained on its Workspace binding overrides any automatic projection until exact reset; keep generated/recovery identity separate from manual and acknowledged display fields. After leader startup, automatic display contraction waits one follower-staleness window so election and follower re-registration cannot briefly remove and restore an acknowledged same-cwd suffix; stop/start generation cancels stale reconciliation. 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.
|
|
105
106
|
|
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
_This file owns unresolved project work only. Completed behavior belongs in `CHANGELOG.md`; durable contracts belong in `AGENTS.md` and `/docs`._
|
|
4
4
|
|
|
5
|
-
- [ ] `
|
|
6
|
-
- [ ] `Manual Thread naming` (`live-acceptance-gated`): Exercise command ordering, dialog/cancel, invalid input, duplicate callbacks, leader/follower rename, manual override, and reset against disposable Threads. Local generation/target fencing and Bot-API-wait replacement regressions are complete.
|
|
7
|
-
- [ ] [`Workspace Thread recovery`](./docs/multi-instance-bus.md) (`operator-/environment-gated`): Finish live and platform evidence without weakening exact owner, admission, journal, or deletion fences.
|
|
8
|
-
- [ ] Confirm the retired K Thread/history is absent after the successful full-A–Z pressure rotation, and repeat the rebuilt leader-election smoke to verify a returning same-directory follower causes no temporary suffix contraction.
|
|
9
|
-
- [ ] Complete follower Restore, inaccessible-callback, already-absent chooser, stale-target, Singleton↔Threaded, and native-Windows acceptance with disposable targets; preserve accepted work and current ownership.
|
|
5
|
+
- [ ] [`Workspace Thread recovery`](./docs/multi-instance-bus.md) (`environment-gated`): Complete native-Windows coverage for follower restore, inaccessible callbacks, stale targets, and Singleton↔Threaded transitions while preserving accepted work and current ownership.
|
|
10
6
|
- [ ] Select an approved exact-absence observation before implementing ambiguous `deletion-issued` recovery. Never replay an unknown deletion or infer absence from cache, heartbeat silence, empty `editForumTopic`, or `sendChatAction` success.
|
|
11
7
|
- [ ] [`Automatic pairing and follower input custody`](./docs/architecture.md#automatic-pairing-confirmation-design) (`activation-gated`): Keep production custody disabled until historical sources and physical references are reconciled, all legacy writers/consumers are retired or excluded under operator authority, migration is complete, and every participating peer supports the final protocol. Preserve outcome-unknown running work, exact receipt/group authority, authenticated handoff, and rollback/downgrade safety. Then compose the prepared v3 lifecycle/bus ports, add bounded operator disposition for retained legacy retry state, and run real-process plus native-Windows acceptance.
|
|
12
|
-
- [ ] `Thread Cleanup Manager` (`activation-gated`): Production currently exposes non-destructive review only. Before enabling deletion, compose the exact cleanup fence/permit coordinator
|
|
13
|
-
- [ ] `Channel operations` (`live-acceptance-gated`): On a disposable channel with real sender rights, verify media rejection, duplicate-send suppression, caption edit, and the durable authored-post create/list/edit/delete flow. Preserve direct-leader authority and outcome-unknown no-replay semantics.
|
|
8
|
+
- [ ] `Thread Cleanup Manager` (`activation-gated`): Production currently exposes non-destructive review only. Before enabling deletion, compose the exact cleanup fence/permit coordinator and prove successor recovery for `commit-ready` without transport replay. Unknown outcomes remain retained.
|
|
14
9
|
- [ ] [`Inference-bypass Generative Apps`](./docs/generative-apps.md) (`hardening`): Complete removal/replacement recovery, process-birth lock recovery, follower routing, refresh/backoff, stale revision rejection, redacted failure diagnostics, CML/JSON parity, and no-model-turn acceptance. Extend the Music Player adapter evidence across volume, toggle, previous, status, restart, unavailable backend, and bounded process failures.
|
|
15
10
|
- [ ] `External compatibility acceptance` (`environment-gated`): Confirm one `telegram_bind` request through the reporter's OMP + llama-server build ([#267](https://github.com/llblab/pi-telegram/issues/267)); validate environment-backed bot-token setup/status for default and named profiles; and extend native in-body controls to a second client, follower routing, disabled cells, and app-method revision rejection.
|
|
16
|
-
- [ ] `Queue recovery evidence` (`operator-gated`): Establish a supported preservation/discard path for any already-wedged in-memory queue before mutation.
|
|
11
|
+
- [ ] `Queue recovery evidence` (`operator-gated`): Establish a supported preservation/discard path for any already-wedged in-memory queue before mutation. Never clear journals, replay settled input, or treat restart as repair.
|
|
17
12
|
- [ ] `Show Me ownership transfer` (`release-coordination`): After a pi-telegram release containing the bundled `show-me` Skill is available, remove the former copy from `@llblab/skills` under that package's release policy, then update Pi Kit. The coordinated final install must expose exactly one Skill identity.
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.51.2: Model switching and typing continuity
|
|
8
|
+
|
|
9
|
+
- `In-flight model switching`: Telegram model selection can again stop, switch, and continue any interruptible agent run in the current Pi session, including local/TUI work without an active Telegram prompt. The exact model-menu chat/Thread/message supplies fallback continuation ownership, active tools defer abort until settlement, and cancellation/session boundaries clear both selection and target state instead of returning a false busy response.
|
|
10
|
+
- `Typing continuity`: Native presence now refreshes only the assigned Thread every three seconds instead of duplicating each action into aggregate `All`. The leader admits at most one concurrent action per chat and shares Telegram 429 cooldown across that chat's Thread keys. Compaction preserves a pre-existing agent typing loop instead of claiming and stopping it, addressing both multi-instance flicker and lifecycle gaps.
|
|
11
|
+
- `Typing status truthfulness`: Failed `sendChatAction(typing)` calls remain bounded structured diagnostics but no longer replace a healthy connected/leader/follower status with `error`. Optional presence failures therefore cannot misreport transport health after the actual turn and delivery continue successfully.
|
|
12
|
+
|
|
7
13
|
## 0.51.1: Queue transitions and follower heartbeat stability
|
|
8
14
|
|
|
9
15
|
- `/next lifecycle notices`: Target command composition now forwards request, exact-turn marker, and cancellation ports. Busy `/next` orders abort then selected-prompt dispatch notices; failures cannot block dispatch, and `/abort`/`/stop` cancel stale notices. A successful dispatch notice keeps first-reply ownership through agent start, so later answer messages do not repeat the queued-prompt reply. Rapid ordinary messages remain distinct turns.
|
|
@@ -123,7 +123,7 @@ Enable the optional capabilities the bridge needs in the [@BotFather](https://t.
|
|
|
123
123
|
| Queue control | Inspect waiting turns, keep or skip stale work, promote important prompts, continue, abort, stop, or force the next queued item. | Long Pi tasks keep running while new mobile prompts stay visible and controllable instead of interrupting or disappearing. |
|
|
124
124
|
| Operator menu | Use `/start` for status, prompt templates, model, thinking, settings, queue, extension sections, and diagnostics. | The bot is an operator panel, not a command cheat sheet. |
|
|
125
125
|
| Prompt templates | Run Pi prompt templates as Telegram-safe commands such as `/fix_tests`. | Reusable local workflows become phone-accessible without exposing arbitrary terminal commands. |
|
|
126
|
-
| Model and thinking | Switch model or thinking level from Telegram through safe continuation flows. | Mobile control can
|
|
126
|
+
| Model and thinking | Switch model or thinking level from Telegram through safe continuation flows, including an active local/TUI agent run. | Mobile control can stop, switch, and resume in the same session context instead of returning a false busy dead end. |
|
|
127
127
|
| Compaction | Confirm `/compact`, show native active status during compaction, and preserve Telegram-owned turn semantics. | Context maintenance is visible and safe from the phone. |
|
|
128
128
|
| Draft previews | Show Telegram's native `…typing` indicator whenever the connected instance is doing agent work, or enable Rich Draft previews for streamed answer text. | Local prompts, Telegram turns, and autonomous continuations remain visibly active while draft visibility stays independent from final rendering. |
|
|
129
129
|
| Activity | Keep the default `verbose` technical surface, show only `thinking`, show only `tools`, or select `quiet` for answer-only delivery. Every instance reloads this shared file-backed choice before a new agent run; thinking accumulates for two seconds and then updates at most every two seconds in a headerless expandable quote, while each tool uses one iconless closed root row containing nested evidence details. | Persistent collapsed technical activity minimizes chat height and stays bounded, redacted, target-fenced, free of URL previews, and visually separate from semantic assistant answers. |
|
|
@@ -676,10 +676,7 @@ export function registerTelegramLifecycleRuntimeHooks({ pi, publicationRuntime,
|
|
|
676
676
|
return false;
|
|
677
677
|
const turn = activeTurnRuntime.get();
|
|
678
678
|
const target = turn?.target ?? proactivePushTargetGetter();
|
|
679
|
-
promptDispatchRuntime.startTypingLoop(ctx, turn?.chatId ?? target?.chatId, {
|
|
680
|
-
target,
|
|
681
|
-
});
|
|
682
|
-
return true;
|
|
679
|
+
return (promptDispatchRuntime.startTypingLoop(ctx, turn?.chatId ?? target?.chatId, { target }) !== false);
|
|
683
680
|
};
|
|
684
681
|
const startActiveTurnTypingLoop = (ctx) => {
|
|
685
682
|
if (uiPromptActive)
|
|
@@ -14,5 +14,4 @@ export interface TelegramBusAwareApiRuntimeDeps {
|
|
|
14
14
|
threadId?: number;
|
|
15
15
|
} | undefined;
|
|
16
16
|
}
|
|
17
|
-
export declare function createTelegramAggregateTypingActionSender(runtime: Pick<TelegramBridgeApiRuntime, "call">): (chatId: number) => Promise<unknown>;
|
|
18
17
|
export declare function createTelegramBusAwareApiRuntime(deps: TelegramBusAwareApiRuntimeDeps): TelegramBridgeApiRuntime;
|
|
@@ -37,9 +37,6 @@ function markFollowerCrossTargetDelivery(body, defaultTarget) {
|
|
|
37
37
|
function rejectTelegramDirectOwnership(method) {
|
|
38
38
|
return Promise.reject(new Error(`Telegram ${method} requires direct transport ownership.`));
|
|
39
39
|
}
|
|
40
|
-
export function createTelegramAggregateTypingActionSender(runtime) {
|
|
41
|
-
return (chatId) => runtime.call("sendChatAction", { chat_id: chatId, action: "typing" });
|
|
42
|
-
}
|
|
43
40
|
export function createTelegramBusAwareApiRuntime(deps) {
|
|
44
41
|
return {
|
|
45
42
|
call(method, body, options) {
|
|
@@ -514,7 +514,6 @@ export default function (pi) {
|
|
|
514
514
|
typing,
|
|
515
515
|
getDefaultChatId: proactivePushChatIdGetter,
|
|
516
516
|
sendTypingAction,
|
|
517
|
-
sendAggregateTypingAction: BusApi.createTelegramAggregateTypingActionSender(telegramApiRuntime),
|
|
518
517
|
updateStatus,
|
|
519
518
|
isContextActive: telegramSessionContextStore.isCurrent,
|
|
520
519
|
getTransportAuthority() {
|
|
@@ -1353,7 +1352,7 @@ export default function (pi) {
|
|
|
1353
1352
|
loadConfig: configStore.load,
|
|
1354
1353
|
setQueuedItems: telegramQueueStore.setQueuedItems,
|
|
1355
1354
|
setCurrentModel: currentModelRuntime.set,
|
|
1356
|
-
setPendingModelSwitch:
|
|
1355
|
+
setPendingModelSwitch: modelSwitchController.clearPendingSwitch,
|
|
1357
1356
|
syncCounters: queue.syncCounters,
|
|
1358
1357
|
syncFlags: lifecycle.syncFlags,
|
|
1359
1358
|
bindDeferredDispatchContext: deferredQueueDispatchRuntime.bind,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Owns model-menu state, scoped model pages, model callback planning, and model-menu message rendering
|
|
5
5
|
*/
|
|
6
6
|
import type { TelegramInlineKeyboardMarkup } from "./keyboard.ts";
|
|
7
|
-
import { type MenuModel, type ScopedTelegramModel, type ThinkingLevel } from "./model.ts";
|
|
7
|
+
import { type MenuModel, type ScopedTelegramModel, type TelegramModelSwitchContinuationSource, type ThinkingLevel } from "./model.ts";
|
|
8
8
|
export type TelegramModelScope = "all" | "scoped";
|
|
9
9
|
export interface TelegramModelMenuState<TModel extends MenuModel = MenuModel> {
|
|
10
10
|
chatId: number;
|
|
@@ -93,8 +93,8 @@ export type TelegramModelMenuCallbackDeps<TModel extends MenuModel = MenuModel>
|
|
|
93
93
|
setModel: (model: TModel) => Promise<boolean>;
|
|
94
94
|
setCurrentModel: (model: TModel) => void;
|
|
95
95
|
setThinkingLevel: (level: ThinkingLevel) => void;
|
|
96
|
-
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel
|
|
97
|
-
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel
|
|
96
|
+
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel>, continuationTurn: TelegramModelSwitchContinuationSource) => void;
|
|
97
|
+
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel>, continuationTurn: TelegramModelSwitchContinuationSource) => Promise<boolean> | boolean;
|
|
98
98
|
};
|
|
99
99
|
export interface TelegramModelMenuOpenDeps<TModel extends MenuModel = MenuModel> {
|
|
100
100
|
isIdle: () => boolean;
|
|
@@ -506,19 +506,33 @@ export async function handleTelegramModelMenuCallbackAction(callbackQueryId, par
|
|
|
506
506
|
if (plan.selection.thinkingLevel) {
|
|
507
507
|
deps.setThinkingLevel(plan.selection.thinkingLevel);
|
|
508
508
|
}
|
|
509
|
-
|
|
509
|
+
const continuationTurn = {
|
|
510
|
+
chatId: params.state.chatId,
|
|
511
|
+
replyToMessageId: params.state.messageId,
|
|
512
|
+
target: {
|
|
513
|
+
chatId: params.state.chatId,
|
|
514
|
+
...(params.state.threadId === undefined
|
|
515
|
+
? {}
|
|
516
|
+
: { threadId: params.state.threadId }),
|
|
517
|
+
},
|
|
518
|
+
};
|
|
510
519
|
if (plan.mode === "restart-after-tool") {
|
|
511
|
-
deps.stagePendingModelSwitch(plan.selection);
|
|
520
|
+
deps.stagePendingModelSwitch(plan.selection, continuationTurn);
|
|
521
|
+
await deps.updateModelMenuMessage();
|
|
512
522
|
await deps.answerCallbackQuery(callbackQueryId, plan.callbackText);
|
|
513
523
|
return true;
|
|
514
524
|
}
|
|
515
525
|
if (plan.mode === "restart-now") {
|
|
516
|
-
const restarted = await deps.restartInterruptedTelegramTurn(plan.selection);
|
|
526
|
+
const restarted = await deps.restartInterruptedTelegramTurn(plan.selection, continuationTurn);
|
|
527
|
+
await deps.updateModelMenuMessage();
|
|
517
528
|
if (!restarted) {
|
|
518
529
|
await deps.answerCallbackQuery(callbackQueryId, "Pi is busy. Send /abort, /next, or /stop.");
|
|
519
530
|
return true;
|
|
520
531
|
}
|
|
521
532
|
}
|
|
533
|
+
else {
|
|
534
|
+
await deps.updateModelMenuMessage();
|
|
535
|
+
}
|
|
522
536
|
await deps.answerCallbackQuery(callbackQueryId, plan.callbackText);
|
|
523
537
|
return true;
|
|
524
538
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Owns app-menu/status state, inline UI text, and callback composition while model/thinking/queue menu details live in dedicated domains
|
|
5
5
|
*/
|
|
6
6
|
import { type TelegramMenuMessageRuntimeDeps, type TelegramModelMenuState, type TelegramModelMenuStateBuilderContext, type TelegramModelMenuStateBuilderDeps, type TelegramReplyMarkup } from "./menu-model.ts";
|
|
7
|
-
import { type MenuModel, type ScopedTelegramModel, type ThinkingLevel } from "./model.ts";
|
|
7
|
+
import { type MenuModel, type ScopedTelegramModel, type TelegramModelSwitchContinuationSource, type ThinkingLevel } from "./model.ts";
|
|
8
8
|
import type { TelegramInputRichMessage } from "./telegram-api.ts";
|
|
9
9
|
import { type TelegramSectionRegistry } from "./sections.ts";
|
|
10
10
|
export { applyTelegramModelPageSelection, applyTelegramModelScopeSelection, buildModelMenuReplyMarkup, buildModelPageMenuReplyMarkup, buildTelegramModelCallbackPlan, buildTelegramModelMenuRenderPayload, buildTelegramModelMenuState, buildTelegramModelMenuStateRuntime, buildTelegramModelPageMenuRenderPayload, createTelegramModelMenuRuntime, createTelegramModelMenuStateBuilder, formatScopedModelButtonText, getModelMenuItems, getStoredTelegramModelMenuState, getTelegramModelMenuPage, getTelegramModelSelection, handleTelegramModelMenuCallbackAction, MODEL_MENU_TITLE, MODEL_PAGE_MENU_TITLE, openTelegramModelMenu, pruneStoredTelegramModelMenus, resolveCachedTelegramModelMenuInputs, sendTelegramModelMenuMessage, storeTelegramModelMenuState, TELEGRAM_MODEL_PAGE_SIZE, updateTelegramModelMenuMessage, } from "./menu-model.ts";
|
|
@@ -49,14 +49,13 @@ export interface TelegramMenuCallbackRuntimeDeps<TContext, TModel extends MenuMo
|
|
|
49
49
|
updateSettingsMenuMessage?: (state: TelegramModelMenuState<TModel>, ctx: TContext) => Promise<void>;
|
|
50
50
|
answerCallbackQuery: (callbackQueryId: string, text?: string) => Promise<void>;
|
|
51
51
|
isIdle: (ctx: TContext) => boolean;
|
|
52
|
-
hasActiveTelegramTurn: () => boolean;
|
|
53
52
|
hasAbortHandler: () => boolean;
|
|
54
53
|
hasActiveToolExecutions: () => boolean;
|
|
55
54
|
persistScopedModelPatterns?: (patterns: string[], ctx: TContext) => Promise<void>;
|
|
56
55
|
setModel: (model: TModel) => Promise<boolean>;
|
|
57
56
|
setCurrentModel: (model: TModel, ctx: TContext) => void;
|
|
58
|
-
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel>, ctx: TContext) => void;
|
|
59
|
-
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel>, ctx: TContext) => Promise<boolean> | boolean;
|
|
57
|
+
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel>, ctx: TContext, continuationTurn: TelegramModelSwitchContinuationSource) => void;
|
|
58
|
+
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel>, ctx: TContext, continuationTurn: TelegramModelSwitchContinuationSource) => Promise<boolean> | boolean;
|
|
60
59
|
sectionRegistry?: TelegramSectionRegistry;
|
|
61
60
|
editInteractiveMessage?: (chatId: number, messageId: number, text: string, mode: "markdown" | "html" | "plain", replyMarkup: TelegramReplyMarkup) => Promise<void>;
|
|
62
61
|
sendInteractiveMessage?: (chatId: number, text: string, mode: "markdown" | "html" | "plain", replyMarkup: TelegramReplyMarkup, options?: {
|
|
@@ -133,14 +132,13 @@ export interface TelegramMenuCallbackRuntimeAdapterDeps<TContext, TModel extends
|
|
|
133
132
|
updateSettingsMenuMessage?: (state: TelegramModelMenuState<TModel>, ctx: TContext) => Promise<void>;
|
|
134
133
|
answerCallbackQuery: (callbackQueryId: string, text?: string) => Promise<void>;
|
|
135
134
|
isIdle: (ctx: TContext) => boolean;
|
|
136
|
-
hasActiveTelegramTurn: () => boolean;
|
|
137
135
|
hasAbortHandler: () => boolean;
|
|
138
136
|
getActiveToolExecutions: () => number;
|
|
139
137
|
persistScopedModelPatterns?: (patterns: string[], ctx: TContext) => Promise<void>;
|
|
140
138
|
setModel: (model: TModel) => Promise<boolean>;
|
|
141
139
|
setCurrentModel: (model: TModel, ctx: TContext) => void;
|
|
142
|
-
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel>, ctx: TContext) => void;
|
|
143
|
-
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel>, ctx: TContext) => Promise<boolean> | boolean;
|
|
140
|
+
stagePendingModelSwitch: (selection: ScopedTelegramModel<TModel>, ctx: TContext, continuationTurn: TelegramModelSwitchContinuationSource) => void;
|
|
141
|
+
restartInterruptedTelegramTurn: (selection: ScopedTelegramModel<TModel>, ctx: TContext, continuationTurn: TelegramModelSwitchContinuationSource) => Promise<boolean> | boolean;
|
|
144
142
|
sectionRegistry?: TelegramSectionRegistry;
|
|
145
143
|
editInteractiveMessage?: (chatId: number, messageId: number, text: string, mode: "markdown" | "html" | "plain", replyMarkup: TelegramReplyMarkup) => Promise<void>;
|
|
146
144
|
sendInteractiveMessage?: (chatId: number, text: string, mode: "markdown" | "html" | "plain", replyMarkup: TelegramReplyMarkup, options?: {
|
|
@@ -99,7 +99,6 @@ export function createTelegramMenuCallbackHandlerForContext(deps) {
|
|
|
99
99
|
updateSettingsMenuMessage: deps.updateSettingsMenuMessage,
|
|
100
100
|
answerCallbackQuery: deps.answerCallbackQuery,
|
|
101
101
|
isIdle: deps.isIdle,
|
|
102
|
-
hasActiveTelegramTurn: deps.hasActiveTelegramTurn,
|
|
103
102
|
hasAbortHandler: deps.hasAbortHandler,
|
|
104
103
|
hasActiveToolExecutions: () => deps.getActiveToolExecutions() > 0,
|
|
105
104
|
persistScopedModelPatterns: deps.persistScopedModelPatterns,
|
|
@@ -228,7 +227,7 @@ export async function handleTelegramMenuCallbackRuntime(query, ctx, deps) {
|
|
|
228
227
|
activeModel: deps.getActiveModel(ctx),
|
|
229
228
|
currentThinkingLevel: deps.getThinkingLevel(),
|
|
230
229
|
isIdle: deps.isIdle(ctx),
|
|
231
|
-
canRestartBusyRun: deps.
|
|
230
|
+
canRestartBusyRun: deps.hasAbortHandler(),
|
|
232
231
|
hasActiveToolExecutions: deps.hasActiveToolExecutions(),
|
|
233
232
|
}, {
|
|
234
233
|
updateModelMenuMessage: () => deps.updateModelMenuMessage(state, ctx),
|
|
@@ -243,10 +242,10 @@ export async function handleTelegramMenuCallbackRuntime(query, ctx, deps) {
|
|
|
243
242
|
deps.setThinkingLevel(level);
|
|
244
243
|
deps.updateStatus(ctx);
|
|
245
244
|
},
|
|
246
|
-
stagePendingModelSwitch: (selection) => {
|
|
247
|
-
deps.stagePendingModelSwitch(selection, ctx);
|
|
245
|
+
stagePendingModelSwitch: (selection, continuationTurn) => {
|
|
246
|
+
deps.stagePendingModelSwitch(selection, ctx, continuationTurn);
|
|
248
247
|
},
|
|
249
|
-
restartInterruptedTelegramTurn: (selection) => deps.restartInterruptedTelegramTurn(selection, ctx),
|
|
248
|
+
restartInterruptedTelegramTurn: (selection, continuationTurn) => deps.restartInterruptedTelegramTurn(selection, ctx, continuationTurn),
|
|
250
249
|
});
|
|
251
250
|
}
|
|
252
251
|
catch (error) {
|
|
@@ -52,14 +52,13 @@ export interface PendingModelSwitchStore<TSelection> {
|
|
|
52
52
|
}
|
|
53
53
|
export interface TelegramInFlightModelSwitchState {
|
|
54
54
|
isIdle: boolean;
|
|
55
|
-
hasActiveTelegramTurn: boolean;
|
|
56
55
|
hasAbortHandler: boolean;
|
|
57
56
|
}
|
|
58
57
|
export declare function createPendingModelSwitchStore<TSelection>(): PendingModelSwitchStore<TSelection>;
|
|
59
|
-
export declare function
|
|
58
|
+
export declare function canRestartAgentRunForTelegramModelSwitch(state: TelegramInFlightModelSwitchState): boolean;
|
|
60
59
|
export declare function shouldTriggerPendingTelegramModelSwitchAbort(state: {
|
|
61
60
|
hasPendingModelSwitch: boolean;
|
|
62
|
-
|
|
61
|
+
hasContinuationTurn: boolean;
|
|
63
62
|
hasAbortHandler: boolean;
|
|
64
63
|
activeToolExecutions: number;
|
|
65
64
|
}): boolean;
|
|
@@ -70,8 +69,9 @@ export declare function restartTelegramModelSwitchContinuation<TTurn, TSelection
|
|
|
70
69
|
queueContinuation: (turn: TTurn, selection: TSelection) => void;
|
|
71
70
|
}): boolean;
|
|
72
71
|
export declare function buildTelegramModelSwitchContinuationText<TModel extends MenuModel>(telegramPrefix: string, model: TModel, thinkingLevel?: ScopedTelegramModel<TModel>["thinkingLevel"]): string;
|
|
72
|
+
export type TelegramModelSwitchContinuationSource = Pick<PendingTelegramTurn, "chatId" | "replyToMessageId" | "target">;
|
|
73
73
|
export declare function buildTelegramModelSwitchContinuationTurn<TModel extends MenuModel>(options: {
|
|
74
|
-
turn:
|
|
74
|
+
turn: TelegramModelSwitchContinuationSource;
|
|
75
75
|
selection: ScopedTelegramModel<TModel>;
|
|
76
76
|
telegramPrefix?: string;
|
|
77
77
|
queueOrder: number;
|
|
@@ -82,22 +82,22 @@ export declare function createTelegramModelSwitchContinuationTurnBuilder<TModel
|
|
|
82
82
|
allocateItemOrder: () => number;
|
|
83
83
|
allocateControlOrder: () => number;
|
|
84
84
|
}): (options: {
|
|
85
|
-
turn:
|
|
85
|
+
turn: TelegramModelSwitchContinuationSource;
|
|
86
86
|
selection: ScopedTelegramModel<TModel>;
|
|
87
87
|
}) => PendingTelegramTurn;
|
|
88
88
|
export declare function createTelegramModelSwitchContinuationQueue<TContext, TSelection extends ScopedTelegramModel>(deps: {
|
|
89
89
|
createContinuationTurn: (options: {
|
|
90
|
-
turn:
|
|
90
|
+
turn: TelegramModelSwitchContinuationSource;
|
|
91
91
|
selection: TSelection;
|
|
92
92
|
}) => PendingTelegramTurn;
|
|
93
93
|
appendQueuedItem: (item: PendingTelegramTurn, ctx: TContext) => void;
|
|
94
|
-
}): (turn:
|
|
94
|
+
}): (turn: TelegramModelSwitchContinuationSource, selection: TSelection, ctx: TContext) => void;
|
|
95
95
|
export declare function createTelegramModelSwitchContinuationQueueRuntime<TContext, TSelection extends ScopedTelegramModel>(deps: {
|
|
96
96
|
telegramPrefix?: string;
|
|
97
97
|
allocateItemOrder: () => number;
|
|
98
98
|
allocateControlOrder: () => number;
|
|
99
99
|
appendQueuedItem: (item: PendingTelegramTurn, ctx: TContext) => void;
|
|
100
|
-
}): (turn:
|
|
100
|
+
}): (turn: TelegramModelSwitchContinuationSource, selection: TSelection, ctx: TContext) => void;
|
|
101
101
|
export interface TelegramModelSwitchControllerDeps<TContext, TSelection> {
|
|
102
102
|
isIdle: (ctx: TContext) => boolean;
|
|
103
103
|
getPendingModelSwitch: () => TSelection | undefined;
|
|
@@ -106,16 +106,16 @@ export interface TelegramModelSwitchControllerDeps<TContext, TSelection> {
|
|
|
106
106
|
getAbortHandler: () => (() => void) | undefined;
|
|
107
107
|
hasAbortHandler: () => boolean;
|
|
108
108
|
getActiveToolExecutions: () => number;
|
|
109
|
-
queueContinuation: (turn:
|
|
109
|
+
queueContinuation: (turn: TelegramModelSwitchContinuationSource, selection: TSelection, ctx: TContext) => void;
|
|
110
110
|
updateStatus: (ctx: TContext) => void;
|
|
111
111
|
}
|
|
112
112
|
export interface TelegramModelSwitchController<TContext, TSelection> {
|
|
113
113
|
canOfferInFlightSwitch: (ctx: TContext) => boolean;
|
|
114
|
-
stagePendingSwitch: (selection: TSelection, ctx: TContext) => void;
|
|
114
|
+
stagePendingSwitch: (selection: TSelection, ctx: TContext, continuationTurn?: TelegramModelSwitchContinuationSource) => void;
|
|
115
115
|
clearPendingSwitch: () => void;
|
|
116
|
-
queueContinuation: (turn:
|
|
116
|
+
queueContinuation: (turn: TelegramModelSwitchContinuationSource, selection: TSelection, ctx: TContext) => void;
|
|
117
117
|
triggerPendingAbort: (ctx: TContext) => boolean;
|
|
118
|
-
restartInterruptedTurn: (selection: TSelection, ctx: TContext) => boolean;
|
|
118
|
+
restartInterruptedTurn: (selection: TSelection, ctx: TContext, continuationTurn?: TelegramModelSwitchContinuationSource) => boolean;
|
|
119
119
|
}
|
|
120
120
|
export interface TelegramModelSwitchControllerRuntimeDeps<TContext, TSelection extends ScopedTelegramModel> extends Omit<TelegramModelSwitchControllerDeps<TContext, TSelection>, "queueContinuation"> {
|
|
121
121
|
telegramPrefix?: string;
|