@ouhuang/pi-mom 0.65.1

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 (67) hide show
  1. package/CHANGELOG.md +500 -0
  2. package/README.md +490 -0
  3. package/dist/agent.d.ts +24 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +756 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/context.d.ts +26 -0
  8. package/dist/context.d.ts.map +1 -0
  9. package/dist/context.js +139 -0
  10. package/dist/context.js.map +1 -0
  11. package/dist/download.d.ts +2 -0
  12. package/dist/download.d.ts.map +1 -0
  13. package/dist/download.js +89 -0
  14. package/dist/download.js.map +1 -0
  15. package/dist/events.d.ts +57 -0
  16. package/dist/events.d.ts.map +1 -0
  17. package/dist/events.js +310 -0
  18. package/dist/events.js.map +1 -0
  19. package/dist/log.d.ts +39 -0
  20. package/dist/log.d.ts.map +1 -0
  21. package/dist/log.js +222 -0
  22. package/dist/log.js.map +1 -0
  23. package/dist/main.d.ts +3 -0
  24. package/dist/main.d.ts.map +1 -0
  25. package/dist/main.js +317 -0
  26. package/dist/main.js.map +1 -0
  27. package/dist/sandbox.d.ts +34 -0
  28. package/dist/sandbox.d.ts.map +1 -0
  29. package/dist/sandbox.js +183 -0
  30. package/dist/sandbox.js.map +1 -0
  31. package/dist/slack.d.ts +128 -0
  32. package/dist/slack.d.ts.map +1 -0
  33. package/dist/slack.js +455 -0
  34. package/dist/slack.js.map +1 -0
  35. package/dist/store.d.ts +60 -0
  36. package/dist/store.d.ts.map +1 -0
  37. package/dist/store.js +180 -0
  38. package/dist/store.js.map +1 -0
  39. package/dist/tools/attach.d.ts +10 -0
  40. package/dist/tools/attach.d.ts.map +1 -0
  41. package/dist/tools/attach.js +34 -0
  42. package/dist/tools/attach.js.map +1 -0
  43. package/dist/tools/bash.d.ts +10 -0
  44. package/dist/tools/bash.d.ts.map +1 -0
  45. package/dist/tools/bash.js +78 -0
  46. package/dist/tools/bash.js.map +1 -0
  47. package/dist/tools/edit.d.ts +11 -0
  48. package/dist/tools/edit.d.ts.map +1 -0
  49. package/dist/tools/edit.js +131 -0
  50. package/dist/tools/edit.js.map +1 -0
  51. package/dist/tools/index.d.ts +5 -0
  52. package/dist/tools/index.d.ts.map +1 -0
  53. package/dist/tools/index.js +16 -0
  54. package/dist/tools/index.js.map +1 -0
  55. package/dist/tools/read.d.ts +11 -0
  56. package/dist/tools/read.d.ts.map +1 -0
  57. package/dist/tools/read.js +134 -0
  58. package/dist/tools/read.js.map +1 -0
  59. package/dist/tools/truncate.d.ts +57 -0
  60. package/dist/tools/truncate.d.ts.map +1 -0
  61. package/dist/tools/truncate.js +184 -0
  62. package/dist/tools/truncate.js.map +1 -0
  63. package/dist/tools/write.d.ts +10 -0
  64. package/dist/tools/write.d.ts.map +1 -0
  65. package/dist/tools/write.js +33 -0
  66. package/dist/tools/write.js.map +1 -0
  67. package/package.json +54 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,500 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.65.0] - 2026-04-03
6
+
7
+ ## [0.64.0] - 2026-03-29
8
+
9
+ ## [0.63.2] - 2026-03-29
10
+
11
+ ## [0.63.1] - 2026-03-27
12
+
13
+ ### Fixed
14
+
15
+ - Fixed Mom compaction status handling to follow the unified `compaction_start` and `compaction_end` session events, keeping compaction notifications working after the event rename ([#2617](https://github.com/badlogic/pi-mono/issues/2617))
16
+
17
+ ## [0.63.0] - 2026-03-27
18
+
19
+ ## [0.62.0] - 2026-03-23
20
+
21
+ ## [0.61.1] - 2026-03-20
22
+
23
+ ## [0.61.0] - 2026-03-20
24
+
25
+ ## [0.60.0] - 2026-03-18
26
+
27
+ ## [0.59.0] - 2026-03-17
28
+
29
+ ## [0.58.4] - 2026-03-16
30
+
31
+ ## [0.58.3] - 2026-03-15
32
+
33
+ ## [0.58.2] - 2026-03-15
34
+
35
+ ## [0.58.1] - 2026-03-14
36
+
37
+ ## [0.58.0] - 2026-03-14
38
+
39
+ ## [0.57.1] - 2026-03-07
40
+
41
+ ## [0.57.0] - 2026-03-07
42
+
43
+ ## [0.56.3] - 2026-03-06
44
+
45
+ ## [0.56.2] - 2026-03-05
46
+
47
+ ## [0.56.1] - 2026-03-05
48
+
49
+ ## [0.56.0] - 2026-03-04
50
+
51
+ ## [0.55.4] - 2026-03-02
52
+
53
+ ### Fixed
54
+
55
+ - Fixed mom startup crash caused by settings API drift by using `SettingsManager` with workspace-backed storage ([#1444](https://github.com/badlogic/pi-mono/issues/1444))
56
+
57
+ ## [0.55.3] - 2026-02-27
58
+
59
+ ## [0.55.2] - 2026-02-27
60
+
61
+ ## [0.55.1] - 2026-02-26
62
+
63
+ ## [0.55.0] - 2026-02-24
64
+
65
+ ## [0.54.2] - 2026-02-23
66
+
67
+ ## [0.54.1] - 2026-02-22
68
+
69
+ ## [0.54.0] - 2026-02-19
70
+
71
+ ## [0.53.1] - 2026-02-19
72
+
73
+ ## [0.53.0] - 2026-02-17
74
+
75
+ ## [0.52.12] - 2026-02-13
76
+
77
+ ## [0.52.11] - 2026-02-13
78
+
79
+ ## [0.52.10] - 2026-02-12
80
+
81
+ ## [0.52.9] - 2026-02-08
82
+
83
+ ## [0.52.8] - 2026-02-07
84
+
85
+ ## [0.52.7] - 2026-02-06
86
+
87
+ ## [0.52.6] - 2026-02-05
88
+
89
+ ## [0.52.5] - 2026-02-05
90
+
91
+ ## [0.52.4] - 2026-02-05
92
+
93
+ ## [0.52.3] - 2026-02-05
94
+
95
+ ## [0.52.2] - 2026-02-05
96
+
97
+ ## [0.52.1] - 2026-02-05
98
+
99
+ ## [0.52.0] - 2026-02-05
100
+
101
+ ## [0.51.6] - 2026-02-04
102
+
103
+ ## [0.51.5] - 2026-02-04
104
+
105
+ ## [0.51.4] - 2026-02-03
106
+
107
+ ## [0.51.3] - 2026-02-03
108
+
109
+ ## [0.51.2] - 2026-02-03
110
+
111
+ ## [0.51.1] - 2026-02-02
112
+
113
+ ## [0.51.0] - 2026-02-01
114
+
115
+ ## [0.50.9] - 2026-02-01
116
+
117
+ ## [0.50.8] - 2026-02-01
118
+
119
+ ## [0.50.7] - 2026-01-31
120
+
121
+ ## [0.50.6] - 2026-01-30
122
+
123
+ ## [0.50.5] - 2026-01-30
124
+
125
+ ## [0.50.3] - 2026-01-29
126
+
127
+ ## [0.50.2] - 2026-01-29
128
+
129
+ ## [0.50.1] - 2026-01-26
130
+
131
+ ## [0.50.0] - 2026-01-26
132
+
133
+ ## [0.49.3] - 2026-01-22
134
+
135
+ ## [0.49.2] - 2026-01-19
136
+
137
+ ## [0.49.1] - 2026-01-18
138
+
139
+ ## [0.49.0] - 2026-01-17
140
+
141
+ ## [0.48.0] - 2026-01-16
142
+
143
+ ## [0.47.0] - 2026-01-16
144
+
145
+ ## [0.46.0] - 2026-01-15
146
+
147
+ ## [0.45.7] - 2026-01-13
148
+
149
+ ## [0.45.6] - 2026-01-13
150
+
151
+ ## [0.45.5] - 2026-01-13
152
+
153
+ ## [0.45.4] - 2026-01-13
154
+
155
+ ## [0.45.3] - 2026-01-13
156
+
157
+ ## [0.45.2] - 2026-01-13
158
+
159
+ ## [0.45.1] - 2026-01-13
160
+
161
+ ## [0.45.0] - 2026-01-13
162
+
163
+ ## [0.44.0] - 2026-01-12
164
+
165
+ ## [0.43.0] - 2026-01-11
166
+
167
+ ## [0.42.5] - 2026-01-11
168
+
169
+ ### Fixed
170
+
171
+ - Use coding-agent's SessionManager instead of custom MomSessionManager to fix API mismatch crash ([#595](https://github.com/badlogic/pi-mono/issues/595))
172
+
173
+ ## [0.42.4] - 2026-01-10
174
+
175
+ ## [0.42.3] - 2026-01-10
176
+
177
+ ## [0.42.2] - 2026-01-10
178
+
179
+ ## [0.42.1] - 2026-01-09
180
+
181
+ ## [0.42.0] - 2026-01-09
182
+
183
+ ## [0.41.0] - 2026-01-09
184
+
185
+ ## [0.40.1] - 2026-01-09
186
+
187
+ ## [0.40.0] - 2026-01-08
188
+
189
+ ## [0.39.1] - 2026-01-08
190
+
191
+ ## [0.39.0] - 2026-01-08
192
+
193
+ ## [0.38.0] - 2026-01-08
194
+
195
+ ## [0.37.8] - 2026-01-07
196
+
197
+ ## [0.37.7] - 2026-01-07
198
+
199
+ ## [0.37.6] - 2026-01-06
200
+
201
+ ## [0.37.5] - 2026-01-06
202
+
203
+ ## [0.37.4] - 2026-01-06
204
+
205
+ ## [0.37.3] - 2026-01-06
206
+
207
+ ## [0.37.2] - 2026-01-05
208
+
209
+ ## [0.37.1] - 2026-01-05
210
+
211
+ ## [0.37.0] - 2026-01-05
212
+
213
+ ## [0.36.0] - 2026-01-05
214
+
215
+ ## [0.35.0] - 2026-01-05
216
+
217
+ ## [0.34.2] - 2026-01-04
218
+
219
+ ## [0.34.1] - 2026-01-04
220
+
221
+ ## [0.34.0] - 2026-01-04
222
+
223
+ ## [0.33.0] - 2026-01-04
224
+
225
+ ## [0.32.3] - 2026-01-03
226
+
227
+ ## [0.32.2] - 2026-01-03
228
+
229
+ ## [0.32.1] - 2026-01-03
230
+
231
+ ## [0.32.0] - 2026-01-03
232
+
233
+ ## [0.31.1] - 2026-01-02
234
+
235
+ ## [0.31.0] - 2026-01-02
236
+
237
+ ### Breaking Changes
238
+
239
+ - `AgentTool` import moved from `@mariozechner/pi-ai` to `@mariozechner/pi-agent-core`
240
+ - `AppMessage` type renamed to `AgentMessage`
241
+ - `Attachment` type replaced with `ImageContent` for image handling
242
+ - `MomSessionManager.loadSession()` renamed to `buildSessionContex()`
243
+ - `MomSessionManager.createBranchedSessionFromEntries()` signature changed to `createBranchedSession(leafId)`
244
+ - `ProviderTransport` removed from Agent config, replaced with direct `getApiKey` callback
245
+ - `messageTransformer` renamed to `convertToLlm`
246
+ - `ANTHROPIC_API_KEY`/`ANTHROPIC_OAUTH_TOKEN` no longer checked at startup (deferred to first API call)
247
+
248
+ ### Changed
249
+
250
+ - Session entries now include `id` and `parentId` fields for tree structure support
251
+ - Auth lookup now uses `AuthStorage` class instead of direct environment variable access
252
+ - Image attachments use `ImageContent` type with `data` field instead of `Attachment` with `content`
253
+ - `session.prompt()` now uses `images` option instead of `attachments`
254
+
255
+ ### Added
256
+
257
+ - Support for OAuth login via coding agent's `/login` command (link `~/.pi/agent/auth.json` to `~/.pi/mom/auth.json`)
258
+
259
+ ## [0.20.2] - 2025-12-13
260
+
261
+ ### Fixed
262
+
263
+ - **Skill paths now use container paths**: Skill file paths in system prompt are translated to container paths (e.g., `/workspace/skills/...`) so mom can read them from inside Docker.
264
+
265
+ ## [0.20.1] - 2025-12-13
266
+
267
+ ### Added
268
+
269
+ - **Skills auto-discovery**: Mom now automatically discovers skills from `workspace/skills/` and `channel/skills/` directories. Skills are directories containing a `SKILL.md` file with `name` and `description` in YAML frontmatter. Available skills are listed in the system prompt with their descriptions. Mom reads the `SKILL.md` file before using a skill.
270
+
271
+ ## [0.19.2] - 2025-12-12
272
+
273
+ ### Added
274
+
275
+ - Events system: schedule wake-ups via JSON files in `workspace/events/`
276
+ - Immediate events: trigger when file is created (for webhooks, external signals)
277
+ - One-shot events: trigger at specific time (for reminders)
278
+ - Periodic events: trigger on cron schedule (for recurring tasks)
279
+ - `SlackBot.enqueueEvent()` for queueing events (max 5 per channel)
280
+ - `[SILENT]` response marker: deletes status message, posts nothing to Slack (for periodic events with nothing to report)
281
+ - Events documentation in `docs/events.md`
282
+ - System prompt section explaining events to mom
283
+
284
+ ## [0.18.8] - 2025-12-12
285
+
286
+ ### Changed
287
+
288
+ - Timestamp prefix now includes timezone offset (`[YYYY-MM-DD HH:MM:SS+HH:MM]`)
289
+
290
+ ## [0.18.7] - 2025-12-12
291
+
292
+ ### Added
293
+
294
+ - Timestamp prefix on user messages (`[YYYY-MM-DD HH:MM:SS]`) so mom knows current date/time
295
+
296
+ ### Fixed
297
+
298
+ - Sync deduplication now strips timestamp prefix before comparing
299
+
300
+ ## [0.18.6] - 2025-12-12
301
+
302
+ ### Fixed
303
+
304
+ - Duplicate message in context when message has attachments (sync from log didn't strip attachment section before comparing)
305
+ - Use `<slack_attachments>` delimiter for attachments in messages (easier to parse/strip)
306
+
307
+ ## [0.18.5] - 2025-12-12
308
+
309
+ ### Added
310
+
311
+ - `--download <channel-id>` flag to download a channel's full history including thread replies as plain text
312
+
313
+ ### Fixed
314
+
315
+ - Error handling: when agent returns `stopReason: "error"`, main message is updated to "Sorry, something went wrong" and error details are posted to the thread
316
+
317
+ ## [0.18.4] - 2025-12-11
318
+
319
+ ### Fixed
320
+
321
+ - Attachment downloads now work correctly
322
+ - SlackBot now receives store for processing file downloads
323
+ - Files are downloaded in background and stored in `<channel>/attachments/`
324
+ - Attachment paths passed to agent as absolute paths in execution environment
325
+ - Backfill also downloads attachments from historical messages
326
+
327
+ ## [0.18.3] - 2025-12-11
328
+
329
+ ### Changed
330
+
331
+ - Complete rewrite of message handling architecture (#115)
332
+ - Now uses `AgentSession` from coding-agent for session management
333
+ - Brings auto-compaction, overflow handling, and proper prompt caching
334
+ - `log.jsonl` is the source of truth for all channel messages
335
+ - `context.jsonl` stores LLM context (messages sent to Claude, same format as coding-agent)
336
+ - Sync mechanism ensures context.jsonl stays in sync with log.jsonl at run start
337
+ - Session header written immediately on new session creation (not lazily)
338
+ - Tool results preserved in context.jsonl for multi-turn continuity
339
+
340
+ - Backfill improvements
341
+ - Only backfills channels that already have a `log.jsonl` file
342
+ - Strips @mentions from backfilled messages (consistent with live messages)
343
+ - Uses largest timestamp in log for efficient incremental backfill
344
+ - Fetches DM channels in addition to public/private channels
345
+
346
+ - Message handling improvements
347
+ - Channel chatter (messages without @mention) logged but doesn't trigger processing
348
+ - Messages sent while mom is busy are logged and synced on next run
349
+ - Pre-startup messages (replayed by Slack on reconnect) logged but not auto-processed
350
+ - Stop command executes immediately (not queued), can interrupt running tasks
351
+ - Channel @mentions no longer double-logged (was firing both app_mention and message events)
352
+
353
+ - Usage summary now includes context window usage
354
+ - Shows current context tokens vs model's context window
355
+ - Example: `Context: 4.2k / 200k (2.1%)`
356
+
357
+ ### Fixed
358
+
359
+ - Slack API errors (msg_too_long) no longer crash the process
360
+ - Added try/catch error handling to all Slack API calls in the message queue
361
+ - Main channel messages truncated at 35K with note to ask for elaboration
362
+ - Thread messages truncated at 20K
363
+ - replaceMessage also truncated at 35K
364
+
365
+ - Private channel messages not being logged
366
+ - Added `message.groups` to required bot events in README
367
+ - Added `groups:history` and `groups:read` to required scopes in README
368
+
369
+ - Stop command now updates "Stopping..." to "Stopped" instead of posting two messages
370
+
371
+ ### Added
372
+
373
+ - Port truncation logic from coding-agent: bash and read tools now use consistent 2000 lines OR 50KB limits with actionable notices
374
+
375
+ ## [0.10.2] - 2025-11-27
376
+
377
+ ### Breaking Changes
378
+
379
+ - Timestamps now use Slack format (seconds.microseconds) and messages are sorted by `ts` field
380
+ - **Migration required**: Run `npx tsx scripts/migrate-timestamps.ts ./data` to fix existing logs
381
+ - Without migration, message context will be incorrectly ordered
382
+
383
+ ### Added
384
+
385
+ - Channel and user ID mappings in system prompt
386
+ - Fetches all channels bot is member of and all workspace users at startup
387
+ - Mom can now reference channels by name and mention users properly
388
+ - Skills documentation in system prompt
389
+ - Explains custom CLI tools pattern with SKILL.md files
390
+ - Encourages mom to create reusable tools for recurring tasks
391
+ - Debug output: writes `last_prompt.txt` to channel directory with full context
392
+ - Bash working directory info in system prompt (/ for Docker, cwd for host)
393
+ - Token-efficient log queries that filter out tool calls/results for summaries
394
+
395
+ ### Changed
396
+
397
+ - Turn-based message context instead of raw line count (#68)
398
+ - Groups consecutive bot messages (tool calls/results) as single turn
399
+ - "50 turns" now means ~50 conversation exchanges, not 50 log lines
400
+ - Prevents tool-heavy runs from pushing out conversation context
401
+ - Messages sorted by Slack timestamp before building context
402
+ - Fixes out-of-order issues from async attachment downloads
403
+ - Added monotonic counter for sub-millisecond ordering
404
+ - Condensed system prompt from ~5k to ~2.7k chars
405
+ - More concise workspace layout (tree format)
406
+ - Clearer log query examples (conversation-only vs full details)
407
+ - Removed redundant guidelines section
408
+ - User prompt simplified: removed duplicate "Current message" (already in history)
409
+ - Tool status labels (`_→ label_`) no longer logged to jsonl
410
+ - Thread messages and thinking no longer double-logged
411
+
412
+ ### Fixed
413
+
414
+ - Duplicate message logging: removed redundant log from app_mention handler
415
+ - Username obfuscation in thread messages to prevent unwanted pings
416
+ - Handles @username, bare username, and <@USERID> formats
417
+ - Escapes special regex characters in usernames
418
+
419
+ ## [0.10.1] - 2025-11-27
420
+
421
+ ### Changed
422
+
423
+ - Reduced tool verbosity in main Slack messages (#65)
424
+ - During execution: show tool labels (with → prefix), thinking, and text
425
+ - After completion: replace main message with only final assistant response
426
+ - Full audit trail preserved in thread (tool details, thinking, text)
427
+ - Added promise queue to ensure message updates execute in correct order
428
+
429
+ ## [0.10.0] - 2025-11-27
430
+
431
+ ### Added
432
+
433
+ - Working memory system with MEMORY.md files
434
+ - Global workspace memory (`workspace/MEMORY.md`) shared across all channels
435
+ - Channel-specific memory (`workspace/<channel>/MEMORY.md`) for per-channel context
436
+ - Automatic memory loading into system prompt on each request
437
+ - Mom can update memory files to remember project details, preferences, and context
438
+ - ISO 8601 date field in log.jsonl for easy date-based grepping
439
+ - Format: `"date":"2025-11-26T10:44:00.123Z"`
440
+ - Enables queries like: `grep '"date":"2025-11-26' log.jsonl`
441
+ - Centralized logging system (`src/log.ts`)
442
+ - Structured, colored console output (green for user messages, yellow for mom activity, dim for details)
443
+ - Consistent format: `[HH:MM:SS] [context] message`
444
+ - Type-safe logging functions for all event types
445
+ - Usage tracking and cost reporting
446
+ - Tracks tokens (input, output, cache read, cache write) and costs per run
447
+ - Displays summary at end of each agent run in console and Slack thread
448
+ - Example: `💰 Usage: 12,543 in + 847 out (5,234 cache read, 127 cache write) = $0.0234`
449
+ - Working indicator in Slack messages
450
+ - Channel messages show "..." while mom is processing
451
+ - Automatically removed when work completes
452
+ - Improved stop command behavior
453
+ - Separate "Stopping..." message that updates to "Stopped" when abort completes
454
+ - Original working message continues to show tool results (including abort errors)
455
+ - Clean separation between status and results
456
+
457
+ ### Changed
458
+
459
+ - Enhanced system prompt with clearer directory structure and path examples
460
+ - Improved memory file path documentation to prevent confusion
461
+ - Message history format now includes ISO 8601 date for better searchability
462
+ - System prompt now includes log.jsonl format documentation with grep examples
463
+ - System prompt now includes current date and time for date-aware operations
464
+ - Added efficient log query patterns using jq to prevent context overflow
465
+ - System prompt emphasizes limiting NUMBER of messages (10-50), not truncating message text
466
+ - Log queries now show full message text and attachments for better context
467
+ - Fixed jq patterns to handle null/empty attachments with `(.attachments // [])`
468
+ - Recent messages in system prompt now formatted as TSV (43% token savings vs raw JSONL)
469
+ - Enhanced security documentation with prompt injection risk warnings and mitigations
470
+ - **Moved recent messages from system prompt to user message** for better prompt caching
471
+ - System prompt is now mostly static (only changes when memory files change)
472
+ - Enables Anthropic's prompt caching to work effectively
473
+ - Significantly reduces costs on subsequent requests
474
+ - Switched from Claude Opus 4.5 to Claude Sonnet 4.5 (~40% cost reduction)
475
+ - Tool result display now extracts actual text instead of showing JSON wrapper
476
+ - Slack thread messages now show cleaner tool call formatting with duration and label
477
+ - All console logging centralized and removed from scattered locations
478
+ - Agent run now returns `{ stopReason }` instead of throwing exceptions
479
+ - Clean handling of "aborted", "error", "stop", "length", "toolUse" cases
480
+ - No more error-based control flow
481
+
482
+ ### Fixed
483
+
484
+ - jq query patterns now properly handle messages without attachments (no more errors on empty arrays)
485
+
486
+ ## [0.9.4] - 2025-11-26
487
+
488
+ ### Added
489
+
490
+ - Initial release of Mom Slack bot
491
+ - Slack integration with @mentions and DMs
492
+ - Docker sandbox mode for isolated execution
493
+ - Bash tool with full shell access
494
+ - Read, write, edit file tools
495
+ - Attach tool for sharing files in Slack
496
+ - Thread-based tool details (clean main messages, verbose details in threads)
497
+ - Single accumulated message per agent run
498
+ - Stop command (`@mom stop`) to abort running tasks
499
+ - Persistent workspace per channel with scratchpad directory
500
+ - Streaming console output for monitoring