conare 0.30.0 → 0.34.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/README.md CHANGED
@@ -62,8 +62,9 @@ const acme = await platform.createOrganization({ name: "Acme", externalId: "acme
62
62
  const { secret } = await new Conare({ apiKey: CUSTOMER_KEY, organization: acme.id }).createKey({ name: "acme" })
63
63
  // Acme's traffic runs on `secret`, which reaches Acme's organization alone.
64
64
  await platform.organizations({ externalId: "acme" }) // every organization of your customer, or the one with this id
65
- await platform.spendByOrganization() // this month's bill by organization: { total, rows: [{ id, name, externalId, charges }] }
65
+ await platform.spendByOrganization() // this month's bill by organization: { total, rows: [{ id, name, externalId, charges, spendCapMicros }] }
66
66
  await platform.renameOrganization(acme.id, "Acme Capital")
67
+ await platform.setOrganizationSpendCap(acme.id, 500) // its own monthly cap in dollars (null removes it): past it, Acme's billed calls get 402 spend_cap_reached
67
68
  await platform.deleteOrganization(acme.id) // 409 until its namespaces and sources are deleted
68
69
  ```
69
70
 
@@ -143,6 +144,57 @@ compare numbers, string bounds compare strings by their UTF-8 bytes, so ISO date
143
144
 
144
145
  `$ne` and `$nin` work in queries; a delete by filter with one answers 400 `invalid_filter`.
145
146
 
147
+ ### Records
148
+
149
+ ```ts
150
+ const { record, sources, results, sourcePassages } = await docs.queryRecord("When do applications close, and is there an interview?", {
151
+ type: "object",
152
+ properties: {
153
+ closes: { type: "string", description: "The date applications close, as YYYY-MM-DD" },
154
+ interview: { type: "string", enum: ["live", "recorded", "none"] },
155
+ essays: { type: "integer", description: "How many essays an applicant writes" },
156
+ },
157
+ });
158
+ record?.interview; // "live" | "recorded" | "none" | null, typed from the schema
159
+ sources.closes; // { id, url, quote }: the document, its address and the words that state the value
160
+ sourcePassages; // a source's passage that results do not hold (the record reads past topK)
161
+ ```
162
+
163
+ A search answered as a record: every field of the schema, its value or null when no passage the search read
164
+ states it, never guessed. A field is a string (with or without an `enum`), a number, an integer, a boolean or a
165
+ list of strings; 1-32 fields. Say in a field's `description` what it holds and in what form. `record` is null when
166
+ the answer model was unavailable; `results` are the search's, and every `query` option applies.
167
+
168
+ ### Changes
169
+
170
+ ```ts
171
+ let cursor = await loadCursor(); // undefined the first time: every document from the start
172
+ for (;;) {
173
+ const page = await docs.changes({ cursor, limit: 1000 });
174
+ for (const c of page.changes) {} // { id, change: "created" | "changed" | "deleted", at, url?, metadata?, diff? }
175
+ cursor = page.nextCursor;
176
+ await saveCursor(cursor);
177
+ if (!page.hasMore) break;
178
+ }
179
+ ```
180
+
181
+ What changed in a namespace, oldest first: each page and file its website, Cloud Storage and file sources read
182
+ (created or changed; one read again unchanged adds nothing) and each of their documents deleted. Documents written
183
+ with `add` or `write` are not listed. Rows are kept 90 days, a live document's latest whatever its age; a cursor
184
+ whose unread rows were dropped throws 410 `cursor_expired`: list again without one.
185
+
186
+ ```ts
187
+ const page = await docs.changes({ source: "src_769140bdee3ce44fc52ddb86", since: lastSyncStart });
188
+ for (const c of page.changes) {
189
+ if (c.diff?.cause === "content") for (const h of c.diff.hunks ?? []) console.log(h.removed, "->", h.added);
190
+ }
191
+ ```
192
+
193
+ `source` keeps the rows to one source's documents, `since` and `until` to a time window. A web page's `changed`
194
+ row says how it changed (`diff`): `content` with the lines removed and added (`["Application deadline: 14 January
195
+ 2026"]` -> `["Application deadline: 13 January 2027"]`), `reader` when the page reads as it did and only how Conare
196
+ reads web pages changed, `fields` when only its fields did. A file's row has none.
197
+
146
198
 
147
199
  ### Grep
148
200
 
@@ -184,12 +236,23 @@ results; its score from another call would not compare.
184
236
  const out = await conare.parse(bytes, { name: "report.pdf", pages: "1-20", layout: true });
185
237
  // { id, state: "done", markdown: "<!-- page 1 -->\n\n# Report...", parts: [{ locator: { page: 1 }, markdown, ocr, confidence, blocks }], withoutText }
186
238
  await conare.parse({ url: "https://example.com/deck.pptx" }); // fetched by the API
239
+ await conare.parse({ url: "https://example.com/" }); // a page: { title, sourceUrl, markdown, ... }
187
240
  await conare.parse(locked, { name: "minutes.pdf", password: "..." });
241
+ await conare.parse(xlsx, { name: "model.xlsx", sheets: ["Q3"], range: "A1:F40", formulas: true }); // "110 `=B2*1.1`"; .sheets names all
242
+ await conare.parse(deck, { name: "deck.pptx", vision: true }); // charts and pictures described; parts carry .vision
188
243
  if (out.state === "parsing") await conare.getParse(out.id); // OCR outlived `wait` (default 60 s): the result, kept 24 h
189
244
  ```
190
245
 
191
246
  `parse` reads a file with the same parser as `uploadFile` and stores nothing; any key can call it, a models-only key
192
247
  too. `uploadFile` takes the same options and answers the same `markdown`, `parts` and `withoutText` beside `ids`.
248
+ A URL is `http` or `https` on a public address; the API reads the one page you name and does not consult robots.txt.
249
+ Its result carries `sourceUrl`, where the fetch landed after redirects, and a page's `title`. A URL that does not
250
+ answer its file throws what its site did (`gone`, `refused`, `sign_in_required`, `slow_down`, `site_error`,
251
+ `unreachable`, `unexpected_status`) with `err.details.status`, the site's HTTP status, and on `slow_down`
252
+ `err.details.retryAfterSeconds`. A page that holds no text until a browser runs its scripts throws 422
253
+ `needs_javascript`; `render: true` asks for it to be read through a browser (not available yet: the error says so).
254
+ `links: true` writes a web page's links as Markdown links, its menus' and footer's too; `mainContent: true` reads
255
+ the page's main content alone.
193
256
  A page OCR could not read is in `ocrFailed` (empty when it read them all), apart from a blank page; an upload's
194
257
  `ocrLayerOnly` lists the pages that kept their text layer alone because OCR could not read them.
195
258
 
@@ -207,11 +270,13 @@ const { source, connectUrl } = await conare.sources.connect({
207
270
  // Send the app owner to connectUrl. They sign in and come back to redirectUrl.
208
271
 
209
272
  await conare.sources.types(); // [{ type, name, logoUrl }]
210
- await conare.sources.list(); // [Source]
273
+ await conare.sources.list(); // { data: [Source, ...], nextCursor }: a page, the connected apps first
274
+ for await (const s of conare.sources.all()) {} // every source, page by page
275
+ await conare.sources.summary(); // { sources, failing, syncing, namespaces: [{ namespace, types: [{ type, sources, failing }] }] }
211
276
  await conare.sources.get(source.id); // { id, type, name, namespace, status, error, documents, lastSyncedAt, createdAt }
212
277
  const synced = await conare.sources.sync(source.id); // sync now: the Source, or a bucket's sync Run
213
278
  if ("state" in synced) await conare.runs.get(synced.id); // a Run has `state`, a Source has `status`
214
- const full = await conare.sources.sync(source.id, { full: true }); // re-read everything (Gmail and apps Conare reads itself); Gmail's rows are billed again
279
+ const full = await conare.sources.sync(source.id, { full: true }); // re-read everything (Gmail and apps Conare reads itself); only documents that changed are indexed again
215
280
  if (!("state" in full)) full.resyncNote; // what the re-read does
216
281
  await conare.sources.update(source.id, { syncIntervalSeconds: 3600 }); // every hour; null is automatic
217
282
  await conare.sources.delete(source.id, { deleteDocuments: true });
@@ -250,6 +315,18 @@ by default), parsing it again only when it changed. Each website is its own sour
250
315
  `Run` it queued (409 `run_active` while one is queued or running), and a custom or files source has
251
316
  nothing to sync (409 `push_source`).
252
317
 
318
+ A deleted Google Cloud Storage, web or files source stops syncing at once but keeps its documents, searchable,
319
+ for an hour: `deletesAt` says when they go, and `sources.restore()` brings it back until then.
320
+
321
+ ```ts
322
+ await conare.sources.delete(site.id); // deleting; its documents go in an hour
323
+ await conare.sources.delete(site.id, { graceSeconds: 0 }); // now (0 to 86,400), also in its grace
324
+ await conare.sources.restore(site.id); // active again, with its documents
325
+ ```
326
+
327
+ While a source is in its grace, connecting the same bucket or site, or uploading to a namespace whose files source
328
+ it is, throws `source_deleting` with `details.sourceId` and `details.deletesAt`: restore it, or delete it now.
329
+
253
330
  ### Custom sources
254
331
 
255
332
  A custom source is a set of documents you push from your own system, keyed by your own ids.
@@ -293,7 +370,8 @@ something, so their retries are safe.
293
370
 
294
371
  ### Errors
295
372
 
296
- Every failure is a `ConareError` with `status`, `code`, `message` and `requestId`
373
+ Every failure is a `ConareError` with `status`, `code`, `message`, `requestId` and `details` (null unless
374
+ the error carries facts beside its message, such as a fetched URL's `status`)
297
375
  (`status` is 0 when no response arrived: `timeout`, `connection_error`). 429, 5xx and network
298
376
  errors are retried twice with backoff, honouring `Retry-After`. Every write carries an
299
377
  `Idempotency-Key`, the same on each of its retries: the API answers a retry with the first answer
@@ -346,31 +424,56 @@ npx conare sync --uninstall # stop the background sync
346
424
  npx conare sync github owner/repo # issues, PRs and markdown docs (GITHUB_TOKEN or gh auth)
347
425
  ```
348
426
 
349
- **Sessions.** Each Claude Code or Codex session becomes one document in the namespace `sessions`:
350
- a readable transcript with the prompts, the answers, one line per tool call, and the errors. Tool
351
- output that succeeded, images and thinking are left out, and secrets (API keys, tokens, private
352
- keys, passwords) are replaced with `[REDACTED:<kind>]` before anything is sent. Ids are
353
- `claude:<session>`, `claude:<session>:agent:<agent>` for a subagent, and `codex:<rollout file
354
- name>`; a session over 250 KB is sent as `<id>:part:000001`, `:part:000002`, and so on (one
355
- layout per session, never both), so a sync sends only the parts that changed. Metadata: `source` (`claude-code` or `codex`), `session_id`,
356
- `agent_id`, `project`, `cwd`, `git_branch`, `started_at`, `date` (the last activity) and
357
- `content_hash`.
427
+ Create the key at https://conare.ai/dashboard/keys (access is by invitation:
428
+ https://conare.ai/request-access). Synced: Claude Code, Codex, Cursor (on Node 22.13 or newer, or
429
+ Bun: it is read with `node:sqlite`), Pi. Not synced yet: OpenCode, Grok; a sync that finds one of
430
+ them on the machine says so, and names Cursor when the runtime cannot read it.
431
+
432
+ **Sessions.** Each Claude Code, Codex, Pi session and Cursor chat becomes one document in the
433
+ namespace `sessions`: a readable transcript with the prompts, the answers, one line per tool call,
434
+ and the errors. Tool output that succeeded, images and thinking are left out, and secrets (API keys,
435
+ tokens, private keys, passwords) are replaced with `[REDACTED:<kind>]` before anything is sent. Ids
436
+ are `claude:<session>`, `claude:<session>:agent:<agent>` for a subagent, `codex:<rollout file
437
+ name>`, `pi:<session file name>` and `cursor:<composer id>`; a session over 250 KB is sent as
438
+ `<id>:part:000001`, `:part:000002`, and so on (one layout per session, never both), so a sync sends
439
+ only the parts that changed. Metadata: `source` (`claude-code`, `codex`, `pi` or `cursor`),
440
+ `session_id`, `agent_id`, `project`, `cwd`, `git_branch`, `started_at`, `date` (the last activity)
441
+ and `content_hash`. A Cursor chat records no directory, so it has no `project` or `cwd`.
358
442
 
359
443
  ```ts
360
444
  const sessions = conare.namespace("sessions");
361
445
  await sessions.query("why did we drop the Redis cache?", { filter: { project: "shop" } });
362
446
  ```
363
447
 
364
- It reads `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR`) and `~/.codex/sessions` (or `$CODEX_HOME`).
365
- The key comes from `--key`, else `CONARE_API_KEY`, else `~/.conare/sync.json`. What the server
366
- already has is kept in `~/.conare/sync-state.json` and checked against the namespace's listing at the start of a run (what
367
- the server lost goes up again), and one run at a time holds `~/.conare/sync.lock`.
448
+ It reads `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR`), `~/.codex/sessions` (or `$CODEX_HOME`),
449
+ `~/.pi/agent/sessions` (or `$PI_CODING_AGENT_SESSION_DIR`, or `sessions` in `$PI_CODING_AGENT_DIR`)
450
+ and Cursor's `User/globalStorage/state.vscdb` (in `~/Library/Application Support/Cursor` on macOS,
451
+ `~/.config/Cursor` on Linux), opened read-only. Cursor keeps every chat in that one database, so each
452
+ chat is tracked by its own last update; the list of chats is kept in `~/.conare/cursor-composers.json`
453
+ and the database is not opened while it is unchanged.
454
+ The key comes from `--key`, else `CONARE_API_KEY`, else `~/.conare/sync.json`; a key of several
455
+ organizations needs `--org org_…` (or `CONARE_ORG`). What the server already has is kept in
456
+ `~/.conare/sync-state.json` and checked against the namespace's listing once a day: a session deleted
457
+ on the server (in the console, say) is uploaded again within a day, unless its project is in
458
+ `~/.conare/sync-exclude`. Sessions of an excluded project, and transcripts with no message this
459
+ version can read, are recorded there too and not read again until they change (or, for the latter,
460
+ another version runs). One run at a time holds `~/.conare/sync.lock`; `~/.conare` is readable by
461
+ you alone.
368
462
  `--install` copies the command to `~/.conare/sync/<version>/`, checks the copy file by file, runs
369
- it once, and only then adds a launchd agent (`ai.conare.sync`) on macOS or a systemd user timer on
370
- Linux. Every run adds a line to `~/.conare/sync.log` (uploaded, skipped and failed counts, duration).
463
+ it once with the key it saved, and only then adds a launchd agent (`ai.conare.sync`) on macOS or a
464
+ systemd user timer on Linux; a key that may not write `sessions` (exit 3) or an organization out of
465
+ credits (exit 5) schedules nothing. On Linux without a systemd user manager, and on Windows, it
466
+ schedules nothing and prints the cron or `schtasks` line to add yourself; on Linux it says when the
467
+ timer stops at logout (`loginctl enable-linger`). The schedule does not update itself: `sync` and
468
+ `sync status` say when it runs an older version than the one you ran. Every run adds a line to
469
+ `~/.conare/sync.log` (uploaded, skipped and failed counts, duration).
371
470
  With `--install --via <command>` the schedule runs the sync through that command, which supplies
372
- `CONARE_API_KEY` (for example a secrets manager's wrapper such as `ops`), and no key is saved to disk.
373
- Up to four batches upload at once.
471
+ `CONARE_API_KEY` (for example a secrets manager's wrapper such as `ops`), and no key is saved to disk;
472
+ the first run goes through it too.
473
+ Up to four batches upload at once. On a machine that has the old Conare CLI (0.7 and earlier, `cmem_`
474
+ keys, retired on 2026-10-02), `--install` also removes its background job (`ai.conare.ingest`, its
475
+ systemd timer or its cron line) and its program in `~/.conare/bin`, and points its `conare` command
476
+ at this version; `~/.conare/config.json` is left as it is.
374
477
 
375
478
  **GitHub.** `conare sync github owner/repo` writes every issue and PR thread (body, comments and
376
479
  review comments; bots other than `greptile-apps[bot]` and `claude[bot]` are left out) into
@@ -382,7 +485,90 @@ and files whose content changed; docs whose file was deleted are deleted. `--sta
382
485
  where that is kept (default `~/.conare/github-state.json`). `<repo>` is the repository's name
383
486
  lowercased, with any character other than letters, digits, `_` and `-` as `-` (`vercel/next.js`
384
487
  writes `next-js-github`). A namespace that already holds another owner's repository of the same
385
- name is left alone, and that repository's sync stops with an error.
488
+ name is left alone, and that repository's sync stops with an error. A GitHub source connected in the
489
+ dashboard keeps a repository in sync without this command.
490
+
491
+ ## Changes in 0.34.0
492
+
493
+ Nothing to change in code that uses the library. The `conare` command:
494
+
495
+ - `conare sync` also uploads Pi sessions and Cursor chats (Cursor on Node 22.13 or newer, or Bun; on
496
+ an older Node it says Cursor is not synced and why). The schedule passes on `PI_CODING_AGENT_DIR`
497
+ and `PI_CODING_AGENT_SESSION_DIR`.
498
+ - `conare --key sk-conare-…` without a command syncs, as `conare sync --key` does. The old CLI's
499
+ flags and commands (`--install-sync`, `--config-file`, `doctor`, a `cmem_` key, …) say how to move to
500
+ this one instead of "Unknown argument"; `sync --install` retires the old CLI where it is installed.
501
+ - Exit codes: a key that may not write the namespace (403) or acts for several organizations without
502
+ `--org` exits 3, not 4; an organization out of credits or over its cap (402) exits 5, with the
503
+ billing page. `--install` schedules nothing after 3 or 5, and checks the platform before copying
504
+ anything. A held lock in `sync github` exits 4, a GitHub token or repository GitHub refuses 1.
505
+ - A 400 that names no document (a key of several organizations without `--org`) stops the run, where
506
+ every document used to be sent again alone and reported "Not accepted" on every run. `--org` (or
507
+ `CONARE_ORG`) is new, and the schedule keeps it.
508
+ - The namespace is listed once a day rather than on every run (a no-op run took about a minute on
509
+ 4,400 sessions), and sessions left out on purpose are recorded, so `sync status` no longer reports
510
+ them as missed forever.
511
+ - `--dry-run` without a key counts against the saved state rather than calling everything new.
512
+ - `~/.conare` is made readable by you alone, and `sync.log` 0600.
513
+ - The key page is https://conare.ai/dashboard/keys.
514
+
515
+ ## Changes in 0.33.0
516
+
517
+ 0.31.0 and 0.32.0 were never published: coming from 0.30.0, read their notes below too. What breaks code
518
+ written for 0.30.0:
519
+
520
+ - `sources.list()` answers one page, `{ data, nextCursor }`, not an array of every source: the connected apps on
521
+ the first page, then up to `limit` (default 100, at most 200) custom, files, Google Cloud Storage and web
522
+ sources, newest first. Pass `nextCursor` as `cursor` for the next page, or iterate `sources.all()` for every
523
+ source. Both take `namespace`, `user` and `type`. Code that read the array reads `.data`, or iterates `all()`
524
+ to keep every source.
525
+ - `sources.list(options)` became `sources.list(params, options)`: request options (`signal`, `timeout`,
526
+ `idempotencyKey`) passed first, as 0.30.0 took them, are now read as filters and do nothing. Pass them second:
527
+ `sources.list({}, { timeout: 5000 })`.
528
+ - `sources.delete(id)` of a Google Cloud Storage, web or files source leaves an hour to take it back: the source
529
+ stops syncing at once and shows `deletesAt`, its documents stay searchable until then, and `sources.restore(id)`
530
+ brings it back. `sources.delete(id, { graceSeconds })` sets the wait (0 to 86,400); `0` deletes at once, as before,
531
+ and also deletes now a source already in its grace.
532
+ - Types that gained required fields, which code building such objects itself (a test double) must now fill:
533
+ `ApiKey.readOnly` and `ApiKey.rateLimitPercent`, and `OrganizationSpend.capped` and each of its
534
+ rows' `spendCapMicros`, and `WebSource.config.pages`.
535
+ - The list no longer carries a site's page addresses: read the source. A web source from `sources.list()` has how
536
+ many pages it has (`config.pages`) and no `config.urls`; `sources.get(id)` answers them (one site can hold 5,000,
537
+ and a page of 124 sites weighed 214 MB). 0.30.0's `sources.list()` reads the missing key as `config.urls: []`: it
538
+ does not throw, but its sources look empty of pages, so read each with `sources.get(id)`.
539
+
540
+ New, nothing to change:
541
+
542
+ - `sources.list()` answers `total` on the first page, how many sources every page holds: `list({ limit: 1 })` reads
543
+ how many there are. `sources.list({ health: "failing" })` (and `all()`) keeps the sources that need you.
544
+ - `sources.summary()` counts the sources by namespace and type, and how many of them fail or sync now, in one read
545
+ however many sources there are (`{ namespace }` for one): which apps feed a namespace, without listing them.
546
+
547
+ - A `source_deleting` error (connecting a bucket or site whose source is in its grace, uploading to a namespace
548
+ whose files source is) carries `details.sourceId` and, while it can still be restored, `details.deletesAt`:
549
+ `sources.restore(details.sourceId)`, or `sources.delete(details.sourceId, { graceSeconds: 0 })` to delete it now.
550
+ - `sources.restore()` takes what `sources.delete()` takes: in the console, an organization admin.
551
+ - `parse` and `uploadFile` take a workbook's `sheets` (names), `range` (`"A1:F40"`) and `formulas: true` (an
552
+ .xlsx's formulas beside their values); `parse`'s result names a workbook's `sheets`, all of them.
553
+ - `parse` and `uploadFile` take `vision: true`: each chart, diagram and picture is described in one line
554
+ `> **Figure description:** ...`, every part carries `vision` (and with `layout`, a figure block its `description`),
555
+ and a picture with no text but a description is a part, not 422 `no_text`. A description is written by a model: it
556
+ describes what the chart, diagram or picture shows and is not text from the page; it can be wrong, and two reads of
557
+ the same file may word it differently; numbers a chart prints are in the page's text as before. A deployment that
558
+ does not offer it answers 400 `invalid_request`.
559
+
560
+ ## Changes in 0.32.0
561
+
562
+ - `changes({ source, since, until })` keeps a page of changes to one source and a time window, and a web page's
563
+ `changed` row says how it changed (`diff`: the lines removed and added, or that only the reader or its fields
564
+ changed).
565
+
566
+ ## Changes in 0.31.0
567
+
568
+ - `queryRecord(query, schema)` answers a search as a record of the fields the schema names, each value typed from
569
+ the schema and with the document, address and words it is from (`sources`).
570
+ - `changes({ cursor, limit })` reads a page of a namespace's changes: the documents its sources created, changed
571
+ and deleted, from a cursor.
386
572
 
387
573
  ## Changes in 0.30.0
388
574
 
package/dist/cli/args.js CHANGED
@@ -1,13 +1,20 @@
1
1
  // Command line: `conare sync [sessions]`, `conare sync status`, `conare sync github <owner/repo>...`.
2
- export const HELP = `Usage:
3
- conare sync [options] Claude Code and Codex sessions -> namespace "sessions"
2
+ export const HELP = `Start: create a key at https://conare.ai/dashboard/keys (access is by invitation:
3
+ https://conare.ai/request-access), then run
4
+ npx conare sync --key sk-conare-… --install
5
+
6
+ Usage:
7
+ conare sync [options] coding agent sessions -> namespace "sessions"
4
8
  conare sync status the last sessions sync; exits 1 when its last success is over 1 h old or it missed transcripts
5
9
  conare sync github <owner/repo>... [opts] issues, PRs and markdown docs -> "<repo>-github", "<repo>-docs"
6
10
 
11
+ Synced: Claude Code, Codex, Cursor (on Node 22.13 or newer, or Bun), Pi. Not synced yet: OpenCode, Grok.
12
+
7
13
  Run it as npx conare … or bunx conare …. Only new or changed sessions, threads and docs are
8
14
  sent; secrets are redacted first. To leave a project's sessions out, put its name (its git
9
15
  repository's, else its directory's) on a line of ~/.conare/sync-exclude; sessions it already
10
- uploaded stay until you delete them.
16
+ uploaded stay until you delete them. A session deleted in the console is uploaded again by a
17
+ later run (within a day) unless its project is in that file.
11
18
 
12
19
  Options:
13
20
  --dry-run count what would upload; upload nothing
@@ -16,17 +23,27 @@ Options:
16
23
  --uninstall sessions: stop the background sync
17
24
  --via <command> with --install: the schedule runs \`<command> node … sync\`, which
18
25
  supplies CONARE_API_KEY (e.g. --via ops); no key is saved to disk
26
+ --org <org_…> the organization to write to, for a key of several (else CONARE_ORG)
19
27
  --state <file> github: what was synced (default ~/.conare/github-state.json)
20
28
  --key <key> save an API key (sk-conare-…) to ~/.conare/sync.json, then sync
21
29
  -v, --version print the version
22
30
  -h, --help show this help
23
31
 
24
- Exit codes: 0 done; 1 error; 2 bad arguments; 3 API key refused; 4 incomplete (documents
25
- refused, the API unreachable, or another sync running), tried again next run.
32
+ Exit codes: 0 done; 1 error (a GitHub token or repository refused included); 2 bad arguments;
33
+ 3 the API key was refused, may not write the namespace, or acts for several organizations
34
+ without --org; 4 incomplete (documents refused, the API unreachable, or another sync running),
35
+ tried again next run; 5 out of credits or over a spend cap (https://conare.ai/dashboard/billing).
36
+ With --quiet, a sessions sync that finds another running exits 0. --install schedules the sync
37
+ only after a first run that exits 0 or 4.
26
38
 
27
39
  The key comes from --key, else CONARE_API_KEY, else ~/.conare/sync.json.
28
- Create one at https://conare.ai/console/keys. GitHub: GITHUB_TOKEN, else \`gh auth token\`.
40
+ Create one at https://conare.ai/dashboard/keys. GitHub: GITHUB_TOKEN, else \`gh auth token\`.
29
41
  `;
42
+ /** What the old CLI's flags and commands get (it was retired with its API, cmem_ keys and all). */
43
+ export const LEGACY_USAGE = `That is the old Conare CLI, retired on 2026-10-02 (cmem_ keys no longer work). Create a key at https://conare.ai/dashboard/keys (access is by invitation: https://conare.ai/request-access), then run:
44
+ npx conare@latest sync --key sk-conare-… --install`;
45
+ const LEGACY_FLAGS = new Set(["--install-sync", "--uninstall-sync", "--ingest-only", "--config-only", "--interactive", "--index", "--project", "--changed", "--force", "--source", "--sync-interval", "--wasm-dir", "--config-file", "--persist-bundle"]);
46
+ const LEGACY_COMMANDS = new Set(["install", "logout", "doctor", "savings"]);
30
47
  const REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
31
48
  /**
32
49
  * The name "<name>-github" and "<name>-docs" start with, for owner/repo: the repository's name
@@ -75,6 +92,8 @@ export function parseArgs(argv) {
75
92
  const key = value();
76
93
  if (!key)
77
94
  return { error: "--key needs a value: --key sk-conare-…" };
95
+ if (key.startsWith("cmem_"))
96
+ return { error: LEGACY_USAGE };
78
97
  if (!key.startsWith("sk-conare-"))
79
98
  return { error: "The key should start with sk-conare-." };
80
99
  args.key = key;
@@ -94,7 +113,16 @@ export function parseArgs(argv) {
94
113
  args.state = state;
95
114
  break;
96
115
  }
116
+ case "--org": {
117
+ const org = value();
118
+ if (!org)
119
+ return { error: "--org needs an organization id: --org org_…" };
120
+ args.org = org;
121
+ break;
122
+ }
97
123
  default:
124
+ if (LEGACY_FLAGS.has(flag))
125
+ return { error: LEGACY_USAGE };
98
126
  if (flag.startsWith("-"))
99
127
  return { error: `Unknown argument: ${arg}` };
100
128
  words.push(arg);
@@ -103,9 +131,11 @@ export function parseArgs(argv) {
103
131
  if (args.help || args.version)
104
132
  return args;
105
133
  const [command, sub, ...more] = words;
106
- if (command === undefined)
107
- return { ...args, help: true };
108
- if (command !== "sync")
134
+ if (command === undefined && !args.key)
135
+ return { ...args, help: true }; // a bare --key means sync
136
+ if (command !== undefined && LEGACY_COMMANDS.has(command))
137
+ return { error: LEGACY_USAGE };
138
+ if (command !== undefined && command !== "sync")
109
139
  return { error: `Unknown command: ${command}` };
110
140
  if (sub === undefined || sub === "sessions" || sub === "status") {
111
141
  if (more.length > 0)
@@ -2,8 +2,9 @@
2
2
  import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
- export function resolvePaths(env = process.env, home = homedir()) {
5
+ export function resolvePaths(env = process.env, home = homedir(), platform = process.platform) {
6
6
  const dir = join(home, ".conare");
7
+ const tilde = (p) => (p.startsWith("~/") ? join(home, p.slice(2)) : p); // Pi expands "~" in its own variables
7
8
  return {
8
9
  dir,
9
10
  keyFile: join(dir, "sync.json"),
@@ -16,8 +17,18 @@ export function resolvePaths(env = process.env, home = homedir()) {
16
17
  installRoot: join(dir, "sync"),
17
18
  claudeDir: env.CLAUDE_CONFIG_DIR || join(home, ".claude"),
18
19
  codexDir: env.CODEX_HOME || join(home, ".codex"),
20
+ piDir: env.PI_CODING_AGENT_SESSION_DIR
21
+ ? tilde(env.PI_CODING_AGENT_SESSION_DIR)
22
+ : join(env.PI_CODING_AGENT_DIR ? tilde(env.PI_CODING_AGENT_DIR) : join(home, ".pi", "agent"), "sessions"),
23
+ cursorDb: cursorDbPath(home, platform),
24
+ cursorListFile: join(dir, "cursor-composers.json"),
19
25
  };
20
26
  }
27
+ /** Where Cursor keeps its chats: under ~/Library/Application Support on macOS, else ~/.config. */
28
+ export function cursorDbPath(home, platform) {
29
+ const base = platform === "darwin" ? join(home, "Library", "Application Support") : join(home, ".config");
30
+ return join(base, "Cursor", "User", "globalStorage", "state.vscdb");
31
+ }
21
32
  export function readSavedKey(keyFile) {
22
33
  try {
23
34
  const key = JSON.parse(readFileSync(keyFile, "utf8")).api_key;
@@ -47,6 +58,15 @@ export function readExcluded(file) {
47
58
  export function saveKey(keyFile, key) {
48
59
  writePrivate(keyFile, `${JSON.stringify({ api_key: key }, null, 2)}\n`);
49
60
  }
61
+ /**
62
+ * ~/.conare readable by the user only: it holds the key, the state and the log of what was
63
+ * synced. mkdir's mode applies only when it creates the directory, so one made by an older
64
+ * version or another tool is narrowed here.
65
+ */
66
+ export function privateDir(dir) {
67
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
68
+ chmodSync(dir, 0o700);
69
+ }
50
70
  /** Atomic write readable only by the user (the directory too). */
51
71
  export function writePrivate(path, content) {
52
72
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
@@ -13,9 +13,9 @@ export const NAMESPACE = "sessions";
13
13
  */
14
14
  export const PART_BYTES = 250_000;
15
15
  const METADATA_VALUE_BYTES = 4096;
16
- /** claude:<session>, claude:<session>:agent:<agent>, codex:<session>. */
16
+ /** claude:<session>, claude:<session>:agent:<agent>, codex:<session>, pi:<session>, cursor:<composer>. */
17
17
  export function baseId(t) {
18
- const prefix = t.source === "codex" ? "codex" : "claude";
18
+ const prefix = t.source === "claude-code" ? "claude" : t.source;
19
19
  return `${prefix}:${idSegment(t.sessionId)}${t.agentId ? `:agent:${idSegment(t.agentId)}` : ""}`;
20
20
  }
21
21
  /** <base>:part:000001 for n = 1. */
@@ -42,6 +42,7 @@ export function toDocuments(t, project) {
42
42
  set("source", t.source);
43
43
  set("session_id", t.sessionId);
44
44
  set("agent_id", t.agentId);
45
+ set("entrypoint", t.entrypoint); // what started it: "claude-desktop", "sdk-go" (an Agent SDK app), …
45
46
  set("project", project);
46
47
  set("cwd", t.cwd);
47
48
  set("git_branch", t.branch);
@@ -0,0 +1,111 @@
1
+ // The old Conare CLI (npm conare 0.7.x and earlier, cmem_ keys) installed itself with
2
+ // --install-sync: ~/.conare/bin/conare-ingest.mjs, a `conare` command (~/.conare/bin/conare,
3
+ // linked from /usr/local/bin or put on PATH) and a job running it every 10 minutes. Its API was
4
+ // removed on 2026-10-02, so that job fails every run and the command answers "Invalid API key".
5
+ // retireLegacy removes the job and the old program, and points the command at this CLI.
6
+ import { execFileSync } from "node:child_process";
7
+ import { chmodSync, existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
8
+ import { homedir } from "node:os";
9
+ import { join } from "node:path";
10
+ import { UNIT, systemdDir } from "./schedule.js";
11
+ export const LEGACY_LABEL = "ai.conare.ingest";
12
+ /** What the old CLI copied to ~/.conare/bin besides the command. ~/.conare/config.json stays. */
13
+ const LEGACY_FILES = ["conare-ingest.mjs", "run.sh", "run.cmd", "run.vbs", "node_modules"];
14
+ const exec = (cmd, args, input) => execFileSync(cmd, args, { input, encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] });
15
+ /**
16
+ * Remove the old CLI's background job and program files, and point its `conare` command (only
17
+ * where it exists) at `script` run by node. Returns a line per thing done; nothing on a machine
18
+ * without the old CLI. Never throws: a failed cleanup must not fail the caller.
19
+ */
20
+ export function retireLegacy(runtime, script, s) {
21
+ // Windows is left alone: --install does not run there, and deleting run.vbs under the old
22
+ // scheduled task would put a script error on screen every 10 minutes.
23
+ if (s.platform !== "darwin" && s.platform !== "linux")
24
+ return [];
25
+ const r = s.run ?? exec;
26
+ const home = s.home ?? homedir();
27
+ const bin = join(home, ".conare", "bin");
28
+ const out = [];
29
+ const jobs = [];
30
+ const attempt = (f) => {
31
+ try {
32
+ f();
33
+ }
34
+ catch {
35
+ // Best effort: the rest still runs.
36
+ }
37
+ };
38
+ attempt(() => {
39
+ const wrapper = join(bin, "conare");
40
+ if (!existsSync(wrapper))
41
+ return;
42
+ // Rewritten in place, so the /usr/local/bin link or the PATH entry the old CLI made still finds it.
43
+ const text = `#!/bin/sh
44
+ # The conare command: the Conare CLI installed in ~/.conare/sync (each npx conare sync --install rewrites this).
45
+ NODE=$(command -v node) || NODE=${sh(runtime)}
46
+ exec "$NODE" ${sh(script)} "$@"
47
+ `;
48
+ if (readFileSync(wrapper, "utf8") === text)
49
+ return;
50
+ const tmp = `${wrapper}.${process.pid}.tmp`;
51
+ writeFileSync(tmp, text);
52
+ chmodSync(tmp, 0o755);
53
+ renameSync(tmp, wrapper);
54
+ out.push("The conare command now runs this version.");
55
+ });
56
+ if (existsSync(bin)) {
57
+ for (const f of LEGACY_FILES)
58
+ attempt(() => rmSync(join(bin, f), { recursive: true, force: true }));
59
+ attempt(() => {
60
+ // Its cron line (Linux without systemd; older macOS installs): `*/10 * * * * "~/.conare/bin/run.sh" # conare-sync`.
61
+ let tab;
62
+ try {
63
+ tab = r("crontab", ["-l"]);
64
+ }
65
+ catch {
66
+ return; // no crontab
67
+ }
68
+ const lines = tab.split("\n");
69
+ const kept = lines.filter((l) => !l.endsWith("# conare-sync") && !l.includes(".conare/bin/run.sh"));
70
+ if (kept.length === lines.length)
71
+ return;
72
+ r("crontab", ["-"], kept.join("\n"));
73
+ jobs.push("cron");
74
+ });
75
+ }
76
+ if (s.platform === "linux") {
77
+ attempt(() => {
78
+ // The old units share the new one's name (conare-sync); they are the old CLI's only while
79
+ // the service still runs ~/.conare/bin/run.sh. The old CLI wrote them under ~/.config always.
80
+ const dir = join(home, ".config", "systemd", "user");
81
+ const service = join(dir, `${UNIT}.service`);
82
+ if (!existsSync(service) || !readFileSync(service, "utf8").includes(".conare/bin/run.sh"))
83
+ return;
84
+ // A new timer in $XDG_CONFIG_HOME is the one systemctl would act on: leave it running.
85
+ const ours = systemdDir(s.env, home) !== dir && existsSync(join(systemdDir(s.env, home), `${UNIT}.timer`));
86
+ if (!ours)
87
+ attempt(() => r("systemctl", ["--user", "disable", "--now", `${UNIT}.timer`]));
88
+ rmSync(join(dir, `${UNIT}.timer`), { force: true });
89
+ rmSync(service, { force: true });
90
+ attempt(() => r("systemctl", ["--user", "daemon-reload"]));
91
+ jobs.push(`systemd ${UNIT}.timer`);
92
+ });
93
+ }
94
+ if (s.platform === "darwin") {
95
+ attempt(() => {
96
+ const plist = join(home, "Library", "LaunchAgents", `${LEGACY_LABEL}.plist`);
97
+ if (!existsSync(plist))
98
+ return;
99
+ rmSync(plist, { force: true });
100
+ jobs.push(LEGACY_LABEL);
101
+ attempt(() => r("launchctl", ["bootout", `gui/${s.uid ?? process.getuid?.() ?? 0}/${LEGACY_LABEL}`]));
102
+ });
103
+ }
104
+ if (jobs.length > 0)
105
+ out.unshift(`Removed the old Conare CLI's background job (${jobs.join(", ")}).`);
106
+ return out;
107
+ }
108
+ /** A single-quoted sh word. */
109
+ function sh(s) {
110
+ return `'${s.replace(/'/g, `'\\''`)}'`;
111
+ }