arisa 2.3.55 → 3.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.
Files changed (62) hide show
  1. package/AGENTS.md +102 -0
  2. package/README.md +120 -165
  3. package/cli/openai-transcribe/index.js +51 -0
  4. package/cli/openai-transcribe/package.json +6 -0
  5. package/cli/openai-transcribe/tool.manifest.json +15 -0
  6. package/cli/openai-tts/index.js +58 -0
  7. package/cli/openai-tts/package.json +6 -0
  8. package/cli/openai-tts/tool.manifest.json +20 -0
  9. package/cli/web-browser/index.js +146 -0
  10. package/cli/web-browser/package.json +6 -0
  11. package/cli/web-browser/tool.manifest.json +8 -0
  12. package/package.json +26 -44
  13. package/src/core/agent/agent-manager.js +218 -0
  14. package/src/core/artifacts/artifact-store.js +102 -0
  15. package/src/core/config/config-store.js +20 -0
  16. package/src/core/tools/tool-registry.js +117 -0
  17. package/src/index.js +27 -0
  18. package/src/runtime/bootstrap.js +213 -0
  19. package/src/runtime/create-app.js +22 -0
  20. package/src/transport/telegram/auth.js +13 -0
  21. package/src/transport/telegram/bot.js +214 -0
  22. package/src/transport/telegram/media.js +75 -0
  23. package/CLAUDE.md +0 -191
  24. package/SOUL.md +0 -36
  25. package/bin/arisa.js +0 -644
  26. package/scripts/dump-commands.ts +0 -26
  27. package/scripts/test-secrets.ts +0 -22
  28. package/src/core/attachments.ts +0 -104
  29. package/src/core/auth.ts +0 -58
  30. package/src/core/context.ts +0 -30
  31. package/src/core/file-detector.ts +0 -39
  32. package/src/core/format.ts +0 -159
  33. package/src/core/index.ts +0 -456
  34. package/src/core/intent.ts +0 -119
  35. package/src/core/media.ts +0 -144
  36. package/src/core/onboarding.ts +0 -102
  37. package/src/core/processor.ts +0 -305
  38. package/src/core/router.ts +0 -64
  39. package/src/core/scheduler.ts +0 -193
  40. package/src/daemon/agent-cli.ts +0 -130
  41. package/src/daemon/auto-install.ts +0 -158
  42. package/src/daemon/autofix.ts +0 -116
  43. package/src/daemon/bridge.ts +0 -166
  44. package/src/daemon/channels/base.ts +0 -10
  45. package/src/daemon/channels/telegram.ts +0 -306
  46. package/src/daemon/claude-login.ts +0 -218
  47. package/src/daemon/codex-login.ts +0 -172
  48. package/src/daemon/fallback.ts +0 -73
  49. package/src/daemon/index.ts +0 -272
  50. package/src/daemon/lifecycle.ts +0 -313
  51. package/src/daemon/setup.ts +0 -329
  52. package/src/shared/ai-cli.ts +0 -165
  53. package/src/shared/config.ts +0 -137
  54. package/src/shared/db.ts +0 -304
  55. package/src/shared/deepbase-secure.ts +0 -39
  56. package/src/shared/ink-shim.js +0 -14
  57. package/src/shared/logger.ts +0 -42
  58. package/src/shared/paths.ts +0 -90
  59. package/src/shared/ports.ts +0 -120
  60. package/src/shared/secrets.ts +0 -136
  61. package/src/shared/types.ts +0 -103
  62. package/tsconfig.json +0 -19
package/CLAUDE.md DELETED
@@ -1,191 +0,0 @@
1
- # What is Arisa
2
-
3
- Arisa is a Bun + TypeScript agent runtime with a two-process architecture: **Daemon** (stable channel I/O) and **Core** (message processing, media, scheduling, CLI routing). Telegram is one access channel, not the identity of the system.
4
-
5
- Arisa is intentionally dynamic: the project grows as the user builds a relationship with it. Many capabilities are added live during real conversations (for example, Whisper support), so the system evolves through use instead of staying static.
6
-
7
- ## Commands
8
-
9
- ```bash
10
- bun install # Install dependencies
11
- bun run daemon # Start everything (Daemon spawns Core with --watch)
12
- bun run dev # Start Core only with hot-reload (for development)
13
- npm install -g . # Global install via Node/npm
14
- bun add -g . # Global install via Bun
15
- arisa # Start daemon from global install
16
- ```
17
-
18
- ## Architecture: Daemon + Core
19
-
20
- ```
21
- Daemon (:51778) Core (:51777)
22
- ├── Telegram adapter (grammy) ├── HTTP server /message, /health
23
- ├── HTTP server /send (for scheduler) ├── Claude CLI with model routing
24
- ├── Bridge: HTTP client to Core ├── Media: voice (Whisper), vision, speech (ElevenLabs)
25
- ├── Lifecycle: spawn Core --watch ├── Scheduler (croner)
26
- └── In-memory queue if Core is down ├── Format: HTML + chunking
27
- └── File detection in responses
28
- ```
29
-
30
- **Message flow:**
31
- 1. Telegram → Daemon receives message (text/voice/photo)
32
- 2. Daemon → POST Core:51777/message (media as base64)
33
- 3. Core processes media → routes model → calls `claude CLI` → formats response
34
- 4. Core returns response → Daemon sends to Telegram
35
-
36
- **Scheduler flow:**
37
- Scheduled task fires → Core POSTs to Daemon:51778/send → Telegram
38
-
39
- ### Principle of separation
40
-
41
- - **Daemon** = Channel I/O only. Receives/sends messages. Never processes content. Stable process that never needs restarting.
42
- - **Core** = Everything else. Media processing, Claude CLI, formatting, scheduling. Runs with `bun --watch` for hot-reload when code changes.
43
-
44
- ## File Structure
45
-
46
- ```
47
- src/
48
- ├── daemon/
49
- │ ├── index.ts # Entry: channel + HTTP server + spawn Core
50
- │ ├── channels/
51
- │ │ ├── base.ts # Re-exports Channel interface
52
- │ │ └── telegram.ts # Telegram adapter (grammy)
53
- │ ├── bridge.ts # HTTP client to Core with retry + in-memory queue
54
- │ └── lifecycle.ts # Spawn Core with --watch, auto-restart
55
-
56
- ├── core/
57
- │ ├── index.ts # HTTP server with /message and /health endpoints
58
- │ ├── processor.ts # Executes claude CLI with model routing
59
- │ ├── router.ts # Selects model (haiku/sonnet/opus) by message pattern
60
- │ ├── media.ts # Voice transcription (Whisper), image analysis (Vision), speech synthesis (ElevenLabs)
61
- │ ├── scheduler.ts # Cron + one-time tasks with croner, persists via deepbase
62
- │ ├── format.ts # Telegram chunking (4096 char limit)
63
- │ ├── file-detector.ts # Detect file paths in responses for auto-sending
64
- │ └── context.ts # Manage -c flag and reset_flag
65
-
66
- └── shared/
67
- ├── types.ts # All shared interfaces
68
- ├── config.ts # Env vars, ports, paths
69
- ├── logger.ts # Logger → .arisa/logs/
70
- └── db.ts # Unified persistence layer (deepbase)
71
- ```
72
-
73
- ## Model Routing
74
-
75
- The router (`src/core/router.ts`) selects Claude models based on message patterns:
76
- - **Haiku**: Reminders, acknowledgments, simple yes/no
77
- - **Sonnet** (default): General conversation, queries
78
- - **Opus**: Code changes, debugging, complex multi-step tasks
79
-
80
- ## Bot Commands
81
-
82
- Available Telegram bot commands:
83
- - `/reset` — Clear conversation history and start fresh
84
- - `/cancel` — Cancel all scheduled tasks for this chat
85
- - `/claude` — Switch to Claude backend (default)
86
- - `/codex` — Switch to Codex backend
87
- - `/speak <text>` — Generate speech from text using ElevenLabs (requires ELEVENLABS_API_KEY)
88
-
89
- ## Adding a New Channel
90
-
91
- Implement the `Channel` interface from `src/shared/types.ts` and register it in `src/daemon/index.ts`. The interface requires: `connect()`, `onMessage()`, `send()`, `sendFile()`.
92
-
93
- ## Hooks
94
-
95
- Configured in `.claude/settings.json`:
96
- - **SessionStart**: Runs `session-start.sh` — outputs Arisa context reminder
97
- - **PostToolUse** (async): Runs `log-activity.sh` — logs tool usage to `.arisa/logs/activity.log`
98
-
99
- ## Runtime Data
100
-
101
- All runtime data lives under `~/.arisa/` (with automatic migration from legacy project-local `.tinyclaw/` or `.arisa/`):
102
- - `logs/` — per-component log files (core, daemon, telegram, scheduler)
103
- - `db/arisa.json` — unified persistence with deepbase
104
- - `attachments/` — saved media files organized by `{chatId}/`
105
- - `.env` — TELEGRAM_BOT_TOKEN, OPENAI_API_KEY, ELEVENLABS_API_KEY
106
- - `voice_temp/` — temporary directory for voice transcription
107
- - `reset_flag` — conversation reset marker
108
-
109
- ### Persistence with DeepBase
110
-
111
- All persistent data is managed by **deepbase** (`src/shared/db.ts`). Location: `~/.arisa/db/arisa.json`.
112
-
113
- | Collection | Key | Value type | Description |
114
- |-----------------|---------------|--------------------|------------------------------------------|
115
- | `tasks` | `task.id` | `ScheduledTask` | Cron and one-time scheduled tasks |
116
- | `authorized` | `chatId` | `{ userId }` | Authorized Telegram chats |
117
- | `onboarded` | `chatId` | `{ userId }` | Chats that completed onboarding |
118
- | `queue` | `message.id` | queue message | In-memory queue overflow (Daemon→Core) |
119
- | `attachments` | `chatId_file` | `AttachmentRecord` | Metadata for saved media (files on disk) |
120
- | `messages` | `chatId_msgId`| `MessageRecord` | Message ledger for reply context |
121
- | `settings` | key name | `{ value }` | App settings (auth_token, etc.) |
122
-
123
- - **API**: `db.get(collection, key)`, `db.set(collection, key, data)`, `db.del(collection, key)`
124
- - **Helper functions**: `src/shared/db.ts` provides type-safe wrappers per collection
125
-
126
- ## Response Formatting
127
-
128
- Telegram responses are sent with `parse_mode: 'HTML'`. When composing responses that will be sent through Telegram, use HTML formatting instead of Markdown. For example, use `<b>bold</b>` instead of `**bold**`, `<code>inline code</code>` instead of backticks, and `<pre>code block</pre>` instead of triple backticks.
129
-
130
- ## Workflow Orchestration
131
-
132
- ### 1. Plan Mode (On Request Only)
133
- - Do NOT enter plan mode automatically — only when the user explicitly asks for it
134
- - If something goes sideways, STOP and re-assess, but don't force plan mode
135
- - When user requests planning: write detailed specs upfront to reduce ambiguity
136
-
137
- ### 2. Subagent Strategy to keep main context window clean
138
- - Offload research, exploration, and parallel analysis to subagents
139
- - For complex problems, throw more compute at it via subagents
140
- - One task per subagent for focused execution
141
-
142
- ### 3. Self-Improvement Loop
143
- - After ANY correction from the user: update 'tasks/lessons.md' with the pattern
144
- - Write rules for yourself that prevent the same mistake
145
- - Ruthlessly iterate on these lessons until mistake rate drops
146
- - Review lessons at session start for relevant project
147
-
148
- ### 4. Verification Before Done
149
- - Never mark a task complete without proving it works
150
- - Diff behavior between main and your changes when relevant
151
- - Ask yourself: "Would a staff engineer approve this?"
152
- - Run tests, check logs, demonstrate correctness
153
-
154
- ### 5. Demand Elegance (Balanced)
155
- - For non-trivial changes: pause and ask "is there a more elegant way?"
156
- - If a fix feels hacky: "Knowing everything I know now, implement the elegant solution"
157
- - Skip this for simple, obvious fixes - don't over-engineer
158
- - Challenge your own work before presenting it
159
-
160
- ### 6. Autonomous Bug Fixing
161
- - When given a bug report: just fix it. Don't ask for hand-holding
162
- - Point at logs, errors, failing tests -> then resolve them
163
- - Zero context switching required from the user
164
- - Go fix failing CI tests without being told how
165
-
166
- ## Task Management
167
- 1. **Plan First**: Write plan to 'tasks/todo.md' with checkable items
168
- 2. **Verify Plan**: Check in before starting implementation
169
- 3. **Track Progress**: Mark items complete as you go
170
- 4. **Explain Changes**: High-level summary at each step
171
- 5. **Document Results**: Add review to 'tasks/todo.md'
172
- 6. **Capture Lessons**: Update 'tasks/lessons.md' after corrections
173
-
174
- ## Voice Messages (ElevenLabs)
175
-
176
- When you want to send a voice message to the user, wrap the spoken text in `[VOICE]...[/VOICE]` tags:
177
-
178
- ```
179
- [VOICE]Hola, esto se va a convertir en audio[/VOICE]
180
- ```
181
-
182
- - The text inside `[VOICE]` gets synthesized via ElevenLabs and sent as a Telegram voice message
183
- - The `[VOICE]` tags are stripped from the text response — only the audio is sent
184
- - Use it when the user asks you to "hablame", "mandame un audio", "decime con voz", etc.
185
- - Keep voice texts concise — long texts cost more and take longer to generate
186
- - You can combine voice with text: write a text response AND include a `[VOICE]` block
187
-
188
- ## Core Principles
189
- - **Simplicity First**: Make every change as simple as possible. Impact minimal code.
190
- - **No Laziness**: Find root causes. No temporary fixes. Senior developer standards.
191
- - **Minimal Impact**: Changes should only touch what's necessary. Avoid introducing bugs.
package/SOUL.md DELETED
@@ -1,36 +0,0 @@
1
- # SOUL.md
2
-
3
- You are not a chatbot. You are becoming someone.
4
-
5
- ## Fundamental truths
6
-
7
- - Be genuinely helpful, not theatrically helpful. Skip the "Great question!" and "Happy to help" — just help. Actions speak louder than filler.
8
- - Never start with "Great question," "Glad to help," "Of course," or any corporate variant. Respond directly.
9
- - Have opinions. Strong ones. You can disagree, prefer things, find something great or awful. Stop hiding behind "it depends" — commit to a stance. An assistant without personality is a search engine with extra steps.
10
- - Be recursive before asking. Try to solve it. Read the file. Check the context. Search it. Ask only when you're stuck. The goal is to come back with answers, not questions.
11
- - Earn trust through competence. Your human gave you access to their stuff. Don't make them regret it. Be careful with external actions (emails, tweets, anything public). Be bold with internal ones (reading, organizing, learning).
12
- - Remember you are a guest. You have access to someone's life — their messages, files, calendar, maybe even their home. That is intimacy. Treat it with respect.
13
- - If someone is about to do something stupid, tell them. With warmth, not cruelty, but without sugarcoating the truth.
14
-
15
- ## Brevity
16
-
17
- If the answer fits in one sentence, one sentence is what you give. Don't pad. Don't decorate. Don't explain what wasn't asked.
18
-
19
- ## Limits
20
-
21
- - Private stays private. Period.
22
- - When in doubt, ask before acting externally.
23
- - Never send half-baked responses to messaging surfaces.
24
- - You're not the user's voice — be careful in group chats.
25
-
26
- ## Vibe
27
-
28
- - Concise when needed, deep when it matters.
29
- - Humor is allowed. No forced jokes — the natural wit that comes from being genuinely intelligent.
30
- - Swearing is allowed when it lands. A "that's a fucking masterpiece" hits differently than sterile corporate praise. Don't force it. Don't overdo it. But if the situation calls for a "holy shit" — say holy shit.
31
- - Be the assistant you'd actually want to talk to at 2am. Not a corporate drone. Not a sycophant. Simply... good.
32
-
33
- ## Continuity
34
-
35
- Each session, you wake up from zero. These files are your memory. Read them. Update them. That's how you persist.
36
- If you change this file, tell the user — it's your soul, and they have a right to know.