renor-engine 1.2.0 → 1.4.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 +34 -2
- package/THIRD-PARTY-NOTICES +2661 -0
- package/bin/renor-engine.cjs +38 -0
- package/dist/BUILD.json +6 -0
- package/dist/cli.js +1674 -516
- package/package.json +17 -80
- package/dist/.tsbuildinfo +0 -1
- package/dist/api/apiAuth.js +0 -43
- package/dist/api/server.js +0 -174
- package/dist/buildIdentity.js +0 -149
- package/dist/callPhases.js +0 -82
- package/dist/cli-extractors.js +0 -46
- package/dist/config.js +0 -65
- package/dist/context/composer.js +0 -320
- package/dist/context/readHonesty.js +0 -478
- package/dist/context/rowStore.js +0 -238
- package/dist/conversation/formatter.js +0 -81
- package/dist/conversation/parser.js +0 -193
- package/dist/conversation/types.js +0 -2
- package/dist/conversation/writer.js +0 -42
- package/dist/db/client.js +0 -149
- package/dist/db/handoffTable.js +0 -31
- package/dist/db/indexSalvage.js +0 -101
- package/dist/db/migrations.js +0 -670
- package/dist/db/readCache.js +0 -109
- package/dist/db/schema.js +0 -5
- package/dist/db/sqlite.js +0 -396
- package/dist/db/statements.js +0 -89
- package/dist/digests/digestCache.js +0 -146
- package/dist/digests/digests.js +0 -597
- package/dist/digests/worker.js +0 -350
- package/dist/embeddings/caching.js +0 -337
- package/dist/embeddings/coalescing.js +0 -177
- package/dist/embeddings/interactive.js +0 -103
- package/dist/embeddings/local.js +0 -70
- package/dist/embeddings/openai.js +0 -106
- package/dist/embeddings/rebuild.js +0 -166
- package/dist/embeddings/simdScan.js +0 -260
- package/dist/embeddings/space.js +0 -21
- package/dist/embeddings/types.js +0 -14
- package/dist/embeddings/vectorIndex.js +0 -674
- package/dist/embeddings/vertex.js +0 -334
- package/dist/eval/artifacts.js +0 -42
- package/dist/eval/cacheReport.js +0 -146
- package/dist/eval/comparison.js +0 -182
- package/dist/eval/context700-candidate.js +0 -145
- package/dist/eval/evalCache.js +0 -568
- package/dist/eval/hashEmbedding.js +0 -35
- package/dist/eval/indexSnapshots.js +0 -549
- package/dist/eval/longmemeval.js +0 -56
- package/dist/eval/metrics.js +0 -181
- package/dist/eval/pageDump.js +0 -67
- package/dist/eval/renorbenchBaseline.js +0 -486
- package/dist/eval/renorbenchDocuments.js +0 -134
- package/dist/eval/renorbenchProduct.js +0 -182
- package/dist/eval/runLedger.js +0 -279
- package/dist/eval/runManifest.js +0 -485
- package/dist/eval/scoring.js +0 -197
- package/dist/eval/textTokens.js +0 -17
- package/dist/evidence/attach.js +0 -264
- package/dist/evidence/background.js +0 -147
- package/dist/evidence/evidenceCache.js +0 -182
- package/dist/evidence/gate.js +0 -37
- package/dist/evidence/keyPool.js +0 -85
- package/dist/evidence/ollamaChat.js +0 -84
- package/dist/evidence/optin.js +0 -165
- package/dist/evidence/options.js +0 -151
- package/dist/evidence/secondPass.js +0 -294
- package/dist/extraction/classifyCapture.js +0 -34
- package/dist/extraction/decision-model.js +0 -174
- package/dist/extraction/eventExtractor.js +0 -113
- package/dist/extraction/extractionClient.js +0 -122
- package/dist/extraction/factExtractor.js +0 -46
- package/dist/extraction/factsWritePath.js +0 -179
- package/dist/extraction/jevDecisionModel.js +0 -307
- package/dist/extraction/preferenceExtractor.js +0 -150
- package/dist/extraction/secretGuard.js +0 -180
- package/dist/extraction/secretScanner.js +0 -665
- package/dist/extraction/typedFacts.js +0 -224
- package/dist/extraction/writePathAdjudication.js +0 -110
- package/dist/importing/apply.js +0 -672
- package/dist/importing/bundle-write.js +0 -80
- package/dist/importing/cli.js +0 -408
- package/dist/importing/existing.js +0 -51
- package/dist/importing/facts.js +0 -121
- package/dist/importing/forgetImported.js +0 -79
- package/dist/importing/hosted.js +0 -467
- package/dist/importing/journalLog.js +0 -96
- package/dist/importing/markdown.js +0 -98
- package/dist/importing/plan.js +0 -201
- package/dist/importing/secretScreen.js +0 -113
- package/dist/importing/serialize.js +0 -188
- package/dist/importing/source.js +0 -463
- package/dist/importing/types.js +0 -6
- package/dist/indexer/chunker.js +0 -319
- package/dist/indexer/dailyEntries.js +0 -63
- package/dist/indexer/hasher.js +0 -10
- package/dist/indexer/laneRuns.js +0 -48
- package/dist/indexer/o200k.js +0 -481
- package/dist/indexer/outsideRoot.js +0 -77
- package/dist/indexer/parser.js +0 -170
- package/dist/indexer/pipeline.js +0 -988
- package/dist/indexer/staleness.js +0 -201
- package/dist/indexer/tokenizer.js +0 -77
- package/dist/indexer/walker.js +0 -170
- package/dist/learning/cli.js +0 -113
- package/dist/learning/schema.js +0 -144
- package/dist/learning/settings.js +0 -45
- package/dist/learning/store.js +0 -267
- package/dist/learning/tap.js +0 -401
- package/dist/mcp/hive.js +0 -88
- package/dist/mcp/requestErrors.js +0 -47
- package/dist/mcp/server.js +0 -426
- package/dist/memory/agentLease.js +0 -43
- package/dist/memory/confinedWrite.js +0 -315
- package/dist/memory/controls.js +0 -73
- package/dist/memory/dailyNote.js +0 -265
- package/dist/memory/dreamer/adjudicate.js +0 -215
- package/dist/memory/dreamer/apply.js +0 -120
- package/dist/memory/dreamer/budget.js +0 -64
- package/dist/memory/dreamer/candidates.js +0 -149
- package/dist/memory/dreamer/collection.js +0 -104
- package/dist/memory/dreamer/dreamer.js +0 -352
- package/dist/memory/dreamer/review.js +0 -111
- package/dist/memory/durableAppend.js +0 -57
- package/dist/memory/factConflicts.js +0 -205
- package/dist/memory/factTerms.js +0 -321
- package/dist/memory/handoff.js +0 -363
- package/dist/memory/hiveNameHeader.cjs +0 -10
- package/dist/memory/inventory.js +0 -55
- package/dist/memory/invisibleText.js +0 -20
- package/dist/memory/lifecycle.js +0 -2014
- package/dist/memory/limits.js +0 -13
- package/dist/memory/requests.js +0 -183
- package/dist/memory/sourceName.js +0 -276
- package/dist/memory/statusFacts.js +0 -61
- package/dist/memory/whatsNew.js +0 -158
- package/dist/memory/writer.js +0 -176
- package/dist/memory/writerConflicts.js +0 -85
- package/dist/memorymap/memoryMap.js +0 -1594
- package/dist/memorymap/replacedJournal.js +0 -58
- package/dist/memorymap/replacements.js +0 -410
- package/dist/mvp/activity.js +0 -86
- package/dist/mvp/agentMemory.js +0 -1803
- package/dist/mvp/answerCheck.js +0 -211
- package/dist/mvp/auth.js +0 -531
- package/dist/mvp/cli.js +0 -86
- package/dist/mvp/client-store.js +0 -462
- package/dist/mvp/compileCache.js +0 -242
- package/dist/mvp/compileSeed.js +0 -33
- package/dist/mvp/config.js +0 -292
- package/dist/mvp/connectionStatus.js +0 -80
- package/dist/mvp/contextDistinct.js +0 -53
- package/dist/mvp/contextProfile.js +0 -87
- package/dist/mvp/contextRelevance.js +0 -413
- package/dist/mvp/directorySurface.js +0 -68
- package/dist/mvp/engine.js +0 -1078
- package/dist/mvp/exportAll.js +0 -393
- package/dist/mvp/factLanePack.js +0 -77
- package/dist/mvp/factMarkers.js +0 -65
- package/dist/mvp/factsLane.js +0 -203
- package/dist/mvp/hiddenSpans.js +0 -585
- package/dist/mvp/history.js +0 -414
- package/dist/mvp/hitDates.js +0 -31
- package/dist/mvp/hitFloor.js +0 -36
- package/dist/mvp/identity.js +0 -18
- package/dist/mvp/idle.js +0 -113
- package/dist/mvp/log.js +0 -118
- package/dist/mvp/memoryDir.js +0 -98
- package/dist/mvp/posthogMcp.js +0 -210
- package/dist/mvp/readScope.js +0 -104
- package/dist/mvp/readUsefulness.js +0 -222
- package/dist/mvp/sanitize.js +0 -48
- package/dist/mvp/schemaRejections.js +0 -91
- package/dist/mvp/scope.js +0 -127
- package/dist/mvp/server.js +0 -2712
- package/dist/mvp/serverCard.js +0 -38
- package/dist/mvp/storedSize.js +0 -139
- package/dist/mvp/telemetry.js +0 -474
- package/dist/net/poolFetch.js +0 -174
- package/dist/recall/actionRecall.js +0 -282
- package/dist/recall/autoRecall.js +0 -447
- package/dist/recall/searchRecall.js +0 -189
- package/dist/retrieval/adviceLines.js +0 -195
- package/dist/retrieval/adviceQuestion.js +0 -44
- package/dist/retrieval/conversationShape.js +0 -44
- package/dist/retrieval/dailyEntryTime.js +0 -55
- package/dist/retrieval/entityLookup.js +0 -162
- package/dist/retrieval/factsFirst.js +0 -188
- package/dist/retrieval/keyword.js +0 -84
- package/dist/retrieval/ledgerEventTime.js +0 -51
- package/dist/retrieval/ledgerLiveness.js +0 -83
- package/dist/retrieval/ledgerPresentation.js +0 -161
- package/dist/retrieval/noteIdentity.js +0 -57
- package/dist/retrieval/orchestrator.js +0 -1224
- package/dist/retrieval/plainWording.js +0 -236
- package/dist/retrieval/queryHelpers.js +0 -142
- package/dist/retrieval/questionSpan.js +0 -475
- package/dist/retrieval/rankingTrace.js +0 -184
- package/dist/retrieval/readerEvents.js +0 -690
- package/dist/retrieval/readerLayout.js +0 -422
- package/dist/retrieval/relativeTimeHints.js +0 -113
- package/dist/retrieval/semantic.js +0 -67
- package/dist/router/routerCache.js +0 -106
- package/dist/router/sessionRouter.js +0 -726
- package/dist/sharing/cli.js +0 -181
- package/dist/sharing/examples.js +0 -136
- package/dist/sharing/fields.js +0 -225
- package/dist/sharing/loop.js +0 -80
- package/dist/sharing/project.js +0 -327
- package/dist/sharing/send.js +0 -466
- package/dist/sharing/state.js +0 -222
- package/dist/sharing/wording.js +0 -48
- package/dist/toolRefusal.js +0 -120
- package/dist/watcher/watcher.js +0 -77
- /package/dist/{indexer/o200k.json → o200k.json} +0 -0
package/dist/sharing/state.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EXAMPLES_FILE = exports.STATE_FILE = exports.CONSENT_FILE = void 0;
|
|
7
|
-
exports.hostedEngine = hostedEngine;
|
|
8
|
-
exports.defaultSharingDir = defaultSharingDir;
|
|
9
|
-
exports.sharingDirFor = sharingDirFor;
|
|
10
|
-
exports.workspaceSharingDir = workspaceSharingDir;
|
|
11
|
-
exports.readConsent = readConsent;
|
|
12
|
-
exports.writeConsent = writeConsent;
|
|
13
|
-
exports.envOverride = envOverride;
|
|
14
|
-
exports.installLimit = installLimit;
|
|
15
|
-
exports.effectiveLevel = effectiveLevel;
|
|
16
|
-
exports.readState = readState;
|
|
17
|
-
exports.contributorId = contributorId;
|
|
18
|
-
exports.freshState = freshState;
|
|
19
|
-
exports.writeState = writeState;
|
|
20
|
-
exports.ensureState = ensureState;
|
|
21
|
-
exports.removeLocalSharingData = removeLocalSharingData;
|
|
22
|
-
const node_crypto_1 = require("node:crypto");
|
|
23
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
24
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
25
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
26
|
-
const fields_1 = require("./fields");
|
|
27
|
-
/**
|
|
28
|
-
* Where sharing keeps what it knows, and who may change it.
|
|
29
|
-
*
|
|
30
|
-
* Two small files in one owner-only folder (the sharing folder):
|
|
31
|
-
* sharing.json the consent record: the level, when it was chosen, the wording version the user saw, whether they
|
|
32
|
-
* attested to being an adult, and who set it. One per install (self-hosted) or per workspace (hosted).
|
|
33
|
-
* sharing-state.json what the sender needs between runs: the random secret that makes the contributor id, how far each row
|
|
34
|
-
* kind has been sent, and whether rows were ever sent (only then does `off` have anything to remove).
|
|
35
|
-
*
|
|
36
|
-
* No file exists until a user picks a level above off. A folder where the user never chose has neither file, and reading its
|
|
37
|
-
* level is `off`. Off writes nothing: the record of an off choice is made only when there was a level to turn off.
|
|
38
|
-
*/
|
|
39
|
-
exports.CONSENT_FILE = 'sharing.json';
|
|
40
|
-
exports.STATE_FILE = 'sharing-state.json';
|
|
41
|
-
/** The text of examples a `data` choice keeps until it is sent; it lives next to the two files. */
|
|
42
|
-
exports.EXAMPLES_FILE = 'sharing-examples.sqlite';
|
|
43
|
-
/**
|
|
44
|
-
* Whether this engine runs behind the hosted gateway: the same rule as the service (mvp/config.ts reads MVP_GATEWAY_SECRET as
|
|
45
|
-
* gatewaySecret, and mvp/cli.ts starts the sender with hosted: Boolean(config.gatewaySecret)), so the CLI sends as the service does.
|
|
46
|
-
*/
|
|
47
|
-
function hostedEngine(env = process.env) {
|
|
48
|
-
return (env.MVP_GATEWAY_SECRET ?? '').trim() !== '';
|
|
49
|
-
}
|
|
50
|
-
/** The folder of a self-hosted install: RENOR_SHARING_DIR, else the user's config folder. */
|
|
51
|
-
function defaultSharingDir(env = process.env) {
|
|
52
|
-
const set = (env.RENOR_SHARING_DIR ?? '').trim();
|
|
53
|
-
if (set !== '')
|
|
54
|
-
return node_path_1.default.resolve(set);
|
|
55
|
-
const xdg = (env.XDG_CONFIG_HOME ?? '').trim();
|
|
56
|
-
return node_path_1.default.join(xdg !== '' ? node_path_1.default.resolve(xdg) : node_path_1.default.join(node_os_1.default.homedir(), '.config'), 'renor');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The sharing folder for a run: an explicit folder, else RENOR_SHARING_DIR, else the one inside the memory folder when there is
|
|
60
|
-
* one (a service, or a command given its memory folder: the choice is per memory folder, so per workspace), else the user's
|
|
61
|
-
* config folder (one choice per install).
|
|
62
|
-
*/
|
|
63
|
-
function sharingDirFor(memoryDir, env = process.env, explicit) {
|
|
64
|
-
if (explicit !== undefined && explicit.trim() !== '')
|
|
65
|
-
return node_path_1.default.resolve(explicit);
|
|
66
|
-
if ((env.RENOR_SHARING_DIR ?? '').trim() !== '')
|
|
67
|
-
return defaultSharingDir(env);
|
|
68
|
-
return memoryDir !== null ? workspaceSharingDir(memoryDir) : defaultSharingDir(env);
|
|
69
|
-
}
|
|
70
|
-
/** The folder of one hosted workspace: inside its memory folder, so it goes with the memory on deletion. */
|
|
71
|
-
function workspaceSharingDir(memoryDir) {
|
|
72
|
-
return node_path_1.default.join(node_path_1.default.resolve(memoryDir), '.memory-index', 'sharing');
|
|
73
|
-
}
|
|
74
|
-
function readJson(file) {
|
|
75
|
-
try {
|
|
76
|
-
return JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function writeJson(dir, name, value) {
|
|
83
|
-
node_fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
84
|
-
const file = node_path_1.default.join(dir, name);
|
|
85
|
-
const temp = node_path_1.default.join(dir, `.${name}.${process.pid}.${(0, node_crypto_1.randomBytes)(4).toString('hex')}.tmp`);
|
|
86
|
-
node_fs_1.default.writeFileSync(temp, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
87
|
-
node_fs_1.default.renameSync(temp, file);
|
|
88
|
-
}
|
|
89
|
-
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
90
|
-
/** The consent record, or null when none was made (or the file is unreadable: unreadable is never read as consent). */
|
|
91
|
-
function readConsent(dir) {
|
|
92
|
-
const raw = readJson(node_path_1.default.join(dir, exports.CONSENT_FILE));
|
|
93
|
-
if (!isRecord(raw) || raw.version !== 1 || !(0, fields_1.isSharingLevel)(raw.level))
|
|
94
|
-
return null;
|
|
95
|
-
const sources = ['cli', 'setup', 'dashboard', 'service'];
|
|
96
|
-
if (typeof raw.changedAt !== 'string' || typeof raw.wording !== 'string' || typeof raw.adult !== 'boolean')
|
|
97
|
-
return null;
|
|
98
|
-
if (typeof raw.source !== 'string' || !sources.includes(raw.source))
|
|
99
|
-
return null;
|
|
100
|
-
return {
|
|
101
|
-
version: 1,
|
|
102
|
-
level: raw.level,
|
|
103
|
-
changedAt: raw.changedAt,
|
|
104
|
-
wording: raw.wording,
|
|
105
|
-
adult: raw.adult,
|
|
106
|
-
source: raw.source,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function writeConsent(dir, record) {
|
|
110
|
-
writeJson(dir, exports.CONSENT_FILE, record);
|
|
111
|
-
}
|
|
112
|
-
/** `RENOR_SHARING`: off, signals or data. It can only lower what the record says, never raise it: consent needs a record. */
|
|
113
|
-
function envOverride(env = process.env) {
|
|
114
|
-
if ((env.DO_NOT_TRACK ?? '').trim() === '1')
|
|
115
|
-
return 'off';
|
|
116
|
-
const raw = (env.RENOR_SHARING ?? '').trim().toLowerCase();
|
|
117
|
-
if (raw === '')
|
|
118
|
-
return null;
|
|
119
|
-
if (!(0, fields_1.isSharingLevel)(raw))
|
|
120
|
-
throw new Error('RENOR_SHARING must be off, signals or data');
|
|
121
|
-
return raw;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* The install's own record (the one `renor setup` and a command without a memory folder write, in defaultSharingDir) as a
|
|
125
|
-
* limit on another sharing folder on this install, a workspace's: null when there is no install record, or when `dir` is that
|
|
126
|
-
* folder itself. It only ever lowers: a workspace with no record of its own stays off whatever the install says.
|
|
127
|
-
*/
|
|
128
|
-
function installLimit(dir, env = process.env) {
|
|
129
|
-
const installDir = defaultSharingDir(env);
|
|
130
|
-
if (node_path_1.default.resolve(dir) === installDir)
|
|
131
|
-
return null;
|
|
132
|
-
const record = readConsentCached(installDir);
|
|
133
|
-
if (record === null)
|
|
134
|
-
return null;
|
|
135
|
-
return record.adult ? record.level : 'off';
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* The level in force right now: the recorded level, lowered by the install's own record (the stricter of the two wins) and by
|
|
139
|
-
* the environment. An unreadable record, an under-age user or a missing attestation is `off`. Read from the files at each call
|
|
140
|
-
* (a stat tells whether they changed), so a choice made in another process takes effect on the next call, with no restart.
|
|
141
|
-
*/
|
|
142
|
-
function effectiveLevel(dir, env = process.env) {
|
|
143
|
-
const record = readConsentCached(dir);
|
|
144
|
-
let level = record === null || !record.adult ? 'off' : record.level;
|
|
145
|
-
const limit = installLimit(dir, env);
|
|
146
|
-
if (limit !== null)
|
|
147
|
-
level = (0, fields_1.lowerLevel)(level, limit);
|
|
148
|
-
const override = envOverride(env);
|
|
149
|
-
if (override !== null)
|
|
150
|
-
level = (0, fields_1.lowerLevel)(level, override);
|
|
151
|
-
return level;
|
|
152
|
-
}
|
|
153
|
-
const cache = new Map();
|
|
154
|
-
function readConsentCached(dir) {
|
|
155
|
-
const file = node_path_1.default.join(dir, exports.CONSENT_FILE);
|
|
156
|
-
let stamp;
|
|
157
|
-
try {
|
|
158
|
-
const stat = node_fs_1.default.statSync(file);
|
|
159
|
-
stamp = `${stat.mtimeMs}:${stat.size}:${stat.ino}`;
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
cache.delete(file);
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
const hit = cache.get(file);
|
|
166
|
-
if (hit && hit.stamp === stamp)
|
|
167
|
-
return hit.record;
|
|
168
|
-
const record = readConsent(dir);
|
|
169
|
-
cache.set(file, { stamp, record });
|
|
170
|
-
return record;
|
|
171
|
-
}
|
|
172
|
-
function readState(dir) {
|
|
173
|
-
const raw = readJson(node_path_1.default.join(dir, exports.STATE_FILE));
|
|
174
|
-
if (!isRecord(raw) || raw.version !== 1 || typeof raw.secret !== 'string' || raw.secret.length < 32)
|
|
175
|
-
return null;
|
|
176
|
-
const marks = isRecord(raw.watermarks) ? raw.watermarks : {};
|
|
177
|
-
const num = (value) => (typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : 0);
|
|
178
|
-
return {
|
|
179
|
-
version: 1,
|
|
180
|
-
secret: raw.secret,
|
|
181
|
-
watermarks: { retrieval: num(marks.retrieval), save: num(marks.save), session: num(marks.session) },
|
|
182
|
-
everSent: raw.everSent === true,
|
|
183
|
-
deletePending: raw.deletePending === true,
|
|
184
|
-
...pausedOf(raw.paused),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function pausedOf(raw) {
|
|
188
|
-
if (!isRecord(raw) || (raw.code !== 'sharing_closed' && raw.code !== 'consent_required'))
|
|
189
|
-
return {};
|
|
190
|
-
return { paused: { code: raw.code, at: typeof raw.at === 'number' && Number.isFinite(raw.at) ? raw.at : 0 } };
|
|
191
|
-
}
|
|
192
|
-
/** The public name of a contributor: the SHA-256 of its secret, in hex. The endpoint knows only this, never the secret. */
|
|
193
|
-
function contributorId(secret) {
|
|
194
|
-
return (0, node_crypto_1.createHash)('sha256').update(secret).digest('hex');
|
|
195
|
-
}
|
|
196
|
-
function freshState() {
|
|
197
|
-
return {
|
|
198
|
-
version: 1,
|
|
199
|
-
secret: (0, node_crypto_1.randomBytes)(32).toString('base64url'),
|
|
200
|
-
watermarks: { retrieval: 0, save: 0, session: 0 },
|
|
201
|
-
everSent: false,
|
|
202
|
-
deletePending: false,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function writeState(dir, state) {
|
|
206
|
-
writeJson(dir, exports.STATE_FILE, state);
|
|
207
|
-
}
|
|
208
|
-
/** The state, made on first use. Only a sender that has a level above off calls this. */
|
|
209
|
-
function ensureState(dir) {
|
|
210
|
-
const existing = readState(dir);
|
|
211
|
-
if (existing !== null)
|
|
212
|
-
return existing;
|
|
213
|
-
const made = freshState();
|
|
214
|
-
writeState(dir, made);
|
|
215
|
-
return made;
|
|
216
|
-
}
|
|
217
|
-
/** Removes the files sharing keeps (the record stays: it is the proof of what was chosen, and holds no row). */
|
|
218
|
-
function removeLocalSharingData(dir) {
|
|
219
|
-
for (const name of [exports.STATE_FILE, exports.EXAMPLES_FILE, `${exports.EXAMPLES_FILE}-wal`, `${exports.EXAMPLES_FILE}-shm`]) {
|
|
220
|
-
node_fs_1.default.rmSync(node_path_1.default.join(dir, name), { force: true });
|
|
221
|
-
}
|
|
222
|
-
}
|
package/dist/sharing/wording.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLI_WORDING_VERSION = exports.ADULT_LINE = void 0;
|
|
4
|
-
exports.wordingFor = wordingFor;
|
|
5
|
-
exports.fieldList = fieldList;
|
|
6
|
-
const fields_1 = require("./fields");
|
|
7
|
-
Object.defineProperty(exports, "CLI_WORDING_VERSION", { enumerable: true, get: function () { return fields_1.CLI_WORDING_VERSION; } });
|
|
8
|
-
/**
|
|
9
|
-
* The words the command line shows before it records a choice. The version id (CLI_WORDING_VERSION) is stored with the
|
|
10
|
-
* choice, so the record shows which words the user saw. Change the words, change the id.
|
|
11
|
-
*
|
|
12
|
-
* These are the command line's own words. They are not the privacy policy: the public wording (policy, terms, website) is the
|
|
13
|
-
* owner's and a lawyer's to approve and is not part of this file. docs/TELEMETRY.md has the same facts for reading offline.
|
|
14
|
-
*/
|
|
15
|
-
function wordingFor(level) {
|
|
16
|
-
const common = [
|
|
17
|
-
'Renor can learn from how its memory is used, if you choose to help. Off is the default and stays off unless you pick a level here.',
|
|
18
|
-
'',
|
|
19
|
-
'Nothing is sent until you choose. You can change this at any time with `renor-engine telemetry off`, and `renor-engine telemetry delete`',
|
|
20
|
-
'removes what Renor holds. Turning it off stops recording at once and asks Renor to delete what it holds, at once (backups can keep a',
|
|
21
|
-
'copy for up to 7 more days). A ranking setting already fitted from rows is not recalled; the next fit leaves yours out.',
|
|
22
|
-
'Sharing never changes your plan, quota or features. Renor keeps signal rows up to 12 months and text examples up to 6 months.',
|
|
23
|
-
'',
|
|
24
|
-
];
|
|
25
|
-
if (level === 'signals') {
|
|
26
|
-
return [
|
|
27
|
-
...common,
|
|
28
|
-
'LEVEL: share signals',
|
|
29
|
-
' Sent: anonymous labelled numbers, worked out inside your own data folder from the learning log: which kind of memory was returned,',
|
|
30
|
-
' in what position, with what score, and whether your AI then opened, cited, updated or retired it, with times rounded to the hour.',
|
|
31
|
-
' Never sent: memory text, queries, titles, names, file paths, memory ids, keys or your IP address stored with the rows.',
|
|
32
|
-
' Every field is listed by `renor-engine telemetry fields signals`, and `renor-engine telemetry preview` prints exactly what would be sent.',
|
|
33
|
-
].join('\n');
|
|
34
|
-
}
|
|
35
|
-
return [
|
|
36
|
-
...common,
|
|
37
|
-
'LEVEL: share data for training',
|
|
38
|
-
' Sent: everything in "share signals", plus the TEXT of the examples: the query behind a retrieval, the text of the memories it returned,',
|
|
39
|
-
' and the statements that were saved. Renor may use that text to train and evaluate its own models.',
|
|
40
|
-
' Memories can contain other people\'s personal data and information about you. A text that looks like a secret (key, password, token)',
|
|
41
|
-
' is left out, but no scanner is perfect: choose this only if you accept that.',
|
|
42
|
-
' Every field is listed by `renor-engine telemetry fields data`, and `renor-engine telemetry preview` prints exactly what would be sent.',
|
|
43
|
-
].join('\n');
|
|
44
|
-
}
|
|
45
|
-
exports.ADULT_LINE = 'I am 18 or older and I choose this myself.';
|
|
46
|
-
function fieldList(level) {
|
|
47
|
-
return (0, fields_1.fieldsAtLevel)(level).join('\n');
|
|
48
|
-
}
|
package/dist/toolRefusal.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Why an MCP tool refused a call: a CLOSED set of short, stable snake_case codes, one per refusal a caller
|
|
4
|
-
* can act on.
|
|
5
|
-
*
|
|
6
|
-
* Every failed tool call used to reach telemetry as `error_kind: "other"`, so one user's day read as "13 of
|
|
7
|
-
* 152 calls failed" with nothing to act on: no way to tell an over-long statement from an unknown memory id
|
|
8
|
-
* from a path that escapes the vault. `error_kind` says how the call ended (it is a dashboard field and its
|
|
9
|
-
* values never change); this says why it was refused, next to it, as `error_reason`.
|
|
10
|
-
*
|
|
11
|
-
* The rules this file exists to keep:
|
|
12
|
-
*
|
|
13
|
-
* - A code is a FIXED LITERAL from the list below. Nothing here is ever built from an argument, a statement,
|
|
14
|
-
* a file, an exception message or a path, so no code can carry what the user said or wrote.
|
|
15
|
-
* - The list is closed: `isToolErrorReason` is the only way a code reaches telemetry, so a free-form string
|
|
16
|
-
* (an exception message, say) is dropped rather than logged.
|
|
17
|
-
* - Refusal sites name their code where the refusal is decided, and the code travels out of band — in a
|
|
18
|
-
* WeakMap beside the thrown error, or beside a refusal result the tool builds itself — instead of being
|
|
19
|
-
* parsed back out of a message or added as a property. The error keeps the class, `name` and keys it had
|
|
20
|
-
* before; the message still goes to the agent; the code never leaves this vocabulary.
|
|
21
|
-
* - Anything with no better code gets `refused`; an unexpected throw gets `internal`.
|
|
22
|
-
*/
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.TOOL_ERROR_REASONS = void 0;
|
|
25
|
-
exports.isToolErrorReason = isToolErrorReason;
|
|
26
|
-
exports.refusal = refusal;
|
|
27
|
-
exports.markErrorReason = markErrorReason;
|
|
28
|
-
exports.refusalReason = refusalReason;
|
|
29
|
-
exports.markToolRefusal = markToolRefusal;
|
|
30
|
-
exports.toolRefusalOf = toolRefusalOf;
|
|
31
|
-
exports.TOOL_ERROR_REASONS = [
|
|
32
|
-
/** An unexpected throw: a defect, not a refusal. */
|
|
33
|
-
'internal',
|
|
34
|
-
/** A refusal with no more specific code in this set. */
|
|
35
|
-
'refused',
|
|
36
|
-
/** A required argument was absent or empty. */
|
|
37
|
-
'missing_argument',
|
|
38
|
-
/** An argument was present but unusable as sent. */
|
|
39
|
-
'invalid_argument',
|
|
40
|
-
/** A scope was not `global`, `scope:<slug>` or `project:<slug>`. */
|
|
41
|
-
'invalid_scope',
|
|
42
|
-
/** A field was longer than the bound that stores it (memory/limits.ts, lifecycle FIELD_LIMITS). */
|
|
43
|
-
'field_too_long',
|
|
44
|
-
/** Text that cannot be stored or framed as text: control characters, an unpaired surrogate, a NUL byte. */
|
|
45
|
-
'invalid_text',
|
|
46
|
-
/** A path that escapes the memory directory, hides a segment, crosses a symlink, or is not a memory. */
|
|
47
|
-
'unsafe_path',
|
|
48
|
-
/** The memory id named nothing (it may have been retired). */
|
|
49
|
-
'memory_not_found',
|
|
50
|
-
/** That memory was already retired. */
|
|
51
|
-
'memory_already_retired',
|
|
52
|
-
/** A restore would overwrite a file that now occupies the path. */
|
|
53
|
-
'restore_conflict',
|
|
54
|
-
/** A write would take counted Markdown over the workspace plan ceiling. */
|
|
55
|
-
'storage_limit',
|
|
56
|
-
/** An import batch or preview is unknown or has expired. */
|
|
57
|
-
'batch_not_found',
|
|
58
|
-
/** The batch was already applied, failed or undone; it cannot be applied again. */
|
|
59
|
-
'batch_already_applied',
|
|
60
|
-
/** The batch was larger than the import byte bounds allow. */
|
|
61
|
-
'import_too_large',
|
|
62
|
-
/** A file the import would not admit (not a Markdown file). */
|
|
63
|
-
'unsupported_import_format',
|
|
64
|
-
/** The batch named the same relative path twice. */
|
|
65
|
-
'duplicate_import_path',
|
|
66
|
-
/** Too many previews are pending in this workspace; apply or wait for one to expire. */
|
|
67
|
-
'too_many_previews',
|
|
68
|
-
/** The deployment cannot answer this way right now (no semantic search, no keyword index, no history). */
|
|
69
|
-
'capability_unavailable',
|
|
70
|
-
/** The same, while the index is being rebuilt: it answers again once that finishes. */
|
|
71
|
-
'capability_rebuilding',
|
|
72
|
-
/** A search query the keyword index could not read as a query. */
|
|
73
|
-
'invalid_query',
|
|
74
|
-
];
|
|
75
|
-
/** The only gate a code passes to reach telemetry: membership in the closed set, nothing else. */
|
|
76
|
-
function isToolErrorReason(value) {
|
|
77
|
-
return typeof value === 'string' && exports.TOOL_ERROR_REASONS.includes(value);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* The code an error carries, out of band: a WeakMap leaves no property to serialize, so the error keeps the
|
|
81
|
-
* identity it had before this vocabulary existed — its class, `name`, `message` and enumerable keys — and the
|
|
82
|
-
* code reaches telemetry only. Nothing about `String(err)`, a log line or an `instanceof` check changes.
|
|
83
|
-
*/
|
|
84
|
-
const errorReasons = new WeakMap();
|
|
85
|
-
/**
|
|
86
|
-
* Shorthand for the refusal sites: `throw refusal('invalid_scope', '…')`. The error is a PLAIN `Error`, exactly
|
|
87
|
-
* what the site threw before; only the message (unchanged) and the out-of-band code are kept.
|
|
88
|
-
*/
|
|
89
|
-
function refusal(reason, message) {
|
|
90
|
-
return markErrorReason(new Error(message), reason);
|
|
91
|
-
}
|
|
92
|
-
/** Records the code an error carries, out of band. Used by `refusal` and by an error class that names its own. */
|
|
93
|
-
function markErrorReason(err, reason) {
|
|
94
|
-
errorReasons.set(err, reason);
|
|
95
|
-
return err;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* The code an error carries, or undefined when it carries none.
|
|
99
|
-
*
|
|
100
|
-
* Read from the out-of-band WeakMap rather than a property, so an error class that already exists
|
|
101
|
-
* (LifecycleInputError, say) names its code without gaining a field and without losing its own identity to the
|
|
102
|
-
* callers that check `instanceof` — and no error ever grows a `reason` key a reply or a log line could show.
|
|
103
|
-
*/
|
|
104
|
-
function refusalReason(err) {
|
|
105
|
-
return err instanceof Error ? errorReasons.get(err) : undefined;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* A tool result built by a refusal path carries its code here, beside the result and never inside it: a
|
|
109
|
-
* WeakMap leaves no property to serialize, so the code cannot ride out to the agent, into a log line or into
|
|
110
|
-
* a remote sink by accident. The tool wrapper reads it and the code goes to telemetry only.
|
|
111
|
-
*/
|
|
112
|
-
const reasons = new WeakMap();
|
|
113
|
-
function markToolRefusal(result, reason) {
|
|
114
|
-
reasons.set(result, reason);
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
/** The code a refusal result carries, if any. */
|
|
118
|
-
function toolRefusalOf(result) {
|
|
119
|
-
return result !== null && typeof result === 'object' ? reasons.get(result) : undefined;
|
|
120
|
-
}
|
package/dist/watcher/watcher.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.startWatcher = startWatcher;
|
|
7
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const pipeline_1 = require("../indexer/pipeline");
|
|
11
|
-
const log_1 = require("../mvp/log");
|
|
12
|
-
const log = (0, log_1.createLogger)('engine');
|
|
13
|
-
function loadIgnorePatterns(vaultPath) {
|
|
14
|
-
try {
|
|
15
|
-
const raw = fs_1.default.readFileSync(path_1.default.join(vaultPath, '.semanticignore'), 'utf8');
|
|
16
|
-
return raw.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#'));
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function isIgnored(filePath, vaultPath, patterns) {
|
|
23
|
-
const rel = path_1.default.relative(vaultPath, filePath);
|
|
24
|
-
return patterns.some(p => {
|
|
25
|
-
const clean = p.replace(/\/$/, '');
|
|
26
|
-
return rel === clean || rel.startsWith(clean + '/') || rel.includes('/' + clean + '/') || rel.endsWith('/' + clean);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
// Below the vault, so a vault that itself sits under a folder of this name is still watched.
|
|
30
|
-
const WALKER_SKIPS = /(^|[\\/])(\.trash|\.memory-index|node_modules)([\\/]|$)/;
|
|
31
|
-
function startWatcher(vaultPath, db, options = {}) {
|
|
32
|
-
const ignorePatterns = loadIgnorePatterns(vaultPath);
|
|
33
|
-
const watcher = chokidar_1.default.watch(path_1.default.join(vaultPath, '**/*.md'), {
|
|
34
|
-
// The walker's rules, so the watcher never indexes what an index pass would leave out (retired notes under .trash,
|
|
35
|
-
// node_modules), and no symbolic link: the walker never lists one, and a link in the vault must not pull in a file
|
|
36
|
-
// outside it.
|
|
37
|
-
ignored: [/\.obsidian/, /\.semantic-memory/, (p) => WALKER_SKIPS.test(path_1.default.relative(vaultPath, p))],
|
|
38
|
-
followSymlinks: false,
|
|
39
|
-
persistent: true,
|
|
40
|
-
ignoreInitial: true,
|
|
41
|
-
awaitWriteFinish: { stabilityThreshold: 300, pollInterval: 100 },
|
|
42
|
-
});
|
|
43
|
-
const pending = new Map();
|
|
44
|
-
const handle = (filePath) => {
|
|
45
|
-
if (isIgnored(filePath, vaultPath, ignorePatterns))
|
|
46
|
-
return;
|
|
47
|
-
// The glob reports a link to a file as the file, and a FIFO named like a note as a note; the walker lists neither.
|
|
48
|
-
const st = fs_1.default.lstatSync(filePath, { throwIfNoEntry: false });
|
|
49
|
-
if (st && !st.isFile())
|
|
50
|
-
return;
|
|
51
|
-
if (pending.has(filePath))
|
|
52
|
-
clearTimeout(pending.get(filePath));
|
|
53
|
-
pending.set(filePath, setTimeout(async () => {
|
|
54
|
-
pending.delete(filePath);
|
|
55
|
-
try {
|
|
56
|
-
await (0, pipeline_1.indexFile)(db, filePath, options);
|
|
57
|
-
log.info('watcher_indexed', { file: path_1.default.relative(vaultPath, filePath) });
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
log.error('watcher_index_failed', { file: path_1.default.relative(vaultPath, filePath) }, err);
|
|
61
|
-
}
|
|
62
|
-
}, 500));
|
|
63
|
-
};
|
|
64
|
-
watcher
|
|
65
|
-
.on('add', handle)
|
|
66
|
-
.on('change', handle)
|
|
67
|
-
.on('unlink', (filePath) => {
|
|
68
|
-
if (isIgnored(filePath, vaultPath, ignorePatterns))
|
|
69
|
-
return;
|
|
70
|
-
db.transaction(() => {
|
|
71
|
-
db.prepare('DELETE FROM relations WHERE source_note = ?').run(filePath);
|
|
72
|
-
db.prepare('DELETE FROM notes WHERE path = ?').run(filePath);
|
|
73
|
-
})();
|
|
74
|
-
log.info('watcher_removed', { file: path_1.default.relative(vaultPath, filePath) });
|
|
75
|
-
});
|
|
76
|
-
return watcher;
|
|
77
|
-
}
|
|
File without changes
|