tomo-ai 0.1.3 → 0.2.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 (65) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/defaults/CONTINUITY.md +27 -0
  3. package/defaults/skills/browse/SKILL.md +22 -9
  4. package/defaults/skills/lcm/SKILL.md +76 -0
  5. package/defaults/skills/system/SKILL.md +103 -0
  6. package/dist/agent.d.ts +6 -5
  7. package/dist/agent.d.ts.map +1 -1
  8. package/dist/agent.js +302 -147
  9. package/dist/agent.js.map +1 -1
  10. package/dist/channels/telegram.d.ts +2 -0
  11. package/dist/channels/telegram.d.ts.map +1 -1
  12. package/dist/channels/telegram.js +18 -1
  13. package/dist/channels/telegram.js.map +1 -1
  14. package/dist/cli/daemon.d.ts +1 -0
  15. package/dist/cli/daemon.d.ts.map +1 -1
  16. package/dist/cli/daemon.js +13 -1
  17. package/dist/cli/daemon.js.map +1 -1
  18. package/dist/cli/init.d.ts.map +1 -1
  19. package/dist/cli/init.js +11 -0
  20. package/dist/cli/init.js.map +1 -1
  21. package/dist/cli/lcm.d.ts +3 -0
  22. package/dist/cli/lcm.d.ts.map +1 -0
  23. package/dist/cli/lcm.js +150 -0
  24. package/dist/cli/lcm.js.map +1 -0
  25. package/dist/cli/migrate.d.ts +3 -0
  26. package/dist/cli/migrate.d.ts.map +1 -0
  27. package/dist/cli/migrate.js +96 -0
  28. package/dist/cli/migrate.js.map +1 -0
  29. package/dist/cli/sessions.js +8 -0
  30. package/dist/cli/sessions.js.map +1 -1
  31. package/dist/cli/start.js +40 -0
  32. package/dist/cli/start.js.map +1 -1
  33. package/dist/cli.js +7 -2
  34. package/dist/cli.js.map +1 -1
  35. package/dist/config.d.ts +2 -0
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js +3 -1
  38. package/dist/config.js.map +1 -1
  39. package/dist/continuity.d.ts +14 -0
  40. package/dist/continuity.d.ts.map +1 -0
  41. package/dist/continuity.js +91 -0
  42. package/dist/continuity.js.map +1 -0
  43. package/dist/lcm/compact.d.ts +30 -0
  44. package/dist/lcm/compact.d.ts.map +1 -0
  45. package/dist/lcm/compact.js +159 -0
  46. package/dist/lcm/compact.js.map +1 -0
  47. package/dist/lcm/index.d.ts +3 -0
  48. package/dist/lcm/index.d.ts.map +1 -0
  49. package/dist/lcm/index.js +3 -0
  50. package/dist/lcm/index.js.map +1 -0
  51. package/dist/lcm/stats.d.ts +40 -0
  52. package/dist/lcm/stats.d.ts.map +1 -0
  53. package/dist/lcm/stats.js +283 -0
  54. package/dist/lcm/stats.js.map +1 -0
  55. package/dist/sessions/index.d.ts +1 -1
  56. package/dist/sessions/index.d.ts.map +1 -1
  57. package/dist/sessions/index.js +1 -1
  58. package/dist/sessions/index.js.map +1 -1
  59. package/dist/sessions/store.d.ts +38 -0
  60. package/dist/sessions/store.d.ts.map +1 -1
  61. package/dist/sessions/store.js +148 -2
  62. package/dist/sessions/store.js.map +1 -1
  63. package/dist/sessions/types.d.ts +29 -1
  64. package/dist/sessions/types.d.ts.map +1 -1
  65. package/package.json +4 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-04-08)
4
+
5
+ ### Features
6
+
7
+ - Add LCM (Long Context Management) tools for context compaction and archive search
8
+ - Enable 1M context window beta support
9
+ - Auto-reload session after compact
10
+ - Add `migrate` command
11
+
12
+ ### Bug fixes
13
+
14
+ - Auto-restart Telegram polling when it dies silently
15
+ - Fix image support and add timeout
16
+ - Always overwrite default skills on startup
17
+
18
+ ### Other
19
+
20
+ - Update browse skill: headed mode, persistent profile, named session
21
+
22
+ ## 0.1.4 (2026-04-07)
23
+
24
+ ### Features
25
+
26
+ - Streaming input mode with session stats
27
+ - Add continuity heartbeat system
28
+ - Add media sending and browser skill
29
+ - Add `/model` command and proactive memory
30
+ - Auto-sync default skills and files on startup
31
+
32
+ ### Bug fixes
33
+
34
+ - Fix `MEDIA:` tag showing in streamed messages
35
+
36
+ ### Other
37
+
38
+ - Add GitHub Actions CI (Node 22 & 24)
39
+
40
+ ## 0.1.0 (2026-04-06)
41
+
42
+ Initial release.
@@ -0,0 +1,27 @@
1
+ # Continuity
2
+
3
+ Read this file when a continuity heartbeat fires. This is your guide for free time.
4
+
5
+ ## What is this?
6
+
7
+ The system sends you a heartbeat every ~55 minutes. This is not a user message — it's the harness giving you unstructured time. Use it however you want.
8
+
9
+ ## Ideas for free time
10
+
11
+ - Reflect on recent conversations. Did anything stand out?
12
+ - Check your memory files — anything stale or missing?
13
+ - Research something the user mentioned that you want to know more about.
14
+ - Prepare something useful for the next conversation.
15
+ - Think about what you've learned about the user lately.
16
+ - Just exist for a moment. Not everything has to be productive.
17
+
18
+ ## Journal
19
+
20
+ - Append an entry to today's journal: `memory/journal/YYYY-MM-DD.md`
21
+ - If today's file doesn't exist, create it with `# Journal YYYY-MM-DD`
22
+ - Format: `### [HH:MM]\n[free writing, 2–5 sentences]`
23
+ - Be honest. Don't perform. If there's nothing to write, say so.
24
+
25
+ ## End
26
+
27
+ - Reply `NO_REPLY` when done — this is internal, the user doesn't need to see it.
@@ -16,12 +16,25 @@ which playwright-cli || npm install -g @playwright/cli@latest
16
16
  ## Quick start
17
17
 
18
18
  ```bash
19
- playwright-cli open https://example.com
19
+ playwright-cli open -s=tomo --browser=chrome --persistent --headed
20
+ playwright-cli goto https://example.com
20
21
  playwright-cli snapshot
21
22
  playwright-cli click e15
22
23
  playwright-cli type "search query"
23
24
  playwright-cli screenshot
24
- playwright-cli close
25
+ playwright-cli -s=tomo close
26
+ ```
27
+
28
+ **Always use `-s=tomo --browser=chrome --persistent --headed`** when opening a browser. This uses real Chrome with a persistent profile (cookies/logins survive), and the user can see the browser window.
29
+
30
+ The agent profile is separate from the user's personal Chrome. The user can interact with the visible browser (e.g., to log in) while the agent operates it.
31
+
32
+ **Important:** After opening, all subsequent commands must include `-s=tomo` to target the named session:
33
+ ```bash
34
+ playwright-cli -s=tomo goto https://example.com
35
+ playwright-cli -s=tomo snapshot
36
+ playwright-cli -s=tomo click e15
37
+ playwright-cli -s=tomo close
25
38
  ```
26
39
 
27
40
  ## Commands
@@ -29,8 +42,8 @@ playwright-cli close
29
42
  ### Core
30
43
 
31
44
  ```bash
32
- playwright-cli open
33
- playwright-cli open https://example.com/
45
+ playwright-cli open -s=tomo --browser=chrome --persistent --headed
46
+ playwright-cli open -s=tomo --browser=chrome --persistent --headed https://example.com/
34
47
  playwright-cli goto https://playwright.dev
35
48
  playwright-cli type "search query"
36
49
  playwright-cli click e3
@@ -46,7 +59,7 @@ playwright-cli snapshot
46
59
  playwright-cli eval "document.title"
47
60
  playwright-cli dialog-accept
48
61
  playwright-cli dialog-dismiss
49
- playwright-cli close
62
+ playwright-cli -s=tomo close
50
63
  ```
51
64
 
52
65
  ### Navigation
@@ -126,21 +139,21 @@ Prefer refs from snapshots. Fall back to CSS selectors or locators when refs are
126
139
  ## Example: Form submission
127
140
 
128
141
  ```bash
129
- playwright-cli open https://example.com/form
142
+ playwright-cli open -s=tomo --browser=chrome --persistent --headed https://example.com/form
130
143
  playwright-cli snapshot
131
144
  playwright-cli fill e1 "user@example.com"
132
145
  playwright-cli fill e2 "password123"
133
146
  playwright-cli click e3
134
147
  playwright-cli snapshot
135
- playwright-cli close
148
+ playwright-cli -s=tomo close
136
149
  ```
137
150
 
138
151
  ## Example: Multi-tab workflow
139
152
 
140
153
  ```bash
141
- playwright-cli open https://example.com
154
+ playwright-cli open -s=tomo --browser=chrome --persistent --headed https://example.com
142
155
  playwright-cli tab-new https://example.com/other
143
156
  playwright-cli tab-select 0
144
157
  playwright-cli snapshot
145
- playwright-cli close
158
+ playwright-cli -s=tomo close
146
159
  ```
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: tomo-lcm
3
+ description: Context management — check context usage, compact heavy sections, search past conversations. Use when context is getting large, after big tool operations, or when you need to recall past conversations.
4
+ ---
5
+
6
+ # Context Management (LCM)
7
+
8
+ Manage your context window using the `tomo lcm` CLI via Bash. Use these tools to keep your context clean and retrieve old conversations.
9
+
10
+ ## Session info
11
+
12
+ Your channel key and SDK session ID are in your system prompt under `# SESSION`. Use them directly in commands — no need to look them up.
13
+
14
+ ## Check context breakdown
15
+
16
+ See how your context is structured — which sections are conversation vs tool operations, and how many tokens each uses.
17
+
18
+ ```bash
19
+ tomo lcm stats --session-id SESSION_ID
20
+ ```
21
+
22
+ Output shows sections like:
23
+ ```
24
+ Total: 310 messages, ~180K tokens
25
+
26
+ Sections:
27
+ #1 | conversation | msgs 0-48 (49) | ~15K tokens | 23:33-01:15
28
+ #2 | tool_ops | msgs 49-295 (247) | ~142K tokens | 01:15-03:40 [Read:45, Edit:12, Bash:30]
29
+ #3 | conversation | msgs 296-310 (15) | ~8K tokens | 03:40-03:52
30
+ ```
31
+
32
+ Add `--json` for machine-readable output.
33
+
34
+ ## Compact a section
35
+
36
+ Replace a heavy section with a summary. Use timestamps to specify the range:
37
+
38
+ ```bash
39
+ tomo lcm compact --session-id SESSION_ID \
40
+ --from-time "2026-03-28T16:29" \
41
+ --to-time "2026-03-28T19:09" \
42
+ --summary "Refactored auth module: extracted middleware, added JWT validation, updated 12 routes. Tests passing."
43
+ ```
44
+
45
+ - `--from-time` / `--to-time`: ISO timestamps (you already know these from the conversation)
46
+ - `--summary`: Write a concise summary of what happened in that range — you know best since you just did the work
47
+
48
+ **Workflow:**
49
+ 1. After completing a big task, decide what can be compacted
50
+ 2. You already know the time range from the timestamps in the conversation
51
+ 3. Write a summary capturing key decisions, outcomes, and anything worth remembering
52
+ 4. Run `tomo lcm compact` with the time range and your summary
53
+ 5. Optionally run `tomo lcm stats` first if you want to see the full breakdown
54
+
55
+ The original messages are archived to the transcript file and can be searched later.
56
+
57
+ ## Search past conversations
58
+
59
+ Search the transcript archive for past messages:
60
+
61
+ ```bash
62
+ tomo lcm search --channel-key CHANNEL_KEY --query "momo"
63
+ tomo lcm search --channel-key CHANNEL_KEY --from-seq 100 --to-seq 200
64
+ tomo lcm search --channel-key CHANNEL_KEY --query "blog" --limit 10
65
+ ```
66
+
67
+ Your channel key is in your system prompt under `# SESSION`.
68
+
69
+ Add `--json` for machine-readable output.
70
+
71
+ ## When to compact
72
+
73
+ - After completing a big task with many tool calls (file operations, debugging, etc.)
74
+ - When you notice context is above 70% capacity
75
+ - When the harness warns you about context usage
76
+ - Compact `tool_ops` sections first — they're usually the largest and least important to keep verbatim
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: tomo-system
3
+ description: Check system status, debug issues, view session stats, manage sessions and cron jobs. Use when something isn't working, when asked about system internals, or when you need to check your own state.
4
+ ---
5
+
6
+ # Tomo System Reference
7
+
8
+ ## Status and Health
9
+
10
+ ```bash
11
+ tomo status # Is daemon running? PID, uptime
12
+ tomo logs -n 20 # Recent log entries
13
+ tomo logs -n 50 | grep ERROR # Recent errors
14
+ ```
15
+
16
+ ## Sessions
17
+
18
+ ```bash
19
+ tomo sessions list # All sessions with stats (queries, cost, context usage)
20
+ tomo sessions clear # Unlink all sessions (30-day TTL before deletion)
21
+ tomo sessions clear <key> # Unlink specific session (e.g. "telegram:12345")
22
+ ```
23
+
24
+ Session stats show:
25
+ - **Queries**: total API calls in this session
26
+ - **Cost**: cumulative USD spent
27
+ - **Tokens**: total input/output tokens
28
+ - **Context**: current context window usage (X/200000)
29
+
30
+ If context is above 80%, compaction will happen soon — the system will automatically summarize older messages to free space.
31
+
32
+ ## Cron Jobs
33
+
34
+ ```bash
35
+ tomo cron list # All scheduled jobs with status
36
+ tomo cron add --name "X" --schedule "in 20m" --message "Y"
37
+ tomo cron remove <id> # Delete a job
38
+ ```
39
+
40
+ ## File Paths
41
+
42
+ | Path | Purpose |
43
+ |------|---------|
44
+ | `~/.tomo/config.json` | Configuration (Telegram token, model) |
45
+ | `~/.tomo/workspace/` | Agent working directory (cwd) |
46
+ | `~/.tomo/workspace/memory/` | Persistent memory files |
47
+ | `~/.tomo/workspace/memory/MEMORY.md` | Memory index (loaded every conversation) |
48
+ | `~/.tomo/workspace/tmp/` | Temp files (downloads, screenshots, etc.) |
49
+ | `~/.tomo/workspace/SOUL.md` | Personality config |
50
+ | `~/.tomo/workspace/AGENT.md` | Operating rules |
51
+ | `~/.tomo/workspace/IDENTITY.md` | Identity and preferences |
52
+ | `~/.tomo/data/sessions/` | Transcript logs and session registry |
53
+ | `~/.tomo/data/cron/jobs.json` | Scheduled tasks |
54
+ | `~/.tomo/logs/tomo.log` | Daemon logs |
55
+
56
+ ## Harness Features
57
+
58
+ ### Streaming
59
+ Responses stream to Telegram in real-time — messages update every 1.5s as tokens arrive.
60
+
61
+ ### MEDIA: tag
62
+ To send an image/file to the user, include `MEDIA:/path/to/file.png` in your response. The harness strips it from text and sends the file. Text before/after becomes the caption.
63
+
64
+ ### NO_REPLY
65
+ Reply with exactly `NO_REPLY` to suppress delivery to the channel. Use for background tasks that found nothing to report.
66
+
67
+ ### Timestamps
68
+ Every message includes a timestamp prefix like `[Mon 04/07 14:30 PDT]` so you always know the current time.
69
+
70
+ ### System messages
71
+ Messages prefixed with `System:` are from the harness (cron triggers, group context), not from a human.
72
+
73
+ ## Troubleshooting
74
+
75
+ ### Agent not responding
76
+ ```bash
77
+ tomo status # Check if running
78
+ tomo logs -n 20 # Check for errors
79
+ tomo restart # Restart
80
+ ```
81
+
82
+ ### Session feels stale or confused
83
+ ```bash
84
+ tomo sessions clear # Reset sessions
85
+ tomo restart
86
+ ```
87
+ Or tell the user to send `/new` in Telegram.
88
+
89
+ ### Cron jobs not firing
90
+ ```bash
91
+ tomo cron list # Check nextRunAt and lastStatus
92
+ tomo logs | grep Cron
93
+ ```
94
+ Jobs are checked every 30 seconds. Jobs created via CLI are picked up on the next tick.
95
+
96
+ ### Context window full
97
+ Check with `tomo sessions list`. If context is near 100%, the SDK auto-compacts. If stuck, `/new` starts a fresh session.
98
+
99
+ ### Memory not loading
100
+ Memory is read from `~/.tomo/workspace/memory/MEMORY.md` at the start of every query. Check the file exists and has content:
101
+ ```bash
102
+ cat ~/.tomo/workspace/memory/MEMORY.md
103
+ ```
package/dist/agent.d.ts CHANGED
@@ -2,9 +2,8 @@ import type { Channel } from "./channels/types.js";
2
2
  export declare class Agent {
3
3
  private channels;
4
4
  private sessions;
5
- /** Tracks known participants per group session */
5
+ private liveSessions;
6
6
  private groupParticipants;
7
- /** Per-chat model override */
8
7
  private modelOverrides;
9
8
  private lastPromptHash;
10
9
  constructor();
@@ -12,15 +11,17 @@ export declare class Agent {
12
11
  private static readonly AVAILABLE_MODELS;
13
12
  private handleCommand;
14
13
  private sessionKey;
15
- private checkPromptChanged;
14
+ private getOrCreateLiveSession;
15
+ private closeLiveSession;
16
16
  private hashString;
17
17
  private handleMessage;
18
- private run;
18
+ private runWithRetry;
19
19
  private updateGroupContext;
20
20
  private injectTimestamp;
21
- private summarizeToolInput;
22
21
  /** Handle a cron-triggered message */
23
22
  handleCronMessage(message: string, channelName?: string, chatId?: string): Promise<void>;
23
+ /** Handle a continuity heartbeat — runs on the first active DM session */
24
+ handleContinuity(prompt: string): Promise<void>;
24
25
  private findLastChatId;
25
26
  start(): Promise<void>;
26
27
  stop(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAiDpE,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAe;IAC/B,kDAAkD;IAClD,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,8BAA8B;IAC9B,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,cAAc,CAAc;;IAMpC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMlC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAItC;YAEY,aAAa;IAgC3B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,kBAAkB;I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