arisa 3.0.9 → 3.0.10
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/README.md +11 -0
- package/package.json +1 -1
- package/src/transport/telegram/bot.js +33 -4
package/README.md
CHANGED
|
@@ -108,6 +108,17 @@ arisa install <source> # install a Pi package into Arisa's runtime
|
|
|
108
108
|
arisa remove <source> # remove a Pi package from Arisa's runtime
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
## Experimental features
|
|
112
|
+
|
|
113
|
+
### Pi Agent packages
|
|
114
|
+
|
|
115
|
+
Arisa can install **Pi Agent packages** from the public registry into your user runtime (`~/.arisa/`), using the same package manager as Pi Agent. Browse and discover packages at [pi.dev/packages](https://pi.dev/packages).
|
|
116
|
+
|
|
117
|
+
- `arisa install <source>` installs a package (by registry name or other source supported by Pi).
|
|
118
|
+
- `arisa remove <source>` removes a previously installed package.
|
|
119
|
+
|
|
120
|
+
Treat this as **experimental**: the registry, package formats, and install behavior follow Pi Agent and may change. Not every listed package is tailored to Arisa’s Telegram transport and artifact-based tools; prefer packages you understand and verify after install.
|
|
121
|
+
|
|
111
122
|
## Bootstrap flow
|
|
112
123
|
|
|
113
124
|
On first run, Arisa will:
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bot, InputFile } from "grammy";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { authorizeChat } from "./auth.js";
|
|
3
4
|
import { captureIncomingArtifact } from "./media.js";
|
|
4
5
|
import { renderTelegramHtml, splitTelegramText } from "./text-format.js";
|
|
@@ -146,10 +147,28 @@ export async function createTelegramBot({ config, artifactStore, toolRegistry, a
|
|
|
146
147
|
return buildPrompt({ ctx, artifact, transcript });
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
async function sendTextReply(
|
|
150
|
+
async function sendTextReply({ sendText, sendDocument, chatId, text }) {
|
|
151
|
+
const attachmentThreshold = 12000;
|
|
152
|
+
|
|
153
|
+
if (text.length > attachmentThreshold) {
|
|
154
|
+
logger?.log("telegram", `sending long reply as markdown attachment for chat ${chatId}`);
|
|
155
|
+
const artifact = await artifactStore.createGeneratedFile({
|
|
156
|
+
fileName: `reply-${Date.now()}.md`,
|
|
157
|
+
content: text,
|
|
158
|
+
kind: "document",
|
|
159
|
+
mimeType: "text/markdown",
|
|
160
|
+
source: { type: "assistant", chatId },
|
|
161
|
+
metadata: { delivery: "telegram-document" }
|
|
162
|
+
});
|
|
163
|
+
await sendDocument(new InputFile(artifact.path, path.basename(artifact.path)), {
|
|
164
|
+
caption: "Response attached as Markdown."
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
150
169
|
logger?.log("telegram", `sending text reply for chat ${chatId}`);
|
|
151
170
|
for (const chunk of splitTelegramText(text)) {
|
|
152
|
-
await
|
|
171
|
+
await sendText(renderTelegramHtml(chunk), { parse_mode: "HTML" });
|
|
153
172
|
}
|
|
154
173
|
}
|
|
155
174
|
|
|
@@ -167,7 +186,12 @@ export async function createTelegramBot({ config, artifactStore, toolRegistry, a
|
|
|
167
186
|
const { session } = await agentManager.getSessionContext(ctx.chat.id, telegram);
|
|
168
187
|
const text = await collectText(session, prompt);
|
|
169
188
|
if (text) {
|
|
170
|
-
await sendTextReply(
|
|
189
|
+
await sendTextReply({
|
|
190
|
+
sendText: (message, extra) => ctx.reply(message, extra),
|
|
191
|
+
sendDocument: (file, extra) => ctx.replyWithDocument(file, extra),
|
|
192
|
+
chatId: ctx.chat.id,
|
|
193
|
+
text
|
|
194
|
+
});
|
|
171
195
|
}
|
|
172
196
|
});
|
|
173
197
|
}
|
|
@@ -260,7 +284,12 @@ export async function createTelegramBot({ config, artifactStore, toolRegistry, a
|
|
|
260
284
|
].filter(Boolean).join("\n");
|
|
261
285
|
const text = await collectText(session, welcomePrompt);
|
|
262
286
|
if (text) {
|
|
263
|
-
await sendTextReply(
|
|
287
|
+
await sendTextReply({
|
|
288
|
+
sendText: (message, extra) => bot.api.sendMessage(chatId, message, extra),
|
|
289
|
+
sendDocument: (file, extra) => bot.api.sendDocument(chatId, file, extra),
|
|
290
|
+
chatId,
|
|
291
|
+
text
|
|
292
|
+
});
|
|
264
293
|
}
|
|
265
294
|
} catch (error) {
|
|
266
295
|
logger?.log("telegram", `startup message failed for chat ${chatId}: ${error instanceof Error ? error.message : String(error)}`);
|