agentsofmine 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +297 -2
- package/dist/adapters/adapter.d.ts +14 -0
- package/dist/adapters/adapter.js +2 -0
- package/dist/adapters/claude-code/accumulator.d.ts +34 -0
- package/dist/adapters/claude-code/accumulator.js +129 -0
- package/dist/adapters/claude-code/content-blocks.d.ts +40 -0
- package/dist/adapters/claude-code/content-blocks.js +93 -0
- package/dist/adapters/claude-code/index.d.ts +20 -0
- package/dist/adapters/claude-code/index.js +92 -0
- package/dist/adapters/claude-code/jsonl-reader.d.ts +14 -0
- package/dist/adapters/claude-code/jsonl-reader.js +31 -0
- package/dist/adapters/claude-code/mapper.d.ts +6 -0
- package/dist/adapters/claude-code/mapper.js +23 -0
- package/dist/adapters/codex/index.d.ts +8 -0
- package/dist/adapters/codex/index.js +42 -0
- package/dist/adapters/codex/log-reader.d.ts +14 -0
- package/dist/adapters/codex/log-reader.js +182 -0
- package/dist/adapters/codex/shell-parser.d.ts +6 -0
- package/dist/adapters/codex/shell-parser.js +72 -0
- package/dist/adapters/opencode/file-changes.d.ts +8 -0
- package/dist/adapters/opencode/file-changes.js +38 -0
- package/dist/adapters/opencode/index.d.ts +13 -0
- package/dist/adapters/opencode/index.js +58 -0
- package/dist/adapters/opencode/mapper.d.ts +4 -0
- package/dist/adapters/opencode/mapper.js +56 -0
- package/dist/adapters/opencode/sqlite-reader.d.ts +19 -0
- package/dist/adapters/opencode/sqlite-reader.js +109 -0
- package/dist/adapters/pi/index.d.ts +8 -0
- package/dist/adapters/pi/index.js +76 -0
- package/dist/adapters/pi/jsonl-reader.d.ts +2 -0
- package/dist/adapters/pi/jsonl-reader.js +2 -0
- package/dist/adapters/pi/mapper.d.ts +22 -0
- package/dist/adapters/pi/mapper.js +230 -0
- package/dist/api/pairing-client.d.ts +41 -0
- package/dist/api/pairing-client.js +77 -0
- package/dist/bin/aom.d.ts +13 -0
- package/dist/bin/aom.js +73 -0
- package/dist/cli/pair.d.ts +28 -0
- package/dist/cli/pair.js +114 -0
- package/dist/cli/start.d.ts +22 -0
- package/dist/cli/start.js +78 -0
- package/dist/cli/status.d.ts +19 -0
- package/dist/cli/status.js +108 -0
- package/dist/cli/sync.d.ts +16 -0
- package/dist/cli/sync.js +50 -0
- package/dist/cli/unpair.d.ts +18 -0
- package/dist/cli/unpair.js +49 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +33 -0
- package/dist/core/canonical.d.ts +957 -0
- package/dist/core/canonical.js +80 -0
- package/dist/core/cursor-store.d.ts +18 -0
- package/dist/core/cursor-store.js +50 -0
- package/dist/core/debug-log.d.ts +12 -0
- package/dist/core/debug-log.js +17 -0
- package/dist/core/git-identity.d.ts +23 -0
- package/dist/core/git-identity.js +127 -0
- package/dist/core/http-client.d.ts +7 -0
- package/dist/core/http-client.js +63 -0
- package/dist/core/last-sync-store.d.ts +9 -0
- package/dist/core/last-sync-store.js +31 -0
- package/dist/core/message-truncation.d.ts +10 -0
- package/dist/core/message-truncation.js +13 -0
- package/dist/core/perform-sync.d.ts +23 -0
- package/dist/core/perform-sync.js +57 -0
- package/dist/core/project-identity.d.ts +40 -0
- package/dist/core/project-identity.js +67 -0
- package/dist/core/providers.d.ts +26 -0
- package/dist/core/providers.js +25 -0
- package/dist/core/providers.json +4 -0
- package/dist/core/redact.d.ts +44 -0
- package/dist/core/redact.js +177 -0
- package/dist/core/safe-json.d.ts +7 -0
- package/dist/core/safe-json.js +14 -0
- package/dist/core/sync-engine.d.ts +17 -0
- package/dist/core/sync-engine.js +64 -0
- package/dist/daemon/state.d.ts +22 -0
- package/dist/daemon/state.js +32 -0
- package/dist/daemon/sync-runner.d.ts +52 -0
- package/dist/daemon/sync-runner.js +104 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +68 -0
- package/dist/infrastructure/config-repository.d.ts +34 -0
- package/dist/infrastructure/config-repository.js +102 -0
- package/dist/keychain/index.d.ts +31 -0
- package/dist/keychain/index.js +62 -0
- package/dist/mcp/json-rpc.d.ts +39 -0
- package/dist/mcp/json-rpc.js +46 -0
- package/dist/mcp/server.d.ts +33 -0
- package/dist/mcp/server.js +110 -0
- package/dist/mcp-tools/status.d.ts +17 -0
- package/dist/mcp-tools/status.js +24 -0
- package/dist/mcp-tools/sync-now.d.ts +9 -0
- package/dist/mcp-tools/sync-now.js +8 -0
- package/dist/services/pairing-service.d.ts +58 -0
- package/dist/services/pairing-service.js +102 -0
- package/dist/watchers/directory-watcher.d.ts +26 -0
- package/dist/watchers/directory-watcher.js +47 -0
- package/dist/watchers/opencode.d.ts +27 -0
- package/dist/watchers/opencode.js +58 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentsOfMine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,298 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AgentsOfMine Collector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **MCP server + CLI** for syncing AI coding sessions to [AgentsOfMine](https://agentsofmine.io).
|
|
4
|
+
|
|
5
|
+
Works with any editor or terminal — Claude Code CLI, OpenCode CLI, Cursor, Zed, or any future agent.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
**Supported platforms:** macOS and Linux.
|
|
12
|
+
|
|
13
|
+
> **Windows:** not yet supported. The port is scoped out in
|
|
14
|
+
> [`docs/CROSS_PLATFORM.md`](docs/CROSS_PLATFORM.md), but we need a **volunteer on
|
|
15
|
+
> Windows** to verify the session-directory paths (OpenCode, Claude Code, Codex,
|
|
16
|
+
> Pi) and test the keychain + file-watcher behavior there. If that's you, open an
|
|
17
|
+
> issue or PR — see [Contributing](#contributing).
|
|
18
|
+
|
|
19
|
+
- **Node.js ≥ 20** (`node --version`). Node 20+ is required for reliable
|
|
20
|
+
recursive file watching on Linux.
|
|
21
|
+
- A native keychain backend, used to store the device token:
|
|
22
|
+
- macOS — Keychain (built in)
|
|
23
|
+
- Linux — `libsecret` plus a **running Secret Service**:
|
|
24
|
+
- Build dependency: `libsecret-1-dev` (e.g. `sudo apt install libsecret-1-dev`
|
|
25
|
+
on Debian/Ubuntu).
|
|
26
|
+
- Runtime: a Secret Service provider must be running — `gnome-keyring` on
|
|
27
|
+
GNOME, `kwalletd` on KDE. **Headless servers without one will fail to
|
|
28
|
+
store the device token** until a keyring is available.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
> **Testing status:** Extensive smoke testing has been performed on **macOS
|
|
35
|
+
> only**. Linux is supported by design (it shares macOS's Unix paths and POSIX
|
|
36
|
+
> semantics, and the Node ≥ 20 requirement covers recursive file watching), but
|
|
37
|
+
> has not yet been exercised end-to-end. Linux reports — successes or
|
|
38
|
+
> bugs — are welcome via [issues](https://github.com/AgentsOfMine/collector/issues).
|
|
39
|
+
|
|
40
|
+
The fastest path on every platform is a global npm install:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install -g agentsofmine
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Verify the install:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
aom --version
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or run it once without installing:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx agentsofmine pair
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### macOS
|
|
59
|
+
|
|
60
|
+
1. **Node.js ≥ 20.** Install via [Homebrew](https://brew.sh) or
|
|
61
|
+
[nodejs.org](https://nodejs.org):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
brew install node # or: brew install node@20
|
|
65
|
+
node --version # must be v20.x or newer
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Keychain — no setup required.** macOS Keychain is built in; the device
|
|
69
|
+
token is stored there automatically after pairing.
|
|
70
|
+
|
|
71
|
+
3. **Install and pair:**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install -g agentsofmine
|
|
75
|
+
aom pair
|
|
76
|
+
aom start
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Linux
|
|
80
|
+
|
|
81
|
+
1. **Node.js ≥ 20.** Use your distro's package manager,
|
|
82
|
+
[nvm](https://github.com/nvm-sh/nvm), or [nodesource](https://github.com/nodesource/distributions):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# nvm (recommended — avoids old distro Node)
|
|
86
|
+
nvm install 20
|
|
87
|
+
node --version # must be v20.x or newer
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. **Keychain backend (`libsecret`).** The device token is stored via the
|
|
91
|
+
Secret Service API, which needs the `libsecret` dev headers at install time
|
|
92
|
+
**and** a running Secret Service provider at runtime.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Debian / Ubuntu
|
|
96
|
+
sudo apt install libsecret-1-dev gnome-keyring
|
|
97
|
+
|
|
98
|
+
# Fedora / RHEL
|
|
99
|
+
sudo dnf install libsecret-devel gnome-keyring
|
|
100
|
+
|
|
101
|
+
# Arch
|
|
102
|
+
sudo pacman -S libsecret gnome-keyring
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- On a **GNOME or KDE desktop**, a keyring (`gnome-keyring` / `kwalletd`) is
|
|
106
|
+
already running — nothing more to do.
|
|
107
|
+
- On a **headless server / SSH session / container**, no keyring runs by
|
|
108
|
+
default, so storing the token will fail. Start one for the session, e.g.:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# unlock a gnome-keyring daemon for this shell session
|
|
112
|
+
eval "$(gnome-keyring-daemon --start --components=secrets)"
|
|
113
|
+
export GNOME_KEYRING_CONTROL
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
(Or run the collector under a desktop session that already provides one.)
|
|
117
|
+
|
|
118
|
+
3. **Install and pair:**
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install -g agentsofmine
|
|
122
|
+
aom pair
|
|
123
|
+
aom start
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> **Windows:** not yet supported — see [Requirements](#requirements) and
|
|
127
|
+
> [`docs/CROSS_PLATFORM.md`](docs/CROSS_PLATFORM.md). We're looking for a Windows
|
|
128
|
+
> volunteer; details under [Contributing](#contributing).
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Quick start
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Step 1 — pair this machine with your AgentsOfMine account (one-time)
|
|
136
|
+
aom pair
|
|
137
|
+
|
|
138
|
+
# Step 2 — run the collector as an MCP server
|
|
139
|
+
aom start
|
|
140
|
+
|
|
141
|
+
# Sessions sync when your agent calls the `sync_now` tool.
|
|
142
|
+
# To sync once from the terminal instead, run: aom sync
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`aom pair` prints a pairing URL and an ASCII QR code to your terminal. Open the URL on your phone, sign in once, tap Approve. The device token is stored in your OS keychain — you never see it again.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Commands
|
|
150
|
+
|
|
151
|
+
| Command | What it does |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `aom pair` | One-time pairing: prints URL + QR, polls until approved, stores device token in OS keychain |
|
|
154
|
+
| `aom pair --force` | Discard the existing pairing and start a fresh one (also accepts `--reset`) |
|
|
155
|
+
| `aom pair --no-browser` | Pair without auto-opening the browser |
|
|
156
|
+
| `aom start` | Starts the MCP server (stdio) with file watchers and sync tools |
|
|
157
|
+
| `aom status` | Prints pairing status and last-synced timestamps |
|
|
158
|
+
| `aom status --json` | Prints a single machine-readable JSON line (`paired`, `deviceId`, `lastSyncAt`, `queueDepth`, `lastError`) — for scripts and status integrations |
|
|
159
|
+
| `aom sync` | Runs one sync cycle now and prints the result as JSON |
|
|
160
|
+
| `aom unpair [-y]` | Removes the device token from the keychain and clears local state (`-y` skips the prompt) |
|
|
161
|
+
| `aom --version` | Prints the installed version |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Build from source
|
|
166
|
+
|
|
167
|
+
Clone the repo and build the compiled `aom` binary into `dist/`:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/AgentsOfMine/collector.git
|
|
171
|
+
cd collector
|
|
172
|
+
npm install # installs deps and runs the build via the `prepare` script
|
|
173
|
+
npm run build # or build again explicitly (tsc → dist/)
|
|
174
|
+
npm run lint # run eslint on src + test
|
|
175
|
+
npm test # run the test suite
|
|
176
|
+
npm run check # build + lint + test in one step
|
|
177
|
+
|
|
178
|
+
# run the locally built CLI without a global install
|
|
179
|
+
node dist/bin/aom.js --version
|
|
180
|
+
|
|
181
|
+
# optional — link it as the global `aom` command
|
|
182
|
+
npm link
|
|
183
|
+
aom --version
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## How it works
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
Your agent has already written its session to local disk
|
|
192
|
+
│
|
|
193
|
+
▼
|
|
194
|
+
agentsofmine-collector (runs as an MCP server: `aom start`)
|
|
195
|
+
├── File watchers detect new/changed sessions in real time
|
|
196
|
+
└── Your agent calls the `sync_now` MCP tool on demand
|
|
197
|
+
│
|
|
198
|
+
▼
|
|
199
|
+
Provider adapters read the sessions already on disk:
|
|
200
|
+
~/.local/share/opencode/opencode.db (OpenCode — SQLite)
|
|
201
|
+
~/.claude/projects/*/*.jsonl (Claude Code — JSONL)
|
|
202
|
+
~/.codex/sessions/ (Codex — JSON)
|
|
203
|
+
~/.pi/agent/sessions/ (Pi — JSONL)
|
|
204
|
+
│
|
|
205
|
+
▼
|
|
206
|
+
Normalize → POST /sync (Bearer device-token)
|
|
207
|
+
│
|
|
208
|
+
▼
|
|
209
|
+
AgentsOfMine cloud → your phone
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The collector exposes two MCP tools over stdio:
|
|
213
|
+
- **`sync_now`** — reads new sessions via the provider adapters and uploads them.
|
|
214
|
+
- **`status`** — returns the result of the last sync.
|
|
215
|
+
|
|
216
|
+
Three sync modes:
|
|
217
|
+
- **MCP tool** — your agent calls `sync_now` during a session.
|
|
218
|
+
- **File watchers** — `aom start` monitors session directories and syncs changes automatically.
|
|
219
|
+
- **CLI one-shot** — `aom sync` triggers a single sync cycle from the terminal.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Provider adapters
|
|
224
|
+
|
|
225
|
+
Each provider has its own adapter that knows the local session format.
|
|
226
|
+
|
|
227
|
+
| Provider | Status | Session path |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| Claude Code | ✅ Phase 1 | `~/.claude/projects/` |
|
|
230
|
+
| OpenCode | ✅ Phase 1 | `~/.local/share/opencode/opencode.db` |
|
|
231
|
+
| Codex | ✅ Phase 1 | `~/.codex/sessions/` |
|
|
232
|
+
| Pi | ✅ Phase 1 | `~/.pi/agent/sessions/` |
|
|
233
|
+
| Cursor | 🔜 Community | — |
|
|
234
|
+
| GitHub Copilot Chat | 🔜 Community | — |
|
|
235
|
+
| Gemini CLI | 🔜 Community | — |
|
|
236
|
+
| Cline | 🔜 Community | — |
|
|
237
|
+
| Continue.dev | 🔜 Community | — |
|
|
238
|
+
|
|
239
|
+
**Adding an adapter** is a weekend's work for someone who knows the target tool. Implement the `Adapter` interface in [`src/adapters/adapter.ts`](src/adapters/adapter.ts) and use [`src/adapters/opencode/`](src/adapters/opencode/) as a reference. If your adapter ships in a release, you become a [founding contributor](https://agentsofmine.io#contributors): your name in the README, co-maintainer on the adapter, and free Pro tier when it launches.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Security
|
|
244
|
+
|
|
245
|
+
- **We never log into your AI accounts.** No Claude, OpenAI, Copilot, or any other AI provider credentials anywhere in this package.
|
|
246
|
+
- The collector reads files your agents have already written to local disk.
|
|
247
|
+
- The device token is stored in your OS keychain (macOS Keychain, Windows Credential Manager, Linux libsecret/kwallet). Note: after pairing, a copy of the device token is also written to `~/.agentsofmine/config.json` with owner-only permissions (`0600`).
|
|
248
|
+
- **Secrets are redacted on your machine before upload** (best-effort, see below).
|
|
249
|
+
- All traffic to `agentsofmine.io` is TLS 1.2+. Data at rest is encrypted with AWS KMS.
|
|
250
|
+
- This package is MIT-licensed. Read every line that runs on your machine.
|
|
251
|
+
|
|
252
|
+
### Secret redaction
|
|
253
|
+
|
|
254
|
+
Every session passes through [`src/core/redact.ts`](src/core/redact.ts) just before it is sent (CLI `aom sync`, the daemon, and the MCP `sync_now` tool all share the same path). It rewrites matches in message text, reasoning, tool input and output, the session title and changed-file paths to a marker such as `<REDACTED:github-token>`.
|
|
255
|
+
|
|
256
|
+
It recognises: AWS access key ids (`AKIA…`) and AWS secret keys next to their name; GitHub tokens (`ghp_`, `github_pat_`, …); `sk-…` API keys (OpenAI, Anthropic); Slack tokens; JWTs; `Bearer` tokens; PEM / OpenSSH private-key blocks (including truncated ones); passwords inside connection-string URLs; and `UPPER_CASE_NAME=value` assignments whose name contains `PASSWORD`, `SECRET`, `TOKEN`, `API_KEY`, `PRIVATE_KEY` or `ACCESS_KEY`. In tool-call JSON, string values under keys like `password` or `api_key` are redacted whatever they look like.
|
|
257
|
+
|
|
258
|
+
**This is best-effort, not a guarantee.** A regex cannot recognise a secret it has no pattern for (a bare random password, an unprefixed API key, a secret split across messages), and it can occasionally redact something harmless. It also does not touch sessions synced before it existed. Treat it as defense in depth on top of encryption, not as permission to paste credentials into an agent.
|
|
259
|
+
|
|
260
|
+
Set `AOM_NO_REDACT=1` to disable it for debugging; the collector prints a warning to stderr when you do.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Architecture
|
|
265
|
+
|
|
266
|
+
The implementation lives in [`src/`](src/):
|
|
267
|
+
- **MCP server entrypoint and tool definitions** — [`src/index.ts`](src/index.ts) (`sync_now`, `status`)
|
|
268
|
+
- **CLI dispatcher and subcommands** — [`src/bin/aom.ts`](src/bin/aom.ts), [`src/cli/`](src/cli/) (`pair`, `start`, `status`, `sync`, `unpair`)
|
|
269
|
+
- **Provider adapters** — [`src/adapters/`](src/adapters/) (one per provider, implementing [`adapter.ts`](src/adapters/adapter.ts))
|
|
270
|
+
- **Session normalization schema** (`CanonicalSession` + `CanonicalMessage`) — [`src/core/canonical.ts`](src/core/canonical.ts)
|
|
271
|
+
- **Project identity resolution** (Git remote normalization, multi-device dedup) — [`src/core/project-identity.ts`](src/core/project-identity.ts), [`src/core/git-identity.ts`](src/core/git-identity.ts)
|
|
272
|
+
- **Sync engine and retry handling** — [`src/core/sync-engine.ts`](src/core/sync-engine.ts), [`src/core/http-client.ts`](src/core/http-client.ts)
|
|
273
|
+
- **Secret redaction** — [`src/core/redact.ts`](src/core/redact.ts)
|
|
274
|
+
- **Device token lifecycle** (pairing → keychain storage) — [`src/services/pairing-service.ts`](src/services/pairing-service.ts), [`src/keychain/`](src/keychain/)
|
|
275
|
+
- **File watchers** — [`src/watchers/`](src/watchers/) (monitors session directories for `aom start`)
|
|
276
|
+
- **Shared utilities** — [`src/core/message-truncation.ts`](src/core/message-truncation.ts), [`src/core/safe-json.ts`](src/core/safe-json.ts)
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Contributing
|
|
281
|
+
|
|
282
|
+
The highest-value contribution is a **provider adapter** for an agent we don't ship with. Implement the `Adapter` interface in [`src/adapters/adapter.ts`](src/adapters/adapter.ts), add tests under [`test/`](test/), and open a PR.
|
|
283
|
+
|
|
284
|
+
**Windows support** is also open for a volunteer. The work is scoped in
|
|
285
|
+
[`docs/CROSS_PLATFORM.md`](docs/CROSS_PLATFORM.md) — primarily verifying each
|
|
286
|
+
agent's session-directory paths on Windows and testing the keychain and file
|
|
287
|
+
watchers. Ship Windows support and you become a
|
|
288
|
+
[founding contributor](https://agentsofmine.io#contributors): your name in the
|
|
289
|
+
README and a **lifetime Pro account when Pro launches**. If you run Windows and
|
|
290
|
+
want to help, open an issue to coordinate.
|
|
291
|
+
|
|
292
|
+
Bug reports and issues: [github.com/AgentsOfMine/collector/issues](https://github.com/AgentsOfMine/collector/issues)
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SessionWithMessages } from "../core/canonical.js";
|
|
2
|
+
export interface Cursor {
|
|
3
|
+
value: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface SyncItem {
|
|
6
|
+
session: SessionWithMessages;
|
|
7
|
+
/** Opaque cursor value valid to persist AFTER this session is accepted. */
|
|
8
|
+
cursor: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Adapter {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
listNewSessions(cursor: Cursor): AsyncIterable<SyncItem>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CanonicalMessage } from "../../core/canonical.js";
|
|
2
|
+
export interface SessionAccumulator {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
projectPath: string;
|
|
5
|
+
title: string | null;
|
|
6
|
+
modelLine: string | null;
|
|
7
|
+
/** True once a real `cwd` has been read from an event; the path is then final. */
|
|
8
|
+
projectPathFromCwd: boolean;
|
|
9
|
+
startedAt: string | null;
|
|
10
|
+
endedAt: string | null;
|
|
11
|
+
messageCount: number;
|
|
12
|
+
linesAdded: number;
|
|
13
|
+
linesRemoved: number;
|
|
14
|
+
filesChanged: Set<string>;
|
|
15
|
+
pendingToolUse: Map<string, {
|
|
16
|
+
linesAdded: number;
|
|
17
|
+
linesRemoved: number;
|
|
18
|
+
filePath: string;
|
|
19
|
+
}>;
|
|
20
|
+
messages: CanonicalMessage[];
|
|
21
|
+
toolNameById: Map<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Claude Code stores each project under `~/.claude/projects/<project-key>/`,
|
|
25
|
+
* where the key is the working directory with `/` replaced by `-`. That
|
|
26
|
+
* encoding is LOSSY (`my-app` and `my/app` collide), so it is only a fallback:
|
|
27
|
+
* every user/assistant line also carries the real `cwd`, which `processEvent`
|
|
28
|
+
* prefers. A key that does not look like an encoded absolute path is returned
|
|
29
|
+
* as-is rather than guessed at.
|
|
30
|
+
*/
|
|
31
|
+
export declare function projectPathFromKeyDir(filePath: string): string;
|
|
32
|
+
export declare function createAccumulator(filePath: string): SessionAccumulator;
|
|
33
|
+
export declare function processEvent(acc: SessionAccumulator, raw: unknown): void;
|
|
34
|
+
//# sourceMappingURL=accumulator.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { basename, dirname } from "node:path";
|
|
2
|
+
import { contentBlocksToParts, extractText, } from "./content-blocks.js";
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code stores each project under `~/.claude/projects/<project-key>/`,
|
|
5
|
+
* where the key is the working directory with `/` replaced by `-`. That
|
|
6
|
+
* encoding is LOSSY (`my-app` and `my/app` collide), so it is only a fallback:
|
|
7
|
+
* every user/assistant line also carries the real `cwd`, which `processEvent`
|
|
8
|
+
* prefers. A key that does not look like an encoded absolute path is returned
|
|
9
|
+
* as-is rather than guessed at.
|
|
10
|
+
*/
|
|
11
|
+
export function projectPathFromKeyDir(filePath) {
|
|
12
|
+
const key = basename(dirname(filePath));
|
|
13
|
+
if (!key.startsWith("-") || key.length < 2)
|
|
14
|
+
return key;
|
|
15
|
+
return key.replace(/-/g, "/");
|
|
16
|
+
}
|
|
17
|
+
export function createAccumulator(filePath) {
|
|
18
|
+
const sessionId = basename(filePath, ".jsonl");
|
|
19
|
+
return {
|
|
20
|
+
sessionId,
|
|
21
|
+
projectPath: projectPathFromKeyDir(filePath),
|
|
22
|
+
projectPathFromCwd: false,
|
|
23
|
+
title: null,
|
|
24
|
+
modelLine: null,
|
|
25
|
+
startedAt: null,
|
|
26
|
+
endedAt: null,
|
|
27
|
+
messageCount: 0,
|
|
28
|
+
linesAdded: 0,
|
|
29
|
+
linesRemoved: 0,
|
|
30
|
+
filesChanged: new Set(),
|
|
31
|
+
pendingToolUse: new Map(),
|
|
32
|
+
messages: [],
|
|
33
|
+
toolNameById: new Map(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function processEvent(acc, raw) {
|
|
37
|
+
if (typeof raw !== "object" || raw === null)
|
|
38
|
+
return;
|
|
39
|
+
const event = raw;
|
|
40
|
+
if (!acc.projectPathFromCwd && typeof event.cwd === "string" && event.cwd.length > 0) {
|
|
41
|
+
acc.projectPath = event.cwd;
|
|
42
|
+
acc.projectPathFromCwd = true;
|
|
43
|
+
}
|
|
44
|
+
const ts = raw["timestamp"];
|
|
45
|
+
if (typeof ts === "string") {
|
|
46
|
+
if (acc.startedAt === null)
|
|
47
|
+
acc.startedAt = ts;
|
|
48
|
+
acc.endedAt = ts;
|
|
49
|
+
}
|
|
50
|
+
const msg = event.message;
|
|
51
|
+
if (!msg)
|
|
52
|
+
return;
|
|
53
|
+
if (typeof msg.model === "string" && acc.modelLine === null) {
|
|
54
|
+
acc.modelLine = msg.model;
|
|
55
|
+
}
|
|
56
|
+
const role = msg.role;
|
|
57
|
+
if (role !== "user" && role !== "assistant")
|
|
58
|
+
return;
|
|
59
|
+
const rawContent = msg.content;
|
|
60
|
+
const blocks = typeof rawContent === "string"
|
|
61
|
+
? [{ type: "text", text: rawContent }]
|
|
62
|
+
: Array.isArray(rawContent)
|
|
63
|
+
? (rawContent)
|
|
64
|
+
: [];
|
|
65
|
+
for (const block of blocks) {
|
|
66
|
+
if (block.type === "tool_use") {
|
|
67
|
+
const b = block;
|
|
68
|
+
if (!b.id || !b.input)
|
|
69
|
+
continue;
|
|
70
|
+
if (b.name === "Edit" || b.name === "str_replace_editor") {
|
|
71
|
+
const filePath = typeof b.input["file_path"] === "string" ? b.input["file_path"] : null;
|
|
72
|
+
const newString = typeof b.input["new_string"] === "string" ? b.input["new_string"] : "";
|
|
73
|
+
const oldString = typeof b.input["old_string"] === "string" ? b.input["old_string"] : "";
|
|
74
|
+
if (filePath) {
|
|
75
|
+
acc.pendingToolUse.set(b.id, {
|
|
76
|
+
linesAdded: newString.split("\n").length,
|
|
77
|
+
linesRemoved: oldString.split("\n").length,
|
|
78
|
+
filePath,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (b.name === "Write" || b.name === "write_file") {
|
|
83
|
+
const filePath = typeof b.input["file_path"] === "string" ? b.input["file_path"] : null;
|
|
84
|
+
const content = typeof b.input["content"] === "string" ? b.input["content"] : "";
|
|
85
|
+
if (filePath) {
|
|
86
|
+
acc.pendingToolUse.set(b.id, {
|
|
87
|
+
linesAdded: content.split("\n").length,
|
|
88
|
+
linesRemoved: 0,
|
|
89
|
+
filePath,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (block.type === "tool_result") {
|
|
95
|
+
const b = block;
|
|
96
|
+
if (!b.tool_use_id)
|
|
97
|
+
continue;
|
|
98
|
+
const pending = acc.pendingToolUse.get(b.tool_use_id);
|
|
99
|
+
if (!pending)
|
|
100
|
+
continue;
|
|
101
|
+
acc.pendingToolUse.delete(b.tool_use_id);
|
|
102
|
+
if (b.is_error === true)
|
|
103
|
+
continue;
|
|
104
|
+
acc.linesAdded += pending.linesAdded;
|
|
105
|
+
acc.linesRemoved += pending.linesRemoved;
|
|
106
|
+
acc.filesChanged.add(pending.filePath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const parts = contentBlocksToParts(blocks, acc.toolNameById);
|
|
110
|
+
if (parts.length === 0)
|
|
111
|
+
return;
|
|
112
|
+
acc.messageCount++;
|
|
113
|
+
if (role === "user" && acc.title === null) {
|
|
114
|
+
const text = extractText(rawContent);
|
|
115
|
+
if (text)
|
|
116
|
+
acc.title = text.trim().slice(0, 80);
|
|
117
|
+
}
|
|
118
|
+
const messageId = typeof event.uuid === "string" ? event.uuid : `${acc.sessionId}-${acc.messageCount}`;
|
|
119
|
+
const createdAt = typeof ts === "string" ? ts : new Date(0).toISOString();
|
|
120
|
+
acc.messages.push({
|
|
121
|
+
messageId,
|
|
122
|
+
sessionId: acc.sessionId,
|
|
123
|
+
role: role === "user" ? "user" : "assistant",
|
|
124
|
+
senderName: role === "user" ? "You" : "Claude Code",
|
|
125
|
+
createdAt,
|
|
126
|
+
parts,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=accumulator.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CanonicalPart } from "../../core/canonical.js";
|
|
2
|
+
export interface ContentBlockText {
|
|
3
|
+
type: "text";
|
|
4
|
+
text?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ContentBlockThinking {
|
|
7
|
+
type: "thinking";
|
|
8
|
+
thinking?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ContentBlockToolUse {
|
|
11
|
+
type: "tool_use";
|
|
12
|
+
id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
input?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface ContentBlockToolResult {
|
|
17
|
+
type: "tool_result";
|
|
18
|
+
tool_use_id?: string;
|
|
19
|
+
content?: string | Array<{
|
|
20
|
+
type: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
}>;
|
|
23
|
+
is_error?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ContentBlockImage {
|
|
26
|
+
type: "image";
|
|
27
|
+
source?: {
|
|
28
|
+
type?: string;
|
|
29
|
+
media_type?: string;
|
|
30
|
+
data?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type ContentBlock = ContentBlockText | ContentBlockThinking | ContentBlockToolUse | ContentBlockToolResult | ContentBlockImage | {
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function extractText(content: string | ContentBlock[] | undefined): string | null;
|
|
38
|
+
export declare function toolResultOutput(block: ContentBlockToolResult): string | undefined;
|
|
39
|
+
export declare function contentBlocksToParts(blocks: ContentBlock[], toolNameById: Map<string, string>): CanonicalPart[];
|
|
40
|
+
//# sourceMappingURL=content-blocks.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export function extractText(content) {
|
|
2
|
+
if (content === undefined)
|
|
3
|
+
return null;
|
|
4
|
+
if (typeof content === "string")
|
|
5
|
+
return content;
|
|
6
|
+
for (const block of content) {
|
|
7
|
+
if (block.type === "text") {
|
|
8
|
+
const b = block;
|
|
9
|
+
if (typeof b.text === "string")
|
|
10
|
+
return b.text;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
export function toolResultOutput(block) {
|
|
16
|
+
const { content } = block;
|
|
17
|
+
if (typeof content === "string")
|
|
18
|
+
return content.slice(0, 500);
|
|
19
|
+
if (Array.isArray(content)) {
|
|
20
|
+
const texts = content
|
|
21
|
+
.filter((c) => c.type === "text" && typeof c.text === "string")
|
|
22
|
+
.map((c) => c.text)
|
|
23
|
+
.join("\n");
|
|
24
|
+
return texts.slice(0, 500) || undefined;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
export function contentBlocksToParts(blocks, toolNameById) {
|
|
29
|
+
const parts = [];
|
|
30
|
+
for (const block of blocks) {
|
|
31
|
+
switch (block.type) {
|
|
32
|
+
case "text": {
|
|
33
|
+
const b = block;
|
|
34
|
+
if (typeof b.text === "string" && b.text.length > 0) {
|
|
35
|
+
parts.push({ type: "text", text: b.text });
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "thinking": {
|
|
40
|
+
const b = block;
|
|
41
|
+
if (typeof b.thinking === "string" && b.thinking.length > 0) {
|
|
42
|
+
parts.push({ type: "reasoning", text: b.thinking });
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "tool_use": {
|
|
47
|
+
const b = block;
|
|
48
|
+
if (b.id && b.name) {
|
|
49
|
+
toolNameById.set(b.id, b.name);
|
|
50
|
+
parts.push({
|
|
51
|
+
type: "tool",
|
|
52
|
+
tool: b.name,
|
|
53
|
+
callId: b.id,
|
|
54
|
+
input: b.input,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "tool_result": {
|
|
60
|
+
const b = block;
|
|
61
|
+
if (b.tool_use_id) {
|
|
62
|
+
const name = toolNameById.get(b.tool_use_id) ?? "unknown";
|
|
63
|
+
parts.push({
|
|
64
|
+
type: "tool",
|
|
65
|
+
tool: name,
|
|
66
|
+
callId: b.tool_use_id,
|
|
67
|
+
output: toolResultOutput(b),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "image": {
|
|
73
|
+
const b = block;
|
|
74
|
+
const src = b.source;
|
|
75
|
+
if (src) {
|
|
76
|
+
if (src.type === "base64" && src.data) {
|
|
77
|
+
parts.push({
|
|
78
|
+
type: "image_url",
|
|
79
|
+
mediaType: src.media_type,
|
|
80
|
+
imageUrl: `data:${src.media_type ?? "image/png"};base64,${src.data.slice(0, 64)}…`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (src.url) {
|
|
84
|
+
parts.push({ type: "image_url", imageUrl: src.url, mediaType: src.media_type });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return parts;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=content-blocks.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Dirent } from "node:fs";
|
|
2
|
+
import type { Adapter, Cursor, SyncItem } from "../adapter.js";
|
|
3
|
+
/**
|
|
4
|
+
* Filesystem seam for discovering `.jsonl` session files. Injectable so file
|
|
5
|
+
* discovery is testable without a real `~/.claude/projects` tree. Mirrors the
|
|
6
|
+
* `GitRunner` DI pattern in `core/git-identity.ts`. The default reads the real
|
|
7
|
+
* filesystem.
|
|
8
|
+
*/
|
|
9
|
+
export interface FsReader {
|
|
10
|
+
existsSync(path: string): boolean;
|
|
11
|
+
readdirSync(path: string): Dirent[];
|
|
12
|
+
}
|
|
13
|
+
export declare class ClaudeCodeAdapter implements Adapter {
|
|
14
|
+
readonly name = "claude-code";
|
|
15
|
+
private readonly projectsDir;
|
|
16
|
+
private readonly fs;
|
|
17
|
+
constructor(projectsGlob?: string, fs?: FsReader);
|
|
18
|
+
listNewSessions(cursor: Cursor): AsyncIterable<SyncItem>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|