@getbourdon/participants 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,649 @@
1
+ import { L5ManifestModel, SessionModel, VisibilityPolicyModel } from '@getbourdon/l5';
2
+ export { EntityModel, L5ManifestModel, SessionModel, Visibility, VisibilityPolicyModel, applyVisibility, filterForFederation, toDict, validateManifest } from '@getbourdon/l5';
3
+ import DatabaseT from 'better-sqlite3';
4
+
5
+ /**
6
+ * Bourdon participant base — the Protocol → TS interface, errors, and the
7
+ * AgentStore / HealthStatus types. Faithful port of `participants/base.py`.
8
+ *
9
+ * The L5 dataclass model (AgentInfo/Entity/Session/VisibilityPolicy/L5Manifest),
10
+ * the `toDict` omission rules, and the visibility helpers all live in
11
+ * `@getbourdon/l5` and are reused verbatim — only THAT output shape is the parity
12
+ * contract. This module owns the participant CONTRACT surface around them.
13
+ *
14
+ * Contract semantics (enforced by every reader, asserted by the conformance
15
+ * fixtures, never by trust):
16
+ * 1. visibility filter BEFORE emission (`filterForFederation`) — private wins.
17
+ * 2. deterministic / idempotent `exportL5` — same store → identical `toDict`.
18
+ * 3. `healthCheck` NEVER throws — catch-all → degraded/blocked.
19
+ * 4. every native string through `@getbourdon/redaction` before it enters L5.
20
+ */
21
+
22
+ /** Tied to Bourdon spec v0.1 — same literals as the Python oracle. */
23
+ declare const CONTRACT_VERSION = "0.1";
24
+ declare const SPEC_VERSION = "0.1";
25
+ /** Base class for participant errors. */
26
+ declare class ParticipantError extends Error {
27
+ constructor(message?: string);
28
+ }
29
+ /** Raised by `discover()` when the native store cannot be found or read.
30
+ * Non-fatal: L6 skips this agent rather than aborting the whole export. */
31
+ declare class ParticipantDiscoveryError extends ParticipantError {
32
+ }
33
+ /** Raised by `exportL5()` / `exportSessions()` when an export fails mid-op
34
+ * (the store WAS present — distinct from a discovery miss). */
35
+ declare class ParticipantExportError extends ParticipantError {
36
+ }
37
+ /** Raised when the native store's version is outside the supported range.
38
+ * Subtype of discovery error (a version mismatch is a discovery-time miss). */
39
+ declare class ParticipantVersionMismatchError extends ParticipantDiscoveryError {
40
+ }
41
+ /** Metadata describing the native agent store. Returned by `discover()`. */
42
+ interface AgentStore {
43
+ path: string;
44
+ version: string;
45
+ metadata: Record<string, unknown>;
46
+ }
47
+ /** Returned by `healthCheck()`. Consumed by the `bourdon doctor` CLI. */
48
+ interface HealthStatus {
49
+ status: "ok" | "degraded" | "blocked";
50
+ reason?: string;
51
+ details: Record<string, unknown>;
52
+ /** A human-runnable command to remedy a non-ok status. */
53
+ proposedFix?: string;
54
+ }
55
+ /**
56
+ * Structural interface every participant must satisfy (the Python
57
+ * `@runtime_checkable Protocol`). Duck-typed at registration: a class is a
58
+ * participant iff it has `agentId` + `agentType` + `exportL5` + `healthCheck`.
59
+ *
60
+ * Optional members (`displayName`, a `defaultNativePath` static) are documented
61
+ * here as in the Python Protocol; discovery + the setup wizard fall back to
62
+ * sensible defaults when absent.
63
+ */
64
+ interface BourdonParticipant {
65
+ agentId: string;
66
+ agentType: string;
67
+ nativePath: string;
68
+ /** Human-friendly label (e.g. "GitHub Copilot"). Optional. */
69
+ displayName?: string;
70
+ /** Quarantined-class marker (Python `QUARANTINED_CLASS`). When true, the CLI
71
+ * requires `--i-understand-the-risk` to register the agent trusted, and its
72
+ * exports are staged for operator review rather than written to the live
73
+ * store (spec D6: quarantine follows the content, not the invoker). Absent =
74
+ * a normal, non-quarantined participant. Read by `bourdon agent add/set-tier`
75
+ * (cli/src/commands/federation.ts). */
76
+ quarantinedClass?: boolean;
77
+ /** Confirm the native store exists; return metadata. Throws
78
+ * {@link ParticipantDiscoveryError} when missing/unreadable. */
79
+ discover(): AgentStore;
80
+ /** Build the L5 manifest from native memory, applying the visibility filter
81
+ * BEFORE return. Deterministic — same store yields the same manifest. */
82
+ exportL5(since?: Date): L5ManifestModel;
83
+ /** Export recent sessions in normalized schema. */
84
+ exportSessions(since?: Date, limit?: number): SessionModel[];
85
+ /** Return ok / degraded / blocked with a reason. MUST NOT throw. */
86
+ healthCheck(): HealthStatus;
87
+ }
88
+ /**
89
+ * Tiny structural guard mirroring Python's `_PARTICIPANT_MARKER_ATTRS`
90
+ * duck-type: a value is a participant iff it carries the four marker members.
91
+ */
92
+ declare function isParticipant(obj: unknown): obj is BourdonParticipant;
93
+
94
+ /**
95
+ * Shared read-only SQLite + normalization helpers — port of
96
+ * `participants/_sqlite_base.py`.
97
+ *
98
+ * A SQLite-backed participant (hermes today; cursor/copilot_cli in the follow-on
99
+ * slice) reads a foreign agent's native DB read-only so a live writer's lock can
100
+ * never block the export, probes the schema defensively (native schemas drift
101
+ * across versions), and turns epoch timestamps + paths into the L5 shapes.
102
+ *
103
+ * `better-sqlite3` is a NATIVE addon. It is loaded lazily through `createRequire`
104
+ * inside a try/catch so this package — and the file/network readers — keep
105
+ * working even on a toolchain where the addon failed to build: in that case
106
+ * {@link sqliteAvailable} returns false and the sqlite readers degrade rather
107
+ * than crashing import. Nothing here applies visibility or builds manifests;
108
+ * that stays in the participant (per PARTICIPANT_CONTRACT.md).
109
+ */
110
+
111
+ /** A better-sqlite3 connection (re-exported type alias for reader signatures). */
112
+ type SqliteDatabase = DatabaseT.Database;
113
+ /** True when the better-sqlite3 native addon loaded successfully. Tests gate
114
+ * the SQLite-reader assertions on this so a missing addon skips, not fails. */
115
+ declare function sqliteAvailable(): boolean;
116
+ interface OpenReadonlyOptions {
117
+ /** `immutable=1`: skip locks + ignore the WAL. Only for genuinely static
118
+ * snapshots; against a live writer it risks stale reads / SQLITE_CORRUPT. */
119
+ immutable?: boolean;
120
+ /** SQLite busy-timeout in milliseconds (Python's `timeout=2.0` seconds). */
121
+ timeoutMs?: number;
122
+ }
123
+ /**
124
+ * Open a SQLite DB read-only so a live writer is never disturbed. The default
125
+ * (`immutable` omitted) is the safe `mode=ro`: it respects SQLite locking and
126
+ * reads the `-wal` sidecar of a live, actively-writing agent. Raises on a
127
+ * genuine open failure; callers wanting the never-raises contract use
128
+ * {@link tryOpenReadonly}.
129
+ */
130
+ declare function openReadonly(dbPath: string, opts?: OpenReadonlyOptions): SqliteDatabase;
131
+ /**
132
+ * Like {@link openReadonly} but returns null instead of raising — for the
133
+ * export/health path where a missing or corrupt DB must degrade to "no rows".
134
+ */
135
+ declare function tryOpenReadonly(dbPath: string, opts?: OpenReadonlyOptions): SqliteDatabase | null;
136
+ /** True if `name` is a table in the connected DB (swallows errors → false). */
137
+ declare function tableExists(db: SqliteDatabase, name: string): boolean;
138
+ /** Column names for `table` (empty set if absent / on error). PRAGMA cannot be
139
+ * parameterized, matching the Python f-string. */
140
+ declare function tableColumns(db: SqliteDatabase, table: string): Set<string>;
141
+ /**
142
+ * Convert epoch seconds (number/string) to an ISO `YYYY-MM-DD` UTC date, or
143
+ * null for missing/unparseable values. Mirrors `epoch_to_iso_date`.
144
+ */
145
+ declare function epochToIsoDate(value: unknown): string | null;
146
+ /**
147
+ * Convert epoch seconds to a full ISO 8601 UTC datetime, or null. The offset is
148
+ * rendered `+00:00` (Python `datetime(...).isoformat()` style) rather than `Z`.
149
+ */
150
+ declare function epochToIsoDatetime(value: unknown): string | null;
151
+ /**
152
+ * Derive a lowercase project key from a working-directory path: the basename
153
+ * lowercased, or null when the cwd is empty or its basename is "generic"
154
+ * (carries no project identity). Mirrors `project_key_from_cwd`.
155
+ */
156
+ declare function projectKeyFromCwd(cwd: string | null | undefined, genericNames?: ReadonlySet<string>): string | null;
157
+ /** Turn a slug-ish key (`my-cool_project`) into a Title Case label. */
158
+ declare function friendlyLabel(key: string): string;
159
+
160
+ /**
161
+ * Network-shaped participant base — port of `participants/_network_base.py`
162
+ * (v0.3 adapter contract). Same `exportL5` / `exportSessions` half as a file
163
+ * participant; only the discovery half differs (fetch from an authenticated
164
+ * API). The base provides the three guarantees so adapters don't reimplement:
165
+ *
166
+ * 1. Local TTL cache under `~/.cache/bourdon/<slug>/payload.json` storing ONLY
167
+ * `{fetched_at, payload}` — NEVER the token. A cache hit = zero network.
168
+ * 2. Graceful degradation: network down → serve the most recent cached payload
169
+ * (even expired) and report `degraded` (not silence).
170
+ * 3. Auth boundary: an injected lazy {@link AuthProvider} (env / keychain).
171
+ * An invalid token (401/403 non-ratelimit) ALWAYS propagates as `blocked`
172
+ * and is NEVER masked by stale cache; a missing token serves stale when a
173
+ * cache exists, else blocks; rate-limit degrades.
174
+ *
175
+ * A subclass sets `participantSlug` / `agentId` / `agentType` (+ `nativePath`)
176
+ * and implements `fetchPayload(token)` + `payloadToL5(payload)` (pure, no I/O).
177
+ */
178
+
179
+ declare const NETWORK_CONTRACT_VERSION = "0.3";
180
+ /** Default cache TTL — adapters override via `cacheTtlSeconds`. */
181
+ declare const DEFAULT_CACHE_TTL_SECONDS: number;
182
+ /** Transport failure / timeout / 5xx / rate-limit — recoverable via cache fallback. */
183
+ declare class NetworkUnavailable extends ParticipantError {
184
+ }
185
+ /** 401/403 / missing credential — NOT recoverable via cache. The user must fix
186
+ * auth; surfaced as `blocked`, never silently served from stale cache (stale
187
+ * data would mask a broken token indefinitely). */
188
+ declare class ParticipantAuthError extends ParticipantError {
189
+ }
190
+ /** A zero-arg callable returning the token string, or null if no credential is
191
+ * available. Kept a callable (not a bare string) so the token is fetched lazily
192
+ * at call time and never sits in the participant's fields or the cache. */
193
+ type AuthProvider = () => string | null;
194
+ /** Auth provider that reads a token from an environment variable. */
195
+ declare function envAuthProvider(varName: string): AuthProvider;
196
+ /** `$XDG_CACHE_HOME/bourdon` or `~/.cache/bourdon`. */
197
+ declare function defaultCacheRoot(): string;
198
+ /** A cached payload + the wall-clock time it was fetched (epoch seconds). */
199
+ declare class CacheEntry {
200
+ readonly fetchedAt: number;
201
+ readonly payload: Record<string, unknown>;
202
+ constructor(fetchedAt: number, payload: Record<string, unknown>);
203
+ get ageSeconds(): number;
204
+ isFresh(ttlSeconds: number): boolean;
205
+ }
206
+ /**
207
+ * A tiny JSON file cache, one file per participant slug. Stores only
208
+ * `{fetched_at, payload}` — never the auth token. Read/write are best-effort: a
209
+ * corrupt or unwritable cache degrades to "no cache", never raises.
210
+ */
211
+ declare class PayloadCache {
212
+ readonly slug: string;
213
+ readonly root: string;
214
+ readonly path: string;
215
+ constructor(slug: string, rootDir?: string);
216
+ read(): CacheEntry | null;
217
+ write(payload: Record<string, unknown>): void;
218
+ }
219
+ interface NetworkParticipantOptions {
220
+ authProvider?: AuthProvider | null;
221
+ cacheRoot?: string;
222
+ }
223
+ /**
224
+ * Base for participants whose native state lives behind an authenticated API.
225
+ * Caching, degradation, the auth boundary, and the
226
+ * `discover`/`exportL5`/`exportSessions`/`healthCheck` plumbing live here;
227
+ * subclasses provide only `fetchPayload` + `payloadToL5`.
228
+ */
229
+ declare abstract class NetworkParticipant implements BourdonParticipant {
230
+ participantSlug: string;
231
+ agentId: string;
232
+ agentType: string;
233
+ cacheTtlSeconds: number;
234
+ nativePath: string;
235
+ protected readonly authProvider: AuthProvider | null;
236
+ private readonly cacheRoot?;
237
+ private cacheInstance?;
238
+ constructor(opts?: NetworkParticipantOptions);
239
+ /** Lazily built so it reads the SUBCLASS's `participantSlug` — subclass field
240
+ * initializers run after `super()`, so building the cache in the constructor
241
+ * would capture the base "network" slug instead. */
242
+ protected get cache(): PayloadCache;
243
+ /** Do the authenticated API call; return a JSON-serializable dict. Raise
244
+ * {@link NetworkUnavailable} on transport/5xx/rate-limit (→ cache fallback) or
245
+ * {@link ParticipantAuthError} on 401/403 (→ blocked, no fallback). */
246
+ abstract fetchPayload(token: string): Record<string, unknown>;
247
+ /** Normalize a (fresh or cached) payload into an L5 manifest. Pure, no I/O. */
248
+ abstract payloadToL5(payload: Record<string, unknown>): L5ManifestModel;
249
+ /**
250
+ * Resolve (payload, source) where source is 'cache' | 'network' | 'stale-cache'.
251
+ * 1. Fresh cache hit → 'cache' (no network)
252
+ * 2. Miss/expired + token → 'network' (fetch + refresh cache)
253
+ * 3. Net fails + any cache → 'stale-cache' (serve last good payload)
254
+ * 4. Net fails + no cache → raise
255
+ * Auth errors are never swallowed — they propagate so health surfaces
256
+ * 'blocked' rather than serving stale data behind a dead token.
257
+ */
258
+ protected getPayload(): {
259
+ payload: Record<string, unknown>;
260
+ source: string;
261
+ };
262
+ discover(): AgentStore;
263
+ exportL5(_since?: Date): L5ManifestModel;
264
+ exportSessions(since?: Date, limit?: number): SessionModel[];
265
+ healthCheck(): HealthStatus;
266
+ }
267
+
268
+ /**
269
+ * Hermes participant — normalize Hermes Agent (Nous Research) memory + sessions
270
+ * into L5. Port of `participants/hermes.py`.
271
+ *
272
+ * Reads two surfaces under `~/.hermes/` (override `$HERMES_HOME`):
273
+ * * `state.db` — a SQLite store (`sessions` + `messages` tables). Recent
274
+ * non-archived sessions + project entities (from cwd basename) come from it.
275
+ * * `memories/{memory.md,user.md}` — durable cross-session facts (one
276
+ * Markdown bullet/line per memory). The highest-signal entities.
277
+ *
278
+ * Read-only (`mode=ro`), deterministic, visibility-enforced-before-emission,
279
+ * and redaction on every native string. `healthCheck` never throws; `discover`
280
+ * raises only {@link ParticipantDiscoveryError}.
281
+ */
282
+
283
+ /** External participant for local Hermes Agent memory + sessions. */
284
+ declare class HermesParticipant implements BourdonParticipant {
285
+ agentId: string;
286
+ agentType: string;
287
+ displayName: string;
288
+ nativePath: string;
289
+ private readonly home;
290
+ static defaultNativePath(home?: string): string;
291
+ /** `hermesHome` is the `.hermes` directory itself (matching the Python ctor). */
292
+ constructor(hermesHome?: string);
293
+ private sources;
294
+ discover(): AgentStore;
295
+ exportSessions(since?: Date, limit?: number): SessionModel[];
296
+ exportL5(since?: Date): L5ManifestModel;
297
+ healthCheck(): HealthStatus;
298
+ }
299
+
300
+ /**
301
+ * Claude Code participant — reads claude-brain + auto-memory + MCP knowledge
302
+ * graph. Port of `participants/claude_code.py`.
303
+ *
304
+ * Three optional sources (the participant degrades gracefully):
305
+ * 1. claude-brain/ — git-synced markdown records
306
+ * 2. ~/.claude/projects/<ws>/memory/ — per-machine auto-memory frontmatter
307
+ * 3. ~/claude-memory/memory.jsonl — MCP knowledge-graph JSONL
308
+ *
309
+ * Privacy: entities typed `person` (+ family/contact variants) and observations
310
+ * containing credential-like strings default to PRIVATE and are filtered before
311
+ * federation. Entities are deduped by case-insensitive name and sorted
312
+ * alphabetically.
313
+ */
314
+
315
+ /** External participant for Anthropic's Claude Code CLI. */
316
+ declare class ClaudeCodeParticipant implements BourdonParticipant {
317
+ agentId: string;
318
+ agentType: string;
319
+ nativePath: string;
320
+ /** Public so a hermetic test can seed the discovered sources directly (path
321
+ * RESOLUTION is not the parity contract — only the export output shape is). */
322
+ brainPath: string | null;
323
+ autoMemoryPath: string | null;
324
+ knowledgeGraphPath: string | null;
325
+ static defaultNativePath(home?: string): string;
326
+ constructor();
327
+ discover(): AgentStore;
328
+ exportL5(since?: Date): L5ManifestModel;
329
+ exportSessions(since?: Date, limit?: number): SessionModel[];
330
+ healthCheck(): HealthStatus;
331
+ }
332
+
333
+ /**
334
+ * GitHub-embedded Copilot participant — the v0.3 network-adapter reference.
335
+ * Port of `participants/github_copilot.py`.
336
+ *
337
+ * Cloud-side Copilot (PR review, `@copilot` comments) persists nothing on the
338
+ * user's machine — its state lives on github.com. This adapter federates it by
339
+ * reading the user's GitHub activity over the REST API. The
340
+ * {@link NetworkParticipant} base provides the cache, degradation, and auth
341
+ * boundary; this class provides only the GitHub-specific fetch + payload→L5.
342
+ *
343
+ * Auth: a token with `repo` + `read:user` scope, sourced from `$GITHUB_TOKEN` /
344
+ * `$GH_TOKEN`, else `gh auth token`. Fetched lazily; never stored in the cache
345
+ * or the manifest.
346
+ */
347
+
348
+ /** Resolve a GitHub token: env var first, then the `gh` CLI keychain. */
349
+ declare function ghTokenProvider(): string | null;
350
+ /** Federates cloud-side GitHub Copilot activity via the GitHub REST API. */
351
+ declare class GitHubCopilotParticipant extends NetworkParticipant {
352
+ participantSlug: string;
353
+ agentId: string;
354
+ agentType: string;
355
+ nativePath: string;
356
+ displayName: string;
357
+ private readonly maxResults;
358
+ constructor(opts?: NetworkParticipantOptions & {
359
+ maxResults?: number;
360
+ });
361
+ static defaultNativePath(): string;
362
+ fetchPayload(token: string): Record<string, unknown>;
363
+ payloadToL5(payload: Record<string, unknown>): L5ManifestModel;
364
+ }
365
+
366
+ /**
367
+ * Cursor participant — reads Cursor's (the AI-first IDE) SQLite-backed
368
+ * workspace/composer state and normalizes it into L5. Port of
369
+ * `participants/cursor.py` + the extraction helper `participants/_cursor_sqlite.py`.
370
+ *
371
+ * Cursor stores workspace state in `state.vscdb` SQLite DBs at platform-specific
372
+ * paths (`~/.config/Cursor/`, `~/Library/Application Support/Cursor/`,
373
+ * `%APPDATA%/Cursor/`). This reader discovers those stores, reads the `ItemTable`
374
+ * key/value rows read-only, parses the composer/chat records into sessions +
375
+ * project/topic entities, and merges curated `.cursor/memory/short-index.json`
376
+ * entities alongside them.
377
+ *
378
+ * SQLite access: the Python oracle copies each DB (+ its `-wal`/`-shm`
379
+ * companions) to a tmp file and opens it read-write so SQLite folds the WAL into
380
+ * a consistent snapshot. The TS mirror instead leans on {@link tryOpenReadonly}
381
+ * (`mode=ro`), which respects SQLite locking and reads the `-wal` sidecar of a
382
+ * live writer — the same consistent view without the copy. Read-only,
383
+ * deterministic, visibility-enforced-before-emission, redaction on every native
384
+ * string; `healthCheck` never throws.
385
+ */
386
+
387
+ /** External participant for Cursor's SQLite workspace state. */
388
+ declare class CursorParticipant implements BourdonParticipant {
389
+ agentId: string;
390
+ agentType: string;
391
+ private readonly cursorDir;
392
+ private readonly workspaceRoot;
393
+ private readonly policy;
394
+ /**
395
+ * Conventional Cursor config dir (`~/.cursor`) used by the setup wizard. The
396
+ * wizard probes `~/.cursor` for presence; the SQLite workspace state that
397
+ * `exportL5` actually reads lives at {@link defaultCursorDir}. Detection and
398
+ * extraction intentionally use different anchors.
399
+ */
400
+ static defaultNativePath(home?: string): string;
401
+ constructor(cursorDir?: string | null, workspaceRoot?: string | null);
402
+ get nativePath(): string;
403
+ discover(): AgentStore;
404
+ exportSessions(since?: Date, limit?: number): SessionModel[];
405
+ exportL5(since?: Date): L5ManifestModel;
406
+ healthCheck(): HealthStatus;
407
+ private extract;
408
+ }
409
+
410
+ /**
411
+ * GitHub Copilot (local convention) participant — reads the convention-based
412
+ * memory file at `~/.copilot-bourdon/memory.md`. Port of `participants/copilot.py`.
413
+ *
414
+ * Copilot has no accessible local session index (its reasoning is cloud-side and
415
+ * its native memory is not exposed on disk), so — like the Codex pre-distillation
416
+ * fallback — this reader normalizes a user-maintained convention file into a
417
+ * Bourdon L5 manifest. The file is YAML front-matter (structured `entities:` /
418
+ * `sessions:`) followed by an optional freeform markdown body that Copilot Chat
419
+ * reads as plain context but this reader ignores.
420
+ *
421
+ * NOT the cloud GitHub-Copilot network adapter ({@link GitHubCopilotParticipant})
422
+ * and NOT the Copilot CLI SQLite reader.
423
+ *
424
+ * Paths checked (in order):
425
+ * 1. `COPILOT_BOURDON_HOME` env-var override
426
+ * 2. `~/.copilot-bourdon/` (default convention path)
427
+ *
428
+ * Defensive throughout: a missing convention directory raises
429
+ * {@link ParticipantDiscoveryError} from `discover()`; malformed YAML degrades to
430
+ * an empty manifest rather than raising; `healthCheck` never throws.
431
+ */
432
+
433
+ /**
434
+ * External participant for GitHub Copilot via `~/.copilot-bourdon/memory.md`.
435
+ * Implements {@link BourdonParticipant} structurally.
436
+ */
437
+ declare class CopilotParticipant implements BourdonParticipant {
438
+ agentId: string;
439
+ agentType: string;
440
+ displayName: string;
441
+ nativePath: string;
442
+ /** Conventional `~/.copilot-bourdon` dir used by the setup wizard's detection. */
443
+ static defaultNativePath(home?: string): string;
444
+ private readonly copilotDir;
445
+ constructor(copilotDir?: string | null);
446
+ discover(): AgentStore;
447
+ exportSessions(since?: Date, limit?: number): SessionModel[];
448
+ exportL5(since?: Date): L5ManifestModel;
449
+ healthCheck(): HealthStatus;
450
+ private read;
451
+ }
452
+
453
+ /**
454
+ * GitHub Copilot CLI participant — normalize the `copilot` terminal agent's
455
+ * SQLite session store into L5. Port of `participants/copilot_cli.py`.
456
+ *
457
+ * Copilot CLI stores session history in a SQLite database at
458
+ * `~/.copilot/session-store.db` (override `$COPILOT_CLI_HOME`). This is distinct
459
+ * from:
460
+ * - the VS Code Copilot Chat extension (`github-copilot` network reader)
461
+ * - the `~/.copilot-bourdon/memory.md` convention-file participant (`copilot`)
462
+ * - GitHub-embedded Copilot (no local state)
463
+ *
464
+ * The schema (schema_version 4) carries `sessions` / `turns` / `checkpoints`
465
+ * plus `session_files` / `session_refs` / `dynamic_context_items`. The reader
466
+ * opens the DB read-only (`mode=ro` via {@link tryOpenReadonly}) so a live
467
+ * writer's lock can never block the export, probes each table defensively (a
468
+ * missing table degrades to "no rows" rather than raising), redacts every native
469
+ * string, applies the visibility filter BEFORE emission, and is deterministic.
470
+ * `healthCheck` never throws.
471
+ */
472
+
473
+ /**
474
+ * External participant for GitHub Copilot CLI (`~/.copilot/session-store.db`).
475
+ * Reads the SQLite database read-only (never locks the live db).
476
+ */
477
+ declare class CopilotCliParticipant implements BourdonParticipant {
478
+ agentId: string;
479
+ agentType: string;
480
+ displayName: string;
481
+ nativePath: string;
482
+ private readonly copilotDir;
483
+ /** Conventional `~/.copilot` dir used by the setup wizard's detection. */
484
+ static defaultNativePath(home?: string): string;
485
+ constructor(copilotDir?: string);
486
+ discover(): AgentStore;
487
+ exportSessions(since?: Date, limit?: number): SessionModel[];
488
+ exportL5(since?: Date): L5ManifestModel;
489
+ healthCheck(): HealthStatus;
490
+ private emptyManifest;
491
+ }
492
+
493
+ /**
494
+ * Cascade (Windsurf) participant — convention-file reader. Port of
495
+ * `participants/cascade.py`.
496
+ *
497
+ * Cascade's internal state is not exposed on the filesystem in a standardized
498
+ * format (like cloud Copilot). Instead this participant uses a CONVENTION FILE:
499
+ * Cascade maintains a structured memory file at `~/.cascade-bourdon/memory.md`
500
+ * with YAML front-matter carrying `entities` + `sessions`. Cascade owns that
501
+ * projection explicitly (it writes what it knows at session end); the
502
+ * participant normalizes the front-matter into an L5 manifest for federation.
503
+ *
504
+ * Privacy: entity/session summaries pass through the redaction SSOT; the
505
+ * visibility policy (private_tags) filters PRIVATE entities before emission.
506
+ */
507
+
508
+ /**
509
+ * Convention-based Bourdon participant for Cascade (Windsurf). Reads structured
510
+ * memory from `~/.cascade-bourdon/memory.md` and normalizes it into L5.
511
+ */
512
+ declare class CascadeParticipant implements BourdonParticipant {
513
+ agentId: string;
514
+ agentType: string;
515
+ displayName: string;
516
+ private readonly dir;
517
+ private readonly policy;
518
+ static defaultNativePath(home?: string): string;
519
+ constructor(cascadeDir?: string, policy?: VisibilityPolicyModel);
520
+ /** Path to the Cascade-Bourdon convention directory. */
521
+ get nativePath(): string;
522
+ private memoryPath;
523
+ private readFrontmatter;
524
+ discover(): AgentStore;
525
+ exportL5(since?: Date): L5ManifestModel;
526
+ exportSessions(since?: Date, limit?: number): SessionModel[];
527
+ healthCheck(): HealthStatus;
528
+ }
529
+
530
+ /**
531
+ * OpenClaw participant — network-shaped, QUARANTINED-CLASS. Port of
532
+ * `participants/openclaw.py` (v0.9.0, spec R4/D9).
533
+ *
534
+ * OpenClaw is the highest-demand adapter target in the ecosystem and also its
535
+ * highest-risk agent class: CVE-2026-25253 (one-click RCE, CVSS 8.8, first
536
+ * patched in 2026.1.29), tens of thousands of internet-exposed instances (~93%
537
+ * without authentication), ClawHub's malicious-skill problem, and auth disabled
538
+ * by default on port 8080. Bourdon therefore treats OpenClaw differently from
539
+ * every on-disk participant:
540
+ *
541
+ * 1. **Network-shaped** — state is read from the OpenClaw instance's local
542
+ * HTTP API, not on-disk artifacts. Because the {@link BourdonParticipant}
543
+ * contract is SYNCHRONOUS (`discover`/`exportL5` return values, not
544
+ * Promises) and `fetch` is async, the reads go through a tiny synchronous
545
+ * `curl` shell-out (the same idiom as the github-copilot reader).
546
+ * 2. **Hard handshake gate** — {@link OpenClawParticipant.discover} refuses to
547
+ * talk to an instance that is unpatched (< 2026.1.29) or has authentication
548
+ * disabled. These are refusals with exact reasons AND fixes, not warnings,
549
+ * and every read re-runs the gate.
550
+ * 3. **Quarantined-class** — `quarantinedClass = true`: registering the agent
551
+ * trusted requires `--i-understand-the-risk`, and exports stage for
552
+ * operator review (spec D6: quarantine follows the content, not the
553
+ * invoker). Its content federates under TEAM, never PUBLIC.
554
+ *
555
+ * We gate on instance hygiene (version, auth) — NOT on auditing the user's
556
+ * installed skills; that's ClawSecure et al.'s job (spec non-goal 3).
557
+ */
558
+
559
+ /** First OpenClaw release that patches CVE-2026-25253 (one-click RCE). */
560
+ declare const MIN_PATCHED_VERSION = "2026.1.29";
561
+ /**
562
+ * Hard handshake preconditions (spec D9). Returns the version on success.
563
+ * Raises {@link ParticipantDiscoveryError} with the exact reason AND the fix —
564
+ * these are refusals, not warnings.
565
+ */
566
+ declare function verifyInstance(status: Record<string, unknown>, url: string): string;
567
+ /**
568
+ * Minimal HTTP client for a local OpenClaw instance. Read-only: status,
569
+ * sessions, memories. Failures raise {@link ParticipantDiscoveryError} with the
570
+ * reason — the participant decides how to surface them.
571
+ *
572
+ * Error mapping (faithful to the Python `urllib` client): an HTTP >= 400
573
+ * response -> "returned HTTP {code}"; a transport failure / timeout / non-JSON
574
+ * body -> "instance unreachable at {url}".
575
+ */
576
+ declare class OpenClawApiClient {
577
+ readonly url: string;
578
+ private readonly token;
579
+ readonly timeout: number;
580
+ constructor(url: string, token?: string, timeout?: number);
581
+ private get;
582
+ status(): Record<string, unknown>;
583
+ sessions(): Record<string, unknown>[];
584
+ memories(): Record<string, unknown>[];
585
+ /** Shared `sessions()`/`memories()` body: try/except-returns-[], unwrap the
586
+ * `{ "<key>": [...] }` envelope, and keep only object rows. */
587
+ private readCollection;
588
+ }
589
+ /** Bourdon participant for OpenClaw (quarantined class). */
590
+ declare class OpenClawParticipant implements BourdonParticipant {
591
+ agentId: string;
592
+ agentType: string;
593
+ displayName: string;
594
+ /** Trust marker consumed by `bourdon agent add/set-tier` + export-all:
595
+ * registering as trusted needs --i-understand-the-risk; exports stage. */
596
+ quarantinedClass: boolean;
597
+ readonly url: string;
598
+ private readonly client;
599
+ static defaultNativePath(home?: string): string;
600
+ constructor(url?: string, token?: string, client?: OpenClawApiClient);
601
+ get nativePath(): string;
602
+ discover(): AgentStore;
603
+ exportSessions(since?: Date, limit?: number): SessionModel[];
604
+ exportL5(since?: Date): L5ManifestModel;
605
+ healthCheck(): HealthStatus;
606
+ }
607
+
608
+ /**
609
+ * Participant discovery — a STATIC TS registry replacing Python's `pkgutil`
610
+ * package scan + entry-point duck-type (`participants/__init__.py`).
611
+ *
612
+ * Python scans the `participants/` package at runtime and duck-types each class
613
+ * by `_PARTICIPANT_MARKER_ATTRS`. A filesystem package scan does not survive
614
+ * bundling (`npx bourdon` is a single file), so the JS side declares an explicit
615
+ * {@link FIRST_PARTY} array. The three preserved invariants:
616
+ * - output sorted by `agentId`
617
+ * - first-wins dedupe on `agentId`
618
+ * - log-and-skip a participant that throws on construction (one broken reader
619
+ * must NOT abort discovery / crash the CLI)
620
+ *
621
+ * The marker-attr duck-typing collapses into the {@link BourdonParticipant}
622
+ * interface conformance (checked structurally via {@link isParticipant}).
623
+ */
624
+
625
+ /** A zero-arg-constructible participant class. */
626
+ type ParticipantCtor = new () => BourdonParticipant;
627
+ /**
628
+ * The first-party reader registry. Order here is irrelevant — discovery sorts by
629
+ * `agentId`. (cursor / copilot-cli are the heavier SQLite readers; copilot is the
630
+ * convention-file reader; cascade reads Windsurf; openclaw is the quarantined-
631
+ * class network reader. codex — the ~2.6k-line turn-compiler reader — is still
632
+ * deferred.)
633
+ */
634
+ declare const FIRST_PARTY: ParticipantCtor[];
635
+ /**
636
+ * Instantiate each registered participant, duck-type the contract, sort by
637
+ * `agentId`, and first-wins dedupe. A class that throws on construction is
638
+ * logged and skipped — never propagated.
639
+ */
640
+ declare function discoverParticipants(ctors?: ParticipantCtor[]): BourdonParticipant[];
641
+ /**
642
+ * Optional Layer 2: third-party plugins declared via a `package.json`
643
+ * `"bourdon": { participants: { ... } }` field. Gated behind `BOURDON_PLUGINS=1`
644
+ * and a no-op today (no external participant exists yet) — the resolver ships so
645
+ * the seam is wired, defaulted off so `npx bourdon` stays predictable.
646
+ */
647
+ declare function resolvePluginParticipants(): ParticipantCtor[];
648
+
649
+ export { type AgentStore, type AuthProvider, type BourdonParticipant, CONTRACT_VERSION, CacheEntry, CascadeParticipant, ClaudeCodeParticipant, CopilotCliParticipant, CopilotParticipant, CursorParticipant, DEFAULT_CACHE_TTL_SECONDS, FIRST_PARTY, GitHubCopilotParticipant, type HealthStatus, HermesParticipant, MIN_PATCHED_VERSION, NETWORK_CONTRACT_VERSION, NetworkParticipant, type NetworkParticipantOptions, NetworkUnavailable, OpenClawApiClient, OpenClawParticipant, type OpenReadonlyOptions, ParticipantAuthError, type ParticipantCtor, ParticipantDiscoveryError, ParticipantError, ParticipantExportError, ParticipantVersionMismatchError, PayloadCache, SPEC_VERSION, type SqliteDatabase, defaultCacheRoot, discoverParticipants, envAuthProvider, epochToIsoDate, epochToIsoDatetime, friendlyLabel, ghTokenProvider, isParticipant, openReadonly, projectKeyFromCwd, resolvePluginParticipants, sqliteAvailable, tableColumns, tableExists, tryOpenReadonly, verifyInstance };