docs: add plugin core and Telegram/OpenClaw adapter skeleton / 補 reply-end-controls 核心與 Telegram/OpenClaw 設計骨架

This commit is contained in:
Alice (OpenClaw)
2026-05-12 22:04:16 +08:00
parent 10fa17efc6
commit 588c3a446d
6 changed files with 191 additions and 0 deletions

37
core/callback-contract.md Normal file
View File

@@ -0,0 +1,37 @@
# Callback Contract
## Goal
Define a stable callback payload contract between channel-specific button handlers and the reusable reply-end-controls core.
## Telegram V1 callback values
- `rec:continue`
- `rec:stop`
## Optional message-scoped extension
If V1 needs tighter message binding later, extend to:
- `rec:continue:<messageId>`
- `rec:stop:<messageId>`
## Normalized internal event
Suggested normalized structure after channel parsing:
```json
{
"choice": "continue | stop",
"conversationId": "string",
"sessionKey": "string | null",
"sourceMessageId": "string",
"sourceCallbackId": "string",
"channel": "telegram",
"timestamp": "ISO timestamp"
}
```
## Why normalize
The Telegram parser should convert platform-specific callback payloads into one internal structure, so the reusable policy/state layer does not need to know Telegram details.

29
core/policy.md Normal file
View File

@@ -0,0 +1,29 @@
# Policy
## Goal
Define how reply-end choices influence later assistant behavior.
## Policy rules
### If `lastChoice = continue`
- assistant/runtime may continue normal follow-up behavior
- assistant may keep short-term task momentum
### If `lastChoice = stop`
- assistant should not proactively extend the previous thread
- assistant should avoid unnecessary follow-up prompts
- assistant should treat the prior exchange as closed
### If user types a new message
- typed input takes priority over button state
- the new message may implicitly reopen the interaction
## V1 constraint
V1 only needs to influence continuation behavior.
It does not need to redesign routing, tool permissions, or long-term memory behavior.

49
core/state-model.md Normal file
View File

@@ -0,0 +1,49 @@
# State Model
## Goal
Define the agent-neutral state model for reply-end controls.
This state should be reusable across multiple agents, while Telegram remains the first delivery channel.
## Core state
Suggested canonical structure:
```json
{
"replyEndControls": {
"lastChoice": "continue | stop",
"lastChoiceAt": "ISO timestamp",
"sourceMessageId": "string",
"sourceCallbackId": "string",
"active": true
}
}
```
## Field meanings
- `lastChoice`
- the latest explicit user choice
- `lastChoiceAt`
- when the choice was made
- `sourceMessageId`
- the assistant message whose buttons were clicked
- `sourceCallbackId`
- the callback event id from the channel
- `active`
- whether the latest state should still affect later assistant behavior
## Semantics
- `continue`
- the conversation should remain open to follow-up handling
- `stop`
- the conversation should be treated as closed unless the user explicitly types a new instruction
## Reset rules
- A new typed user message overrides prior button state.
- A later `continue` click overrides an earlier `stop` click.
- The system may optionally expire stale button state in a later version, but V1 does not require timeout expiry.