polygram 0.34.0 → 0.34.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "polygram",
|
|
4
|
-
"version": "0.34.
|
|
4
|
+
"version": "0.34.1",
|
|
5
5
|
"description": "Telegram integration for Claude Code that preserves the OpenClaw per-chat session model. Migration target for OpenClaw users. Multi-bot, multi-chat, per-topic isolation; SQLite transcripts; inline-keyboard approvals. Bundles /polygram:status|logs|pair-code|approvals admin commands plus history (transcript queries) and polygram-send (out-of-turn IPC sends with file-upload validation) skills.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"telegram",
|
|
@@ -1,25 +1,97 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const crypto = require('node:crypto');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
|
|
3
8
|
const CODEX_TEMP_SELECTOR = 'POLYGRAM_CODEX_TMPDIR';
|
|
4
9
|
const ENV_BIN = '/usr/bin/env';
|
|
10
|
+
const APPEND_PROMPT_FLAG = '--append-system-prompt';
|
|
11
|
+
const APPEND_PROMPT_FILE_FLAG = '--append-system-prompt-file';
|
|
12
|
+
|
|
13
|
+
function removePromptFile(file) {
|
|
14
|
+
if (!file) return;
|
|
15
|
+
try { fs.unlinkSync(file); } catch {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function stageAppendPrompt(args) {
|
|
19
|
+
const rewritten = [...(args ?? [])];
|
|
20
|
+
const promptIndex = rewritten.indexOf(APPEND_PROMPT_FLAG);
|
|
21
|
+
if (promptIndex === -1) return { args: rewritten, promptFile: null };
|
|
22
|
+
|
|
23
|
+
const prompt = rewritten[promptIndex + 1];
|
|
24
|
+
if (typeof prompt !== 'string') {
|
|
25
|
+
throw new TypeError(`${APPEND_PROMPT_FLAG} requires a string value`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const promptFile = path.join(
|
|
29
|
+
os.tmpdir(),
|
|
30
|
+
`polygram-claude-prompt-${crypto.randomUUID()}.txt`,
|
|
31
|
+
);
|
|
32
|
+
try {
|
|
33
|
+
fs.writeFileSync(promptFile, prompt, {
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
flag: 'wx',
|
|
36
|
+
mode: 0o600,
|
|
37
|
+
});
|
|
38
|
+
fs.chmodSync(promptFile, 0o600);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
removePromptFile(promptFile);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
rewritten.splice(
|
|
45
|
+
promptIndex,
|
|
46
|
+
2,
|
|
47
|
+
APPEND_PROMPT_FILE_FLAG,
|
|
48
|
+
promptFile,
|
|
49
|
+
);
|
|
50
|
+
return { args: rewritten, promptFile };
|
|
51
|
+
}
|
|
5
52
|
|
|
6
53
|
function createClaudeTmuxRunner(runner) {
|
|
7
54
|
if (!runner || typeof runner.spawn !== 'function') {
|
|
8
55
|
throw new TypeError('Claude tmux runner requires spawn()');
|
|
9
56
|
}
|
|
57
|
+
const promptFiles = new Map();
|
|
58
|
+
|
|
10
59
|
return {
|
|
11
60
|
...runner,
|
|
12
|
-
spawn(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
61
|
+
async spawn(options) {
|
|
62
|
+
const staged = stageAppendPrompt(options.args);
|
|
63
|
+
if (staged.promptFile) {
|
|
64
|
+
removePromptFile(promptFiles.get(options.name));
|
|
65
|
+
promptFiles.set(options.name, staged.promptFile);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
return await runner.spawn({
|
|
70
|
+
...options,
|
|
71
|
+
command: ENV_BIN,
|
|
72
|
+
args: [
|
|
73
|
+
'-u',
|
|
74
|
+
CODEX_TEMP_SELECTOR,
|
|
75
|
+
options.command,
|
|
76
|
+
...staged.args,
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (promptFiles.get(options.name) === staged.promptFile) {
|
|
81
|
+
promptFiles.delete(options.name);
|
|
82
|
+
}
|
|
83
|
+
removePromptFile(staged.promptFile);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
async killSession(name, ...args) {
|
|
88
|
+
try {
|
|
89
|
+
return await runner.killSession?.(name, ...args);
|
|
90
|
+
} finally {
|
|
91
|
+
const promptFile = promptFiles.get(name);
|
|
92
|
+
promptFiles.delete(name);
|
|
93
|
+
removePromptFile(promptFile);
|
|
94
|
+
}
|
|
23
95
|
},
|
|
24
96
|
};
|
|
25
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polygram",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.1",
|
|
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": {
|