polygram 0.5.6 → 0.5.8
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/lib/abort-detector.js +24 -10
- package/package.json +1 -1
- package/polygram.js +15 -2
package/lib/abort-detector.js
CHANGED
|
@@ -6,14 +6,17 @@
|
|
|
6
6
|
* interrupt the in-flight turn instead of queueing the message behind it.
|
|
7
7
|
*
|
|
8
8
|
* Conservative on purpose. False positives hijack user intent — "stop using
|
|
9
|
-
* emoji" should NOT abort. So we require:
|
|
10
|
-
* 1. The message (after stripping leading @-mention + trailing
|
|
11
|
-
*
|
|
12
|
-
* 2. It
|
|
9
|
+
* emoji" should NOT abort. So we require ONE of:
|
|
10
|
+
* 1. The whole message (after stripping leading @-mention + trailing
|
|
11
|
+
* punctuation) is an exact match against a known abort phrase, OR
|
|
12
|
+
* 2. It starts with an explicit slash command: /stop, /abort, /cancel, OR
|
|
13
|
+
* 3. The FIRST SENTENCE (split on . ! ?) is an exact abort phrase. This
|
|
14
|
+
* catches "Stop. I'll ask in another session." — clear abort intent
|
|
15
|
+
* with continuation explaining what comes next. Comma is not a split
|
|
16
|
+
* character ("Stop, look here" is ambiguous and stays non-abort).
|
|
13
17
|
*
|
|
14
18
|
* Not detected (on purpose):
|
|
15
|
-
* - "
|
|
16
|
-
* - "stop using markdown" → has trailing content
|
|
19
|
+
* - "stop using markdown" → first sentence is the whole thing, not exact
|
|
17
20
|
* - "I said stop" → not at start / not exact match
|
|
18
21
|
*/
|
|
19
22
|
|
|
@@ -54,10 +57,21 @@ function isAbortRequest(text) {
|
|
|
54
57
|
|
|
55
58
|
const n = normalize(text);
|
|
56
59
|
if (!n) return false;
|
|
57
|
-
//
|
|
58
|
-
// content, not an abort.
|
|
59
|
-
if (n.length
|
|
60
|
-
|
|
60
|
+
// Whole-message exact match (capped — a long message that happens to
|
|
61
|
+
// start with "stop" is real content, not an abort).
|
|
62
|
+
if (n.length <= 40 && ABORT_PHRASES.has(n)) return true;
|
|
63
|
+
|
|
64
|
+
// First-sentence exact match. Splits on . ! ? (NOT comma — "Stop, look
|
|
65
|
+
// here" is ambiguous and stays non-abort). The leading @-mention has
|
|
66
|
+
// already been stripped by normalize but only on the whole string, so
|
|
67
|
+
// we strip it again on the raw text before splitting.
|
|
68
|
+
const head = text.trim().replace(LEADING_MENTION_RE, '');
|
|
69
|
+
const firstSentence = head.split(/[.!?]/, 1)[0]?.trim().toLowerCase();
|
|
70
|
+
if (firstSentence && firstSentence.length <= 40 && ABORT_PHRASES.has(firstSentence)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return false;
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
module.exports = { isAbortRequest, ABORT_PHRASES };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polygram",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Telegram daemon for Claude Code that preserves the OpenClaw per-chat session model. Migration path for OpenClaw users moving to Claude Code.",
|
|
5
5
|
"main": "lib/ipc-client.js",
|
|
6
6
|
"bin": {
|
package/polygram.js
CHANGED
|
@@ -811,7 +811,18 @@ function buildConfigKeyboard(chatConfig, show = 'all') {
|
|
|
811
811
|
// Card text shown above the inline keyboard. Includes plain-language
|
|
812
812
|
// guidance on when to pick which model / effort, since most users
|
|
813
813
|
// (especially in shared groups) don't know which option to tap.
|
|
814
|
-
|
|
814
|
+
//
|
|
815
|
+
// Model versions: polygram passes the alias ("opus", "sonnet", "haiku")
|
|
816
|
+
// to claude, which resolves it to the latest snapshot. We mirror those
|
|
817
|
+
// snapshots here for display only, and verify them on each release with
|
|
818
|
+
// `claude --model <alias>` (probing the system:init event's `model`
|
|
819
|
+
// field). Bumping is a manual step — when claude releases a new
|
|
820
|
+
// snapshot the alias maps to, update this map and ship.
|
|
821
|
+
const MODEL_VERSIONS_DESC = {
|
|
822
|
+
opus: 'claude-opus-4-7',
|
|
823
|
+
sonnet: 'claude-sonnet-4-6',
|
|
824
|
+
haiku: 'claude-haiku-4-5',
|
|
825
|
+
};
|
|
815
826
|
|
|
816
827
|
function formatConfigInfoText(chatConfig, show, sessionKey) {
|
|
817
828
|
const alive = pm.has(sessionKey) && !pm.get(sessionKey).closed;
|
|
@@ -1196,7 +1207,9 @@ async function handleMessage(sessionKey, chatId, msg, bot) {
|
|
|
1196
1207
|
...(tid && { message_thread_id: tid }),
|
|
1197
1208
|
});
|
|
1198
1209
|
|
|
1199
|
-
|
|
1210
|
+
// Single source of truth at module scope (MODEL_VERSIONS_DESC) — see the
|
|
1211
|
+
// comment there for the bump procedure.
|
|
1212
|
+
const MODEL_VERSIONS = MODEL_VERSIONS_DESC;
|
|
1200
1213
|
|
|
1201
1214
|
const botAllowsCommands = !!config.bot?.allowConfigCommands;
|
|
1202
1215
|
const cmdUser = msg.from?.first_name || msg.from?.username || null;
|