arisa 3.0.14 → 3.1.2
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/AGENTS.md +11 -0
- package/README.md +37 -0
- package/docs/async-event-queue-flow.md +68 -0
- package/package.json +7 -8
- package/pnpm-workspace.yaml +12 -0
- package/src/core/agent/agent-manager.js +73 -25
- package/src/core/agent/runtime-context.js +2 -2
- package/src/core/artifacts/artifact-store.js +50 -25
- package/src/core/artifacts/normalize-for-reasoning.js +90 -0
- package/src/core/tasks/task-store.js +9 -5
- package/src/core/tools/daemon-runtime.js +167 -0
- package/src/core/tools/tool-config.js +15 -7
- package/src/core/tools/tool-registry.js +20 -9
- package/src/index.js +105 -12
- package/src/runtime/bootstrap.js +211 -19
- package/src/runtime/create-app.js +45 -3
- package/src/runtime/paths.js +26 -3
- package/src/runtime/service-manager.js +2 -2
- package/src/transport/telegram/bot.js +83 -38
- package/src/transport/telegram/media.js +17 -11
- package/tools/openai-transcribe/index.js +1 -1
|
@@ -6,56 +6,62 @@ async function downloadToBuffer(ctx, fileId) {
|
|
|
6
6
|
return Buffer.from(await response.arrayBuffer());
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function incomingCaptionMetadata(ctx) {
|
|
10
|
+
return ctx.message?.caption ? { caption: ctx.message.caption } : {};
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
export async function captureIncomingArtifact(ctx, artifactStore) {
|
|
14
|
+
const chatId = ctx.chat.id;
|
|
15
|
+
const store = artifactStore.forChat(chatId);
|
|
10
16
|
const baseSource = {
|
|
11
17
|
type: "telegram",
|
|
12
|
-
chatId
|
|
18
|
+
chatId,
|
|
13
19
|
messageId: ctx.msg.message_id,
|
|
14
20
|
userId: ctx.from.id
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
if (ctx.message?.voice) {
|
|
18
|
-
const fileName = `${
|
|
24
|
+
const fileName = `${chatId}-${ctx.msg.message_id}.ogg`;
|
|
19
25
|
const content = await downloadToBuffer(ctx, ctx.message.voice.file_id);
|
|
20
|
-
return
|
|
26
|
+
return store.createGeneratedFile({
|
|
21
27
|
fileName,
|
|
22
28
|
content,
|
|
23
29
|
kind: "audio",
|
|
24
30
|
mimeType: "audio/ogg",
|
|
25
31
|
source: baseSource,
|
|
26
|
-
metadata: { duration: ctx.message.voice.duration }
|
|
32
|
+
metadata: { duration: ctx.message.voice.duration, ...incomingCaptionMetadata(ctx) }
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
if (ctx.message?.document) {
|
|
31
|
-
const fileName = ctx.message.document.file_name || `${
|
|
37
|
+
const fileName = ctx.message.document.file_name || `${chatId}-${ctx.msg.message_id}`;
|
|
32
38
|
const content = await downloadToBuffer(ctx, ctx.message.document.file_id);
|
|
33
|
-
return
|
|
39
|
+
return store.createGeneratedFile({
|
|
34
40
|
fileName,
|
|
35
41
|
content,
|
|
36
42
|
kind: "document",
|
|
37
43
|
mimeType: ctx.message.document.mime_type || "application/octet-stream",
|
|
38
44
|
source: baseSource,
|
|
39
|
-
metadata:
|
|
45
|
+
metadata: incomingCaptionMetadata(ctx)
|
|
40
46
|
});
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
if (ctx.message?.photo?.length) {
|
|
44
50
|
const photo = ctx.message.photo.at(-1);
|
|
45
|
-
const fileName = `${
|
|
51
|
+
const fileName = `${chatId}-${ctx.msg.message_id}.jpg`;
|
|
46
52
|
const content = await downloadToBuffer(ctx, photo.file_id);
|
|
47
|
-
return
|
|
53
|
+
return store.createGeneratedFile({
|
|
48
54
|
fileName,
|
|
49
55
|
content,
|
|
50
56
|
kind: "image",
|
|
51
57
|
mimeType: "image/jpeg",
|
|
52
58
|
source: baseSource,
|
|
53
|
-
metadata: { width: photo.width, height: photo.height }
|
|
59
|
+
metadata: { width: photo.width, height: photo.height, ...incomingCaptionMetadata(ctx) }
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
if (ctx.message?.text) {
|
|
58
|
-
return
|
|
64
|
+
return store.createText({
|
|
59
65
|
text: ctx.message.text,
|
|
60
66
|
source: baseSource,
|
|
61
67
|
metadata: {}
|
|
@@ -9,7 +9,7 @@ const toolName = "openai-transcribe";
|
|
|
9
9
|
const config = await loadToolConfig(toolName, defaults);
|
|
10
10
|
|
|
11
11
|
function printHelp() {
|
|
12
|
-
console.log(`openai-transcribe\n\nUsage:\n node index.js --help\n node index.js run --request-file <json>\n\nExpected input:\n {\n
|
|
12
|
+
console.log(`openai-transcribe\n\nUsage:\n node index.js --help\n node index.js run --request-file <json>\n\nExpected input:\n {\n "artifact": { "path": "/abs/audio.ogg", "mimeType": "audio/ogg" },\n "args": {}\n }\n\nConfig at ${getToolConfigPath(toolName)}:\n OPENAI_API_KEY\n MODEL\n`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async function run(requestFile) {
|