bare-agent 0.12.2 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Build a curated bridge config that mounts litectx-mcp read-only on its own db.
3
+ * @param {object} opts
4
+ * @param {string} opts.root - the child's OWN litectx root/db (passed as `--root`). Isolation.
5
+ * @param {string} [opts.command='litectx-mcp'] - the server command (override for a fake/abs path).
6
+ * @param {string[]} [opts.args=[]] - extra args appended after `--root <root>` (e.g. `--no-embeddings`).
7
+ * @param {boolean} [opts.writable=false] - opt-in: allow remember/forget (still child-db-local).
8
+ * @param {string} [opts.name='litectx'] - server name (tool prefix → `<name>_recall`, …).
9
+ * @param {string} [opts.ttl='24h'] - bridge config TTL.
10
+ * @param {string} [opts.now] - ISO timestamp for `discovered` (default: now). Pre-seed fresh so
11
+ * `createMCPBridge` skips IDE discovery and connects straight to this curated server.
12
+ * @returns {import('../src/mcp-bridge').BridgeConfig}
13
+ */
14
+ export function liteCtxMcpBridgeConfig(opts: {
15
+ root: string;
16
+ command?: string | undefined;
17
+ args?: string[] | undefined;
18
+ writable?: boolean | undefined;
19
+ name?: string | undefined;
20
+ ttl?: string | undefined;
21
+ now?: string | undefined;
22
+ }): import("../src/mcp-bridge").BridgeConfig;
23
+ /** Read/reason verbs a child is given by default. */
24
+ export const READ_VERBS: string[];
25
+ /** Write verbs — denied unless `writable`, then allowed (writes still land in the child's OWN db). */
26
+ export const WRITE_VERBS: string[];
27
+ /** Admin/review verbs — always denied to a child (human/hook + review flows). */
28
+ export const ADMIN_VERBS: string[];
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ // RT-4 — mount litectx-mcp into a child agent, read-only, on its own db. A thin recipe helper: it
4
+ // builds the curated `.mcp-bridge.json` config that `createMCPBridge` consumes, so a parent composing
5
+ // a child's toolbox can't fat-finger the allow-list (e.g. accidentally allow a write verb). It encodes
6
+ // ONE thing — the agreed read-only default (PRD §4.2) — and knows only litectx-mcp's public verb names
7
+ // (the same strings a hand-written `.mcp-bridge.json` would carry). It does NOT import litectx: the
8
+ // dependency direction stays one-way; this is config curation, bareagent's job.
9
+ //
10
+ // Default toolbox (PRD §4.2):
11
+ // recall · get · impact · recent → allow (read / reason — the point of giving a child memory)
12
+ // remember · forget → deny (agent writes are by:"agent", suspect-until-curated;
13
+ // flip with { writable: true } as the explicit opt-in)
14
+ // index · promotions → deny (index is human/hook-driven; promotions is a review flow)
15
+ //
16
+ // Isolation is OWN-DB, not a scope column (this is what decouples RT-4 from RT-5): the child gets its
17
+ // own `--root` → physical isolation, zero schema change. An opted-in child's writes land in ITS db;
18
+ // promotion to the parent is an explicit parent-side `recall`→`remember`, never automatic.
19
+
20
+ /** Read/reason verbs a child is given by default. */
21
+ const READ_VERBS = ['recall', 'get', 'impact', 'recent'];
22
+ /** Write verbs — denied unless `writable`, then allowed (writes still land in the child's OWN db). */
23
+ const WRITE_VERBS = ['remember', 'forget'];
24
+ /** Admin/review verbs — always denied to a child (human/hook + review flows). */
25
+ const ADMIN_VERBS = ['index', 'promotions'];
26
+
27
+ /**
28
+ * Build a curated bridge config that mounts litectx-mcp read-only on its own db.
29
+ * @param {object} opts
30
+ * @param {string} opts.root - the child's OWN litectx root/db (passed as `--root`). Isolation.
31
+ * @param {string} [opts.command='litectx-mcp'] - the server command (override for a fake/abs path).
32
+ * @param {string[]} [opts.args=[]] - extra args appended after `--root <root>` (e.g. `--no-embeddings`).
33
+ * @param {boolean} [opts.writable=false] - opt-in: allow remember/forget (still child-db-local).
34
+ * @param {string} [opts.name='litectx'] - server name (tool prefix → `<name>_recall`, …).
35
+ * @param {string} [opts.ttl='24h'] - bridge config TTL.
36
+ * @param {string} [opts.now] - ISO timestamp for `discovered` (default: now). Pre-seed fresh so
37
+ * `createMCPBridge` skips IDE discovery and connects straight to this curated server.
38
+ * @returns {import('../src/mcp-bridge').BridgeConfig}
39
+ */
40
+ function liteCtxMcpBridgeConfig(opts) {
41
+ if (!opts || typeof opts.root !== 'string' || !opts.root) {
42
+ throw new Error('[litectx-mcp] requires opts.root (the child\'s own db root — own-db isolation)');
43
+ }
44
+ const { root, command = 'litectx-mcp', args = [], writable = false, name = 'litectx', ttl = '24h', now } = opts;
45
+
46
+ /** @type {Record<string, string>} */
47
+ const tools = {};
48
+ for (const v of READ_VERBS) tools[v] = 'allow';
49
+ for (const v of WRITE_VERBS) tools[v] = writable ? 'allow' : 'deny';
50
+ for (const v of ADMIN_VERBS) tools[v] = 'deny';
51
+
52
+ return {
53
+ discovered: now || new Date().toISOString(),
54
+ ttl,
55
+ servers: {
56
+ [name]: {
57
+ command,
58
+ args: ['--root', root, ...args],
59
+ tools,
60
+ },
61
+ },
62
+ };
63
+ }
64
+
65
+ module.exports = { liteCtxMcpBridgeConfig, READ_VERBS, WRITE_VERBS, ADMIN_VERBS };