omnius 1.0.591 → 1.0.592
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/.aiwg/addons/omnius-docs/README.md +15 -1
- package/.aiwg/addons/omnius-docs/manifest.json +28 -68
- package/.aiwg/addons/omnius-docs/skills/agent-failure-recovery/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/browser-interaction-validation/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/evidence-directed-delivery/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/hardware-evidence-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/omnius-docs/SKILL.md +17 -7
- package/.aiwg/addons/omnius-docs/skills/omnius-inference-docs/SKILL.md +27 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-integration-docs/SKILL.md +21 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-ops-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-realtime-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-sponsor-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-telegram-docs/SKILL.md +2 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-tools-docs/SKILL.md +23 -0
- package/.aiwg/addons/omnius-docs/skills/omnius-version-compatibility-docs/SKILL.md +23 -0
- package/.aiwg/addons/omnius-docs/skills/runtime-provenance-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/secrets-and-config-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/test-surface-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-docs/skills/workspace-reality-audit/SKILL.md +2 -1
- package/.aiwg/addons/omnius-rest-docs/README.md +3 -0
- package/.aiwg/addons/omnius-rest-docs/manifest.json +27 -20
- package/.aiwg/addons/omnius-rest-docs/skills/omnius-rest-docs/SKILL.md +9 -5
- package/README.md +36 -0
- package/dist/discovery.d.ts +50 -0
- package/dist/index.js +5975 -4021
- package/dist/library.d.ts +7 -0
- package/dist/library.js +950 -0
- package/dist/postinstall-daemon.cjs +18 -0
- package/dist/providerRegistry.d.ts +80 -0
- package/dist/service-version.d.ts +35 -0
- package/docs/.vitepress/config.mts +8 -0
- package/docs/DISCOVERY.json +20224 -0
- package/docs/DISCOVERY.md +648 -0
- package/docs/HANDOFF-crl-encoder-decoder-fix.md +129 -0
- package/docs/agent-memory/INDEX.md +9 -4
- package/docs/agent-memory/index.md +7 -0
- package/docs/concept-relational-language.md +869 -0
- package/docs/context-management-medium-models-proposal.md +449 -0
- package/docs/dedup-false-positive-meta-analysis.md +96 -0
- package/docs/discovery/catalog-overrides.json +724 -0
- package/docs/duplicate-calls-root-cause-analysis.md +91 -0
- package/docs/duplicate-calls-root-cause-deep.md +155 -0
- package/docs/ephemeral-skill-pack-small-context.md +57 -0
- package/docs/explorations/context-window-todo-association.md +156 -0
- package/docs/explorations/todo-association-verify.json +30 -0
- package/docs/explorations/verification-ledger.json +45 -0
- package/docs/explorations/verify-todo-association.sh +30 -0
- package/docs/flowstate.md +806 -0
- package/docs/getting-started/install.md +24 -0
- package/docs/getting-started/model-providers.md +13 -0
- package/docs/guides/agent-integration.md +87 -0
- package/docs/guides/bring-your-own-inference.md +126 -0
- package/docs/guides/tools-and-web-search.md +95 -0
- package/docs/index.md +14 -0
- package/docs/longhaul-35b-workorders.md +496 -0
- package/docs/memory-integration-analysis.md +303 -0
- package/docs/model-capability-awareness-and-multimodal-memory-root-fix.md +799 -0
- package/docs/multimodal-identity-memory-implementation.md +76 -0
- package/docs/omnius-self-edit-eval-2026-06-10.md +169 -0
- package/docs/opencode-agentic-loop-comparison.md +290 -0
- package/docs/operations/security-and-remote-access.md +2 -2
- package/docs/operations/version-compatibility.md +63 -0
- package/docs/proposals/git-progress-tracking-strategy.md +289 -0
- package/docs/proposals/opencode-modules/backendAdapter.ts +443 -0
- package/docs/proposals/opencode-modules/childSession.ts +288 -0
- package/docs/proposals/opencode-modules/compactionAgent.ts +101 -0
- package/docs/proposals/opencode-modules/orchestrator.ts +387 -0
- package/docs/proposals/opencode-modules/runner.ts +258 -0
- package/docs/reference/auth-map.md +87 -196
- package/docs/reference/configuration.md +27 -0
- package/docs/reference/rest-api.md +7 -0
- package/docs/reference/slash-commands.md +125 -2
- package/docs/research/_archived/README.md +18 -0
- package/docs/research/_archived/context_window_attention_model.py +418 -0
- package/docs/research/_archived/context_window_attention_spec.md +55 -0
- package/docs/research/_archived/context_window_attention_weights.json +68 -0
- package/docs/research/k-splanifolds.pdf +0 -0
- package/docs/research/personality-verbosity-control.md +293 -0
- package/docs/rest/INDEX.md +7 -0
- package/docs/rest/QUICKREF.md +18 -0
- package/docs/rest/REST-DOCS-MANIFEST.json +1 -0
- package/docs/rest/auth-and-scopes.md +7 -1
- package/docs/rest/endpoints/discovery.md +44 -0
- package/docs/rest/endpoints/events.md +5 -0
- package/docs/rest/endpoints/tools.md +9 -0
- package/docs/reviews/adversary-system-review.md +42 -0
- package/docs/sana-and-video-generation-integration-plan.md +712 -0
- package/docs/session-diary-llm-training-analysis.md +218 -0
- package/docs/telegram-dmn-curiosity-outreach-scaffold.md +91 -0
- package/docs/telegram-mid-horizon-download-loop-handoff.md +468 -0
- package/docs/telegram-reflection-corpus-integration-plan.md +306 -0
- package/docs/telegram-unified-tooling-architecture.md +332 -0
- package/docs/threat-model.md +868 -0
- package/docs/trajectory-grounding.md +160 -0
- package/docs/voice-flow-architecture.md +489 -0
- package/docs/work-orders/WO-AM-GAPS.md +638 -0
- package/docs/work-orders/daemon-hud-ui-overhaul.md +82 -0
- package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/INDEX.md +21 -0
- package/docs/work-orders/hermes-architecture-deltas/01-public-scrutiny-provenance-control/WORKORDER.md +225 -0
- package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/INDEX.md +20 -0
- package/docs/work-orders/hermes-architecture-deltas/02-context-engine-plugin-boundary/WORKORDER.md +198 -0
- package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/INDEX.md +19 -0
- package/docs/work-orders/hermes-architecture-deltas/03-typed-gateway-event-stream/WORKORDER.md +172 -0
- package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/INDEX.md +19 -0
- package/docs/work-orders/hermes-architecture-deltas/04-task-local-gateway-context/WORKORDER.md +169 -0
- package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/05-process-lifecycle-monitoring-notifications/WORKORDER.md +189 -0
- package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/06-vision-evidence-routing-ladder/WORKORDER.md +199 -0
- package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/INDEX.md +20 -0
- package/docs/work-orders/hermes-architecture-deltas/07-durable-multi-agent-kanban/WORKORDER.md +174 -0
- package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/INDEX.md +22 -0
- package/docs/work-orders/hermes-architecture-deltas/08-completion-critic-reconciliation-ledger/WORKORDER.md +226 -0
- package/docs/work-orders/hermes-architecture-deltas/INDEX.md +38 -0
- package/docs/work-orders/omnius-context-engineering-behavior-fixes.md +281 -0
- package/docs/work-orders/telegram-dropbear-context-rca-workorder.md +202 -0
- package/docs/work-orders/world-class-memory-compiler/README.md +162 -0
- package/docs/work-orders/world-class-memory-compiler/TRACKER.md +179 -0
- package/docs/work-orders/world-class-memory-compiler/WO-01-exact-request-budget.md +79 -0
- package/docs/work-orders/world-class-memory-compiler/WO-02-typed-memory-fabric.md +65 -0
- package/docs/work-orders/world-class-memory-compiler/WO-03-dependency-working-set.md +55 -0
- package/docs/work-orders/world-class-memory-compiler/WO-04-inference-memory-compiler.md +67 -0
- package/docs/work-orders/world-class-memory-compiler/WO-05-artifact-fidelity-materialization.md +72 -0
- package/docs/work-orders/world-class-memory-compiler/WO-06-temporal-hybrid-retrieval.md +49 -0
- package/docs/work-orders/world-class-memory-compiler/WO-07-evaluation-harness.md +45 -0
- package/docs/work-orders/world-class-memory-compiler/WO-08-rollout-legacy-removal.md +45 -0
- package/docs/x402-remote-inference-plan.md +323 -0
- package/npm-shrinkwrap.json +108 -117
- package/package.json +7 -6
- package/templates/AGENTS.md +6 -0
- package/templates/OMNIUS.md +20 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# Telegram Reflection Corpus Integration Plan
|
|
2
|
+
|
|
3
|
+
Date: 2026-05-15
|
|
4
|
+
|
|
5
|
+
Status: planning and implementation tracker
|
|
6
|
+
|
|
7
|
+
Goal: make Telegram reflection cycles operate over a durable scoped corpus, not just the retained in-memory chat window. Each cycle must efficiently perform tagging, summation, titling, extraction, and linking over Telegram-scoped conversation data, then commit the resulting artifacts back into memory and graph stores so future reflection, live replies, and multimodal identity recall can use them.
|
|
8
|
+
|
|
9
|
+
## Hard Requirements
|
|
10
|
+
|
|
11
|
+
- No implementation stubs, placeholder functions, dead exports, or unused planning-only branches.
|
|
12
|
+
- No hidden fallback to workspace filesystem dream mode from Telegram chat contexts.
|
|
13
|
+
- Every artifact must be scoped by Telegram session key, chat id, chat type, and message anchors.
|
|
14
|
+
- Public group reflection must stay private unless a later model-gated outreach pass chooses a safe same-group reply.
|
|
15
|
+
- Private DM outreach remains disabled unless an explicit consent and delivery policy is added.
|
|
16
|
+
- Graph traversal must start from scoped Telegram corpus candidates, not repo files.
|
|
17
|
+
- Vector search must be used first when embeddings are available; lexical/recent fallback is allowed only when embedding generation is unavailable and must be recorded in artifact metadata.
|
|
18
|
+
- Candidate selection must prefer inner graph nodes with meaningful degree and evidence, then randomly choose one candidate from the eligible set for reflection.
|
|
19
|
+
- The graph walk must expand from the selected node across valid scoped edges until depth, candidate, and token budgets are met.
|
|
20
|
+
- The model extraction pass must return structured data for all five required operations: tagging, summation, titling, extraction, and linking.
|
|
21
|
+
- All committed memory must preserve source message ids and reply relationships.
|
|
22
|
+
|
|
23
|
+
## Current State
|
|
24
|
+
|
|
25
|
+
Telegram already has a scoped reflection command path:
|
|
26
|
+
|
|
27
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2152` has `handleTelegramReflectionSlash`.
|
|
28
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2710` has `runTelegramChannelDmnForSession`.
|
|
29
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2746` has `runTelegramChannelDmnSweep`.
|
|
30
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2767` has `maybeSendTelegramReflectionFollowup`.
|
|
31
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2877` injects the latest reflection context into live routing.
|
|
32
|
+
|
|
33
|
+
The existing artifact builder is still mostly a retained-history summarizer:
|
|
34
|
+
|
|
35
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:44` defines `TelegramChannelDaydreamInput`.
|
|
36
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:57` defines `TelegramChannelDaydreamArtifact`.
|
|
37
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:516` builds the artifact.
|
|
38
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:579` formats markdown.
|
|
39
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:641` writes JSON and markdown.
|
|
40
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts:666` formats injected runtime context.
|
|
41
|
+
|
|
42
|
+
Telegram conversation retention exists but does not yet commit text turns into the shared graph/vector corpus:
|
|
43
|
+
|
|
44
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2539` computes scoped conversation file paths.
|
|
45
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2556` loads persisted chat history.
|
|
46
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2623` saves chat history, participants, memory cards, stimulation, and reflection state.
|
|
47
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2901` records user messages in scoped history.
|
|
48
|
+
- `packages/cli/src/tui/telegram-bridge.ts:2949` records assistant messages in scoped history.
|
|
49
|
+
- `packages/cli/src/tui/telegram-bridge.ts:3216` updates JSON-only memory cards.
|
|
50
|
+
- `packages/cli/src/tui/telegram-bridge.ts:3322` builds the live Telegram context stream.
|
|
51
|
+
|
|
52
|
+
Shared memory primitives already exist:
|
|
53
|
+
|
|
54
|
+
- `packages/memory/src/episodeStore.ts:66` includes `social`, `text`, and `reflection` modalities.
|
|
55
|
+
- `packages/memory/src/episodeStore.ts:355` inserts episodes and auto-links them when a graph is attached.
|
|
56
|
+
- `packages/memory/src/episodeStore.ts:412` performs lexical plus vector search.
|
|
57
|
+
- `packages/memory/src/episodeStore.ts:545` merges PPR graph retrieval with normal search.
|
|
58
|
+
- `packages/memory/src/episodeStore.ts:625` stores native embeddings.
|
|
59
|
+
- `packages/memory/src/episodeStore.ts:631` stores CLIP-compatible embeddings.
|
|
60
|
+
- `packages/memory/src/temporalGraph.ts:24` includes Telegram-relevant relations such as `contains`, `authored_by`, `said_by`, `replied_to`, `depicts`, `named_as`, `voice_sample_of`, and `same_person_candidate`.
|
|
61
|
+
- `packages/memory/src/temporalGraph.ts:121` creates graph nodes.
|
|
62
|
+
- `packages/memory/src/temporalGraph.ts:186` creates graph edges.
|
|
63
|
+
- `packages/memory/src/temporalGraph.ts:253` returns valid one-hop neighbors.
|
|
64
|
+
- `packages/memory/src/zettelkasten.ts:94` finds vector/CLIP neighbors.
|
|
65
|
+
- `packages/memory/src/zettelkasten.ts:127` links related episodes into the graph.
|
|
66
|
+
- `packages/memory/src/pprRetrieval.ts:161` runs personalized PageRank.
|
|
67
|
+
- `packages/memory/src/pprRetrieval.ts:252` maps PPR graph scores back to episodes.
|
|
68
|
+
- `packages/memory/src/multimodalIdentity.ts:178` ingests multimodal evidence into episodes and graph nodes.
|
|
69
|
+
|
|
70
|
+
## Target Architecture
|
|
71
|
+
|
|
72
|
+
### Corpus Layer
|
|
73
|
+
|
|
74
|
+
Add `packages/cli/src/tui/telegram-reflection-corpus.ts`.
|
|
75
|
+
|
|
76
|
+
Responsibilities:
|
|
77
|
+
|
|
78
|
+
- Convert scoped Telegram history entries into durable `EpisodeStore` episodes.
|
|
79
|
+
- Use `MultimodalIdentityService` for message, sender, reply, and media graph atoms where the message has Telegram evidence.
|
|
80
|
+
- Generate text embeddings for new or missing scoped Telegram text/reflection episodes when an embedding backend is configured.
|
|
81
|
+
- Add graph nodes and edges that make text-only Telegram turns traversable even without media:
|
|
82
|
+
- scope node contains message node
|
|
83
|
+
- message node authored_by sender node
|
|
84
|
+
- assistant/user message node replied_to target message node when present
|
|
85
|
+
- message node said_by sender node for natural-language content
|
|
86
|
+
- message node related_to derived tag/title/summary nodes after extraction
|
|
87
|
+
- Expose a single integrated function for the reflection runner:
|
|
88
|
+
- `buildTelegramReflectionCorpus(options): Promise<TelegramReflectionCorpusResult>`
|
|
89
|
+
|
|
90
|
+
Required result shape:
|
|
91
|
+
|
|
92
|
+
- `stats`: counts for retained messages, inserted episodes, reused episodes, embedded episodes, candidate episodes, graph nodes, graph edges, selected nodes, walked episodes.
|
|
93
|
+
- `seed`: selected episode id, node id, node text, selection method, vector search limit used, graph depth used.
|
|
94
|
+
- `walk`: ordered nodes, edges, episodes, source message ids, reply message ids.
|
|
95
|
+
- `fallbacks`: explicit list of degraded paths such as embedding unavailable or no inner graph candidates found.
|
|
96
|
+
|
|
97
|
+
### Graph/Vector Selection Layer
|
|
98
|
+
|
|
99
|
+
Add `packages/memory/src/graphWalk.ts` and export it from `packages/memory/src/index.ts`.
|
|
100
|
+
|
|
101
|
+
Responsibilities:
|
|
102
|
+
|
|
103
|
+
- Accept a list of vector/lexical episode candidates plus a `TemporalGraph`.
|
|
104
|
+
- Resolve candidate episodes to graph nodes through current edges carrying `sourceEpisodeId`.
|
|
105
|
+
- Score inner node candidates by:
|
|
106
|
+
- valid degree;
|
|
107
|
+
- distinct source episode count;
|
|
108
|
+
- relation diversity;
|
|
109
|
+
- scoped Telegram metadata match;
|
|
110
|
+
- recency of source evidence.
|
|
111
|
+
- Expand candidate search limits in order: 48, 96, 192, 384, 500 until at least one eligible inner node exists or the corpus is exhausted.
|
|
112
|
+
- Randomly choose one eligible inner node using a deterministic seeded RNG derived from session key plus artifact run id.
|
|
113
|
+
- Walk outward breadth-first from the selected node across valid graph edges.
|
|
114
|
+
- Return the selected seed, visited nodes, traversed edges, source episode ids, and degree/evidence diagnostics.
|
|
115
|
+
|
|
116
|
+
Exact memory anchors:
|
|
117
|
+
|
|
118
|
+
- `packages/memory/src/temporalGraph.ts:253` currently provides only one-hop neighbors; `graphWalk.ts` will compose this without changing graph storage.
|
|
119
|
+
- `packages/memory/src/pprRetrieval.ts:161` remains available for PPR scoring, but this reflection cycle needs explicit node candidate selection, seeded random choice, and bounded walk diagnostics.
|
|
120
|
+
- `packages/memory/src/index.ts:74` currently exports PPR helpers; add graph walk exports adjacent to this section.
|
|
121
|
+
|
|
122
|
+
### Extraction Layer
|
|
123
|
+
|
|
124
|
+
Add `packages/cli/src/tui/telegram-reflection-extraction.ts`.
|
|
125
|
+
|
|
126
|
+
Responsibilities:
|
|
127
|
+
|
|
128
|
+
- Build a compact corpus packet from the graph walk and source episodes.
|
|
129
|
+
- Ask the configured backend for strict JSON output.
|
|
130
|
+
- Validate and normalize the parsed structure without regex-based semantic decisions.
|
|
131
|
+
- Return all five required operation groups:
|
|
132
|
+
- `tagging`: scoped tags with confidence, source message ids, and target node/episode ids.
|
|
133
|
+
- `summation`: concise channel/thread/user/message-window summaries with evidence anchors.
|
|
134
|
+
- `titling`: artifact title, thread titles, memory card titles, and graph node labels.
|
|
135
|
+
- `extraction`: facts, preferences, open questions, decisions, identity assertion candidates, media references, and follow-up opportunities.
|
|
136
|
+
- `linking`: proposed graph links between messages, users, topics, media, summaries, and prior memory cards.
|
|
137
|
+
- Never claim a face, voice, or person identity unless the source corpus contains explicit identity evidence or the `identity_memory` tool later verifies it.
|
|
138
|
+
|
|
139
|
+
Required schema:
|
|
140
|
+
|
|
141
|
+
- `artifact_title: string`
|
|
142
|
+
- `tags: Array<{ label, kind, confidence, source_message_ids, target_episode_ids, target_node_ids }>`
|
|
143
|
+
- `summaries: Array<{ title, scope, text, confidence, source_message_ids, target_episode_ids }>`
|
|
144
|
+
- `extractions: Array<{ kind, text, confidence, source_message_ids, target_episode_ids, target_node_ids }>`
|
|
145
|
+
- `links: Array<{ relation, src_node_text, dst_node_text, confidence, fact, source_message_ids, target_episode_ids }>`
|
|
146
|
+
- `followups: Array<{ target, text, reply_to_message_id, rationale, confidence }>`
|
|
147
|
+
|
|
148
|
+
### Artifact Layer
|
|
149
|
+
|
|
150
|
+
Extend `packages/cli/src/tui/telegram-channel-dmn.ts`.
|
|
151
|
+
|
|
152
|
+
Required changes:
|
|
153
|
+
|
|
154
|
+
- Bump artifact `version` from `2` to `3`.
|
|
155
|
+
- Add `corpus`, `selectedSeed`, `graphWalk`, `tagging`, `summation`, `titling`, `extraction`, and `linking` fields to `TelegramChannelDaydreamArtifact`.
|
|
156
|
+
- Keep existing fields only when they are either directly useful to live routing or backed by corpus extraction.
|
|
157
|
+
- Update `buildTelegramChannelDaydream` to accept an optional corpus/extraction result and merge it into the artifact.
|
|
158
|
+
- Update markdown formatting at `packages/cli/src/tui/telegram-channel-dmn.ts:579` to show source anchors, graph seed, walk stats, tags, summaries, titles, extractions, and links.
|
|
159
|
+
- Update injected context at `packages/cli/src/tui/telegram-channel-dmn.ts:666` to prioritize:
|
|
160
|
+
- selected seed;
|
|
161
|
+
- graph walk summary;
|
|
162
|
+
- top tags;
|
|
163
|
+
- strongest summaries;
|
|
164
|
+
- unresolved extraction items;
|
|
165
|
+
- reply-linked source message ids.
|
|
166
|
+
|
|
167
|
+
### Telegram Bridge Wiring
|
|
168
|
+
|
|
169
|
+
Modify `packages/cli/src/tui/telegram-bridge.ts`.
|
|
170
|
+
|
|
171
|
+
Required changes:
|
|
172
|
+
|
|
173
|
+
- At `recordTelegramUserMessage` (`packages/cli/src/tui/telegram-bridge.ts:2901`), enqueue or immediately upsert the text turn into the scoped reflection corpus after local history is recorded.
|
|
174
|
+
- At `recordTelegramAssistantMessage` (`packages/cli/src/tui/telegram-bridge.ts:2949`), upsert assistant outputs into the same corpus with assistant sender metadata and reply anchors.
|
|
175
|
+
- At `runTelegramChannelDmnForSession` (`packages/cli/src/tui/telegram-bridge.ts:2710`), build the corpus first, run graph/vector selection, run extraction, then build and write the artifact.
|
|
176
|
+
- At `maybeSendTelegramReflectionFollowup` (`packages/cli/src/tui/telegram-bridge.ts:2767`), source `candidateMessageIds` from artifact extraction/linking/source anchors, not only curiosity threads and memory proposals.
|
|
177
|
+
- At `handleTelegramReflectionSlash`, expose status lines for corpus episode count, selected seed, walk size, tags, summaries, extraction count, and link count.
|
|
178
|
+
- Preserve current `/reflect`, `/reflection`, `/daydream`, and Telegram-scoped `/dream` behavior; do not route these into TUI DreamEngine.
|
|
179
|
+
|
|
180
|
+
### Persistence And Indexing
|
|
181
|
+
|
|
182
|
+
Use existing shared stores:
|
|
183
|
+
|
|
184
|
+
- `episodes.db` for text, social, and reflection episodes.
|
|
185
|
+
- `knowledge.db` for graph nodes and edges.
|
|
186
|
+
- `.omnius/telegram-daydreams/<session-hash>/` for JSON and markdown reflection artifacts.
|
|
187
|
+
- `.omnius/telegram-conversations/<session-hash>.json` remains the lightweight retained context cache.
|
|
188
|
+
|
|
189
|
+
Required data model conventions:
|
|
190
|
+
|
|
191
|
+
- Episode `sessionId` is the Telegram `sessionKey`.
|
|
192
|
+
- Episode `metadata.sourceSurface` is `telegram`.
|
|
193
|
+
- Episode `metadata.scope` contains `{ kind: "group" | "private", id: chatId, title }`.
|
|
194
|
+
- Episode `metadata.telegram` contains chat id, chat type, chat title, message id, thread id, sender id, username, display name, reply target, and media summary.
|
|
195
|
+
- Graph scope node text matches `scope:telegram:<chatType>:<chatId>`.
|
|
196
|
+
- Graph message node text uses a stable Telegram message key.
|
|
197
|
+
- Summary/tag/title/extraction nodes must carry `sourceEpisodeId` on their creating edges.
|
|
198
|
+
|
|
199
|
+
### Zettelkasten And Multimodal Memory Integration
|
|
200
|
+
|
|
201
|
+
Required changes:
|
|
202
|
+
|
|
203
|
+
- Text Telegram episodes with embeddings must use existing zettelkasten linking through `EpisodeStore.insert` plus explicit post-embedding link refresh.
|
|
204
|
+
- CLIP-only visual/audio episodes already link through `packages/memory/src/zettelkasten.ts:94`; reflection cycles must include related visual/audio episodes when graph walk reaches media nodes.
|
|
205
|
+
- `packages/memory/src/multimodalIdentity.ts:178` remains the central ingest service for media and explicit identity evidence.
|
|
206
|
+
- Reflection extraction can propose identity assertion candidates, but must not commit `named_as`, `depicts`, or `voice_sample_of` unless the underlying message already contains explicit user-supplied identity evidence or a later tool call verifies it.
|
|
207
|
+
|
|
208
|
+
### Efficient Small-Context Handling
|
|
209
|
+
|
|
210
|
+
The reflection cycle must not dump entire chat history into the model.
|
|
211
|
+
|
|
212
|
+
Budgeting rules:
|
|
213
|
+
|
|
214
|
+
- Vector/lexical search candidate budget starts at 48 and expands only if no inner graph candidates are found.
|
|
215
|
+
- Graph walk depth defaults to 2, expands to 3 only if fewer than 8 source episodes are recovered.
|
|
216
|
+
- Corpus packet passed to extraction includes compact episode snippets, source anchors, and graph relation facts, not raw full logs.
|
|
217
|
+
- Summaries and tags are committed as artifacts so future cycles can read compressed memories instead of rereading old turns.
|
|
218
|
+
- Live Telegram context injection displays only top-scoring structured outputs and source anchors.
|
|
219
|
+
|
|
220
|
+
## Implementation Checklist
|
|
221
|
+
|
|
222
|
+
### Planning
|
|
223
|
+
|
|
224
|
+
- [x] Create this tracking document before code changes.
|
|
225
|
+
- [x] Confirm all existing reflection/dream tests still represent Telegram-scoped behavior.
|
|
226
|
+
|
|
227
|
+
### Shared Graph Walk
|
|
228
|
+
|
|
229
|
+
- [x] Add `packages/memory/src/graphWalk.ts`.
|
|
230
|
+
- [x] Export graph walk helpers from `packages/memory/src/index.ts`.
|
|
231
|
+
- [x] Add tests for vector candidate expansion, inner node selection, seeded random choice, scoped filtering, and bounded graph walking.
|
|
232
|
+
|
|
233
|
+
### Telegram Corpus
|
|
234
|
+
|
|
235
|
+
- [x] Add `packages/cli/src/tui/telegram-reflection-corpus.ts`.
|
|
236
|
+
- [x] Upsert scoped Telegram user messages into `EpisodeStore`.
|
|
237
|
+
- [x] Upsert scoped Telegram assistant messages into `EpisodeStore`.
|
|
238
|
+
- [x] Preserve reply relationships in graph edges.
|
|
239
|
+
- [x] Generate or fill text embeddings when configured.
|
|
240
|
+
- [x] Refresh zettelkasten links after embeddings are stored.
|
|
241
|
+
- [x] Include scoped visual/audio/media graph neighbors in walks.
|
|
242
|
+
|
|
243
|
+
### Extraction
|
|
244
|
+
|
|
245
|
+
- [x] Add `packages/cli/src/tui/telegram-reflection-extraction.ts`.
|
|
246
|
+
- [x] Build strict JSON extraction prompt with source anchors.
|
|
247
|
+
- [x] Validate tagging, summation, titling, extraction, and linking groups.
|
|
248
|
+
- [x] Commit summary/tag/title/extraction episodes and graph nodes.
|
|
249
|
+
- [x] Add tests for malformed JSON, empty corpus, embedding-disabled fallback, and complete five-operation output.
|
|
250
|
+
|
|
251
|
+
### Artifact
|
|
252
|
+
|
|
253
|
+
- [x] Bump Telegram daydream artifact to version 3.
|
|
254
|
+
- [x] Add corpus, seed, walk, tags, summaries, titles, extractions, and links to the artifact.
|
|
255
|
+
- [x] Update markdown output to make source anchors readable.
|
|
256
|
+
- [x] Update runtime context injection to use structured reflection data.
|
|
257
|
+
|
|
258
|
+
### Bridge
|
|
259
|
+
|
|
260
|
+
- [x] Wire corpus upsert into `recordTelegramUserMessage`.
|
|
261
|
+
- [x] Wire corpus upsert into `recordTelegramAssistantMessage`.
|
|
262
|
+
- [x] Wire corpus build, graph/vector seed selection, graph walk, extraction, and artifact commit into `runTelegramChannelDmnForSession`.
|
|
263
|
+
- [x] Update reflection follow-up candidate message id selection to use extraction/link anchors.
|
|
264
|
+
- [x] Update `/reflect status` output with corpus and graph metrics.
|
|
265
|
+
|
|
266
|
+
### Validation
|
|
267
|
+
|
|
268
|
+
- [x] Run `pnpm --filter @omnius/memory test`.
|
|
269
|
+
- [x] Run `pnpm --filter omnius test -- tests/telegram-bot-api-10.test.ts`.
|
|
270
|
+
- [x] Add and run focused tests for the new corpus/extraction modules.
|
|
271
|
+
- [x] Run `pnpm --filter @omnius/memory build`.
|
|
272
|
+
- [x] Run `pnpm --filter omnius build`.
|
|
273
|
+
- [x] Run `git diff --check`.
|
|
274
|
+
- [x] Backward-pass each checklist item against the final diff before commit.
|
|
275
|
+
|
|
276
|
+
## Backward-Pass Verification
|
|
277
|
+
|
|
278
|
+
- `packages/memory/src/graphWalk.ts` implements inner-node selection from episode-backed graph evidence, seeded random choice, and bounded graph walking.
|
|
279
|
+
- `packages/memory/src/temporalGraph.ts` now exposes current edges by source episode id so vector candidates can be mapped into graph neighborhoods.
|
|
280
|
+
- `packages/memory/src/multimodalIdentity.ts` accepts `sessionId` and caller metadata so Telegram text/media evidence lands in the scoped episode corpus.
|
|
281
|
+
- `packages/cli/src/tui/telegram-reflection-corpus.ts` upserts Telegram user and assistant turns, fills embeddings when configured, refreshes zettelkasten links, expands candidate limits, and selects graph walks.
|
|
282
|
+
- `packages/cli/src/tui/telegram-reflection-extraction.ts` builds strict JSON prompts, validates all five operation groups, and commits reflection/gist episodes plus graph nodes and links.
|
|
283
|
+
- `packages/cli/src/tui/telegram-channel-dmn.ts` writes version 3 artifacts with corpus, selected seed, graph walk, tags, summaries, titles, extractions, links, and follow-up candidates.
|
|
284
|
+
- `packages/cli/src/tui/telegram-bridge.ts` records live Telegram turns into the corpus and routes `/reflect` through corpus build, graph walk, model extraction, artifact writing, and model-gated follow-up anchoring.
|
|
285
|
+
- Regression coverage:
|
|
286
|
+
- `packages/memory/tests/graphWalk.test.ts`
|
|
287
|
+
- `packages/cli/tests/telegram-reflection-corpus.test.ts`
|
|
288
|
+
- `packages/cli/tests/telegram-reflection-extraction.test.ts`
|
|
289
|
+
- `packages/cli/tests/telegram-bot-api-10.test.ts`
|
|
290
|
+
|
|
291
|
+
## Completion Definition
|
|
292
|
+
|
|
293
|
+
This integration is complete only when a Telegram `/reflect` run can:
|
|
294
|
+
|
|
295
|
+
1. Read the scoped chat corpus.
|
|
296
|
+
2. Persist new text turns into `episodes.db`.
|
|
297
|
+
3. Preserve sender, message, reply, scope, and media relationships in `knowledge.db`.
|
|
298
|
+
4. Search scoped episodes with embeddings where available.
|
|
299
|
+
5. Expand candidate search depth when there are not enough graph candidates.
|
|
300
|
+
6. Select an inner graph node from eligible vector-search candidates.
|
|
301
|
+
7. Walk the graph outward from that node within depth and token budgets.
|
|
302
|
+
8. Produce structured tagging, summation, titling, extraction, and linking data.
|
|
303
|
+
9. Write JSON and markdown artifacts with source message anchors.
|
|
304
|
+
10. Commit reflection outputs back into episodes and graph links.
|
|
305
|
+
11. Inject compact structured context into future Telegram agent turns.
|
|
306
|
+
12. Let the model-gated follow-up path use the same source anchors when deciding whether to reply.
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
# Telegram Unified Tooling Architecture
|
|
2
|
+
|
|
3
|
+
Goal: give Telegram-sourced agent runs one scoped `telegram` tool that covers
|
|
4
|
+
Telegram Bot API operations behind explicit Omnius policy, Telegram bot rights,
|
|
5
|
+
and admin-controlled toggles. This replaces the current drift where some
|
|
6
|
+
Telegram powers exist as private helpers, some exist as TUI slash commands, and
|
|
7
|
+
only `telegram_send_file` is model-facing.
|
|
8
|
+
|
|
9
|
+
## Current State
|
|
10
|
+
|
|
11
|
+
The bot does not currently expose message deletion as an agent tool.
|
|
12
|
+
|
|
13
|
+
Existing code paths:
|
|
14
|
+
|
|
15
|
+
- `packages/cli/src/tui/telegram-bridge.ts`
|
|
16
|
+
- `deleteLiveMessage(...)` is a private cleanup helper for Omnius streaming
|
|
17
|
+
messages. It calls `deleteMessage`, but it is not a model-facing tool and
|
|
18
|
+
cannot be used for janitorial moderation.
|
|
19
|
+
- `deleteMessageReaction(...)` and `deleteAllMessageReactions(...)` exist as
|
|
20
|
+
bridge methods.
|
|
21
|
+
- `getChatAdministrators(...)` exists as a bridge method.
|
|
22
|
+
- `sendCallButton(...)` sends an inline URL keyboard, but the bridge does not
|
|
23
|
+
poll `callback_query` updates and does not answer callback queries.
|
|
24
|
+
- `buildSubAgentTools(...)` exposes `telegram_send_file`, not a unified
|
|
25
|
+
Telegram admin/moderation tool.
|
|
26
|
+
- `packages/cli/src/tui/commands.ts`
|
|
27
|
+
- `/telegram delete-reaction ...`
|
|
28
|
+
- `/telegram delete-reactions ...`
|
|
29
|
+
- `/telegram admins ...`
|
|
30
|
+
- No `/telegram delete-message` or `/telegram delete-messages`.
|
|
31
|
+
- `packages/cli/src/tui/tool-policy.ts`
|
|
32
|
+
- Whole-tool context gating exists.
|
|
33
|
+
- There is no action-level policy for one high-scope Telegram tool.
|
|
34
|
+
|
|
35
|
+
Result: Omnius can send files and delete reactions, but it cannot agentically
|
|
36
|
+
delete its own messages or user messages. It also cannot offer Telegram inline
|
|
37
|
+
buttons for scoped tool enable/disable because callback queries are not wired.
|
|
38
|
+
|
|
39
|
+
## Official API Constraints
|
|
40
|
+
|
|
41
|
+
Sources:
|
|
42
|
+
|
|
43
|
+
- https://core.telegram.org/bots/api#deletemessage
|
|
44
|
+
- https://core.telegram.org/bots/api#deletemessages
|
|
45
|
+
- https://core.telegram.org/bots/api#getchatadministrators
|
|
46
|
+
- https://core.telegram.org/bots/api#callbackquery
|
|
47
|
+
- https://core.telegram.org/bots/api#answercallbackquery
|
|
48
|
+
- https://core.telegram.org/bots/api#inlinekeyboardmarkup
|
|
49
|
+
|
|
50
|
+
Deletion constraints to model explicitly:
|
|
51
|
+
|
|
52
|
+
- Bots can delete outgoing messages in private chats, groups, and supergroups.
|
|
53
|
+
- Bots can delete incoming messages in private chats.
|
|
54
|
+
- In groups, a bot must be an administrator to delete arbitrary messages.
|
|
55
|
+
- In supergroups/channels, the bot needs `can_delete_messages` to delete
|
|
56
|
+
arbitrary messages.
|
|
57
|
+
- Telegram applies message-age and service-message limits. Failed deletes must
|
|
58
|
+
report the Bot API error back to the tool result.
|
|
59
|
+
- `deleteMessages` is the batch endpoint for multiple message IDs and should be
|
|
60
|
+
preferred when deleting more than one message.
|
|
61
|
+
|
|
62
|
+
Inline button constraints:
|
|
63
|
+
|
|
64
|
+
- The poll loop must request `callback_query` updates.
|
|
65
|
+
- Every callback query should be answered with `answerCallbackQuery`, even when
|
|
66
|
+
no alert is shown, so Telegram clients stop the progress spinner.
|
|
67
|
+
- Callback payloads are limited and should carry only a short signed state key
|
|
68
|
+
or compact action token, not full policy JSON.
|
|
69
|
+
|
|
70
|
+
## Target Shape
|
|
71
|
+
|
|
72
|
+
Expose one model-facing tool:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
telegram({
|
|
76
|
+
action: "...",
|
|
77
|
+
target: "...",
|
|
78
|
+
message_id: 123,
|
|
79
|
+
message_ids: [123, 124],
|
|
80
|
+
user_id: 777,
|
|
81
|
+
permissions: {...},
|
|
82
|
+
text: "...",
|
|
83
|
+
reason: "...",
|
|
84
|
+
dry_run: false
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Keep `telegram_send_file` as a compatibility alias for now, but route it through
|
|
89
|
+
the same underlying delivery ledger and policy checks.
|
|
90
|
+
|
|
91
|
+
### Action Groups
|
|
92
|
+
|
|
93
|
+
Read actions:
|
|
94
|
+
|
|
95
|
+
- `get_me`
|
|
96
|
+
- `get_chat`
|
|
97
|
+
- `get_chat_member`
|
|
98
|
+
- `get_chat_administrators`
|
|
99
|
+
- `get_message_context`
|
|
100
|
+
- `get_tool_scope`
|
|
101
|
+
|
|
102
|
+
Message actions:
|
|
103
|
+
|
|
104
|
+
- `send_message`
|
|
105
|
+
- `edit_message_text`
|
|
106
|
+
- `edit_message_caption`
|
|
107
|
+
- `edit_message_reply_markup`
|
|
108
|
+
- `delete_message`
|
|
109
|
+
- `delete_messages`
|
|
110
|
+
- `pin_message`
|
|
111
|
+
- `unpin_message`
|
|
112
|
+
- `unpin_all_messages`
|
|
113
|
+
|
|
114
|
+
Media actions:
|
|
115
|
+
|
|
116
|
+
- `send_file`
|
|
117
|
+
- `send_photo`
|
|
118
|
+
- `send_document`
|
|
119
|
+
- `send_audio`
|
|
120
|
+
- `send_voice`
|
|
121
|
+
- `send_video`
|
|
122
|
+
|
|
123
|
+
Moderation actions:
|
|
124
|
+
|
|
125
|
+
- `ban_chat_member`
|
|
126
|
+
- `unban_chat_member`
|
|
127
|
+
- `restrict_chat_member`
|
|
128
|
+
- `promote_chat_member`
|
|
129
|
+
- `set_chat_permissions`
|
|
130
|
+
- `approve_chat_join_request`
|
|
131
|
+
- `decline_chat_join_request`
|
|
132
|
+
|
|
133
|
+
Reaction actions:
|
|
134
|
+
|
|
135
|
+
- `set_message_reaction`
|
|
136
|
+
- `delete_message_reaction`
|
|
137
|
+
- `delete_all_message_reactions`
|
|
138
|
+
|
|
139
|
+
Bot and admin actions:
|
|
140
|
+
|
|
141
|
+
- `set_my_commands`
|
|
142
|
+
- `get_my_commands`
|
|
143
|
+
- `set_chat_menu_button`
|
|
144
|
+
- `get_chat_menu_button`
|
|
145
|
+
- `set_my_description`
|
|
146
|
+
- `get_my_description`
|
|
147
|
+
|
|
148
|
+
Policy actions:
|
|
149
|
+
|
|
150
|
+
- `scope_status`
|
|
151
|
+
- `enable_action`
|
|
152
|
+
- `disable_action`
|
|
153
|
+
- `enable_group`
|
|
154
|
+
- `disable_group`
|
|
155
|
+
- `render_admin_buttons`
|
|
156
|
+
|
|
157
|
+
## Scope Model
|
|
158
|
+
|
|
159
|
+
The `telegram` tool should evaluate four layers before making any Bot API call.
|
|
160
|
+
|
|
161
|
+
1. Telegram source context
|
|
162
|
+
|
|
163
|
+
- `telegram-public`: current chat only. No janitorial or moderation actions.
|
|
164
|
+
- `telegram-admin-group`: current chat only. Janitorial actions allowed only if
|
|
165
|
+
the Omnius policy enables them and the sender is the authenticated admin.
|
|
166
|
+
- `telegram-admin-dm`: may target the current DM or a known prior chat from the
|
|
167
|
+
bridge target registry. Unknown numeric chat IDs are allowed only when the
|
|
168
|
+
local admin explicitly supplies them.
|
|
169
|
+
|
|
170
|
+
2. Omnius action policy
|
|
171
|
+
|
|
172
|
+
Add action-level policy below the current whole-tool policy:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
interface TelegramToolPolicy {
|
|
176
|
+
enabledActionGroups?: Record<string, boolean>;
|
|
177
|
+
enabledActions?: Record<string, boolean>;
|
|
178
|
+
chatOverrides?: Record<string, {
|
|
179
|
+
enabledActionGroups?: Record<string, boolean>;
|
|
180
|
+
enabledActions?: Record<string, boolean>;
|
|
181
|
+
}>;
|
|
182
|
+
requireAdminForMutation?: boolean;
|
|
183
|
+
dryRunByDefault?: boolean;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Persist this under `OmniusSettings.telegramToolPolicy`.
|
|
188
|
+
|
|
189
|
+
3. Bot rights
|
|
190
|
+
|
|
191
|
+
Before mutating chat state, call or cache bot rights:
|
|
192
|
+
|
|
193
|
+
- `getMe` for bot id.
|
|
194
|
+
- `getChatMember(chat_id, bot_id)` or `getChatAdministrators(chat_id, true)`.
|
|
195
|
+
- Require `can_delete_messages` before `delete_message(s)` for supergroups and
|
|
196
|
+
channels.
|
|
197
|
+
- Require matching rights for pinning, restricting, banning, promotion, and
|
|
198
|
+
permissions changes.
|
|
199
|
+
|
|
200
|
+
4. Operation proof
|
|
201
|
+
|
|
202
|
+
Mutating tool results should include:
|
|
203
|
+
|
|
204
|
+
- `action`
|
|
205
|
+
- `chat_id`
|
|
206
|
+
- `message_id` or `message_ids`
|
|
207
|
+
- `telegram_method`
|
|
208
|
+
- `ok`
|
|
209
|
+
- `bot_rights_checked`
|
|
210
|
+
- `policy_scope`
|
|
211
|
+
- Telegram error description if failed
|
|
212
|
+
|
|
213
|
+
## Admin Buttons
|
|
214
|
+
|
|
215
|
+
Add a Telegram admin control surface using inline keyboards.
|
|
216
|
+
|
|
217
|
+
Command routes:
|
|
218
|
+
|
|
219
|
+
- `/telegram tools` in TUI: print current policy and optionally send a Telegram
|
|
220
|
+
admin panel to the admin DM.
|
|
221
|
+
- `/tools` or `/telegram_tools` in Telegram admin DM: show buttons.
|
|
222
|
+
- `/telegram tools group <chat>`: show/edit policy for a group.
|
|
223
|
+
|
|
224
|
+
Button behavior:
|
|
225
|
+
|
|
226
|
+
- Add `callback_query` to `allowed_updates` in `pollLoop`.
|
|
227
|
+
- Normalize callback updates beside messages.
|
|
228
|
+
- Add `handleTelegramCallbackQuery(...)`.
|
|
229
|
+
- Verify callback sender is the authenticated admin.
|
|
230
|
+
- Call `answerCallbackQuery` for every callback.
|
|
231
|
+
- Store button state server-side:
|
|
232
|
+
- `.omnius/telegram-tool-buttons/<nonce>.json`
|
|
233
|
+
- callback payload: `omni:v1:tool:<nonce>:<action>`
|
|
234
|
+
- short TTL, e.g. 15 minutes.
|
|
235
|
+
- Toggle action groups or actions, then edit the menu message with updated
|
|
236
|
+
checkboxes.
|
|
237
|
+
|
|
238
|
+
Suggested panels:
|
|
239
|
+
|
|
240
|
+
- Global policy:
|
|
241
|
+
- Read
|
|
242
|
+
- Message send/edit
|
|
243
|
+
- Janitorial delete
|
|
244
|
+
- Reactions
|
|
245
|
+
- Moderation
|
|
246
|
+
- Bot profile/admin
|
|
247
|
+
- Current chat override:
|
|
248
|
+
- Same groups, but scoped to one chat id.
|
|
249
|
+
- Safety buttons:
|
|
250
|
+
- Dry-run by default on/off.
|
|
251
|
+
- Require admin confirmation for delete-many/moderation on/off.
|
|
252
|
+
|
|
253
|
+
## Code Anchors
|
|
254
|
+
|
|
255
|
+
Primary implementation anchors:
|
|
256
|
+
|
|
257
|
+
- `packages/cli/src/tui/telegram-bridge.ts`
|
|
258
|
+
- Add `buildTelegramTool(context, repoRoot, chatId, msg)`.
|
|
259
|
+
- Register this tool in `buildSubAgentTools(...)`.
|
|
260
|
+
- Replace direct action helpers with shared `callTelegramApiAction(...)`.
|
|
261
|
+
- Add public bridge methods:
|
|
262
|
+
- `deleteTelegramMessage(...)`
|
|
263
|
+
- `deleteTelegramMessages(...)`
|
|
264
|
+
- `getChatMember(...)`
|
|
265
|
+
- `getBotChatRights(...)`
|
|
266
|
+
- `answerCallbackQuery(...)`
|
|
267
|
+
- `sendTelegramToolPanel(...)`
|
|
268
|
+
- `handleTelegramCallbackQuery(...)`
|
|
269
|
+
- Add `callback_query` to `allowed_updates`.
|
|
270
|
+
- `packages/cli/src/tui/tool-policy.ts`
|
|
271
|
+
- Add `telegram` to safe allowlists only for read/status actions.
|
|
272
|
+
- Keep high-risk behavior inside action-level policy.
|
|
273
|
+
- `packages/cli/src/tui/omnius-directory.ts`
|
|
274
|
+
- Add `telegramToolPolicy?: TelegramToolPolicy`.
|
|
275
|
+
- `packages/cli/src/tui/commands.ts`
|
|
276
|
+
- Add `/telegram tools`.
|
|
277
|
+
- Add `/telegram delete-message <chat> <message_id>`.
|
|
278
|
+
- Add `/telegram delete-messages <chat> <message_id,...>`.
|
|
279
|
+
- `packages/cli/src/tui/interactive.ts`
|
|
280
|
+
- Wire settings save/load and bridge policy updates.
|
|
281
|
+
- `packages/cli/tests/telegram-bot-api-10.test.ts`
|
|
282
|
+
- Add coverage for message deletion, batch deletion, callback query toggles,
|
|
283
|
+
policy denials, and bot-rights denials.
|
|
284
|
+
- `README.md`
|
|
285
|
+
- Document the unified `telegram` tool, policy defaults, and button controls
|
|
286
|
+
after implementation.
|
|
287
|
+
|
|
288
|
+
## Default Policy Recommendation
|
|
289
|
+
|
|
290
|
+
Defaults should be conservative:
|
|
291
|
+
|
|
292
|
+
- `telegram-public`
|
|
293
|
+
- allow read-only context actions only.
|
|
294
|
+
- deny deletion, moderation, bot profile, and arbitrary target sends.
|
|
295
|
+
- `telegram-admin-group`
|
|
296
|
+
- allow `delete_message` only for current chat when the target message is the
|
|
297
|
+
bot's own message by default.
|
|
298
|
+
- require explicit policy enablement for deleting user messages.
|
|
299
|
+
- deny moderation by default.
|
|
300
|
+
- `telegram-admin-dm`
|
|
301
|
+
- allow full read and send actions.
|
|
302
|
+
- allow janitorial actions only after explicit enablement.
|
|
303
|
+
- allow moderation only after explicit enablement and bot-rights confirmation.
|
|
304
|
+
|
|
305
|
+
## Implementation Checklist
|
|
306
|
+
|
|
307
|
+
- [x] Add `TelegramToolPolicy` settings type and load/save plumbing.
|
|
308
|
+
- [x] Add `telegram` action tool with scoped target resolution.
|
|
309
|
+
- [x] Add delete single/batch message bridge methods.
|
|
310
|
+
- [x] Add bot-rights introspection and cache.
|
|
311
|
+
- [x] Register `telegram` in Telegram admin DM, admin group, and public contexts.
|
|
312
|
+
- [x] Add action-level policy enforcement before each Bot API call.
|
|
313
|
+
- [x] Keep `telegram_send_file` as alias/wrapper over `telegram(action=send_file)`.
|
|
314
|
+
- [x] Add TUI slash routes for delete-message(s) and tools policy.
|
|
315
|
+
- [x] Add callback query polling and `answerCallbackQuery`.
|
|
316
|
+
- [x] Add inline keyboard policy panel for admin toggles.
|
|
317
|
+
- [x] Add tests for allowed deletes, denied deletes, rights failures, and callback
|
|
318
|
+
toggles.
|
|
319
|
+
- [x] Update README once behavior is real.
|
|
320
|
+
|
|
321
|
+
## Done Criteria
|
|
322
|
+
|
|
323
|
+
This is complete when:
|
|
324
|
+
|
|
325
|
+
1. An admin DM can ask the agent to delete a bot message or user message in a
|
|
326
|
+
known group, and the model calls `telegram(action="delete_message", ...)`.
|
|
327
|
+
2. A public group user cannot cause deletion unless the sender is authenticated
|
|
328
|
+
admin, the action is enabled, the target is in the current chat, and the bot
|
|
329
|
+
has Telegram rights.
|
|
330
|
+
3. The admin can open Telegram inline buttons to enable/disable action groups.
|
|
331
|
+
4. The same policy can be changed from TUI slash commands.
|
|
332
|
+
5. Tool results show enough provenance to audit what happened.
|