arisa 2.0.0
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/CLAUDE.md +191 -0
- package/README.md +200 -0
- package/SOUL.md +36 -0
- package/bin/arisa.js +85 -0
- package/package.json +43 -0
- package/scripts/test-secrets.ts +22 -0
- package/src/core/attachments.ts +104 -0
- package/src/core/auth.ts +58 -0
- package/src/core/context.ts +30 -0
- package/src/core/file-detector.ts +39 -0
- package/src/core/format.ts +159 -0
- package/src/core/history.ts +193 -0
- package/src/core/index.ts +437 -0
- package/src/core/intent.ts +112 -0
- package/src/core/media.ts +144 -0
- package/src/core/onboarding.ts +115 -0
- package/src/core/processor.ts +268 -0
- package/src/core/router.ts +64 -0
- package/src/core/scheduler.ts +192 -0
- package/src/daemon/agent-cli.ts +119 -0
- package/src/daemon/autofix.ts +116 -0
- package/src/daemon/bridge.ts +162 -0
- package/src/daemon/channels/base.ts +10 -0
- package/src/daemon/channels/telegram.ts +306 -0
- package/src/daemon/fallback.ts +49 -0
- package/src/daemon/index.ts +213 -0
- package/src/daemon/lifecycle.ts +288 -0
- package/src/daemon/setup.ts +79 -0
- package/src/shared/config.ts +130 -0
- package/src/shared/db.ts +304 -0
- package/src/shared/deepbase-secure.ts +39 -0
- package/src/shared/logger.ts +42 -0
- package/src/shared/paths.ts +90 -0
- package/src/shared/ports.ts +98 -0
- package/src/shared/secrets.ts +136 -0
- package/src/shared/types.ts +103 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module shared/types
|
|
3
|
+
* @role Define all shared interfaces for Daemon ↔ Core communication.
|
|
4
|
+
* @responsibilities
|
|
5
|
+
* - IncomingMessage: what a channel adapter produces
|
|
6
|
+
* - CoreRequest/CoreResponse: HTTP payloads between Daemon and Core
|
|
7
|
+
* - SendRequest: Core → Daemon push (scheduler, etc.)
|
|
8
|
+
* - ScheduledTask: persisted task for croner/one-time
|
|
9
|
+
* - ModelConfig: router output
|
|
10
|
+
* @dependencies None
|
|
11
|
+
* @effects None (types only)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface IncomingMessage {
|
|
15
|
+
chatId: string;
|
|
16
|
+
sender: string;
|
|
17
|
+
senderId: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
audio?: { base64: string; filename: string };
|
|
20
|
+
image?: { base64: string; caption?: string };
|
|
21
|
+
document?: { base64: string; filename: string; mimeType: string; caption?: string };
|
|
22
|
+
command?: string;
|
|
23
|
+
messageId?: number;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
replyTo?: {
|
|
26
|
+
messageId?: number;
|
|
27
|
+
text?: string;
|
|
28
|
+
sender: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CoreRequest {
|
|
34
|
+
message: IncomingMessage;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CoreResponse {
|
|
38
|
+
text: string;
|
|
39
|
+
files?: string[];
|
|
40
|
+
audio?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SendRequest {
|
|
44
|
+
chatId: string;
|
|
45
|
+
text: string;
|
|
46
|
+
files?: string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ScheduledTask {
|
|
50
|
+
id: string;
|
|
51
|
+
chatId: string;
|
|
52
|
+
sender: string;
|
|
53
|
+
senderId: string;
|
|
54
|
+
type: "once" | "cron";
|
|
55
|
+
origin?: "cron" | "recurring";
|
|
56
|
+
message: string;
|
|
57
|
+
originalMessage: string;
|
|
58
|
+
createdAt: number;
|
|
59
|
+
runAt?: number;
|
|
60
|
+
cron?: string;
|
|
61
|
+
lastRunAt?: number;
|
|
62
|
+
status?: "pending" | "done";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AttachmentRecord {
|
|
66
|
+
id: string;
|
|
67
|
+
chatId: string;
|
|
68
|
+
type: "image" | "audio" | "document";
|
|
69
|
+
filename: string;
|
|
70
|
+
relPath: string;
|
|
71
|
+
mimeType?: string;
|
|
72
|
+
sizeBytes: number;
|
|
73
|
+
createdAt: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ModelConfig {
|
|
77
|
+
model: string;
|
|
78
|
+
timeout: number;
|
|
79
|
+
reason: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface MessageRecord {
|
|
83
|
+
id: string; // "{chatId}_{messageId}"
|
|
84
|
+
chatId: string;
|
|
85
|
+
messageId: number; // Telegram message_id
|
|
86
|
+
direction: "in" | "out";
|
|
87
|
+
sender: string;
|
|
88
|
+
timestamp: number;
|
|
89
|
+
text?: string;
|
|
90
|
+
mediaType?: "image" | "audio" | "document";
|
|
91
|
+
attachmentPath?: string;
|
|
92
|
+
mediaDescription?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface Channel {
|
|
96
|
+
name: string;
|
|
97
|
+
connect(): Promise<void>;
|
|
98
|
+
onMessage(handler: (msg: IncomingMessage) => void): void;
|
|
99
|
+
send(chatId: string, text: string, parseMode?: "HTML" | "plain"): Promise<number | undefined>;
|
|
100
|
+
sendFile(chatId: string, filePath: string): Promise<void>;
|
|
101
|
+
sendAudio?(chatId: string, filePath: string): Promise<void>;
|
|
102
|
+
sendTyping(chatId: string): Promise<void>;
|
|
103
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"types": ["bun"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"noUnusedLocals": false,
|
|
15
|
+
"noUnusedParameters": false
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|