@llblab/pi-kit 0.4.0 → 0.5.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
  4. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +11 -0
  5. package/node_modules/@llblab/pi-telegram/README.md +4 -2
  6. package/node_modules/@llblab/pi-telegram/docs/README.md +1 -1
  7. package/node_modules/@llblab/pi-telegram/docs/architecture.md +9 -5
  8. package/node_modules/@llblab/pi-telegram/docs/compact-matrix-literal.md +39 -11
  9. package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +2 -2
  10. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +1 -1
  11. package/node_modules/@llblab/pi-telegram/docs/outbound.md +6 -4
  12. package/node_modules/@llblab/pi-telegram/docs/public-api.md +1 -1
  13. package/node_modules/@llblab/pi-telegram/index.ts +12 -1
  14. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +12 -3
  15. package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +5 -3
  16. package/node_modules/@llblab/pi-telegram/lib/locks.ts +99 -16
  17. package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +72 -15
  18. package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +81 -9
  19. package/node_modules/@llblab/pi-telegram/lib/outbound.ts +2 -0
  20. package/node_modules/@llblab/pi-telegram/lib/polling.ts +142 -30
  21. package/node_modules/@llblab/pi-telegram/lib/prompts.ts +8 -6
  22. package/node_modules/@llblab/pi-telegram/lib/queue.ts +4 -0
  23. package/node_modules/@llblab/pi-telegram/lib/replies.ts +1 -1
  24. package/node_modules/@llblab/pi-telegram/lib/status.ts +4 -0
  25. package/node_modules/@llblab/pi-telegram/lib/updates.ts +6 -0
  26. package/node_modules/@llblab/pi-telegram/package.json +1 -1
  27. package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +4 -2
  28. package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/references/layout-and-state.md +4 -2
  29. package/node_modules/@llblab/pi-telegram/skills/generative-apps/SKILL.md +4 -3
  30. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +19 -8
  31. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/references/diagnosis.md +2 -0
  32. package/package.json +2 -2
@@ -10,7 +10,7 @@ Model the surface as ordered ragged rows, not a rectangle to fill. Infer indepen
10
10
  - A horizontal pair is earned only by genuine peers with unmistakably compact labels and no plausible wrapping or truncation.
11
11
  - Three through five columns are for short symbols, coordinates, glyphs, or codes whose position carries meaning.
12
12
  - Six through eight columns require single-glyph or similarly minimal position-bearing labels. Never exceed eight columns on a phone surface.
13
- - Vary row width intentionally; never pad with empty, duplicate, or no-op controls.
13
+ - Vary row width intentionally; never pad for symmetry with empty, duplicate, or no-op controls. A blank disabled cell is appropriate only when it represents a real unavailable position in a spatial grid.
14
14
  - Preserve reading order: orientation/navigation, primary content or choices, secondary controls, then separated destructive actions.
15
15
  - Rectangular grids require genuine spatial or coordinate correspondence. Vertical continuity may justify many rows; non-spatial button walls should paginate or group.
16
16
 
@@ -32,4 +32,6 @@ Keep trivial state in conversation. Persist a small human-auditable artifact whe
32
32
 
33
33
  Evaluate repeated clicks against current state, not stale button appearance. Preserve tap-ahead when the transport queues each click independently. In source-then-destination interaction, retain the source selection without duplicating the whole surface; regenerate after a completed transition, invalid input, or evidence that the transport cannot preserve the intermediate view.
34
34
 
35
- Omit unavailable controls when layout does not matter. Preserve occupied or selected cells when spatial topology depends on stable coordinates.
35
+ Omit unavailable controls when layout does not matter. Preserve occupied or selected cells when spatial topology depends on stable coordinates, using the transport's disabled state without a fabricated prompt. Keep a useful enabled navigation or inspection action.
36
+
37
+ Place each control group beside the content it governs when in-body blocks are supported; keep global navigation and whole-view actions in the footer. Do not duplicate one action in both positions merely for visibility. Row topology and current-state validation stay the same across compact and named representations and across placements; renderer limits and selection feedback belong to the transport.
@@ -29,9 +29,9 @@ Generated Control Surface → current context → model → one ephemeral surfac
29
29
  Generative App → model → reusable program → many evolving surfaces
30
30
  ```
31
31
 
32
- Both Skills use the same logical button matrix and `label + prompt` interaction model. The Telegram runtime owns its full JSON/CML notation and callback routing; this Skill owns reusable program judgment, while `generated-control-surface` owns ephemeral agent-authored composition. Shared rendering needs no third button Skill and does not collapse those responsibilities.
32
+ Both Skills use the same logical button matrix and `label + prompt` interaction model. An app may place groups beside their related content using the transport's in-body button blocks or keep whole-view controls in the footer; placement does not change binding, disabled state, or method authority. The Telegram runtime owns its full JSON/CML notation and callback routing; this Skill owns reusable program judgment, while `generated-control-surface` owns ephemeral agent-authored composition. Shared rendering needs no third button Skill and does not collapse those responsibilities.
33
33
 
34
- An app may mix deterministic `app::method` controls and ordinary prompts in one view. Compile only the stable transitions that benefit from inference bypass; keep explanation, interpretation, teaching, and adaptation on the model-mediated plane. When no reusable state or deterministic loop earns a script, load and use `generated-control-surface` instead.
34
+ An app may mix deterministic `app::method` controls and ordinary prompts in one view, including one control group. Compact and named cells may coexist under the shared transport grammar; neither representation nor placement creates another action plane. Compile only the stable transitions that benefit from inference bypass; keep explanation, interpretation, teaching, and adaptation on the model-mediated plane. When no reusable state or deterministic loop earns a script, load and use `generated-control-surface` instead.
35
35
 
36
36
  The `generated` / `generative` distinction is intentional. Do not rename `generated-control-surface` to a competing generative term.
37
37
 
@@ -76,7 +76,7 @@ Another capability remains the authoritative real owner. The app stores validate
76
76
  1. Identify the repeated feedback loop, real state owner, and actions that are truly deterministic.
77
77
  2. Choose one stable lowercase app and one self-contained `<app>.mjs` source outside the managed installation directory.
78
78
  3. Keep `init` and every exported method small, named, bounded, shell-free, and capability-specific.
79
- 4. Render one complete next view after each action.
79
+ 4. Render one complete next view after each action. Derive disabled controls from current state using the shared transport contract; visible disabled controls neither invoke methods nor enqueue prompts. Revalidate domain preconditions when an enabled control is invoked, because previously rendered views may be stale.
80
80
  5. Mix action planes intentionally:
81
81
 
82
82
  ```text
@@ -107,6 +107,7 @@ Before presenting an app as working:
107
107
  - Inspect the installed initial view and persisted bounded state.
108
108
  - Exercise at least one real bound action and prove it bypasses Pi queue/model admission.
109
109
  - Exercise at least one ordinary prompt when the app intentionally uses the model plane.
110
+ - Verify the placements actually used by the app and prove disabled cells invoke nothing. A successful ordinary prompt-button smoke is not evidence of app-method dispatch or stale-revision rejection.
110
111
  - Verify replacement rejects stale buttons and failed initialization preserves the prior app.
111
112
  - For adapters, prove fresh external status and terminal mutation evidence.
112
113
  - Confirm failures are bounded, redacted, and do not silently render success.
@@ -15,7 +15,8 @@ Use Telegram as a mobile companion to the current Pi session. Preserve the exact
15
15
  | Attach a requested file to the current turn | `telegram_attach(path)` without targeting |
16
16
  | Explicitly send from local/TUI to Telegram | `telegram_message` or `telegram_attach` |
17
17
  | Explicitly send to a different live Thread | `telegram_message(thread=...)` |
18
- | Add prompt buttons or explicit voice | Top-level hidden action comments |
18
+ | Add buttons | Hidden comment for footer; `telegram_button` fence for in-body rows |
19
+ | Add explicit voice | Top-level hidden action comment |
19
20
  | Build a repeated deterministic interaction | Follow `generative-apps` |
20
21
 
21
22
  A connected Telegram session proves capability, not user intent. Use Telegram features on Telegram-originated turns or explicit Telegram delivery requests only. Never call `telegram_message` for the current active target.
@@ -39,7 +40,7 @@ Reply in concise, phone-width Telegram Rich Markdown. Use `$...$` and `$$...$$`
39
40
 
40
41
  ## Assistant Actions
41
42
 
42
- `telegram_button` and `telegram_voice` are hidden HTML comments, not tools. Emit each complete action comment at column zero, outside lists, quotes, code blocks, and indentation. Telegram removes every assistant-authored HTML comment from previews and final replies regardless of owner or Markdown position, but only recognized top-level comments activate actions; comment-only output sends no text message.
43
+ `telegram_button` and `telegram_voice` are markup, not tools. Emit action comments at column zero outside lists, quotes, code, and indentation. Comments create footer buttons or voice artifacts. For buttons between paragraphs, use a column-zero triple-backtick `telegram_button` block. Both button wrappers accept the same singleton JSON/CML cell or mixed matrix; the wrapper determines placement. Telegram removes every assistant-authored HTML comment from previews and final replies regardless of owner or Markdown position; only recognized top-level wrappers activate actions; comment-only output sends no text message.
43
44
 
44
45
  ### Shared Encoding Rule
45
46
 
@@ -48,25 +49,35 @@ Choose the least verbose sufficient representation:
48
49
  1. Positional CML — default.
49
50
  2. JSON — only when multiline content, named fields, or escaping earns it.
50
51
 
51
- CML trims atom boundaries and decodes `\|`, `\}`, and `\\`. Keep one complete action in one comment.
52
+ CML trims atom boundaries and decodes `\|`, `\}`, and `\\`. Keep each payload inside one complete wrapper.
52
53
 
53
54
  ### Prompt Buttons
54
55
 
55
- Every button has a self-contained prompt and an optional selection style. Use a short distinct `emoji + space + text` label when separate human-readable labeling adds meaning; established coordinates or symbolic tokens may use the prompt itself as visible text. A click creates an ordinary user request; it never grants authority or bypasses confirmation.
56
+ Every enabled button has a self-contained prompt and an optional selection style. Use a short distinct `emoji + space + text` label when separate human-readable labeling adds meaning; established coordinates or symbolic tokens may use the prompt itself as visible text. A click creates an ordinary user request; it never grants authority or bypasses confirmation.
56
57
 
57
58
  - `{prompt}` uses the same text for label and prompt.
58
59
  - `{|prompt}` omits a separately authored label and uses the prompt as both visible text and queued prompt.
59
60
  - `{label|prompt}` separates visible label from queued prompt.
60
61
  - `{label|prompt|selected_style}` and `{|prompt|selected_style}` accept `primary`, `success`, or `danger`.
62
+ - Fourth-position `1`/`true` disables, `0`/`false` enables; omission means enabled. JSON uses boolean `disabled`. `{|Next||1}` omits label/style; `{Next|||1}` omits prompt/style; `{|||1}` is blank (Telegram receives a non-breaking space). Prefer meaningful labels and retain a useful enabled action. Enabled CML requires a prompt. Disabled controls stay visible but have no callback, queued prompt, or bound-method invocation.
61
63
  - Top-level cells form vertical rows; one nested row groups horizontal peers.
62
- - Prefer one matrix comment for the complete surface.
64
+ - Prefer one matrix per related group. Fenced blocks stay in place in Rich mode; HTML compatibility moves them to the footer. Native rows allow eight buttons. Malformed/oversized/unclosed blocks activate nothing; drafts hide them. Outer code fences and quoted/indented examples remain literal.
65
+ - Both placements share prompt/app routing. In-body clicks acknowledge without recoloring; selected-style highlighting remains footer-only.
66
+
67
+ A single in-body button (the four-backtick wrapper below makes this a literal example):
68
+
69
+ ````markdown
70
+ ```telegram_button
71
+ {📖 Details|Explain this section.}
72
+ ```
73
+ ````
63
74
 
64
75
  ```html
65
76
  <!-- telegram_button [{▶️ Continue|Continue the current plan.}[{✅ Approve|Approve this.}{❌ Reject|Reject this.}]] -->
66
77
  <!-- telegram_button {"label":"💡 Explain","prompt":"Explain this.\nInclude the risks."} -->
67
78
  ```
68
79
 
69
- Proactively use `generated-control-surface` whenever controls can materially shorten likely feedback; once active, it must emit useful buttons rather than prose alone. That Skill owns action composition; this Skill owns Telegram serialization and delivery. If buttons form the whole reply, the bridge supplies the standard choice heading.
80
+ Proactively use `generated-control-surface` whenever controls can materially shorten likely feedback; once active, it must emit useful buttons rather than prose alone. That Skill owns action composition; this Skill owns Telegram serialization and delivery. Footer-only replies receive the standard choice heading.
70
81
 
71
82
  ### Voice
72
83
 
@@ -113,6 +124,6 @@ Before replying:
113
124
 
114
125
  - Use the ordinary path for the current target and direct tools only for explicit other delivery.
115
126
  - Attach requested files rather than only mentioning them.
116
- - Keep action comments top-level, complete, and canonical: CML first, JSON when necessary.
117
- - Give every button a self-contained prompt; preserve confirmation for dangerous actions.
127
+ - Keep action comments and button fences top-level, complete, and canonical: CML first, JSON when necessary; either syntax may coexist within one matrix.
128
+ - Give every enabled button a self-contained prompt; preserve confirmation for dangerous actions.
118
129
  - Expose no secret or hidden reasoning.
@@ -13,4 +13,6 @@ These slash commands are registered Pi commands, not shell executables or agent
13
13
 
14
14
  When `PI_CODING_AGENT_DIR` selects another compatible runtime, resolve its equivalent `tmp/telegram` directory.
15
15
 
16
+ A `persistent-conflict` polling stop means the bounded competing-`getUpdates` threshold triggered full transport stand-down, not cancellation of accepted local Pi work. The terminal diagnostic distinguishes lost local ownership from a competing client despite an apparently owned lock. Check other profiles, agent directories, installations, or non-Pi clients sharing the bot; after removing the competition, reconnect through the supported Pi command. Do not restart repeatedly or alter lock files to compete for the stream.
17
+
16
18
  Do not mutate ownership files, bridge state, journals, bindings, or locks to force recovery. Use supported commands and preserve exact profile, target, transport, and session authority. Never claim successful delivery without transport evidence.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-kit",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -45,7 +45,7 @@
45
45
  "@llblab/pi-codex-usage": "0.9.4",
46
46
  "@llblab/pi-grow-loop": "0.7.4",
47
47
  "@llblab/pi-state-flow": "0.3.0",
48
- "@llblab/pi-telegram": "0.42.4",
48
+ "@llblab/pi-telegram": "0.43.1",
49
49
  "@llblab/skills": "1.14.0"
50
50
  },
51
51
  "bundledDependencies": [