agentel 0.2.8 → 0.3.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.
@@ -17,6 +17,13 @@ binary.
17
17
 
18
18
  Runs the recall command surface used by installed skills and slash commands.
19
19
 
20
+ ### `scripts/postinstall.js`
21
+
22
+ Runs the install-time onboarding helper for direct installs. It skips CI,
23
+ `npx`/`npm exec`, and indirect dependency installs; when npm provides an
24
+ interactive terminal, it offers `agentlog update` for existing configs and
25
+ `agentlog init` for new installs.
26
+
20
27
  ## `src/archive.js`
21
28
 
22
29
  Archive storage, transcript normalization, canonical event persistence,
@@ -30,9 +37,13 @@ Exports:
30
37
  - `encodeSegment(value)`: URL-encodes an archive path segment.
31
38
  - `ensureConversationMarkdown(session, env)`: materializes a missing
32
39
  `conversation.md` from an existing transcript JSONL.
33
- - `listSessions(env)`: reads all archived metadata files and returns session
34
- records sorted newest first, including derived raw source archive paths when
35
- present.
40
+ - `listSessions(env)`: returns archived session records sorted newest first,
41
+ using the persisted session-list index when available and rebuilding it from
42
+ metadata files when missing or invalid.
43
+ - `listSessionsSnapshot(env)`: returns `{ sessions, fingerprint, count }` for
44
+ list-derived web endpoints and ETags.
45
+ - `rebuildSessionListIndex(env)`: re-derives `agentlog/indexes/sessions` from
46
+ archived metadata files.
36
47
  - `normalizeMessages(messages)`: normalizes raw messages into indexed,
37
48
  timestamped transcript records; `writeSession` adds per-message visible-token
38
49
  estimates before archiving.
@@ -50,9 +61,10 @@ Exports:
50
61
  deterministic fallback session id.
51
62
  - `toIso(value)`: converts date-ish values to ISO strings.
52
63
  - `walk(dir, visit)`: recursively walks a directory tree.
53
- - `writeSession(input, env)`: redacts, normalizes, writes, indexes, computes
54
- stats metadata (`messageCount`, `userMessageCount`, `usage`, `models`), and
55
- copies declared raw source files for one archived session.
64
+ - `writeSession(input, env)`: redacts, normalizes, writes, indexes, stamps the
65
+ configured device identity into session metadata, computes stats metadata
66
+ (`messageCount`, `userMessageCount`, `usage`, `models`), and copies declared
67
+ raw source files for one archived session.
56
68
 
57
69
  Internal helpers:
58
70
 
@@ -99,12 +111,14 @@ low-signal filtering.
99
111
  Exports:
100
112
 
101
113
  - `CANONICAL_EVENT_SCHEMA_VERSION`: current event schema id,
102
- `agentlog.events.v2`.
114
+ `agentlog.events.v5`.
103
115
  - `EVENT_KINDS`: constants for `session.started`, `prompt.submitted`,
104
- `response.generated`, `tool.called`, and `tool.completed`.
116
+ `response.generated`, `tool.called`, `tool.completed`, `memory.read`,
117
+ `memory.write`, and `memory.loaded`.
105
118
  - `normalizeSessionEvents(session, messages, options)`: maps transcript
106
119
  messages into canonical events and links `tool.completed` events to matching
107
- `tool.called` parents.
120
+ `tool.called` parents. Memory tool completions additionally emit
121
+ `memory.*` events that the viewer can render as memory activity.
108
122
  - `messageToCanonicalEvents(message, session, options)`: maps one message into
109
123
  zero or more canonical events.
110
124
  - `stableEventId(sessionId, messageIndex, kind, ordinal, content)`: creates a
@@ -208,8 +222,14 @@ Command handlers:
208
222
  - `autostartCommand(action)`: compatibility helper behind
209
223
  `agentlog watcher login`.
210
224
  - `resetCommand(flags, env)`: removes agentlog local state and archive objects.
211
- - `updateCommand(flags, env)`: preserves preferences, removes derived local
212
- archive/import state, reimports configured sources, and rebuilds the index.
225
+ - `updateCommand(flags, env)`: preserves preferences and unrecoverable local
226
+ archives, removes derived local archive/import state, reimports configured
227
+ sources, restores sessions whose original source files are gone, and rebuilds
228
+ the index.
229
+ - `statsPayload(filters, env, sessionsInput)`: builds normalized stats totals
230
+ and range-shaped chart series; default web payloads include the current chart
231
+ window and recent activity, while all-time daily series are requested
232
+ explicitly.
213
233
  - `uninstallCommand(flags, env)`: stops services, removes autostart, and
214
234
  optionally removes data.
215
235
  - `revealCommand(sessionId, env)`: prints unredacted reveal-cache JSONL.
@@ -289,24 +309,44 @@ Session display and API helpers:
289
309
 
290
310
  Recall integration helpers:
291
311
 
292
- - `addRecallToAgent(target, env)`: installs MCP config or recall command files
293
- for one agent.
312
+ - `addRecallToAgent(target, env)`: installs MCP config plus recall and
313
+ continue-from command files for one agent.
294
314
  - `installRecallSurface(target, env, options)`: installs slash-command/skill
295
- recall surfaces.
315
+ recall and continue-from surfaces.
296
316
  - `normalizeRecallTarget(target)`: maps common source/client aliases to recall
297
317
  installer targets.
298
318
  - `writeTextFile(file, text)`: writes a text file after ensuring its directory.
299
319
  - `genericRecallInstructions()`: common recall workflow text for agents.
320
+ - `genericContinueFromInstructions()`: common continue-from workflow text for
321
+ agents.
300
322
  - `claudeRecallCommand()`: generated Claude `/recall` command body.
323
+ - `claudeContinueFromCommand()`: generated Claude `/continue-from` command body.
301
324
  - `geminiRecallCommand()`: generated Gemini recall command config.
325
+ - `geminiContinueFromCommand()`: generated Gemini continue-from command config.
302
326
  - `antigravityRecallSkill()`: generated Antigravity recall skill body.
327
+ - `antigravityContinueFromSkill()`: generated Antigravity continue-from skill
328
+ body.
303
329
  - `cursorRecallCommand()`: generated Cursor project `/recall` command body.
304
330
  - `cursorRecallRule()`: generated Cursor rule that advertises agentlog recall.
331
+ - `cursorContinueFromCommand()`: generated Cursor project `/continue-from`
332
+ command body.
333
+ - `cursorContinueFromRule()`: generated Cursor rule that advertises agentlog
334
+ continue-from.
305
335
  - `devinRecallSkill()`: generated Devin `/recall` skill body.
336
+ - `devinContinueFromSkill()`: generated Devin `/continue-from` skill body.
306
337
  - `opencodeRecallCommand()`: generated OpenCode `/recall` command body.
338
+ - `opencodeContinueFromCommand()`: generated OpenCode `/continue-from` command
339
+ body.
307
340
  - `clineRecallWorkflow()`: generated Cline `/recall.md` workflow body.
341
+ - `clineContinueFromWorkflow()`: generated Cline `/continue-from.md` workflow
342
+ body.
308
343
  - `aiderRecallInstructions()`: generated Aider loadable recall instructions.
344
+ - `aiderContinueFromInstructions()`: generated Aider loadable continue-from
345
+ instructions.
309
346
  - `codexRecallSkill()`: generated Codex skill body.
347
+ - `codexContinueFromSkill()`: generated Codex continue-from skill body.
348
+ - `continueFromSurfaceTemplates()`: returns generated continue-from
349
+ command/skill templates.
310
350
  - `recallArchiveHints()`: shared archive path and filter hints.
311
351
  - `commandOnPath(command)`: finds an executable on `PATH`.
312
352
  - `shellQuote(value)`: quotes a shell argument.
@@ -482,6 +522,19 @@ Internal helpers:
482
522
  - `safeJson(body)`: parses JSON or wraps raw text.
483
523
  - `looksLikeJson(body)`: cheaply detects JSON-looking request bodies.
484
524
 
525
+ ## `src/pricing.js`
526
+
527
+ Versioned model pricing lookup used by stats spend estimates. Provider-reported
528
+ costs remain authoritative; this module only prices known token splits when no
529
+ actual cost is archived.
530
+
531
+ Exports:
532
+
533
+ - `PRICING_SOURCE`: stable label for the bundled pricing table.
534
+ - `PRICING_VERSION`: version stamp emitted in stats payloads.
535
+ - `pricingForSession(provider, model)`: returns per-million-token input,
536
+ output, cache-read, and cache-write rates for known models.
537
+
485
538
  ## `src/config.js`
486
539
 
487
540
  Config defaults, persistence, and key access.
@@ -901,14 +954,19 @@ Gemini and Antigravity helpers:
901
954
  - `parseGenericJsonHistory(file, source, fallbackTime)`: generic JSON parser.
902
955
  - `parseMarkdownChatFile(file, source, fallbackTime)`: Markdown chat parser.
903
956
  - `importWindsurfTrajectoryExport(target, options, env)`: imports downloaded
904
- Windsurf "Download trajectory" Markdown exports.
957
+ Windsurf "Download trajectory" Markdown exports. With `options.claim`, a
958
+ single Markdown export replaces the matching zero-message Windsurf protobuf
959
+ repair stub.
905
960
  - `readWindsurfTrajectoryExport(target, options)`: reads Windsurf trajectory
906
961
  Markdown files from a user-selected file or folder.
907
- - `readWindsurfSessions(options)`: disabled experimental helper retained for
908
- future Windsurf decoder work.
909
- - `readAntigravitySessions(options, env)`: reads Antigravity Markdown artifacts,
910
- imports partial trajectory summaries from Antigravity global state when
911
- artifacts are absent, and counts binary stores.
962
+ - `readWindsurfSessions(options, env)`: reads local Windsurf Cascade brain
963
+ artifacts from `.codeium/windsurf/brain`, preserves matching Cascade
964
+ protobufs as raw files when present, enriches session IDs from Windsurf's ACP
965
+ metadata cache, and emits binary-only protobuf stores as repair stubs.
966
+ - `readAntigravitySessions(options, env)`: reads Antigravity transcript logs and
967
+ Markdown artifacts, links `INVOKE_SUBAGENT` child transcripts into
968
+ `antigravitySubagentRuns`, imports partial trajectory summaries from
969
+ Antigravity global state when artifacts are absent, and counts binary stores.
912
970
  - `readMarkdownArtifactSessions({ ... })`: common Markdown artifact reader.
913
971
  - `markdownArtifactSession(provider, dir, artifactNames, sourceType, detailKey)`:
914
972
  converts one artifact directory into a session.
@@ -1042,9 +1100,11 @@ Recall search, history listing, filters, and the event-first keyword index.
1042
1100
 
1043
1101
  Exports:
1044
1102
 
1045
- - `buildIndex(env)`: reads canonical events when present, falls back to
1046
- transcripts, chunks searchable text, and writes the BM25 JSON index plus the
1047
- SQLite FTS5 sidecar when `sqlite3` is available.
1103
+ - `buildIndex(env)`: reads canonical events, chunks searchable text, and writes
1104
+ the compatibility BM25 JSON index plus the SQLite FTS5 sidecar. The index is
1105
+ keyed by the session-list fingerprint.
1106
+ - `buildIndexSummary(env)`: writes the normal summary JSON index and SQLite FTS5
1107
+ sidecar without retaining all docs/postings in the parent process.
1048
1108
  - `chunkText(text, maxTokens, overlap)`: chunks long content for indexing.
1049
1109
  - `listHistorySessions(options, env)`: returns filtered archived session rows.
1050
1110
  - `listRecentSessions(limit, options, env)`: returns recent session rows.
@@ -1052,30 +1112,33 @@ Exports:
1052
1112
  `null` for missing/stale/incompatible indexes without parsing obsolete JSON.
1053
1113
  - `readIndexSummary(indexPath)`: reads only the JSON index header fields needed
1054
1114
  for status displays.
1115
+ - `rebuildIndexSummary(env)`: rebuilds the summary/FTS index, usually in a
1116
+ short-lived child process.
1055
1117
  - `reindexIfNeeded(env)`: rebuilds the index when stale and not paused.
1056
1118
  - `sessionHistoryTime(session)`: returns display-safe session times, including
1057
1119
  hiding Cursor raw-salvage timestamps that were synthesized from SQLite mtimes.
1058
- - `searchPastSessions(query, options, env)`: searches the event index first,
1059
- then legacy markdown/transcript fallback. Interactive callers can pass
1060
- `noRebuild`, `skipJsonIndex`, `allowStaleFts`, and `skipMarkdownFallback` to
1061
- avoid synchronous index rebuilds, large BM25 JSON parses, or full-archive
1062
- Markdown scans during typing.
1120
+ - `searchPastSessions(query, options, env)`: searches the canonical event index.
1121
+ Legacy BM25 JSON search requires `legacyJsonIndex`/`allowJsonIndex`, and
1122
+ legacy markdown/transcript scanning requires `markdownFallback`; interactive
1123
+ callers pass `noRebuild`, `skipJsonIndex`, `allowStaleFts`, and
1124
+ `skipMarkdownFallback` to keep typing paths bounded.
1063
1125
  - `tokenize(text)`: lowercases and tokenizes searchable text.
1064
1126
 
1065
1127
  Internal helpers:
1066
1128
 
1067
1129
  - `docsForEvents(session, events)`: converts canonical events into index
1068
1130
  documents with event ids, event kinds, message indexes, and rendered text.
1069
- - `docsForTranscript(session, messages)`: builds legacy transcript index
1070
- documents when no event file exists.
1131
+ - `docsForTranscript(session, messages)`: builds legacy transcript documents for
1132
+ explicit markdown/transcript recovery paths.
1071
1133
  - `buildFtsIndex(index, env)`: writes the SQLite FTS5 sidecar from indexed
1072
1134
  chunks, skipping the optional sidecar when `sqlite3` is unavailable.
1073
1135
  - `ftsIndexAvailable(env, options)`: validates FTS5 sidecar version/freshness
1074
1136
  without loading the JSON index.
1075
- - `searchMarkdownSessions(query, options, env)`: legacy conversation Markdown
1076
- search with `rg`/JS fallback.
1077
- - `searchIndexedSessions(query, options, env)`: searches the event/transcript
1078
- FTS5 sidecar or JSON index and aggregates hits by session.
1137
+ - `searchMarkdownSessions(query, options, env)`: explicit legacy conversation
1138
+ Markdown search with `rg`/JS fallback.
1139
+ - `searchIndexedSessions(query, options, env)`: searches the canonical-event
1140
+ FTS5 sidecar, optionally falling back to the legacy JSON index when requested,
1141
+ and aggregates hits by session.
1079
1142
  - `searchFtsSessions(query, queryTokens, context, env)`: searches the SQLite
1080
1143
  FTS5 sidecar with prefix matching and returns session-shaped results.
1081
1144
  - `candidateDocsForQuery(index, queryTokens, phrase)`: reads term postings to
@@ -1128,7 +1191,11 @@ Exports:
1128
1191
  log lines.
1129
1192
  - `stopSupervisor(env)`: sends SIGTERM to the recorded supervisor process.
1130
1193
  - `supervisorStatus(env)`: reports supervisor PID and running state.
1131
- - `tick(env)`: runs one import, reindex, and sync cycle.
1194
+ - `tick(env, state)`: runs one import, reindex, and sync cycle.
1195
+ - `applyWatchedSourceImportOutcome(sourceState, now)`: rests a watched source
1196
+ until the 15-minute heartbeat after an import.
1197
+ - `sourceEligibleForImport(sourceState, pending, now)`: pending filesystem
1198
+ activity bypasses idle/heartbeat scheduling but not error backoff.
1132
1199
 
1133
1200
  Internal helpers:
1134
1201
 
@@ -1136,6 +1203,67 @@ Internal helpers:
1136
1203
  - `isAlive(pid)`: checks whether a PID is alive.
1137
1204
  - `log(message, env)`: appends to supervisor log.
1138
1205
 
1206
+ ## `src/slack-notify.js`
1207
+
1208
+ Slack notify layer (`notify.slack` config block; see
1209
+ `docs/agentlog-slack-scope.md`). `writeSession` appends changed sessions to a
1210
+ state-dir queue; the supervisor tick drains it in a child process and posts
1211
+ one completion summary per session after it goes quiet.
1212
+
1213
+ Exports:
1214
+
1215
+ - `slackNotifySettings(cfg, env)`: resolved settings with independent
1216
+ `summary` (channel, quietMinutes) and `stream` (channel, batchSeconds)
1217
+ blocks; legacy single-channel configs map onto `summary`. Token falls back
1218
+ to `AGENTLOG_SLACK_BOT_TOKEN`/`SLACK_BOT_TOKEN`, API base URL to
1219
+ `AGENTLOG_SLACK_API_BASE_URL` (test override).
1220
+ - `enqueueSlackNotification(session, cfg, env)`: gated hot-path append from
1221
+ `writeSession`; honors the per-repo allowlist.
1222
+ - `runSlackNotify(env, options)`: drains the queue into tracked state,
1223
+ streams new events for firehose sessions (one thread per session, event
1224
+ cursor per session, batched per `batchSeconds`), posts summaries for quiet
1225
+ sessions (also closing the firehose thread), and returns
1226
+ `{ posted, streamed, tracked, skipped, errors, nextCheckMs }`. Sessions
1227
+ older than 24h never post (reimport-flood guard); failed posts stay tracked
1228
+ for retry; `options.dryRun` collects messages without posting.
1229
+ - `streamMessagesForEvents(events, opts)`: per-turn firehose rendering —
1230
+ each prompt/response becomes its own Slack post under a per-speaker
1231
+ identity: the agent as its model name (`modelDisplayName`) with the
1232
+ company logo as avatar (GitHub org avatar PNGs; Slack's `icon_url` needs a
1233
+ public raster, and the viewer's brand logos are inline SVGs). Needs
1234
+ chat:write.customize; falls back to plain bot posts and remembers via
1235
+ `state.customizeUnsupported`. Whole messages, formatting preserved; tool
1236
+ calls only with `stream.includeTools`. Long in-flight sessions replay only
1237
+ the most recent turns on first attach.
1238
+ - Thread lifecycle: going quiet closes the session's thread (the recap, when
1239
+ summaries are on, doubles as the close), keeping the event cursor; a
1240
+ session picked back up later opens a fresh thread marked "(resumed)" and
1241
+ streams only the new turns.
1242
+ - `buildCompletionMessage(meta, tracked)`: summary text from session metadata.
1243
+ - `buildSlackAppManifest(appName)` / `slackAppCreationUrl(appName)`: app
1244
+ manifest (chat:write only) and the pre-filled api.slack.com creation link
1245
+ used by the `agentlog notify slack setup` wizard.
1246
+ - `postSlackMessage(settings, payload)` / `slackAuthTest(settings)`: Slack Web
1247
+ API via built-in fetch.
1248
+ - `queuePath(env)` / `statePath(env)`: state-dir file locations.
1249
+
1250
+ ## `src/source-watch.js`
1251
+
1252
+ Filesystem-event layer for the supervisor. Maps each import source to its
1253
+ on-disk history roots (mirroring importer path resolution and env overrides
1254
+ without loading `src/importers.js`) and watches them with `fs.watch`.
1255
+
1256
+ Exports:
1257
+
1258
+ - `watchRootsForSource(source, env)`: watch roots
1259
+ (`{ dir, recursive, filter, coalesceMs }`) for a source; empty for sources
1260
+ that stay on polling (for example Aider project folders).
1261
+ - `startSourceWatchers(sources, env, onSourceDirty, options)`: dedupes shared
1262
+ roots into one OS watch each, coalesces events per source in a fixed-delay
1263
+ window (3s default, 20s for SQLite-backed stores), retries missing or dead
1264
+ watches every 5 minutes, and reports dirty sources. Returns
1265
+ `{ isWatched, activeWatchCount, refresh, close }`.
1266
+
1139
1267
  ## `src/sync.js`
1140
1268
 
1141
1269
  Remote archive sync to file targets or S3-compatible object storage. Sync is
@@ -1150,8 +1278,8 @@ Exports:
1150
1278
  - `configureRemoteFromFlags(flags, env)`: persists remote sync settings from CLI
1151
1279
  flags.
1152
1280
  - `hasRemoteTarget(cfg, env)`: reports whether a remote target is configured.
1153
- - `listLocalArchiveObjects(env, prefix)`: lists local archive objects as remote
1154
- keys with hashes.
1281
+ - `listLocalArchiveObjects(env, prefix)`: lists canonical local archive objects
1282
+ as remote keys with hashes, excluding derived `indexes/` caches.
1155
1283
  - `listRemoteSnapshots(options, env)`: lists snapshot folders and object counts
1156
1284
  for the configured/flag remote target.
1157
1285
  - `parseListBucketResult(xml)`: parses S3 ListObjectsV2 XML.