@remnic/core 9.66.10 → 9.66.11
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/dist/access-admin-ops-surface.js +2 -1
- package/dist/access-authorization-probe.js +2 -1
- package/dist/access-boundary.js +2 -1
- package/dist/access-cli.js +8 -7
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +2 -1
- package/dist/access-http-query.js +2 -1
- package/dist/access-http.js +2 -1
- package/dist/access-identity-continuity-surface.js +2 -1
- package/dist/access-lcm-surface.js +2 -1
- package/dist/access-mcp.js +2 -1
- package/dist/access-namespace-preflight.js +2 -1
- package/dist/access-observe-write-surface.js +2 -1
- package/dist/access-operations-batch.js +2 -1
- package/dist/access-operations.js +2 -1
- package/dist/access-recall-concurrency.js +2 -1
- package/dist/access-recall-response.js +2 -1
- package/dist/access-recall-surface.js +2 -1
- package/dist/access-service.js +2 -1
- package/dist/access-surface-catalog.js +2 -1
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/causal-consolidation.js +3 -2
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/chunk-3UXOZBHV.js +20 -0
- package/dist/chunk-3UXOZBHV.js.map +1 -0
- package/dist/{chunk-YYDOUOYM.js → chunk-6H7JWYTC.js} +16 -11
- package/dist/chunk-6H7JWYTC.js.map +1 -0
- package/dist/{chunk-KWVXCRFZ.js → chunk-BCM6ZAJ3.js} +4 -4
- package/dist/{chunk-TXCLDIXJ.js → chunk-K6PWPC7O.js} +2 -2
- package/dist/{chunk-M2BY5IZL.js → chunk-PVV42HM4.js} +5 -2
- package/dist/chunk-PVV42HM4.js.map +1 -0
- package/dist/{chunk-VSQG4AXL.js → chunk-PWVRMD37.js} +1 -1
- package/dist/{chunk-NR36NW24.js → chunk-UWOA5L6N.js} +40 -43
- package/dist/{chunk-NR36NW24.js.map → chunk-UWOA5L6N.js.map} +1 -1
- package/dist/{chunk-ZPZLGN4Y.js → chunk-XZ7QLOTJ.js} +4 -20
- package/dist/chunk-XZ7QLOTJ.js.map +1 -0
- package/dist/cli.js +5 -4
- package/dist/coding/export-okf-codegraph.js +1 -1
- package/dist/compounding/engine.js +1 -1
- package/dist/connectors/codex-materialize-runner.js +2 -1
- package/dist/connectors/index.js +2 -1
- package/dist/external-wiki-access.js +2 -1
- package/dist/extraction.js +2 -1
- package/dist/index.js +8 -7
- package/dist/orchestrator.js +8 -7
- package/dist/semantic-consolidation.js +3 -2
- package/dist/source-agent-qualifier.js +2 -1
- package/dist/support-passport/index.js +2 -1
- package/dist/transfer/export-okf.d.ts +8 -0
- package/dist/transfer/export-okf.js +3 -2
- package/package.json +2 -2
- package/src/cli/okf-commands.ts +2 -5
- package/src/okf/render.ts +11 -2
- package/src/transfer/export-okf.test.ts +77 -1
- package/src/transfer/export-okf.ts +25 -9
- package/dist/chunk-M2BY5IZL.js.map +0 -1
- package/dist/chunk-YYDOUOYM.js.map +0 -1
- package/dist/chunk-ZPZLGN4Y.js.map +0 -1
- /package/dist/{chunk-KWVXCRFZ.js.map → chunk-BCM6ZAJ3.js.map} +0 -0
- /package/dist/{chunk-TXCLDIXJ.js.map → chunk-K6PWPC7O.js.map} +0 -0
- /package/dist/{chunk-VSQG4AXL.js.map → chunk-PWVRMD37.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/okf/lint.ts","../src/okf/render.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { MAGIC_BYTES } from \"../secure-store/secure-fs.js\";\nimport { OKF_RESERVED_BASENAMES } from \"./type-mapping.js\";\n\nexport interface OkfLintFinding {\n file: string;\n code: \"missing_frontmatter\" | \"missing_type\" | \"empty_type\" | \"reserved_basename\" | \"skipped_encrypted\";\n message: string;\n}\n\nexport interface OkfLintResult {\n ok: boolean;\n scanned: number;\n findings: OkfLintFinding[];\n}\n\nfunction isEncryptedBlob(raw: string): boolean {\n // secure-store writes a binary envelope starting with MAGIC_BYTES at offset\n // 0 — match that fixed position, never a substring anywhere in the file.\n return raw.startsWith(MAGIC_BYTES.toString(\"ascii\"));\n}\n\nfunction hasFrontmatter(raw: string): boolean {\n return raw.startsWith(\"---\\n\") || raw.startsWith(\"---\\r\\n\");\n}\n\nfunction readType(raw: string): string | undefined {\n const close = raw.indexOf(\"\\n---\", 4);\n if (close === -1) return undefined;\n const block = raw.slice(4, close);\n const match = /^type:[ \\t]*(.*)$/m.exec(block);\n if (!match) return undefined;\n const value = match[1]!.trim().replace(/^[\"']|[\"']$/g, \"\");\n return value;\n}\n\nfunction walkMarkdown(root: string, out: string[]): void {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(root, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n if (entry.name === \"state\" || entry.name === \".git\") continue;\n const full = path.join(root, entry.name);\n let stat: fs.Stats;\n try {\n stat = fs.lstatSync(full);\n } catch {\n continue;\n }\n if (stat.isSymbolicLink()) continue;\n if (stat.isDirectory()) {\n walkMarkdown(full, out);\n continue;\n }\n if (stat.isFile() && entry.name.endsWith(\".md\")) out.push(full);\n }\n}\n\nexport function lintOkfDir(memoryDir: string): OkfLintResult {\n const files: string[] = [];\n walkMarkdown(memoryDir, files);\n const findings: OkfLintFinding[] = [];\n for (const file of files) {\n const rel = path.relative(memoryDir, file);\n const base = path.basename(file);\n if (OKF_RESERVED_BASENAMES[base] === true) {\n findings.push({\n file: rel,\n code: \"reserved_basename\",\n message: `${base} is reserved by OKF §6/§7`,\n });\n continue;\n }\n let raw: string;\n try {\n raw = fs.readFileSync(file, \"utf8\");\n } catch {\n continue;\n }\n if (isEncryptedBlob(raw)) {\n findings.push({\n file: rel,\n code: \"skipped_encrypted\",\n message: \"skipped (encrypted)\",\n });\n continue;\n }\n if (!hasFrontmatter(raw)) {\n findings.push({\n file: rel,\n code: \"missing_frontmatter\",\n message: \"missing YAML frontmatter\",\n });\n continue;\n }\n const type = readType(raw);\n if (type === undefined) {\n findings.push({ file: rel, code: \"missing_type\", message: \"missing type\" });\n } else if (type.length === 0) {\n findings.push({ file: rel, code: \"empty_type\", message: \"empty type\" });\n }\n }\n const actionable = findings.filter((f) => f.code !== \"skipped_encrypted\");\n return { ok: actionable.length === 0, scanned: files.length, findings };\n}\n","/**\n * Shared OKF bundle-rendering helpers (issues #1948 + #1950).\n *\n * One source of truth for the mechanics every OKF bundle exporter uses:\n * deterministic frontmatter rendering, staging-directory file writes, the\n * symlink-guarded atomic publish, and the bundle version stamp. The memory\n * exporter (transfer/export-okf.ts) and the codegraph exporter\n * (coding/export-okf-codegraph.ts) both consume this module so their\n * bundles are byte-compatible in convention (rule 38 — deterministic\n * rendering discipline; rule 9 — stable seam over shared mechanics).\n */\nimport { randomUUID } from \"node:crypto\";\nimport { lstatSync, mkdirSync, readdirSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/** OKF spec version emitted in every bundle root index. */\nexport const OKF_EXPORT_VERSION = \"0.1\";\n\n/**\n * Render a YAML frontmatter block from a flat field map.\n *\n * Key order: the canonical OKF keys first (`type`, `title`, `description`,\n * `tags`, `timestamp`), everything else alphabetical — one deterministic\n * layout so identical inputs always render byte-identical files. A key set\n * to `undefined` is omitted; callers must not pass a key twice.\n */\nexport function renderFrontmatter(fields: Record<string, unknown>): string {\n const keys = Object.keys(fields).sort((a, b) => {\n const order = [\"type\", \"title\", \"description\", \"tags\", \"timestamp\"];\n const ai = order.indexOf(a);\n const bi = order.indexOf(b);\n if (ai >= 0 || bi >= 0) return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);\n return a.localeCompare(b);\n });\n const lines = keys.flatMap((key) => yamlLine(key, fields[key]));\n return `---\\n${lines.join(\"\\n\")}\\n---\\n\\n`;\n}\n\nfunction yamlLine(key: string, value: unknown): string[] {\n if (value === undefined) return [];\n if (Array.isArray(value)) {\n if (value.length === 0) return [`${key}: []`];\n if (value.every((item) => typeof item !== \"object\" || item === null)) {\n return [`${key}:`, ...value.map((item) => ` - ${yamlScalar(item)}`)];\n }\n return [`${key}: ${JSON.stringify(value)}`];\n }\n if (typeof value === \"object\" && value !== null) return [`${key}: ${JSON.stringify(value)}`];\n return [`${key}: ${yamlScalar(value)}`];\n}\n\nfunction yamlScalar(value: unknown): string {\n if (typeof value === \"string\") {\n if (value === \"\" || /[:#\\n]/.test(value) || value !== value.trim()) return JSON.stringify(value);\n return value;\n }\n return String(value);\n}\n\n/**\n * Write one file into a bundle staging tree. `rel` is a POSIX-style\n * bundle-relative path; parent directories are created as needed.\n */\nexport function writeBundleFile(root: string, rel: string, content: string): void {\n const dest = path.join(root, ...rel.split(\"/\"));\n mkdirSync(path.dirname(dest), { recursive: true });\n writeFileSync(dest, content, \"utf8\");\n}\n\n/**\n * Publish a staged bundle: refuse a non-empty target without `--force`,\n * swap via rename so the target is never observed half-written, and keep a\n * restorable backup when replacing an existing tree.\n */\nexport function publishBundle(staging: string, outDir: string, force: boolean): void {\n let exists = false;\n try {\n const stat = lstatSync(outDir);\n if (stat.isSymbolicLink()) throw new Error(`--out must not be a symlink: ${outDir}`);\n if (!stat.isDirectory()) throw new Error(`--out exists and is not a directory: ${outDir}`);\n exists = true;\n const entries = readdirSync(outDir).filter((name) => name !== \".\" && name !== \"..\");\n if (entries.length > 0 && !force) {\n rmSync(staging, { recursive: true, force: true });\n throw new Error(`--out ${outDir} is not empty; pass --force to replace it`);\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n mkdirSync(path.dirname(outDir), { recursive: true });\n if (exists && force) {\n // A fixed backup name is not reusable: an earlier crash between the two\n // renames, or an unrelated directory a user created, leaves the path\n // occupied and every later --force export fails on the rename. Each\n // attempt takes its own name and removes it on both the success and the\n // rollback path.\n const backup = `${outDir}.okf-prev-${randomUUID().slice(0, 8)}`;\n try {\n renameSync(outDir, backup);\n } catch {\n rmSync(staging, { recursive: true, force: true });\n throw new Error(`cannot replace --out ${outDir}`);\n }\n try {\n renameSync(staging, outDir);\n rmSync(backup, { recursive: true, force: true });\n } catch (err) {\n try {\n renameSync(backup, outDir);\n rmSync(staging, { recursive: true, force: true });\n } catch {\n // Keep the backup when the restore itself fails: it is the only\n // surviving copy of the operator's previous bundle.\n }\n throw err;\n }\n return;\n }\n renameSync(staging, outDir);\n}\n\n/**\n * Reject a --out path with a symlink anywhere in its component chain\n * (pattern 42 + hermes-shim precedent): a symlinked component could aim\n * the atomic rename outside the operator's chosen directory.\n */\nexport function rejectSymlinkPath(target: string): void {\n let current = path.resolve(target);\n while (true) {\n try {\n if (lstatSync(current).isSymbolicLink()) {\n throw new Error(`--out path component is a symlink: ${current}`);\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n const parent = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n}\n\n"],"mappings":";;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAiBjB,SAAS,gBAAgB,KAAsB;AAG7C,SAAO,IAAI,WAAW,YAAY,SAAS,OAAO,CAAC;AACrD;AAEA,SAAS,eAAe,KAAsB;AAC5C,SAAO,IAAI,WAAW,OAAO,KAAK,IAAI,WAAW,SAAS;AAC5D;AAEA,SAAS,SAAS,KAAiC;AACjD,QAAM,QAAQ,IAAI,QAAQ,SAAS,CAAC;AACpC,MAAI,UAAU,GAAI,QAAO;AACzB,QAAM,QAAQ,IAAI,MAAM,GAAG,KAAK;AAChC,QAAM,QAAQ,qBAAqB,KAAK,KAAK;AAC7C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,MAAM,CAAC,EAAG,KAAK,EAAE,QAAQ,gBAAgB,EAAE;AACzD,SAAO;AACT;AAEA,SAAS,aAAa,MAAc,KAAqB;AACvD,MAAI;AACJ,MAAI;AACF,cAAU,GAAG,YAAY,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,EACxD,QAAQ;AACN;AAAA,EACF;AACA,aAAW,SAAS,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|
20
20
|
import {
|
|
21
21
|
exportSqlite
|
|
22
22
|
} from "./chunk-BV2TIZ4F.js";
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
} from "./chunk-HSSERO3E.js";
|
|
77
77
|
import {
|
|
78
78
|
lintOkfDir
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-PVV42HM4.js";
|
|
80
80
|
import {
|
|
81
81
|
getUtilityLearningStatus,
|
|
82
82
|
learnUtilityPromotionWeights
|
|
@@ -260,7 +260,7 @@ import {
|
|
|
260
260
|
} from "./chunk-7MOYAT4Y.js";
|
|
261
261
|
import {
|
|
262
262
|
resolveNamespaceChildRoot
|
|
263
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-3UXOZBHV.js";
|
|
264
264
|
import {
|
|
265
265
|
analyzeGraphHealth
|
|
266
266
|
} from "./chunk-YMOPYG3K.js";
|
|
@@ -379,7 +379,7 @@ import {
|
|
|
379
379
|
} from "./chunk-3WCASNQZ.js";
|
|
380
380
|
|
|
381
381
|
// src/cli.ts
|
|
382
|
-
import
|
|
382
|
+
import path6 from "path";
|
|
383
383
|
import { access, lstat as lstat3, readFile as readFile2, readdir as readdir3, realpath as realpath3, unlink } from "fs/promises";
|
|
384
384
|
import { createHash } from "crypto";
|
|
385
385
|
|
|
@@ -1177,9 +1177,6 @@ function registerMeetingsCommands(cmd, orchestrator) {
|
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
|
-
// src/cli/okf-commands.ts
|
|
1181
|
-
import path3 from "path";
|
|
1182
|
-
|
|
1183
1180
|
// src/okf/sweep.ts
|
|
1184
1181
|
import fs from "fs";
|
|
1185
1182
|
import path from "path";
|
|
@@ -1401,9 +1398,9 @@ function registerExportOkfCommand(exportCmd, orchestrator) {
|
|
|
1401
1398
|
if (!out) throw new Error("Missing --out");
|
|
1402
1399
|
const includeStatus = parseIncludeStatus(options.includeStatus);
|
|
1403
1400
|
const namespace = options.namespace ? String(options.namespace) : "";
|
|
1404
|
-
const memoryDir = namespace ? path3.join(orchestrator.config.memoryDir, "namespaces", namespace) : orchestrator.config.memoryDir;
|
|
1405
1401
|
const result = await exportOkfBundle({
|
|
1406
|
-
memoryDir,
|
|
1402
|
+
memoryDir: orchestrator.config.memoryDir,
|
|
1403
|
+
namespace,
|
|
1407
1404
|
outDir: out,
|
|
1408
1405
|
includeStatus,
|
|
1409
1406
|
includeCategories: options.includeCategories ? String(options.includeCategories).split(",") : void 0,
|
|
@@ -1424,13 +1421,13 @@ function registerExportOkfCommand(exportCmd, orchestrator) {
|
|
|
1424
1421
|
|
|
1425
1422
|
// src/procedural/skill-io.ts
|
|
1426
1423
|
import { lstat, mkdir, readdir, readFile, realpath, writeFile } from "fs/promises";
|
|
1427
|
-
import
|
|
1424
|
+
import path3 from "path";
|
|
1428
1425
|
async function exportSkillBundles(options) {
|
|
1429
|
-
const outDir =
|
|
1426
|
+
const outDir = path3.resolve(options.outDir);
|
|
1430
1427
|
await mkdir(outDir, { recursive: true });
|
|
1431
1428
|
const slugs = [];
|
|
1432
1429
|
for (const bundle of options.bundles) {
|
|
1433
|
-
const dir =
|
|
1430
|
+
const dir = path3.join(outDir, bundle.slug);
|
|
1434
1431
|
if (!pathIsInside(outDir, dir)) {
|
|
1435
1432
|
throw new Error(`skill export: refusing to write outside ${outDir} (slug ${bundle.slug})`);
|
|
1436
1433
|
}
|
|
@@ -1443,7 +1440,7 @@ async function exportSkillBundles(options) {
|
|
|
1443
1440
|
if (err.code !== "ENOENT") throw err;
|
|
1444
1441
|
}
|
|
1445
1442
|
await mkdir(dir, { recursive: true });
|
|
1446
|
-
const skillPath =
|
|
1443
|
+
const skillPath = path3.join(dir, SKILL_FILE_NAME);
|
|
1447
1444
|
try {
|
|
1448
1445
|
const existingSkill = await lstat(skillPath);
|
|
1449
1446
|
if (existingSkill.isSymbolicLink()) {
|
|
@@ -1458,7 +1455,7 @@ async function exportSkillBundles(options) {
|
|
|
1458
1455
|
return { outDir, slugs };
|
|
1459
1456
|
}
|
|
1460
1457
|
async function readSkillBundlesFromDir(dir) {
|
|
1461
|
-
const root =
|
|
1458
|
+
const root = path3.resolve(dir);
|
|
1462
1459
|
const rootStat = await lstat(root);
|
|
1463
1460
|
if (rootStat.isSymbolicLink()) {
|
|
1464
1461
|
throw new Error(`skill import: refusing to walk symlinked directory ${root}`);
|
|
@@ -1478,13 +1475,13 @@ async function readSkillBundlesFromDir(dir) {
|
|
|
1478
1475
|
continue;
|
|
1479
1476
|
}
|
|
1480
1477
|
if (!entry.isDirectory()) continue;
|
|
1481
|
-
const bundleDir =
|
|
1478
|
+
const bundleDir = path3.join(root, entry.name);
|
|
1482
1479
|
const bundleReal = await realpath(bundleDir);
|
|
1483
1480
|
if (!pathIsInside(rootReal, bundleReal)) {
|
|
1484
1481
|
skipped.push({ entry: entry.name, reason: "resolves outside the import root" });
|
|
1485
1482
|
continue;
|
|
1486
1483
|
}
|
|
1487
|
-
const skillPath =
|
|
1484
|
+
const skillPath = path3.join(bundleDir, SKILL_FILE_NAME);
|
|
1488
1485
|
let skillStat;
|
|
1489
1486
|
try {
|
|
1490
1487
|
skillStat = await lstat(skillPath);
|
|
@@ -2021,10 +2018,10 @@ function registerCreationLedgerCommands(cmd, orchestrator) {
|
|
|
2021
2018
|
}
|
|
2022
2019
|
|
|
2023
2020
|
// src/maintenance/rebuild-memory-lifecycle-ledger-cli.ts
|
|
2024
|
-
import
|
|
2021
|
+
import path4 from "path";
|
|
2025
2022
|
async function runRebuildMemoryLifecycleLedgerCliCommand(options) {
|
|
2026
2023
|
const storage = options.storage;
|
|
2027
|
-
const ledgerPath =
|
|
2024
|
+
const ledgerPath = path4.join(options.memoryDir, "state", "memory-lifecycle-ledger.jsonl");
|
|
2028
2025
|
const encrypted = await probeEncryptedRegularFileHeader(ledgerPath);
|
|
2029
2026
|
if (encrypted && !(storage?.isSecureStoreUnlocked() ?? false)) {
|
|
2030
2027
|
throw new Error(
|
|
@@ -2522,7 +2519,7 @@ assistant> ${result.reply}
|
|
|
2522
2519
|
// src/training-export/converter.ts
|
|
2523
2520
|
import { constants } from "fs";
|
|
2524
2521
|
import { lstat as lstat2, open, readdir as readdir2, realpath as realpath2 } from "fs/promises";
|
|
2525
|
-
import
|
|
2522
|
+
import path5 from "path";
|
|
2526
2523
|
function parseFrontmatter(raw) {
|
|
2527
2524
|
const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
2528
2525
|
if (!match) return null;
|
|
@@ -2562,7 +2559,7 @@ async function safeRealpath(p) {
|
|
|
2562
2559
|
}
|
|
2563
2560
|
}
|
|
2564
2561
|
function isContainedPath(real, containmentRoot) {
|
|
2565
|
-
return real === containmentRoot || real.startsWith(containmentRoot +
|
|
2562
|
+
return real === containmentRoot || real.startsWith(containmentRoot + path5.sep);
|
|
2566
2563
|
}
|
|
2567
2564
|
async function collectMarkdownFiles(dir, containmentRoot) {
|
|
2568
2565
|
const files = [];
|
|
@@ -2582,7 +2579,7 @@ async function collectMarkdownFiles(dir, containmentRoot) {
|
|
|
2582
2579
|
}
|
|
2583
2580
|
const sorted = [...entries].sort((a, b) => a.name.localeCompare(b.name));
|
|
2584
2581
|
for (const entry of sorted) {
|
|
2585
|
-
const full =
|
|
2582
|
+
const full = path5.join(d, entry.name);
|
|
2586
2583
|
if (entry.isSymbolicLink()) continue;
|
|
2587
2584
|
if (entry.isDirectory()) {
|
|
2588
2585
|
await walk(full);
|
|
@@ -2664,9 +2661,9 @@ async function convertMemoriesToRecords(options) {
|
|
|
2664
2661
|
const { memoryDir } = options;
|
|
2665
2662
|
const containmentRoot = await safeRealpath(memoryDir);
|
|
2666
2663
|
if (!containmentRoot) return [];
|
|
2667
|
-
const dirs = RECALL_FALLBACK_DIRS.map((dir) =>
|
|
2664
|
+
const dirs = RECALL_FALLBACK_DIRS.map((dir) => path5.join(memoryDir, dir));
|
|
2668
2665
|
if (options.includeEntities) {
|
|
2669
|
-
dirs.push(
|
|
2666
|
+
dirs.push(path5.join(memoryDir, "entities"));
|
|
2670
2667
|
}
|
|
2671
2668
|
const allFiles = [];
|
|
2672
2669
|
for (const dir of dirs) {
|
|
@@ -3674,7 +3671,7 @@ function policyVersionForValues(values, config) {
|
|
|
3674
3671
|
return createHash("sha256").update(JSON.stringify(normalized)).digest("hex").slice(0, 12);
|
|
3675
3672
|
}
|
|
3676
3673
|
async function readRuntimePolicySnapshot2(config, fileName) {
|
|
3677
|
-
const filePath =
|
|
3674
|
+
const filePath = path6.join(config.memoryDir, "state", fileName);
|
|
3678
3675
|
const snapshot = await readRuntimePolicySnapshot(filePath, {
|
|
3679
3676
|
maxStaleDecayThreshold: config.lifecycleArchiveDecayThreshold
|
|
3680
3677
|
});
|
|
@@ -4451,7 +4448,7 @@ async function exists(p) {
|
|
|
4451
4448
|
}
|
|
4452
4449
|
}
|
|
4453
4450
|
function assertSafeNamespaceSegment(namespace) {
|
|
4454
|
-
if (namespace.length === 0 || namespace === "." || namespace === ".." || namespace.includes("/") || namespace.includes("\\") ||
|
|
4451
|
+
if (namespace.length === 0 || namespace === "." || namespace === ".." || namespace.includes("/") || namespace.includes("\\") || path6.isAbsolute(namespace) || path6.win32.isAbsolute(namespace)) {
|
|
4455
4452
|
throw new Error(`invalid namespace: ${namespace}`);
|
|
4456
4453
|
}
|
|
4457
4454
|
}
|
|
@@ -4501,7 +4498,7 @@ async function walkMemoryMarkdownFiles(memoryDir, visit) {
|
|
|
4501
4498
|
for (const entry of entries) {
|
|
4502
4499
|
if (entry.isSymbolicLink()) continue;
|
|
4503
4500
|
const entryName = typeof entry.name === "string" ? entry.name : entry.name.toString("utf-8");
|
|
4504
|
-
const fullPath =
|
|
4501
|
+
const fullPath = path6.join(dir, entryName);
|
|
4505
4502
|
try {
|
|
4506
4503
|
assertPathInsideRoot(memoryRootReal, await realpath3(fullPath), fullPath);
|
|
4507
4504
|
} catch (err) {
|
|
@@ -4516,7 +4513,7 @@ async function walkMemoryMarkdownFiles(memoryDir, visit) {
|
|
|
4516
4513
|
await visit(fullPath);
|
|
4517
4514
|
}
|
|
4518
4515
|
};
|
|
4519
|
-
for (const root of RECALL_FALLBACK_DIRS.map((dir) =>
|
|
4516
|
+
for (const root of RECALL_FALLBACK_DIRS.map((dir) => path6.join(memoryDir, dir))) {
|
|
4520
4517
|
await walk(root);
|
|
4521
4518
|
}
|
|
4522
4519
|
}
|
|
@@ -5126,7 +5123,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
5126
5123
|
if (plan.moved.length > 0) {
|
|
5127
5124
|
console.log("\nEntries:");
|
|
5128
5125
|
for (const move of plan.moved) {
|
|
5129
|
-
console.log(`- ${
|
|
5126
|
+
console.log(`- ${path6.basename(move.from)}`);
|
|
5130
5127
|
}
|
|
5131
5128
|
}
|
|
5132
5129
|
if (dryRun) {
|
|
@@ -5427,15 +5424,15 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
5427
5424
|
const capsulesDir = defaultCapsulesDir(memoryDir);
|
|
5428
5425
|
const { stat: statMerge } = await import("fs/promises");
|
|
5429
5426
|
let sourceArchive = expandTildePath(parsed.archive);
|
|
5430
|
-
const looksLikePath = sourceArchive.startsWith("/") || sourceArchive.startsWith("./") || sourceArchive.startsWith("../") || sourceArchive.includes(
|
|
5427
|
+
const looksLikePath = sourceArchive.startsWith("/") || sourceArchive.startsWith("./") || sourceArchive.startsWith("../") || sourceArchive.includes(path6.sep);
|
|
5431
5428
|
if (!looksLikePath) {
|
|
5432
|
-
const cwdResolved =
|
|
5429
|
+
const cwdResolved = path6.resolve(sourceArchive);
|
|
5433
5430
|
const cwdSt = await statMerge(cwdResolved).catch(() => null);
|
|
5434
5431
|
if (cwdSt && cwdSt.isFile()) {
|
|
5435
5432
|
sourceArchive = cwdResolved;
|
|
5436
5433
|
} else {
|
|
5437
|
-
const byId =
|
|
5438
|
-
const byIdEnc =
|
|
5434
|
+
const byId = path6.join(capsulesDir, `${sourceArchive}.capsule.json.gz`);
|
|
5435
|
+
const byIdEnc = path6.join(capsulesDir, `${sourceArchive}.capsule.json.gz.enc`);
|
|
5439
5436
|
const stId = await statMerge(byId).catch(() => null);
|
|
5440
5437
|
if (stId && stId.isFile()) {
|
|
5441
5438
|
sourceArchive = byId;
|
|
@@ -5516,10 +5513,10 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
5516
5513
|
).sort();
|
|
5517
5514
|
const entries = [];
|
|
5518
5515
|
for (const archiveName of archives) {
|
|
5519
|
-
const archivePath =
|
|
5516
|
+
const archivePath = path6.join(capsulesDir, archiveName);
|
|
5520
5517
|
const id = archiveName.replace(/\.capsule\.json\.gz\.enc$/, "").replace(/\.capsule\.json\.gz$/, "");
|
|
5521
5518
|
const manifestName = `${id}.manifest.json`;
|
|
5522
|
-
const manifestPath =
|
|
5519
|
+
const manifestPath = path6.join(capsulesDir, manifestName);
|
|
5523
5520
|
let createdAt = null;
|
|
5524
5521
|
let pluginVersion = null;
|
|
5525
5522
|
let fileCount = null;
|
|
@@ -5574,15 +5571,15 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
5574
5571
|
const parsed = parseCapsuleInspectOptions(archiveArg, opts);
|
|
5575
5572
|
const { stat } = await import("fs/promises");
|
|
5576
5573
|
let archivePath = expandTildePath(parsed.archive);
|
|
5577
|
-
const looksLikePath = archivePath.startsWith("/") || archivePath.startsWith("./") || archivePath.startsWith("../") || archivePath.includes(
|
|
5574
|
+
const looksLikePath = archivePath.startsWith("/") || archivePath.startsWith("./") || archivePath.startsWith("../") || archivePath.includes(path6.sep);
|
|
5578
5575
|
if (!looksLikePath) {
|
|
5579
|
-
const cwdResolved =
|
|
5576
|
+
const cwdResolved = path6.resolve(archivePath);
|
|
5580
5577
|
const cwdSt = await stat(cwdResolved).catch(() => null);
|
|
5581
5578
|
if (cwdSt && cwdSt.isFile()) {
|
|
5582
5579
|
archivePath = cwdResolved;
|
|
5583
5580
|
} else {
|
|
5584
|
-
const byId =
|
|
5585
|
-
const byIdEnc =
|
|
5581
|
+
const byId = path6.join(capsulesDir, `${archivePath}.capsule.json.gz`);
|
|
5582
|
+
const byIdEnc = path6.join(capsulesDir, `${archivePath}.capsule.json.gz.enc`);
|
|
5586
5583
|
const st = await stat(byId).catch(() => null);
|
|
5587
5584
|
if (st && st.isFile()) {
|
|
5588
5585
|
archivePath = byId;
|
|
@@ -7573,7 +7570,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
7573
7570
|
return;
|
|
7574
7571
|
}
|
|
7575
7572
|
const expandedTarget = expandTildePath(rawTarget);
|
|
7576
|
-
const targetPath =
|
|
7573
|
+
const targetPath = path6.isAbsolute(expandedTarget) ? expandedTarget : path6.join(orchestrator.config.memoryDir, expandedTarget);
|
|
7577
7574
|
const { runConsolidationUndo, formatConsolidationUndoResult } = await import("./consolidation-undo.js");
|
|
7578
7575
|
const result = await runConsolidationUndo({
|
|
7579
7576
|
storage: orchestrator.storage,
|
|
@@ -7611,7 +7608,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
7611
7608
|
}
|
|
7612
7609
|
});
|
|
7613
7610
|
cmd.command("identity").description("Show agent identity reflections").action(async () => {
|
|
7614
|
-
const workspaceDir =
|
|
7611
|
+
const workspaceDir = path6.join(resolveHomeDir(), ".openclaw", "workspace");
|
|
7615
7612
|
const identity = await orchestrator.storage.readIdentity(workspaceDir);
|
|
7616
7613
|
if (!identity) {
|
|
7617
7614
|
console.log("No identity file found.");
|
|
@@ -7834,8 +7831,8 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
7834
7831
|
const options = args[0] ?? {};
|
|
7835
7832
|
const threadId = options.thread;
|
|
7836
7833
|
const top = parseInt(options.top ?? "10", 10);
|
|
7837
|
-
const memoryDir =
|
|
7838
|
-
const threading = new ThreadingManager(
|
|
7834
|
+
const memoryDir = path6.join(resolveHomeDir(), ".openclaw", "workspace", "memory", "local");
|
|
7835
|
+
const threading = new ThreadingManager(path6.join(memoryDir, "threads"));
|
|
7839
7836
|
if (threadId) {
|
|
7840
7837
|
const thread = await threading.loadThread(threadId);
|
|
7841
7838
|
if (!thread) {
|
|
@@ -8865,4 +8862,4 @@ export {
|
|
|
8865
8862
|
listMemoryMarkdownFilePaths,
|
|
8866
8863
|
registerCli
|
|
8867
8864
|
};
|
|
8868
|
-
//# sourceMappingURL=chunk-
|
|
8865
|
+
//# sourceMappingURL=chunk-UWOA5L6N.js.map
|