total-recall-brain 3.47.0 → 3.47.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.
- package/bin/total-recall.mjs +5 -0
- package/package.json +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/auth/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/auth/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/auth/plugin.json +30 -5
- package/scaffold/.agent/skills/total-recall/plugins/auth/skills/auth/SKILL.md +35 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/home.js +494 -79
- package/scaffold/.agent/skills/total-recall/plugins/automations/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/automations/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/automations/plugin.json +33 -8
- package/scaffold/.agent/skills/total-recall/plugins/automations/skills/automations/SKILL.md +29 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/dream-consolidation.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/plugin.json +31 -4
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/skills/code-quality/SKILL.md +27 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package.json +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/plugin.json +17 -3
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/plugin.json +24 -4
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/skills/embeddings/SKILL.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/git/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/git/plugin.json +293 -58
- package/scaffold/.agent/skills/total-recall/plugins/git/skills/git/SKILL.md +36 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/mesh/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/mesh/plugin.json +47 -14
- package/scaffold/.agent/skills/total-recall/plugins/mesh/skills/mesh/SKILL.md +36 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/cli.mjs +6 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package.json +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/plugin.json +5 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/cascade.mjs +4 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/coordinator.mjs +28 -9
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch.mjs +7 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/model-selection.mjs +59 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/remote-operation.mjs +3 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/router.mjs +9 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worker.mjs +50 -6
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/session-controls.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/cli.mjs +56 -7
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/package-lock.json +6 -6
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/plugin.json +199 -36
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/skills/openwiki/SKILL.md +32 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/config.mjs +34 -8
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/generate.mjs +6 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh.mjs +15 -7
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/upstream-watcher.mjs +4 -3
- package/scaffold/.agent/skills/total-recall/plugins/security/package-lock.json +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/security/package.json +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/security/plugin.json +22 -5
- package/scaffold/.agent/skills/total-recall/plugins/ssss/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/ssss/plugin.json +169 -37
- package/scaffold/.agent/skills/total-recall/plugins/ssss/skills/ssss/SKILL.md +30 -0
- package/src/cli/plugin/create.mjs +2 -1
- package/src/cli/plugin/monetization.mjs +66 -32
- package/src/cli/plugin/search.mjs +25 -3
- package/src/cli/preflight.mjs +40 -6
- package/src/core/gate-mode.mjs +13 -24
- package/src/core/plugin-distribution.mjs +35 -1
- package/src/core/preflight-gate.mjs +28 -8
- package/src/core/preflight-receipt.mjs +11 -0
|
@@ -12,7 +12,41 @@ function describePluginWithShare(plugin, projectRoot) {
|
|
|
12
12
|
return result;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
async function
|
|
15
|
+
async function resolveStoreBundle(id, { storeUrl = process.env.TR_STORE_URL || 'http://127.0.0.1:3000', fetchImpl = fetch, licenseKey } = {}) {
|
|
16
|
+
const base = storeUrl.replace(/\/+$/, '');
|
|
17
|
+
const headers = {};
|
|
18
|
+
const resolvedKey = licenseKey || process.env[`${id.toUpperCase().replace(/-/g, '_')}_LICENSE_KEY`] || process.env.TR_LICENSE_KEY;
|
|
19
|
+
if (resolvedKey) headers['x-license-key'] = resolvedKey;
|
|
20
|
+
const listRes = await fetchImpl(`${base}/api/store/plugins?q=${encodeURIComponent(id)}`);
|
|
21
|
+
if (!listRes.ok) throw new Error(`Store catalog unavailable (HTTP ${listRes.status})`);
|
|
22
|
+
const listData = await listRes.json();
|
|
23
|
+
const entry = (listData.plugins || []).find((p) => p.id === id);
|
|
24
|
+
if (!entry) throw new Error(`Plugin '${id}' not found in Store catalog`);
|
|
25
|
+
const bundleRes = await fetchImpl(`${base}/api/store/plugins/${encodeURIComponent(id)}/bundle`, { headers });
|
|
26
|
+
if (!bundleRes.ok) {
|
|
27
|
+
let reason = `HTTP ${bundleRes.status}`;
|
|
28
|
+
try { const err = await bundleRes.json(); if (err?.error) reason = err.error; } catch {}
|
|
29
|
+
throw new Error(`Store install denied for '${id}': ${reason}`);
|
|
30
|
+
}
|
|
31
|
+
const bundle = Buffer.from(await bundleRes.arrayBuffer());
|
|
32
|
+
const sha256 = bundleRes.headers?.get?.('x-plugin-sha256') || entry.sha256;
|
|
33
|
+
return { bundle, sha256, sourceRecord: { kind: 'store', ref: `store:${id}`, store_url: base }, expectedId: id };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function resolveBundle(source, { peerDeps, publicDeps, storeDeps } = {}) {
|
|
37
|
+
if (typeof source === 'string' && source.startsWith('store:')) {
|
|
38
|
+
const id = source.slice('store:'.length).trim();
|
|
39
|
+
if (!id) throw new Error('Missing plugin id in store:<id>');
|
|
40
|
+
const { bundle, sha256, sourceRecord, expectedId } = await resolveStoreBundle(id, storeDeps);
|
|
41
|
+
const decoded = decodeBundle(bundle, sha256 ? { expectedSha256: sha256 } : {});
|
|
42
|
+
const entry = decoded.entries.find(e => e.path === 'plugin.json');
|
|
43
|
+
if (!entry) throw new Error('Store plugin bundle has no plugin.json');
|
|
44
|
+
const manifest = JSON.parse(entry.data.toString('utf8'));
|
|
45
|
+
const validation = validatePluginManifest(manifest);
|
|
46
|
+
if (!validation.valid) throw new Error(`Invalid plugin manifest: ${validation.errors.join('; ')}`);
|
|
47
|
+
if (manifest.id !== expectedId) throw new Error(`Requested '${expectedId}' but bundle contained '${manifest.id}'`);
|
|
48
|
+
return { manifest, entries: decoded.entries, sha256: decoded.sha256, source: sourceRecord };
|
|
49
|
+
}
|
|
16
50
|
const peerModule = typeof source === 'string' && source.startsWith('peer:')
|
|
17
51
|
? await import('./plugin-peers.mjs') : null;
|
|
18
52
|
const peer = peerModule?.parsePeerSource(source);
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
* (`gate.router`). Reading, searching and native subagents stay open, as does any
|
|
30
30
|
* plain Total Recall command, so routing can always run. A process the router
|
|
31
31
|
* started has already been routed. It warns once per receipt, not on every call.
|
|
32
|
+
* 8. With a receipt, once the router has selected a harness for this repository, a write from
|
|
33
|
+
* any other harness is denied, whatever the mode. Only a run the router started may write
|
|
34
|
+
* for it. A selection lasts as long as a receipt, and routing again replaces it. A call with
|
|
35
|
+
* no named harness is not judged by this rule, because it cannot be told apart.
|
|
32
36
|
* Rules 6 and 7 follow a mode (see gate-mode.mjs): `off`, `warn` (the default) or `enforce`.
|
|
33
37
|
* `enforce` blocks only while the owner passes its health check, so a broken plugin can
|
|
34
38
|
* never trap an agent. Warnings are statements of fact, because harnesses treat
|
|
@@ -154,6 +158,13 @@ export function ackDirectory(command, cwd) {
|
|
|
154
158
|
return target ? path.resolve(cwd || process.cwd(), target.replace(/^(["'])([\s\S]*)\1$/, '$2')) : cwd;
|
|
155
159
|
}
|
|
156
160
|
|
|
161
|
+
export function isBlockedGrep(command) {
|
|
162
|
+
const text = runnableText(command);
|
|
163
|
+
if (/(^|[\s;&|(])(grep|egrep|fgrep|rg|ripgrep|ag)(\s|$)/.test(text)) return true;
|
|
164
|
+
if (/(^|[\s;&|(])git\s+grep(\s|$)/.test(text)) return true;
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
157
168
|
/** A repository-wide search used to answer a question, as the DSH `tr-first.sh` rule defined it. */
|
|
158
169
|
export function isRepoSweep(command) {
|
|
159
170
|
const c = String(command || '');
|
|
@@ -235,10 +246,7 @@ const staleness = (receipt) => (receipt.ageMs > receipt.limitMs
|
|
|
235
246
|
* What a rule that steers work toward a plugin does with a call it matched: nothing (null),
|
|
236
247
|
* a denial, or a warning to carry.
|
|
237
248
|
*/
|
|
238
|
-
function steer(deps, {
|
|
239
|
-
const mode = deps.mode ? deps.mode(kind, plugin) : DEFAULT_GATE_MODE;
|
|
240
|
-
if (mode === 'off') return null;
|
|
241
|
-
if (mode !== 'enforce') return { name, warning: note };
|
|
249
|
+
function steer(deps, { plugin, name, reason, note, use }) {
|
|
242
250
|
if (!deps.ownerHealthy || deps.ownerHealthy(plugin, use)) return deny(name, reason, use);
|
|
243
251
|
return { name, warning: `${note} The ${plugin} plugin failed its health check, so this call was not blocked.` };
|
|
244
252
|
}
|
|
@@ -287,7 +295,7 @@ export function whenGateFails(call, err) {
|
|
|
287
295
|
|
|
288
296
|
/**
|
|
289
297
|
* @param {{ tool: string, command?: string, path?: string, cwd?: string }} call
|
|
290
|
-
* @param {{ check: () => { ok: boolean, problems: string[], ageMs?: number|null, limitMs?: number }, recentConsult?: () => boolean, readablePaths?: RegExp[], ownedCommands?: () => { plugin: string, pattern: string, use: string }[], router?: () => ({ plugin: string, pattern: string, use: string } | null), routed?: (receipt: object) => boolean, routeWarned?: (receipt: object) => boolean, sessionAcknowledged?: (receipt: object) => boolean, sessionLapsed?: () => boolean, arrival?: () => (string | null), dispatched?: boolean, mode?: (kind: 'router'|'owned', plugin: string) => string, ownerHealthy?: (plugin: string, use: string) => boolean }} deps
|
|
298
|
+
* @param {{ check: () => { ok: boolean, problems: string[], ageMs?: number|null, limitMs?: number }, recentConsult?: () => boolean, readablePaths?: RegExp[], ownedCommands?: () => { plugin: string, pattern: string, use: string }[], router?: () => ({ plugin: string, pattern: string, use: string } | null), routed?: (receipt: object) => boolean, routeWarned?: (receipt: object) => boolean, sessionAcknowledged?: (receipt: object) => boolean, sessionLapsed?: () => boolean, arrival?: () => (string | null), dispatched?: boolean, harness?: string|null, routerRun?: boolean, selection?: (receipt: object) => ({ harness: string|null, at: number } | null), mode?: (kind: 'router'|'owned', plugin: string) => string, ownerHealthy?: (plugin: string, use: string) => boolean }} deps
|
|
291
299
|
*/
|
|
292
300
|
export function decide(call, deps) {
|
|
293
301
|
try {
|
|
@@ -313,14 +321,26 @@ export function decide(call, deps) {
|
|
|
313
321
|
: `this session has not acknowledged (directory: ${call.cwd || 'unknown'}). A receipt from another agent does not count.`;
|
|
314
322
|
return deny('receipt:session', `TR-PREFLIGHT gate: ${state} ${nextStep(call)}`);
|
|
315
323
|
}
|
|
316
|
-
if (tool === 'shell' &&
|
|
317
|
-
return deny('
|
|
324
|
+
if (tool === 'shell' && isBlockedGrep(call.command)) {
|
|
325
|
+
return deny('grep', 'TR-PREFLIGHT gate: `grep`/`rg`/`ag` is blocked. Use Total Recall OpenWiki (`total-recall openwiki` / `openwiki/`) or `total-recall recall "<topic>" --local` instead.',
|
|
326
|
+
'total-recall openwiki hubs --json');
|
|
327
|
+
}
|
|
328
|
+
if ((tool === 'search' || (tool === 'shell' && isRepoSweep(call.command))) && !(deps.recentConsult ? deps.recentConsult() : false)) {
|
|
329
|
+
return deny('sweep', 'TR-PREFLIGHT gate: do not sweep or search the repository before consulting Total Recall / OpenWiki. Run `total-recall openwiki hubs --json`, `total-recall recall "<topic>" --local`, or `total-recall help "<task>"` first.',
|
|
318
330
|
'total-recall help "<task>"');
|
|
319
331
|
}
|
|
332
|
+
const router = deps.router ? deps.router() : null;
|
|
333
|
+
if (tool === 'write' && deps.harness && !deps.routerRun) {
|
|
334
|
+
const chosen = deps.selection ? deps.selection(receipt) : null;
|
|
335
|
+
if (chosen?.harness && chosen.harness !== deps.harness) {
|
|
336
|
+
const by = router?.plugin || 'the router';
|
|
337
|
+
return deny('route:selected', `TR-PREFLIGHT gate: ${by} selected ${chosen.harness} for this task, so ${deps.harness} may not write here. Only a run ${by} started may write: hand the task over with its --execute form, or route it again.`,
|
|
338
|
+
router?.use || 'route the task again');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
320
341
|
const notes = [];
|
|
321
342
|
const arrival = deps.arrival ? deps.arrival() : null;
|
|
322
343
|
if (arrival) notes.push({ name: 'arrival', warning: arrival });
|
|
323
|
-
const router = deps.router ? deps.router() : null;
|
|
324
344
|
if (router && !deps.dispatched) {
|
|
325
345
|
const open = ['read', 'search', 'web', 'agent'].includes(tool) || (tool === 'shell' && isPlainTotalRecall(call.command));
|
|
326
346
|
if (!open && !(deps.routed ? deps.routed(receipt.receipt) : false)) {
|
|
@@ -339,6 +339,17 @@ export function lastRouteWarnedMs(root, { home = os.homedir(), session = null }
|
|
|
339
339
|
return readStamp(routeWarnedPath(root, home, session));
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
const selectionPath = (root, home) => path.join(stateDir(home), scoped('route-selected', root));
|
|
343
|
+
|
|
344
|
+
/** The harness the router chose for work in this repository, or null when it chose none. */
|
|
345
|
+
export function markRouteSelection(root, harness, { home = os.homedir(), now = Date.now() } = {}) {
|
|
346
|
+
writeBookkeeping(selectionPath(root, home), (target) => fs.writeFileSync(target, JSON.stringify({ at: now, harness: harness || null, root }), { mode: 0o600 }));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function lastRouteSelection(root, { home = os.homedir() } = {}) {
|
|
350
|
+
return newestRecord(selectionPath(root, home));
|
|
351
|
+
}
|
|
352
|
+
|
|
342
353
|
const sessionAckPath = (session, home) => path.join(stateDir(home), `session-ack-${sessionKey(session)}.stamp`);
|
|
343
354
|
const delegatedPath = (root, home) => path.join(stateDir(home), scoped('delegated', root));
|
|
344
355
|
|