@remnic/plugin-openclaw 1.0.53 → 9.3.515
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/index.js +510 -2071
- package/openclaw.plugin.json +3 -3
- package/package.json +4 -3
- package/scripts/faiss_index.py +141 -29
- package/dist/calibration-RKL2LRW4.js +0 -250
- package/dist/capsule-cli-EHZPMXBC.js +0 -33
- package/dist/capsule-crypto-JS67OSWM.js +0 -17
- package/dist/capsule-export-DX53CPIT.js +0 -17
- package/dist/capsule-import-4OXCPHOT.js +0 -16
- package/dist/capsule-merge-25AUN33Q.js +0 -195
- package/dist/causal-chain-BVTOWZKC.js +0 -23
- package/dist/causal-consolidation-V533DIGW.js +0 -233
- package/dist/causal-retrieval-XAP6QKHZ.js +0 -182
- package/dist/causal-trajectory-graph-ZWQWZ7N5.js +0 -59
- package/dist/chunk-25J4PXDH.js +0 -30
- package/dist/chunk-2RQU6GVD.js +0 -453
- package/dist/chunk-3A5ELHTT.js +0 -61
- package/dist/chunk-3G7FAF6S.js +0 -60
- package/dist/chunk-3IKMUNW5.js +0 -177
- package/dist/chunk-4XDQ3KEC.js +0 -4048
- package/dist/chunk-5ZW5XJQ6.js +0 -128
- package/dist/chunk-6IWEAUN6.js +0 -148
- package/dist/chunk-7JOLBJJ5.js +0 -874
- package/dist/chunk-B52XADV3.js +0 -244
- package/dist/chunk-BQZ7JACP.js +0 -389
- package/dist/chunk-BU5KJVWF.js +0 -78
- package/dist/chunk-BZ4EYURA.js +0 -181
- package/dist/chunk-CEL5ZLKP.js +0 -233
- package/dist/chunk-EH4AXGRO.js +0 -48
- package/dist/chunk-I2KLQ2HA.js +0 -22
- package/dist/chunk-IO5WWY6A.js +0 -156
- package/dist/chunk-JC3FCKYL.js +0 -516
- package/dist/chunk-JZBOXOUC.js +0 -259
- package/dist/chunk-KC7KSQR4.js +0 -302
- package/dist/chunk-LZCGPRHS.js +0 -228
- package/dist/chunk-MBIFE6SA.js +0 -250
- package/dist/chunk-MWLY7VQX.js +0 -896
- package/dist/chunk-MXFJXUHC.js +0 -292
- package/dist/chunk-NUWDSTP7.js +0 -233
- package/dist/chunk-PSAPZGDX.js +0 -725
- package/dist/chunk-QCCP4RU5.js +0 -190
- package/dist/chunk-QMUQV5NP.js +0 -146
- package/dist/chunk-QQXJODFL.js +0 -328
- package/dist/chunk-QVTGUY3H.js +0 -1295
- package/dist/chunk-SWOYEQN2.js +0 -1005
- package/dist/chunk-TH5FF5SC.js +0 -16
- package/dist/chunk-TXOEHSVP.js +0 -275
- package/dist/chunk-UFU5GGGA.js +0 -47
- package/dist/chunk-UZJ7EERS.js +0 -272
- package/dist/chunk-W6EEFUCJ.js +0 -349
- package/dist/chunk-YGGGUTG3.js +0 -125
- package/dist/chunk-YJYZMLD5.js +0 -360
- package/dist/chunk-YKV4EFUI.js +0 -199
- package/dist/chunk-YXDXRE6N.js +0 -6500
- package/dist/chunk-ZS6VABML.js +0 -185
- package/dist/cipher-E23BHBSO.js +0 -27
- package/dist/consolidation-undo-FKJZCJHS.js +0 -426
- package/dist/contradiction-review-WJRWNQ5N.js +0 -29
- package/dist/contradiction-scan-5X423QGT.js +0 -12
- package/dist/dreams-ledger-KDX44I7R.js +0 -290
- package/dist/engine-7VG3IXKN.js +0 -16
- package/dist/extraction-judge-telemetry-O4ZVGLTU.js +0 -14
- package/dist/fallback-llm-43UMEXNJ.js +0 -10
- package/dist/first-start-migration-H2SAXAGR.js +0 -263
- package/dist/forget-ZECIDNL5.js +0 -68
- package/dist/fs-utils-OYXSZSVV.js +0 -39
- package/dist/graph-edge-decay-24ZKD5QL.js +0 -202
- package/dist/kdf-RXKIWHRU.js +0 -25
- package/dist/logger-XG7JKLPS.js +0 -9
- package/dist/memory-governance-TK4B4ZZ2.js +0 -25
- package/dist/metadata-WK2TRPYZ.js +0 -20
- package/dist/migrate-from-identity-anchor-SNDNKHZD.js +0 -7
- package/dist/path-ZKO74XXC.js +0 -7
- package/dist/peers-W53WSDXG.js +0 -43
- package/dist/purge-IKJISXEQ.js +0 -204
- package/dist/resolution-BN35OXDS.js +0 -11
- package/dist/secure-store-6RWYM6GK.js +0 -155
- package/dist/state-4ITLYMAU.js +0 -7
- package/dist/state-store-ET3ADVY5.js +0 -14
- package/dist/storage-HUNVVHZ7.js +0 -27
- package/dist/tier-stats-ZRQBV6G2.js +0 -147
- package/dist/trace-IL2Y34EH.js +0 -289
- package/dist/tui-7KRDCMYK.js +0 -12
- package/dist/types-MBUINTB2.js +0 -30
package/dist/index.js
CHANGED
|
@@ -1,52 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import "./chunk-JC3FCKYL.js";
|
|
19
|
-
import "./chunk-YJYZMLD5.js";
|
|
20
|
-
import "./chunk-IO5WWY6A.js";
|
|
21
|
-
import "./chunk-MWLY7VQX.js";
|
|
22
|
-
import "./chunk-TH5FF5SC.js";
|
|
23
|
-
import "./chunk-3IKMUNW5.js";
|
|
24
|
-
import "./chunk-3G7FAF6S.js";
|
|
25
|
-
import "./chunk-25J4PXDH.js";
|
|
26
|
-
import "./chunk-QVTGUY3H.js";
|
|
27
|
-
import {
|
|
28
|
-
external_exports
|
|
29
|
-
} from "./chunk-4XDQ3KEC.js";
|
|
30
|
-
import "./chunk-2RQU6GVD.js";
|
|
31
|
-
import "./chunk-MXFJXUHC.js";
|
|
32
|
-
import "./chunk-JZBOXOUC.js";
|
|
33
|
-
import "./chunk-6IWEAUN6.js";
|
|
34
|
-
import "./chunk-SWOYEQN2.js";
|
|
35
|
-
import "./chunk-3A5ELHTT.js";
|
|
36
|
-
import "./chunk-5ZW5XJQ6.js";
|
|
37
|
-
import "./chunk-YXDXRE6N.js";
|
|
38
|
-
import "./chunk-QMUQV5NP.js";
|
|
39
|
-
import "./chunk-BQZ7JACP.js";
|
|
40
|
-
import "./chunk-UFU5GGGA.js";
|
|
41
|
-
import "./chunk-YGGGUTG3.js";
|
|
42
|
-
import "./chunk-NUWDSTP7.js";
|
|
43
|
-
import {
|
|
44
|
-
resolveHomeDir
|
|
45
|
-
} from "./chunk-EH4AXGRO.js";
|
|
46
|
-
import {
|
|
47
|
-
__export,
|
|
48
|
-
__reExport
|
|
49
|
-
} from "./chunk-I2KLQ2HA.js";
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
50
18
|
|
|
51
19
|
// ../../src/day-summary.ts
|
|
52
20
|
var day_summary_exports = {};
|
|
@@ -54,8 +22,8 @@ __reExport(day_summary_exports, day_summary_star);
|
|
|
54
22
|
import * as day_summary_star from "@remnic/core/day-summary";
|
|
55
23
|
|
|
56
24
|
// ../../src/index.ts
|
|
57
|
-
import
|
|
58
|
-
import { createRequire
|
|
25
|
+
import OpenAI from "openai";
|
|
26
|
+
import { createRequire } from "module";
|
|
59
27
|
|
|
60
28
|
// ../../src/config.ts
|
|
61
29
|
var config_exports = {};
|
|
@@ -72,10 +40,8 @@ var sdk_compat_exports = {};
|
|
|
72
40
|
__reExport(sdk_compat_exports, sdk_compat_star);
|
|
73
41
|
import * as sdk_compat_star from "@remnic/core/sdk-compat";
|
|
74
42
|
|
|
75
|
-
// ../../src/
|
|
76
|
-
|
|
77
|
-
__reExport(orchestrator_exports, orchestrator_star);
|
|
78
|
-
import * as orchestrator_star from "@remnic/core/orchestrator";
|
|
43
|
+
// ../../src/index.ts
|
|
44
|
+
import { Orchestrator, sanitizeSessionKeyForFilename, defaultWorkspaceDir } from "@remnic/core/orchestrator";
|
|
79
45
|
|
|
80
46
|
// ../../src/tools.ts
|
|
81
47
|
import { createHash } from "crypto";
|
|
@@ -2696,41 +2662,27 @@ var explicit_capture_exports = {};
|
|
|
2696
2662
|
__reExport(explicit_capture_exports, explicit_capture_star);
|
|
2697
2663
|
import * as explicit_capture_star from "@remnic/core/explicit-capture";
|
|
2698
2664
|
|
|
2699
|
-
// ../../src/
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
import
|
|
2703
|
-
|
|
2704
|
-
// ../../src/work/board.ts
|
|
2705
|
-
var board_exports = {};
|
|
2706
|
-
__reExport(board_exports, board_star);
|
|
2707
|
-
import * as board_star from "@remnic/core/work/board";
|
|
2708
|
-
|
|
2709
|
-
// ../../src/work/boundary.ts
|
|
2710
|
-
var boundary_exports = {};
|
|
2711
|
-
__reExport(boundary_exports, boundary_star);
|
|
2712
|
-
import * as boundary_star from "@remnic/core/work/boundary";
|
|
2665
|
+
// ../../src/tools.ts
|
|
2666
|
+
import { WorkStorage } from "@remnic/core/work/storage";
|
|
2667
|
+
import { exportWorkBoardMarkdown, exportWorkBoardSnapshot, importWorkBoardSnapshot } from "@remnic/core/work/board";
|
|
2668
|
+
import { wrapWorkLayerContext } from "@remnic/core/work/boundary";
|
|
2713
2669
|
|
|
2714
2670
|
// ../../src/profiling.ts
|
|
2715
2671
|
var profiling_exports = {};
|
|
2716
2672
|
__reExport(profiling_exports, profiling_star);
|
|
2717
2673
|
import * as profiling_star from "@remnic/core/profiling";
|
|
2718
2674
|
|
|
2719
|
-
// ../../src/maintenance/memory-governance.ts
|
|
2720
|
-
var memory_governance_exports = {};
|
|
2721
|
-
__reExport(memory_governance_exports, memory_governance_star);
|
|
2722
|
-
import * as memory_governance_star from "@remnic/core/maintenance/memory-governance";
|
|
2723
|
-
|
|
2724
2675
|
// ../../src/tools.ts
|
|
2676
|
+
import { runMemoryGovernance } from "@remnic/core/maintenance/memory-governance";
|
|
2725
2677
|
function toolResult(text) {
|
|
2726
2678
|
return { content: [{ type: "text", text }], details: void 0 };
|
|
2727
2679
|
}
|
|
2728
2680
|
function toolJsonResult(value, options) {
|
|
2729
2681
|
const payload = JSON.stringify(value, null, 2);
|
|
2730
|
-
return toolResult(
|
|
2682
|
+
return toolResult(wrapWorkLayerContext(payload, { linkToMemory: options?.linkToMemory === true }));
|
|
2731
2683
|
}
|
|
2732
2684
|
function workLayerTextResult(text, options) {
|
|
2733
|
-
return toolResult(
|
|
2685
|
+
return toolResult(wrapWorkLayerContext(text, { linkToMemory: options?.linkToMemory === true }));
|
|
2734
2686
|
}
|
|
2735
2687
|
function asNonEmptyString(value) {
|
|
2736
2688
|
if (typeof value !== "string") return void 0;
|
|
@@ -2746,6 +2698,20 @@ function clampUnitInterval(value, fallback) {
|
|
|
2746
2698
|
if (value > 1) return 1;
|
|
2747
2699
|
return value;
|
|
2748
2700
|
}
|
|
2701
|
+
function normalizeProfilingReportLimit(value) {
|
|
2702
|
+
if (value === void 0) return 5;
|
|
2703
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value)) {
|
|
2704
|
+
return 5;
|
|
2705
|
+
}
|
|
2706
|
+
return Math.min(Math.max(value, 1), 20);
|
|
2707
|
+
}
|
|
2708
|
+
function normalizeMemorySearchResultLimit(value) {
|
|
2709
|
+
if (value === void 0) return 8;
|
|
2710
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value)) {
|
|
2711
|
+
return 8;
|
|
2712
|
+
}
|
|
2713
|
+
return Math.min(Math.max(value, 1), 50);
|
|
2714
|
+
}
|
|
2749
2715
|
function normalizeMemoryActionEligibilitySource(value) {
|
|
2750
2716
|
switch (value) {
|
|
2751
2717
|
case "extraction":
|
|
@@ -2791,15 +2757,15 @@ function asTaskStatus(value) {
|
|
|
2791
2757
|
if (!normalized || !WORK_TASK_STATUSES.has(normalized)) return void 0;
|
|
2792
2758
|
return normalized;
|
|
2793
2759
|
}
|
|
2794
|
-
function
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
return normalized;
|
|
2760
|
+
function parseEnumParam(params, key, allowed) {
|
|
2761
|
+
if (!Object.prototype.hasOwnProperty.call(params, key) || params[key] === void 0) {
|
|
2762
|
+
return { ok: true, value: void 0 };
|
|
2763
|
+
}
|
|
2764
|
+
const normalized = asNonEmptyString(params[key]);
|
|
2765
|
+
if (!normalized || !allowed.has(normalized)) {
|
|
2766
|
+
return { ok: false, message: `invalid \`${key}\`: expected one of ${[...allowed].join(", ")}.` };
|
|
2767
|
+
}
|
|
2768
|
+
return { ok: true, value: normalized };
|
|
2803
2769
|
}
|
|
2804
2770
|
function asNullablePatchString(params, key) {
|
|
2805
2771
|
if (!Object.prototype.hasOwnProperty.call(params, key)) return void 0;
|
|
@@ -3053,12 +3019,11 @@ Best for:
|
|
|
3053
3019
|
async execute(_toolCallId, params) {
|
|
3054
3020
|
const { query, maxResults, collection, namespace } = params;
|
|
3055
3021
|
const namespaceFilter = namespace && namespace.length > 0 ? namespace : void 0;
|
|
3056
|
-
const
|
|
3057
|
-
|
|
3058
|
-
) : await orchestrator.searchAcrossNamespaces({
|
|
3022
|
+
const resultLimit = normalizeMemorySearchResultLimit(maxResults);
|
|
3023
|
+
const filtered = collection === "global" && !namespaceFilter ? (await orchestrator.qmd.searchGlobal(query, resultLimit)).slice(0, resultLimit) : await orchestrator.searchAcrossNamespaces({
|
|
3059
3024
|
query,
|
|
3060
3025
|
namespaces: namespaceFilter ? [namespaceFilter] : void 0,
|
|
3061
|
-
maxResults,
|
|
3026
|
+
maxResults: resultLimit,
|
|
3062
3027
|
mode: "search"
|
|
3063
3028
|
});
|
|
3064
3029
|
if (filtered.length === 0) {
|
|
@@ -4768,7 +4733,7 @@ Best for:
|
|
|
4768
4733
|
const recentDays = typeof params.recentDays === "number" && Number.isFinite(params.recentDays) ? Math.max(1, Math.floor(params.recentDays)) : void 0;
|
|
4769
4734
|
const maxMemories = typeof params.maxMemories === "number" && Number.isFinite(params.maxMemories) ? Math.max(1, Math.floor(params.maxMemories)) : void 0;
|
|
4770
4735
|
const batchSize = typeof params.batchSize === "number" && Number.isFinite(params.batchSize) ? Math.max(1, Math.floor(params.batchSize)) : void 0;
|
|
4771
|
-
const result = await
|
|
4736
|
+
const result = await runMemoryGovernance({
|
|
4772
4737
|
memoryDir: storage.dir,
|
|
4773
4738
|
mode,
|
|
4774
4739
|
recentDays,
|
|
@@ -4911,18 +4876,22 @@ Best for:
|
|
|
4911
4876
|
async execute(_toolCallId, params) {
|
|
4912
4877
|
const p = params;
|
|
4913
4878
|
const action = String(p.action ?? "");
|
|
4914
|
-
const storage = new
|
|
4879
|
+
const storage = new WorkStorage(orchestrator.config.memoryDir);
|
|
4915
4880
|
try {
|
|
4916
4881
|
await storage.ensureDirectories();
|
|
4917
4882
|
if (action === "create") {
|
|
4918
4883
|
if (typeof p.title !== "string" || p.title.trim().length === 0) {
|
|
4919
4884
|
return workLayerTextResult("work_task.create requires non-empty `title`.");
|
|
4920
4885
|
}
|
|
4886
|
+
const status = parseEnumParam(p, "status", WORK_TASK_STATUSES);
|
|
4887
|
+
if (!status.ok) return workLayerTextResult(`work_task.create received ${status.message}`);
|
|
4888
|
+
const priority = parseEnumParam(p, "priority", WORK_TASK_PRIORITIES);
|
|
4889
|
+
if (!priority.ok) return workLayerTextResult(`work_task.create received ${priority.message}`);
|
|
4921
4890
|
const created = await storage.createTask({
|
|
4922
4891
|
title: p.title,
|
|
4923
4892
|
description: typeof p.description === "string" ? p.description : void 0,
|
|
4924
|
-
status:
|
|
4925
|
-
priority:
|
|
4893
|
+
status: status.value,
|
|
4894
|
+
priority: priority.value,
|
|
4926
4895
|
owner: asNonEmptyString(p.owner),
|
|
4927
4896
|
assignee: asNonEmptyString(p.assignee),
|
|
4928
4897
|
projectId: asNonEmptyString(p.projectId),
|
|
@@ -4940,8 +4909,10 @@ Best for:
|
|
|
4940
4909
|
return toolJsonResult({ action, task });
|
|
4941
4910
|
}
|
|
4942
4911
|
if (action === "list") {
|
|
4912
|
+
const status = parseEnumParam(p, "status", WORK_TASK_STATUSES);
|
|
4913
|
+
if (!status.ok) return workLayerTextResult(`work_task.list received ${status.message}`);
|
|
4943
4914
|
const tasks = await storage.listTasks({
|
|
4944
|
-
status:
|
|
4915
|
+
status: status.value,
|
|
4945
4916
|
owner: asNonEmptyString(p.owner),
|
|
4946
4917
|
assignee: asNonEmptyString(p.assignee),
|
|
4947
4918
|
projectId: asNonEmptyString(p.projectId)
|
|
@@ -4956,10 +4927,12 @@ Best for:
|
|
|
4956
4927
|
const patch = {};
|
|
4957
4928
|
if (typeof p.title === "string") patch.title = p.title;
|
|
4958
4929
|
if (typeof p.description === "string") patch.description = p.description;
|
|
4959
|
-
const status =
|
|
4960
|
-
if (status)
|
|
4961
|
-
|
|
4962
|
-
|
|
4930
|
+
const status = parseEnumParam(p, "status", WORK_TASK_STATUSES);
|
|
4931
|
+
if (!status.ok) return workLayerTextResult(`work_task.update received ${status.message}`);
|
|
4932
|
+
if (status.value) patch.status = status.value;
|
|
4933
|
+
const priority = parseEnumParam(p, "priority", WORK_TASK_PRIORITIES);
|
|
4934
|
+
if (!priority.ok) return workLayerTextResult(`work_task.update received ${priority.message}`);
|
|
4935
|
+
if (priority.value) patch.priority = priority.value;
|
|
4963
4936
|
const owner = asNullablePatchString(p, "owner");
|
|
4964
4937
|
if (owner !== void 0) patch.owner = owner;
|
|
4965
4938
|
const assignee = asNullablePatchString(p, "assignee");
|
|
@@ -5023,17 +4996,19 @@ Best for:
|
|
|
5023
4996
|
async execute(_toolCallId, params) {
|
|
5024
4997
|
const p = params;
|
|
5025
4998
|
const action = String(p.action ?? "");
|
|
5026
|
-
const storage = new
|
|
4999
|
+
const storage = new WorkStorage(orchestrator.config.memoryDir);
|
|
5027
5000
|
try {
|
|
5028
5001
|
await storage.ensureDirectories();
|
|
5029
5002
|
if (action === "create") {
|
|
5030
5003
|
if (typeof p.name !== "string" || p.name.trim().length === 0) {
|
|
5031
5004
|
return workLayerTextResult("work_project.create requires non-empty `name`.");
|
|
5032
5005
|
}
|
|
5006
|
+
const status = parseEnumParam(p, "status", WORK_PROJECT_STATUSES);
|
|
5007
|
+
if (!status.ok) return workLayerTextResult(`work_project.create received ${status.message}`);
|
|
5033
5008
|
const project = await storage.createProject({
|
|
5034
5009
|
name: p.name,
|
|
5035
5010
|
description: typeof p.description === "string" ? p.description : void 0,
|
|
5036
|
-
status:
|
|
5011
|
+
status: status.value,
|
|
5037
5012
|
owner: asNonEmptyString(p.owner),
|
|
5038
5013
|
tags: Array.isArray(p.tags) ? p.tags.filter((x) => typeof x === "string") : void 0
|
|
5039
5014
|
});
|
|
@@ -5059,8 +5034,9 @@ Best for:
|
|
|
5059
5034
|
const patch = {};
|
|
5060
5035
|
if (typeof p.name === "string") patch.name = p.name;
|
|
5061
5036
|
if (typeof p.description === "string") patch.description = p.description;
|
|
5062
|
-
const status =
|
|
5063
|
-
if (status)
|
|
5037
|
+
const status = parseEnumParam(p, "status", WORK_PROJECT_STATUSES);
|
|
5038
|
+
if (!status.ok) return workLayerTextResult(`work_project.update received ${status.message}`);
|
|
5039
|
+
if (status.value) patch.status = status.value;
|
|
5064
5040
|
const owner = asNullablePatchString(p, "owner");
|
|
5065
5041
|
if (owner !== void 0) patch.owner = owner;
|
|
5066
5042
|
if (Array.isArray(p.tags)) patch.tags = p.tags.filter((x) => typeof x === "string");
|
|
@@ -5116,13 +5092,13 @@ Best for:
|
|
|
5116
5092
|
const projectId = asNonEmptyString(p.projectId);
|
|
5117
5093
|
const linkToMemory = p.linkToMemory === true;
|
|
5118
5094
|
try {
|
|
5119
|
-
await new
|
|
5095
|
+
await new WorkStorage(orchestrator.config.memoryDir).ensureDirectories();
|
|
5120
5096
|
if (action === "export_markdown") {
|
|
5121
|
-
const markdown = await
|
|
5122
|
-
return toolResult(
|
|
5097
|
+
const markdown = await exportWorkBoardMarkdown({ memoryDir: orchestrator.config.memoryDir, projectId });
|
|
5098
|
+
return toolResult(wrapWorkLayerContext(markdown, { linkToMemory }));
|
|
5123
5099
|
}
|
|
5124
5100
|
if (action === "export_snapshot") {
|
|
5125
|
-
const snapshot = await
|
|
5101
|
+
const snapshot = await exportWorkBoardSnapshot({ memoryDir: orchestrator.config.memoryDir, projectId });
|
|
5126
5102
|
return toolJsonResult(snapshot, { linkToMemory });
|
|
5127
5103
|
}
|
|
5128
5104
|
if (action === "import_snapshot") {
|
|
@@ -5130,7 +5106,7 @@ Best for:
|
|
|
5130
5106
|
return workLayerTextResult("work_board.import_snapshot requires `snapshotJson`.", { linkToMemory });
|
|
5131
5107
|
}
|
|
5132
5108
|
const snapshot = JSON.parse(p.snapshotJson);
|
|
5133
|
-
const result = await
|
|
5109
|
+
const result = await importWorkBoardSnapshot({
|
|
5134
5110
|
memoryDir: orchestrator.config.memoryDir,
|
|
5135
5111
|
snapshot,
|
|
5136
5112
|
projectId: asNonEmptyString(p.projectId)
|
|
@@ -5400,7 +5376,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
5400
5376
|
);
|
|
5401
5377
|
}
|
|
5402
5378
|
const format = asNonEmptyString(params.format) ?? "ascii";
|
|
5403
|
-
const limit =
|
|
5379
|
+
const limit = normalizeProfilingReportLimit(params.limit);
|
|
5404
5380
|
const traces = profiler.getRecentTraces(limit);
|
|
5405
5381
|
const stats = profiler.getStats();
|
|
5406
5382
|
const bottleneck = profiler.identifyBottleneck();
|
|
@@ -5471,7 +5447,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
5471
5447
|
);
|
|
5472
5448
|
}
|
|
5473
5449
|
const format = asNonEmptyString(params.format) ?? "ascii";
|
|
5474
|
-
const limit =
|
|
5450
|
+
const limit = normalizeProfilingReportLimit(params.limit);
|
|
5475
5451
|
const traces = profiler.getRecentTraces(limit);
|
|
5476
5452
|
const stats = profiler.getStats();
|
|
5477
5453
|
const bottleneck = profiler.identifyBottleneck();
|
|
@@ -5517,17 +5493,9 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
5517
5493
|
);
|
|
5518
5494
|
}
|
|
5519
5495
|
|
|
5520
|
-
// ../../src/lcm/index.ts
|
|
5521
|
-
var lcm_exports = {};
|
|
5522
|
-
__reExport(lcm_exports, lcm_star);
|
|
5523
|
-
import * as lcm_star from "@remnic/core/lcm/index";
|
|
5524
|
-
|
|
5525
|
-
// ../../src/lcm/archive.ts
|
|
5526
|
-
var archive_exports = {};
|
|
5527
|
-
__reExport(archive_exports, archive_star);
|
|
5528
|
-
import * as archive_star from "@remnic/core/lcm/archive";
|
|
5529
|
-
|
|
5530
5496
|
// ../../src/index.ts
|
|
5497
|
+
import { registerLcmTools } from "@remnic/core/lcm/index";
|
|
5498
|
+
import { estimateTokens as estimateLcmTokens } from "@remnic/core/lcm/archive";
|
|
5531
5499
|
import { registerCli } from "@remnic/core/cli";
|
|
5532
5500
|
|
|
5533
5501
|
// ../../src/objective-state.ts
|
|
@@ -5565,23 +5533,19 @@ __reExport(access_http_exports, access_http_star);
|
|
|
5565
5533
|
import * as access_http_star from "@remnic/core/access-http";
|
|
5566
5534
|
|
|
5567
5535
|
// ../../src/index.ts
|
|
5568
|
-
import
|
|
5569
|
-
import
|
|
5536
|
+
import path3 from "path";
|
|
5537
|
+
import os from "os";
|
|
5570
5538
|
|
|
5571
5539
|
// ../../src/opik-exporter.ts
|
|
5572
5540
|
var opik_exporter_exports = {};
|
|
5573
5541
|
__reExport(opik_exporter_exports, opik_exporter_star);
|
|
5574
5542
|
import * as opik_exporter_star from "@remnic/core/opik-exporter";
|
|
5575
5543
|
|
|
5576
|
-
// ../../src/
|
|
5577
|
-
|
|
5578
|
-
__reExport(env_exports, env_star);
|
|
5579
|
-
import * as env_star from "@remnic/core/runtime/env";
|
|
5544
|
+
// ../../src/index.ts
|
|
5545
|
+
import { readEnvVar, resolveHomeDir } from "@remnic/core/runtime/env";
|
|
5580
5546
|
|
|
5581
5547
|
// ../../src/migrate/from-engram.ts
|
|
5582
|
-
|
|
5583
|
-
__reExport(from_engram_exports, from_engram_star);
|
|
5584
|
-
import * as from_engram_star from "@remnic/core/migrate/from-engram";
|
|
5548
|
+
import { migrateFromEngram, rollbackFromEngramMigration } from "@remnic/core/migrate/from-engram";
|
|
5585
5549
|
|
|
5586
5550
|
// ../../src/user-message-cleaning.ts
|
|
5587
5551
|
function cleanUserMessage(content) {
|
|
@@ -5590,12 +5554,18 @@ function cleanUserMessage(content) {
|
|
|
5590
5554
|
/<supermemory-context[^>]*>[\s\S]*?<\/supermemory-context>\s*/gi,
|
|
5591
5555
|
""
|
|
5592
5556
|
);
|
|
5557
|
+
const platformHeader = cleaned.match(/^\[\w+\s+.+?\s+id:\d+\s+[^\]]+\]\s*/);
|
|
5558
|
+
const hasPlatformHeader = platformHeader !== null;
|
|
5559
|
+
if (platformHeader) {
|
|
5560
|
+
cleaned = cleaned.slice(platformHeader[0].length);
|
|
5561
|
+
}
|
|
5593
5562
|
cleaned = cleaned.replace(
|
|
5594
|
-
|
|
5563
|
+
/^\s*## Memory Context \((?:Engram|Remnic)\)[\s\S]*?(?=\n## |\n$)/i,
|
|
5595
5564
|
""
|
|
5596
5565
|
);
|
|
5597
|
-
|
|
5598
|
-
|
|
5566
|
+
if (hasPlatformHeader) {
|
|
5567
|
+
cleaned = cleaned.replace(/\s*\[message_id:\s*[^\]]+\]\s*$/i, "");
|
|
5568
|
+
}
|
|
5599
5569
|
return cleaned.trim();
|
|
5600
5570
|
}
|
|
5601
5571
|
|
|
@@ -5743,1780 +5713,8 @@ async function listRemnicPublicArtifacts(params) {
|
|
|
5743
5713
|
return [...deduped.values()];
|
|
5744
5714
|
}
|
|
5745
5715
|
|
|
5746
|
-
//
|
|
5747
|
-
import
|
|
5748
|
-
var DEFAULT_MEMORY_DIR = path2.join(
|
|
5749
|
-
resolveHomeDir(),
|
|
5750
|
-
".openclaw",
|
|
5751
|
-
"workspace",
|
|
5752
|
-
"memory",
|
|
5753
|
-
"local"
|
|
5754
|
-
);
|
|
5755
|
-
var DEFAULT_WORKSPACE_DIR = path2.join(
|
|
5756
|
-
resolveHomeDir(),
|
|
5757
|
-
".openclaw",
|
|
5758
|
-
"workspace"
|
|
5759
|
-
);
|
|
5760
|
-
var CLIENT_SECRET_FIELD = ["client", "Secret"].join("");
|
|
5761
|
-
var REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("");
|
|
5762
|
-
var LEGACY_ACTIVE_RECALL_CUSTOM_FIELD = [
|
|
5763
|
-
"activeRecall",
|
|
5764
|
-
"Prompt",
|
|
5765
|
-
"Override"
|
|
5766
|
-
].join("");
|
|
5767
|
-
|
|
5768
|
-
// ../remnic-core/src/migrate/from-engram.ts
|
|
5769
|
-
import { createHash as createHash2 } from "crypto";
|
|
5770
|
-
import path3 from "path";
|
|
5771
|
-
import * as fsReadModule0 from "fs/promises";
|
|
5772
|
-
const chmod = fsReadModule0.chmod;
|
|
5773
|
-
const copyFile = fsReadModule0.copyFile;
|
|
5774
|
-
const lstat2 = fsReadModule0.lstat;
|
|
5775
|
-
const mkdir = fsReadModule0.mkdir;
|
|
5776
|
-
const open = fsReadModule0.open;
|
|
5777
|
-
const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
|
|
5778
|
-
const readdir2 = fsReadModule0.readdir;
|
|
5779
|
-
const rm = fsReadModule0.rm;
|
|
5780
|
-
const stat2 = fsReadModule0.stat;
|
|
5781
|
-
const unlink = fsReadModule0.unlink;
|
|
5782
|
-
const writeFile = fsReadModule0.writeFile;
|
|
5783
|
-
import { existsSync } from "fs";
|
|
5784
|
-
|
|
5785
|
-
// ../remnic-core/src/runtime/child-process.ts
|
|
5786
|
-
import { createRequire } from "module";
|
|
5787
|
-
var require2 = createRequire(import.meta.url);
|
|
5788
|
-
|
|
5789
|
-
// ../remnic-core/src/orchestrator.ts
|
|
5790
|
-
import path42 from "path";
|
|
5791
|
-
import os3 from "os";
|
|
5792
|
-
import { createHash as createHash11, randomBytes } from "crypto";
|
|
5793
|
-
import { existsSync as existsSync3 } from "fs";
|
|
5794
|
-
import * as fsReadModule1 from "fs/promises";
|
|
5795
|
-
const mkdir29 = fsReadModule1.mkdir;
|
|
5796
|
-
const readdir16 = fsReadModule1.readdir;
|
|
5797
|
-
const fileReader25 = fsReadModule1["re"+"ad"+"Fi"+"le"];
|
|
5798
|
-
const stat12 = fsReadModule1.stat;
|
|
5799
|
-
const unlink7 = fsReadModule1.unlink;
|
|
5800
|
-
const writeFile28 = fsReadModule1.writeFile;
|
|
5801
|
-
|
|
5802
|
-
// ../remnic-core/src/day-summary.ts
|
|
5803
|
-
import path4 from "path";
|
|
5804
|
-
import { fileURLToPath } from "url";
|
|
5805
|
-
var PROMPT_RELATIVE_PATH = path4.join("prompts", "day_summary.prompt.md");
|
|
5806
|
-
|
|
5807
|
-
// ../remnic-core/src/extraction.ts
|
|
5808
|
-
import OpenAI from "openai";
|
|
5809
|
-
|
|
5810
|
-
// ../remnic-core/src/local-llm.ts
|
|
5811
|
-
import fs from "fs";
|
|
5812
|
-
import os from "os";
|
|
5813
|
-
|
|
5814
|
-
// ../remnic-core/src/schemas.ts
|
|
5815
|
-
var MemoryActionTypeSchema = external_exports.enum([
|
|
5816
|
-
"store_episode",
|
|
5817
|
-
"store_note",
|
|
5818
|
-
"update_note",
|
|
5819
|
-
"create_artifact",
|
|
5820
|
-
"summarize_node",
|
|
5821
|
-
"discard",
|
|
5822
|
-
"link_graph"
|
|
5823
|
-
]);
|
|
5824
|
-
var MemoryActionEligibilityContextSchema = external_exports.object({
|
|
5825
|
-
confidence: external_exports.number().min(0).max(1),
|
|
5826
|
-
lifecycleState: external_exports.enum(["active", "validated", "candidate", "stale", "archived"]),
|
|
5827
|
-
importance: external_exports.number().min(0).max(1),
|
|
5828
|
-
source: external_exports.enum(["extraction", "consolidation", "replay", "manual", "unknown"])
|
|
5829
|
-
}).strict();
|
|
5830
|
-
var ProcedureStepExtractSchema = external_exports.object({
|
|
5831
|
-
order: external_exports.number(),
|
|
5832
|
-
intent: external_exports.string(),
|
|
5833
|
-
toolCall: external_exports.object({
|
|
5834
|
-
kind: external_exports.string(),
|
|
5835
|
-
signature: external_exports.string()
|
|
5836
|
-
}).optional().nullable(),
|
|
5837
|
-
expectedOutcome: external_exports.string().optional().nullable(),
|
|
5838
|
-
optional: external_exports.boolean().optional().nullable()
|
|
5839
|
-
});
|
|
5840
|
-
var ExtractedFactSchema = external_exports.object({
|
|
5841
|
-
category: external_exports.enum([
|
|
5842
|
-
"fact",
|
|
5843
|
-
"preference",
|
|
5844
|
-
"correction",
|
|
5845
|
-
"entity",
|
|
5846
|
-
"decision",
|
|
5847
|
-
"relationship",
|
|
5848
|
-
"principle",
|
|
5849
|
-
"commitment",
|
|
5850
|
-
"moment",
|
|
5851
|
-
"skill",
|
|
5852
|
-
"rule",
|
|
5853
|
-
"procedure",
|
|
5854
|
-
"reasoning_trace"
|
|
5855
|
-
]),
|
|
5856
|
-
content: external_exports.string().describe("The memory content \u2014 a clear, standalone statement"),
|
|
5857
|
-
confidence: external_exports.number().min(0).max(1).describe("How confident are you this is correct (0-1)"),
|
|
5858
|
-
tags: external_exports.array(external_exports.string()).describe("Relevant tags for categorization"),
|
|
5859
|
-
entityRef: external_exports.string().optional().nullable().describe("If about an entity, its normalized name (e.g. person-jane-doe)"),
|
|
5860
|
-
promptedByQuestion: external_exports.string().optional().nullable().describe("Optional proactive follow-up question that surfaced this fact."),
|
|
5861
|
-
scope: external_exports.enum(["project", "global"]).optional().nullable().describe(
|
|
5862
|
-
'Scope classification: "global" for cross-project knowledge (framework bugs, library behavior, API patterns, user preferences, tool configs, general coding patterns); "project" for project-specific knowledge (file paths, env configs, deployment details, project workarounds). Defaults to "project" when a coding context is active.'
|
|
5863
|
-
),
|
|
5864
|
-
structuredAttributes: external_exports.record(external_exports.string(), external_exports.string()).optional().nullable().describe('Structured key-value attributes when the fact contains measurable or categorical data (e.g., {"price": "29.99", "color": "blue", "date": "2024-03-15"}).'),
|
|
5865
|
-
procedureSteps: external_exports.array(ProcedureStepExtractSchema).optional().nullable().describe(
|
|
5866
|
-
'For category "procedure" only: ordered steps (intent per step). At least two steps; include explicit trigger phrasing in content (e.g. "When you deploy\u2026").'
|
|
5867
|
-
),
|
|
5868
|
-
reasoningTrace: external_exports.object({
|
|
5869
|
-
steps: external_exports.array(
|
|
5870
|
-
external_exports.object({
|
|
5871
|
-
order: external_exports.number(),
|
|
5872
|
-
description: external_exports.string()
|
|
5873
|
-
})
|
|
5874
|
-
).min(2).describe("Ordered reasoning steps the user walked through (require >=2)."),
|
|
5875
|
-
// Accept snake_case aliases so a loose gateway model using
|
|
5876
|
-
// `final_answer` / `observed_outcome` does not fail schema parsing
|
|
5877
|
-
// and drop the entire extraction result. Local/direct-client
|
|
5878
|
-
// normalization already tolerates these keys; the gateway path must
|
|
5879
|
-
// too. Zod's `union` keeps the parse successful either way.
|
|
5880
|
-
finalAnswer: external_exports.string().optional().nullable().describe("The conclusion, decision, or answer the chain arrived at."),
|
|
5881
|
-
final_answer: external_exports.string().optional().nullable().describe("Alias for finalAnswer (snake_case). Gateway-tolerance shim."),
|
|
5882
|
-
observedOutcome: external_exports.string().optional().nullable().describe("Optional note about how the answer actually played out."),
|
|
5883
|
-
observed_outcome: external_exports.string().optional().nullable().describe("Alias for observedOutcome (snake_case). Gateway-tolerance shim.")
|
|
5884
|
-
}).refine(
|
|
5885
|
-
(v) => typeof v.finalAnswer === "string" && v.finalAnswer.trim().length > 0 || typeof v.final_answer === "string" && v.final_answer.trim().length > 0,
|
|
5886
|
-
{ message: "reasoningTrace requires finalAnswer (or final_answer)" }
|
|
5887
|
-
).optional().nullable().describe(
|
|
5888
|
-
'For category "reasoning_trace" only: a stored solution chain with ordered steps, a final answer, and an optional observed outcome. Require at least two steps.'
|
|
5889
|
-
)
|
|
5890
|
-
});
|
|
5891
|
-
var EntityMentionSchema = external_exports.object({
|
|
5892
|
-
name: external_exports.string().describe("Normalized entity name (e.g. jane-doe, acme-corp, my-project)"),
|
|
5893
|
-
type: external_exports.enum(["person", "project", "tool", "company", "place", "other"]),
|
|
5894
|
-
facts: external_exports.array(external_exports.string()).describe("New facts learned about this entity in this conversation"),
|
|
5895
|
-
promptedByQuestion: external_exports.string().optional().nullable().describe("Optional proactive follow-up question that surfaced this entity."),
|
|
5896
|
-
structuredSections: external_exports.array(external_exports.object({
|
|
5897
|
-
key: external_exports.string(),
|
|
5898
|
-
title: external_exports.string(),
|
|
5899
|
-
facts: external_exports.array(external_exports.string())
|
|
5900
|
-
})).optional().nullable().describe("Optional named sections for entity-specific facts. Use when facts clearly belong under a durable heading such as Beliefs or Building / Working On.")
|
|
5901
|
-
});
|
|
5902
|
-
var ExtractedQuestionSchema = external_exports.object({
|
|
5903
|
-
question: external_exports.string().describe("A genuine question the AI is curious about based on this conversation"),
|
|
5904
|
-
context: external_exports.string().describe("Why this question matters or what prompted it"),
|
|
5905
|
-
priority: external_exports.number().min(0).max(1).describe("How important/urgent this question is (0-1)")
|
|
5906
|
-
});
|
|
5907
|
-
var ProactiveQuestionsResultSchema = external_exports.object({
|
|
5908
|
-
questions: external_exports.array(ExtractedQuestionSchema).describe("Additional follow-up questions discovered in a proactive second-pass extraction.")
|
|
5909
|
-
});
|
|
5910
|
-
var ExtractedRelationshipSchema = external_exports.object({
|
|
5911
|
-
source: external_exports.string().describe("Source entity name (normalized, e.g. person-jane-doe)"),
|
|
5912
|
-
target: external_exports.string().describe("Target entity name (normalized, e.g. company-acme-corp)"),
|
|
5913
|
-
label: external_exports.string().describe("Relationship label (e.g. 'works at', 'created', 'manages')"),
|
|
5914
|
-
promptedByQuestion: external_exports.string().optional().nullable().describe("Optional proactive follow-up question that surfaced this relationship.")
|
|
5915
|
-
});
|
|
5916
|
-
var ProactiveExtractionResultSchema = external_exports.object({
|
|
5917
|
-
facts: external_exports.array(ExtractedFactSchema).describe(
|
|
5918
|
-
"Additional high-confidence memories recovered only after answering proactive follow-up questions from the same buffered conversation."
|
|
5919
|
-
),
|
|
5920
|
-
profileUpdates: external_exports.array(external_exports.string()).describe(
|
|
5921
|
-
"Additional profile updates directly supported by the buffered conversation. Omit anything speculative."
|
|
5922
|
-
),
|
|
5923
|
-
entities: external_exports.array(EntityMentionSchema).describe(
|
|
5924
|
-
"Additional entities or entity facts surfaced by the proactive follow-up pass."
|
|
5925
|
-
),
|
|
5926
|
-
relationships: external_exports.array(ExtractedRelationshipSchema).optional().nullable().describe(
|
|
5927
|
-
"Additional relationships surfaced by the proactive follow-up pass."
|
|
5928
|
-
)
|
|
5929
|
-
});
|
|
5930
|
-
var ExtractionResultSchema = external_exports.object({
|
|
5931
|
-
facts: external_exports.array(ExtractedFactSchema).describe(
|
|
5932
|
-
"Extracted memories from the conversation. Include facts, preferences, corrections, and decisions. Only extract genuinely new, durable information \u2014 skip transient task state."
|
|
5933
|
-
),
|
|
5934
|
-
profileUpdates: external_exports.array(external_exports.string()).describe(
|
|
5935
|
-
"Updates to the user's behavioral profile. Each string is a standalone statement about the user's preferences, habits, or personality. Only include genuinely new insights."
|
|
5936
|
-
),
|
|
5937
|
-
entities: external_exports.array(EntityMentionSchema).describe(
|
|
5938
|
-
"Entities mentioned in the conversation with new facts about them."
|
|
5939
|
-
),
|
|
5940
|
-
questions: external_exports.array(ExtractedQuestionSchema).describe(
|
|
5941
|
-
"1-3 genuine questions you're curious about from this conversation. These should be things you'd actually want to know the answer to in future sessions."
|
|
5942
|
-
),
|
|
5943
|
-
identityReflection: external_exports.string().optional().nullable().describe(
|
|
5944
|
-
"A brief reflection on what you learned about yourself as an agent in this interaction \u2014 patterns in your behavior, growth, things you did well or could improve."
|
|
5945
|
-
),
|
|
5946
|
-
relationships: external_exports.array(ExtractedRelationshipSchema).optional().nullable().describe(
|
|
5947
|
-
"Relationships between entities discovered in this conversation. Max 5 per extraction. Format: {source, target, label}."
|
|
5948
|
-
)
|
|
5949
|
-
});
|
|
5950
|
-
var ConsolidationItemSchema = external_exports.object({
|
|
5951
|
-
existingId: external_exports.string().describe("The ID of the existing memory being evaluated"),
|
|
5952
|
-
action: external_exports.enum(["ADD", "MERGE", "UPDATE", "INVALIDATE", "SKIP"]),
|
|
5953
|
-
mergeWith: external_exports.string().optional().nullable().describe("If MERGE, the ID of the memory to merge with"),
|
|
5954
|
-
updatedContent: external_exports.string().optional().nullable().describe("If UPDATE or MERGE, the new content"),
|
|
5955
|
-
reason: external_exports.string().describe("Brief reason for this decision")
|
|
5956
|
-
});
|
|
5957
|
-
var ConsolidationResultSchema = external_exports.object({
|
|
5958
|
-
items: external_exports.array(ConsolidationItemSchema).describe(
|
|
5959
|
-
"Decisions for each existing memory: ADD (keep as-is), MERGE (combine with another), UPDATE (revise content), INVALIDATE (mark as outdated/wrong), SKIP (no action needed)"
|
|
5960
|
-
),
|
|
5961
|
-
profileUpdates: external_exports.array(external_exports.string()).describe("New profile statements to add or update"),
|
|
5962
|
-
entityUpdates: external_exports.array(EntityMentionSchema).describe("Entity updates from consolidation analysis")
|
|
5963
|
-
});
|
|
5964
|
-
function buildProfileConsolidationResultSchema(targetLines) {
|
|
5965
|
-
return external_exports.object({
|
|
5966
|
-
consolidatedProfile: external_exports.string().describe(
|
|
5967
|
-
`The full consolidated profile as markdown. Preserve all ## section headers. Merge duplicate or near-duplicate bullets into single clear statements. Remove stale or superseded information. Keep the most important and durable observations. Target roughly ${targetLines} lines.`
|
|
5968
|
-
),
|
|
5969
|
-
removedCount: external_exports.number().describe("Number of bullets removed or merged during consolidation"),
|
|
5970
|
-
summary: external_exports.string().describe("Brief summary of what was consolidated")
|
|
5971
|
-
});
|
|
5972
|
-
}
|
|
5973
|
-
var ProfileConsolidationResultSchema = buildProfileConsolidationResultSchema(50);
|
|
5974
|
-
var IdentityConsolidationResultSchema = external_exports.object({
|
|
5975
|
-
learnedPatterns: external_exports.array(external_exports.string()).describe(
|
|
5976
|
-
"Consolidated behavioral patterns and lessons learned, each a concise standalone statement"
|
|
5977
|
-
),
|
|
5978
|
-
summary: external_exports.string().describe(
|
|
5979
|
-
"A brief paragraph summarizing the agent's core identity insights"
|
|
5980
|
-
)
|
|
5981
|
-
});
|
|
5982
|
-
var ContradictionVerificationSchema = external_exports.object({
|
|
5983
|
-
isContradiction: external_exports.boolean().describe("Whether the two memories truly contradict each other"),
|
|
5984
|
-
confidence: external_exports.number().min(0).max(1).describe("How confident are you in this assessment (0-1)"),
|
|
5985
|
-
reasoning: external_exports.string().describe("Explanation of why these are or are not contradictory"),
|
|
5986
|
-
whichIsNewer: external_exports.enum(["first", "second", "unclear"]).describe("Which memory represents the more recent/current state")
|
|
5987
|
-
});
|
|
5988
|
-
var MemoryLinkSchema = external_exports.object({
|
|
5989
|
-
targetId: external_exports.string().describe("The ID of the memory this links to"),
|
|
5990
|
-
linkType: external_exports.enum(["follows", "references", "contradicts", "supports", "related"]).describe("The type of relationship"),
|
|
5991
|
-
strength: external_exports.number().min(0).max(1).describe("How strong is this relationship (0-1)"),
|
|
5992
|
-
reason: external_exports.string().optional().nullable().describe("Why this link exists")
|
|
5993
|
-
});
|
|
5994
|
-
var SuggestedLinksSchema = external_exports.object({
|
|
5995
|
-
links: external_exports.array(MemoryLinkSchema).describe("Suggested links between memories based on semantic analysis")
|
|
5996
|
-
});
|
|
5997
|
-
var MemorySummarySchema = external_exports.object({
|
|
5998
|
-
summaryText: external_exports.string().describe("A concise summary of the batch of memories"),
|
|
5999
|
-
keyFacts: external_exports.array(external_exports.string()).describe("The most important facts extracted from these memories"),
|
|
6000
|
-
keyEntities: external_exports.array(external_exports.string()).describe("Key entities mentioned across these memories")
|
|
6001
|
-
});
|
|
6002
|
-
var DaySummaryResultSchema = external_exports.object({
|
|
6003
|
-
summary: external_exports.string().min(1).describe("A concise end-of-day summary paragraph."),
|
|
6004
|
-
bullets: external_exports.array(external_exports.string()).default([]).describe("The most important moments from the day."),
|
|
6005
|
-
next_actions: external_exports.array(external_exports.string()).default([]).describe("Concrete next actions for tomorrow."),
|
|
6006
|
-
risks_or_open_loops: external_exports.array(external_exports.string()).default([]).describe("Open loops, blockers, or fragile assumptions still needing attention.")
|
|
6007
|
-
});
|
|
6008
|
-
var BehaviorLoopAdjustmentSchema = external_exports.object({
|
|
6009
|
-
parameter: external_exports.string().min(1),
|
|
6010
|
-
previousValue: external_exports.number(),
|
|
6011
|
-
nextValue: external_exports.number(),
|
|
6012
|
-
delta: external_exports.number(),
|
|
6013
|
-
evidenceCount: external_exports.number().int().min(0),
|
|
6014
|
-
confidence: external_exports.number().min(0).max(1),
|
|
6015
|
-
reason: external_exports.string(),
|
|
6016
|
-
appliedAt: external_exports.string()
|
|
6017
|
-
});
|
|
6018
|
-
var BehaviorLoopPolicyStateSchema = external_exports.object({
|
|
6019
|
-
version: external_exports.number().int().min(0),
|
|
6020
|
-
windowDays: external_exports.number().int().min(0),
|
|
6021
|
-
minSignalCount: external_exports.number().int().min(0),
|
|
6022
|
-
maxDeltaPerCycle: external_exports.number().min(0).max(1),
|
|
6023
|
-
protectedParams: external_exports.array(external_exports.string()),
|
|
6024
|
-
adjustments: external_exports.array(BehaviorLoopAdjustmentSchema),
|
|
6025
|
-
updatedAt: external_exports.string()
|
|
6026
|
-
});
|
|
6027
|
-
|
|
6028
|
-
// ../remnic-core/src/model-registry.ts
|
|
6029
|
-
import fs2 from "fs";
|
|
6030
|
-
import { join } from "path";
|
|
6031
|
-
var DEFAULT_CAPABILITIES = {
|
|
6032
|
-
modelId: "default",
|
|
6033
|
-
maxPositionEmbeddings: 32768,
|
|
6034
|
-
contextWindow: 32768,
|
|
6035
|
-
supportsExtendedContext: false,
|
|
6036
|
-
typicalOutputTokens: 8192,
|
|
6037
|
-
source: "default",
|
|
6038
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6039
|
-
};
|
|
6040
|
-
|
|
6041
|
-
// ../remnic-core/src/profiling.ts
|
|
6042
|
-
import {
|
|
6043
|
-
existsSync as existsSync2,
|
|
6044
|
-
mkdirSync,
|
|
6045
|
-
writeFileSync,
|
|
6046
|
-
promises as fsp
|
|
6047
|
-
} from "fs";
|
|
6048
|
-
import { join as join2 } from "path";
|
|
6049
|
-
|
|
6050
|
-
// ../remnic-core/src/extraction-judge.ts
|
|
6051
|
-
import { createHash as createHash3 } from "crypto";
|
|
6052
|
-
|
|
6053
|
-
// ../remnic-core/src/extraction-judge-training.ts
|
|
6054
|
-
import path5 from "path";
|
|
6055
|
-
import { homedir } from "os";
|
|
6056
|
-
import * as fsReadModule2 from "fs/promises";
|
|
6057
|
-
const appendFile = fsReadModule2.appendFile;
|
|
6058
|
-
const chmod2 = fsReadModule2.chmod;
|
|
6059
|
-
const mkdir2 = fsReadModule2.mkdir;
|
|
6060
|
-
const fileReader2 = fsReadModule2["re"+"ad"+"Fi"+"le"];
|
|
6061
|
-
const readdir3 = fsReadModule2.readdir;
|
|
6062
|
-
|
|
6063
|
-
// ../remnic-core/src/search/factory.ts
|
|
6064
|
-
import path11 from "path";
|
|
6065
|
-
|
|
6066
|
-
// ../remnic-core/src/search/document-scanner.ts
|
|
6067
|
-
import path6 from "path";
|
|
6068
|
-
import * as fsReadModule3 from "fs/promises";
|
|
6069
|
-
const readdir4 = fsReadModule3.readdir;
|
|
6070
|
-
const fileReader3 = fsReadModule3["re"+"ad"+"Fi"+"le"];
|
|
6071
|
-
|
|
6072
|
-
// ../remnic-core/src/search/orama-backend.ts
|
|
6073
|
-
import path7 from "path";
|
|
6074
|
-
import * as fsReadModule4 from "fs/promises";
|
|
6075
|
-
const mkdir3 = fsReadModule4.mkdir;
|
|
6076
|
-
const readdir5 = fsReadModule4.readdir;
|
|
6077
|
-
const fileReader4 = fsReadModule4["re"+"ad"+"Fi"+"le"];
|
|
6078
|
-
const writeFile2 = fsReadModule4.writeFile;
|
|
6079
|
-
|
|
6080
|
-
// ../remnic-core/src/qmd.ts
|
|
6081
|
-
import { createHash as createHash4 } from "crypto";
|
|
6082
|
-
import os2 from "os";
|
|
6083
|
-
import path8 from "path";
|
|
6084
|
-
|
|
6085
|
-
// ../remnic-core/src/abort-error.ts
|
|
6086
|
-
function abortError(message) {
|
|
6087
|
-
const err = new Error(message);
|
|
6088
|
-
Object.defineProperty(err, "name", { value: "AbortError" });
|
|
6089
|
-
return err;
|
|
6090
|
-
}
|
|
6091
|
-
function throwIfAborted(signal, message = "operation aborted") {
|
|
6092
|
-
if (signal?.aborted) {
|
|
6093
|
-
throw abortError(message);
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
|
-
|
|
6097
|
-
// ../remnic-core/src/qmd.ts
|
|
6098
|
-
var QMD_UPDATE_BACKOFF_MS = 15 * 60 * 1e3;
|
|
6099
|
-
var QMD_EMBED_BACKOFF_MS = 60 * 60 * 1e3;
|
|
6100
|
-
var QMD_CLI_WARN_THROTTLE_MS = 15 * 60 * 1e3;
|
|
6101
|
-
var QMD_AUTO_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 6e4;
|
|
6102
|
-
var QMD_FALLBACK_PATHS = [
|
|
6103
|
-
path8.join(os2.homedir(), ".bun", "bin", "qmd"),
|
|
6104
|
-
"/usr/local/bin/qmd",
|
|
6105
|
-
"/opt/homebrew/bin/qmd"
|
|
6106
|
-
];
|
|
6107
|
-
var AsyncMutex = class {
|
|
6108
|
-
locked = false;
|
|
6109
|
-
queue = [];
|
|
6110
|
-
async runExclusive(fn, signal) {
|
|
6111
|
-
const release = await this.acquire(signal);
|
|
6112
|
-
try {
|
|
6113
|
-
throwIfAborted(signal);
|
|
6114
|
-
return await fn();
|
|
6115
|
-
} finally {
|
|
6116
|
-
release();
|
|
6117
|
-
}
|
|
6118
|
-
}
|
|
6119
|
-
acquire(signal) {
|
|
6120
|
-
throwIfAborted(signal);
|
|
6121
|
-
if (!this.locked) {
|
|
6122
|
-
this.locked = true;
|
|
6123
|
-
return Promise.resolve(() => this.release());
|
|
6124
|
-
}
|
|
6125
|
-
return new Promise((resolve2, reject) => {
|
|
6126
|
-
const waiter = {
|
|
6127
|
-
resolve: (release) => {
|
|
6128
|
-
signal?.removeEventListener("abort", waiter.onAbort);
|
|
6129
|
-
resolve2(release);
|
|
6130
|
-
},
|
|
6131
|
-
reject: (reason) => {
|
|
6132
|
-
signal?.removeEventListener("abort", waiter.onAbort);
|
|
6133
|
-
reject(reason);
|
|
6134
|
-
},
|
|
6135
|
-
signal,
|
|
6136
|
-
onAbort: () => {
|
|
6137
|
-
this.queue = this.queue.filter((entry) => entry !== waiter);
|
|
6138
|
-
reject(abortError("operation aborted while waiting for qmd mutex"));
|
|
6139
|
-
}
|
|
6140
|
-
};
|
|
6141
|
-
signal?.addEventListener("abort", waiter.onAbort, { once: true });
|
|
6142
|
-
this.queue.push(waiter);
|
|
6143
|
-
});
|
|
6144
|
-
}
|
|
6145
|
-
release() {
|
|
6146
|
-
while (this.queue.length > 0) {
|
|
6147
|
-
const next = this.queue.shift();
|
|
6148
|
-
if (!next) break;
|
|
6149
|
-
if (next.signal?.aborted) {
|
|
6150
|
-
next.reject(abortError("operation aborted while waiting for qmd mutex"));
|
|
6151
|
-
continue;
|
|
6152
|
-
}
|
|
6153
|
-
this.locked = true;
|
|
6154
|
-
next.resolve(() => this.release());
|
|
6155
|
-
return;
|
|
6156
|
-
}
|
|
6157
|
-
this.locked = false;
|
|
6158
|
-
}
|
|
6159
|
-
};
|
|
6160
|
-
var QMD_MUTEX = new AsyncMutex();
|
|
6161
|
-
|
|
6162
|
-
// ../remnic-core/src/conversation-index/faiss-adapter.ts
|
|
6163
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6164
|
-
import path9 from "path";
|
|
6165
|
-
|
|
6166
|
-
// ../remnic-core/src/conversation-index/indexer.ts
|
|
6167
|
-
import { lstat as lstat3, mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
|
|
6168
|
-
import path10 from "path";
|
|
6169
|
-
|
|
6170
|
-
// ../remnic-core/src/threading.ts
|
|
6171
|
-
import * as fsReadModule5 from "fs/promises";
|
|
6172
|
-
const readdir6 = fsReadModule5.readdir;
|
|
6173
|
-
const fileReader5 = fsReadModule5["re"+"ad"+"Fi"+"le"];
|
|
6174
|
-
const writeFile4 = fsReadModule5.writeFile;
|
|
6175
|
-
const mkdir5 = fsReadModule5.mkdir;
|
|
6176
|
-
const stat3 = fsReadModule5.stat;
|
|
6177
|
-
|
|
6178
|
-
// ../remnic-core/src/storage-paths.ts
|
|
6179
|
-
import { createHash as createHash5 } from "crypto";
|
|
6180
|
-
import { lstat as lstat4, realpath as realpath2 } from "fs/promises";
|
|
6181
|
-
import path12 from "path";
|
|
6182
|
-
|
|
6183
|
-
// ../remnic-core/src/transcript.ts
|
|
6184
|
-
import * as fsReadModule6 from "fs/promises";
|
|
6185
|
-
const appendFile2 = fsReadModule6.appendFile;
|
|
6186
|
-
const mkdir6 = fsReadModule6.mkdir;
|
|
6187
|
-
const readdir8 = fsReadModule6.readdir;
|
|
6188
|
-
const fileReader7 = fsReadModule6["re"+"ad"+"Fi"+"le"];
|
|
6189
|
-
const stat4 = fsReadModule6.stat;
|
|
6190
|
-
const unlink3 = fsReadModule6.unlink;
|
|
6191
|
-
const writeFile6 = fsReadModule6.writeFile;
|
|
6192
|
-
import path14 from "path";
|
|
6193
|
-
|
|
6194
|
-
// ../remnic-core/src/session-integrity.ts
|
|
6195
|
-
import path13 from "path";
|
|
6196
|
-
import * as fsReadModule7 from "fs/promises";
|
|
6197
|
-
const fileReader6 = fsReadModule7["re"+"ad"+"Fi"+"le"];
|
|
6198
|
-
const readdir7 = fsReadModule7.readdir;
|
|
6199
|
-
const unlink2 = fsReadModule7.unlink;
|
|
6200
|
-
const writeFile5 = fsReadModule7.writeFile;
|
|
6201
|
-
|
|
6202
|
-
// ../remnic-core/src/summarizer.ts
|
|
6203
|
-
import * as fsReadModule8 from "fs/promises";
|
|
6204
|
-
const mkdir8 = fsReadModule8.mkdir;
|
|
6205
|
-
const fileReader9 = fsReadModule8["re"+"ad"+"Fi"+"le"];
|
|
6206
|
-
const writeFile8 = fsReadModule8.writeFile;
|
|
6207
|
-
const readdir9 = fsReadModule8.readdir;
|
|
6208
|
-
import path16 from "path";
|
|
6209
|
-
|
|
6210
|
-
// ../remnic-core/src/summary-snapshot.ts
|
|
6211
|
-
import * as fsReadModule9 from "fs/promises";
|
|
6212
|
-
const mkdir7 = fsReadModule9.mkdir;
|
|
6213
|
-
const open2 = fsReadModule9.open;
|
|
6214
|
-
const fileReader8 = fsReadModule9["re"+"ad"+"Fi"+"le"];
|
|
6215
|
-
const stat5 = fsReadModule9.stat;
|
|
6216
|
-
const unlink4 = fsReadModule9.unlink;
|
|
6217
|
-
const utimes = fsReadModule9.utimes;
|
|
6218
|
-
const writeFile7 = fsReadModule9.writeFile;
|
|
6219
|
-
import path15 from "path";
|
|
6220
|
-
var summarySnapshotSchemaVersion = 1;
|
|
6221
|
-
var SummarySnapshotItemSchema = external_exports.object({
|
|
6222
|
-
hour: external_exports.string(),
|
|
6223
|
-
sessionKey: external_exports.string(),
|
|
6224
|
-
bullets: external_exports.array(external_exports.string()),
|
|
6225
|
-
turnCount: external_exports.number().int().nonnegative(),
|
|
6226
|
-
generatedAt: external_exports.string()
|
|
6227
|
-
});
|
|
6228
|
-
var SummarySnapshotSchema = external_exports.object({
|
|
6229
|
-
schemaVersion: external_exports.number().default(summarySnapshotSchemaVersion),
|
|
6230
|
-
sessionKey: external_exports.string(),
|
|
6231
|
-
generatedAt: external_exports.string().datetime({ offset: true }),
|
|
6232
|
-
summaries: external_exports.array(SummarySnapshotItemSchema)
|
|
6233
|
-
});
|
|
6234
|
-
var summarySnapshotLockStaleMs = 3e4;
|
|
6235
|
-
var summarySnapshotLockHeartbeatMs = Math.max(
|
|
6236
|
-
1e3,
|
|
6237
|
-
Math.floor(summarySnapshotLockStaleMs / 3)
|
|
6238
|
-
);
|
|
6239
|
-
|
|
6240
|
-
// ../remnic-core/src/summarizer.ts
|
|
6241
|
-
var HourlySummarySchema = external_exports.object({
|
|
6242
|
-
bullets: external_exports.array(external_exports.string()).describe("3-5 bullet points summarizing the hour's activity")
|
|
6243
|
-
});
|
|
6244
|
-
var HourlySummaryExtendedSchema = external_exports.object({
|
|
6245
|
-
topics: external_exports.array(external_exports.string()).default([]),
|
|
6246
|
-
decisions: external_exports.array(external_exports.string()).default([]),
|
|
6247
|
-
actionItems: external_exports.array(external_exports.string()).default([]),
|
|
6248
|
-
rejected: external_exports.array(external_exports.string()).default([])
|
|
6249
|
-
});
|
|
6250
|
-
|
|
6251
|
-
// ../remnic-core/src/maintenance/memory-governance-cron.ts
|
|
6252
|
-
import * as fsReadModule10 from "fs/promises";
|
|
6253
|
-
const mkdir9 = fsReadModule10.mkdir;
|
|
6254
|
-
const fileReader10 = fsReadModule10["re"+"ad"+"Fi"+"le"];
|
|
6255
|
-
const rename = fsReadModule10.rename;
|
|
6256
|
-
const rm2 = fsReadModule10.rm;
|
|
6257
|
-
const stat6 = fsReadModule10.stat;
|
|
6258
|
-
const writeFile9 = fsReadModule10.writeFile;
|
|
6259
|
-
import path17 from "path";
|
|
6260
|
-
|
|
6261
|
-
// ../remnic-core/src/connectors/live/google-drive.ts
|
|
6262
|
-
var DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6263
|
-
var MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
6264
|
-
var MAX_TEXT_BYTES = 5 * 1024 * 1024;
|
|
6265
|
-
var CLIENT_SECRET_FIELD2 = ["client", "Secret"].join("");
|
|
6266
|
-
var REFRESH_TOKEN_FIELD2 = ["refresh", "Token"].join("");
|
|
6267
|
-
var GOOGLE_NATIVE_EXPORT_MIME = Object.freeze({
|
|
6268
|
-
"application/vnd.google-apps.document": "text/plain",
|
|
6269
|
-
"application/vnd.google-apps.spreadsheet": "text/csv",
|
|
6270
|
-
"application/vnd.google-apps.presentation": "text/plain"
|
|
6271
|
-
});
|
|
6272
|
-
|
|
6273
|
-
// ../remnic-core/src/connectors/live/notion.ts
|
|
6274
|
-
var NOTION_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6275
|
-
var NOTION_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
6276
|
-
var MAX_TEXT_BYTES2 = 5 * 1024 * 1024;
|
|
6277
|
-
|
|
6278
|
-
// ../remnic-core/src/connectors/live/gmail.ts
|
|
6279
|
-
var GMAIL_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6280
|
-
var GMAIL_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
6281
|
-
var MAX_TEXT_BYTES3 = 2 * 1024 * 1024;
|
|
6282
|
-
var CLIENT_SECRET_FIELD3 = ["client", "Secret"].join("");
|
|
6283
|
-
var REFRESH_TOKEN_FIELD3 = ["refresh", "Token"].join("");
|
|
6284
|
-
|
|
6285
|
-
// ../remnic-core/src/connectors/live/github.ts
|
|
6286
|
-
var GITHUB_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6287
|
-
var GITHUB_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
6288
|
-
var MAX_BODY_BYTES = 5 * 1024 * 1024;
|
|
6289
|
-
|
|
6290
|
-
// ../remnic-core/src/retrieval-agents.ts
|
|
6291
|
-
import path18 from "path";
|
|
6292
|
-
import * as fsReadModule11 from "fs/promises";
|
|
6293
|
-
const readdir10 = fsReadModule11.readdir;
|
|
6294
|
-
const fileReader11 = fsReadModule11["re"+"ad"+"Fi"+"le"];
|
|
6295
|
-
const stat7 = fsReadModule11.stat;
|
|
6296
|
-
|
|
6297
|
-
// ../remnic-core/src/relevance.ts
|
|
6298
|
-
import * as fsReadModule12 from "fs/promises";
|
|
6299
|
-
const mkdir10 = fsReadModule12.mkdir;
|
|
6300
|
-
const fileReader12 = fsReadModule12["re"+"ad"+"Fi"+"le"];
|
|
6301
|
-
const writeFile10 = fsReadModule12.writeFile;
|
|
6302
|
-
import path19 from "path";
|
|
6303
|
-
|
|
6304
|
-
// ../remnic-core/src/negative.ts
|
|
6305
|
-
import * as fsReadModule13 from "fs/promises";
|
|
6306
|
-
const mkdir11 = fsReadModule13.mkdir;
|
|
6307
|
-
const fileReader13 = fsReadModule13["re"+"ad"+"Fi"+"le"];
|
|
6308
|
-
const writeFile11 = fsReadModule13.writeFile;
|
|
6309
|
-
import path20 from "path";
|
|
6310
|
-
|
|
6311
|
-
// ../remnic-core/src/recall-state.ts
|
|
6312
|
-
import * as fsReadModule14 from "fs/promises";
|
|
6313
|
-
const appendFile3 = fsReadModule14.appendFile;
|
|
6314
|
-
const mkdir12 = fsReadModule14.mkdir;
|
|
6315
|
-
const fileReader14 = fsReadModule14["re"+"ad"+"Fi"+"le"];
|
|
6316
|
-
const writeFile12 = fsReadModule14.writeFile;
|
|
6317
|
-
import path21 from "path";
|
|
6318
|
-
import { createHash as createHash6, randomUUID } from "crypto";
|
|
6319
|
-
var DEFAULT_TIER_MIGRATION_STATUS = {
|
|
6320
|
-
updatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
6321
|
-
lastCycle: null,
|
|
6322
|
-
totals: {
|
|
6323
|
-
cycles: 0,
|
|
6324
|
-
scanned: 0,
|
|
6325
|
-
migrated: 0,
|
|
6326
|
-
promoted: 0,
|
|
6327
|
-
demoted: 0,
|
|
6328
|
-
errors: 0
|
|
6329
|
-
}
|
|
6330
|
-
};
|
|
6331
|
-
|
|
6332
|
-
// ../remnic-core/src/recall-xray.ts
|
|
6333
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
6334
|
-
|
|
6335
|
-
// ../remnic-core/src/evals.ts
|
|
6336
|
-
import path22 from "path";
|
|
6337
|
-
import { cp, mkdir as mkdir13, rm as rm3, stat as stat8, writeFile as writeFile13 } from "fs/promises";
|
|
6338
|
-
|
|
6339
|
-
// ../remnic-core/src/session-observer-state.ts
|
|
6340
|
-
import path23 from "path";
|
|
6341
|
-
import * as fsReadModule15 from "fs/promises";
|
|
6342
|
-
const mkdir14 = fsReadModule15.mkdir;
|
|
6343
|
-
const open3 = fsReadModule15.open;
|
|
6344
|
-
const fileReader16 = fsReadModule15["re"+"ad"+"Fi"+"le"];
|
|
6345
|
-
const stat9 = fsReadModule15.stat;
|
|
6346
|
-
const unlink5 = fsReadModule15.unlink;
|
|
6347
|
-
const writeFile14 = fsReadModule15.writeFile;
|
|
6348
|
-
|
|
6349
|
-
// ../remnic-core/src/embedding-fallback.ts
|
|
6350
|
-
import path24 from "path";
|
|
6351
|
-
import * as fsReadModule16 from "fs/promises";
|
|
6352
|
-
const mkdir15 = fsReadModule16.mkdir;
|
|
6353
|
-
const fileReader17 = fsReadModule16["re"+"ad"+"Fi"+"le"];
|
|
6354
|
-
const writeFile15 = fsReadModule16.writeFile;
|
|
6355
|
-
|
|
6356
|
-
// ../remnic-core/src/bootstrap.ts
|
|
6357
|
-
import path25 from "path";
|
|
6358
|
-
import * as fsReadModule17 from "fs/promises";
|
|
6359
|
-
const readdir12 = fsReadModule17.readdir;
|
|
6360
|
-
const fileReader18 = fsReadModule17["re"+"ad"+"Fi"+"le"];
|
|
6361
|
-
|
|
6362
|
-
// ../remnic-core/src/entity-retrieval.ts
|
|
6363
|
-
import { createHash as createHash8 } from "crypto";
|
|
6364
|
-
import * as fsReadModule18 from "fs/promises";
|
|
6365
|
-
const mkdir17 = fsReadModule18.mkdir;
|
|
6366
|
-
const fileReader20 = fsReadModule18["re"+"ad"+"Fi"+"le"];
|
|
6367
|
-
const writeFile17 = fsReadModule18.writeFile;
|
|
6368
|
-
import path27 from "path";
|
|
6369
|
-
|
|
6370
|
-
// ../remnic-core/src/native-knowledge.ts
|
|
6371
|
-
import { createHash as createHash7 } from "crypto";
|
|
6372
|
-
import path26 from "path";
|
|
6373
|
-
import * as fsReadModule19 from "fs/promises";
|
|
6374
|
-
const mkdir16 = fsReadModule19.mkdir;
|
|
6375
|
-
const fileReader19 = fsReadModule19["re"+"ad"+"Fi"+"le"];
|
|
6376
|
-
const readdir13 = fsReadModule19.readdir;
|
|
6377
|
-
const stat10 = fsReadModule19.stat;
|
|
6378
|
-
const writeFile16 = fsReadModule19.writeFile;
|
|
6379
|
-
|
|
6380
|
-
// ../remnic-core/src/explicit-cue-recall.ts
|
|
6381
|
-
var CONTENT_LEXICAL_CUE_STOPWORDS = /* @__PURE__ */ new Set([
|
|
6382
|
-
"about",
|
|
6383
|
-
"across",
|
|
6384
|
-
"after",
|
|
6385
|
-
"again",
|
|
6386
|
-
"also",
|
|
6387
|
-
"and",
|
|
6388
|
-
"answer",
|
|
6389
|
-
"answers",
|
|
6390
|
-
"are",
|
|
6391
|
-
"before",
|
|
6392
|
-
"between",
|
|
6393
|
-
"can",
|
|
6394
|
-
"could",
|
|
6395
|
-
"different",
|
|
6396
|
-
"did",
|
|
6397
|
-
"does",
|
|
6398
|
-
"during",
|
|
6399
|
-
"feature",
|
|
6400
|
-
"features",
|
|
6401
|
-
"from",
|
|
6402
|
-
"have",
|
|
6403
|
-
"help",
|
|
6404
|
-
"how",
|
|
6405
|
-
"implement",
|
|
6406
|
-
"into",
|
|
6407
|
-
"made",
|
|
6408
|
-
"many",
|
|
6409
|
-
"me",
|
|
6410
|
-
"mention",
|
|
6411
|
-
"my",
|
|
6412
|
-
"need",
|
|
6413
|
-
"only",
|
|
6414
|
-
"order",
|
|
6415
|
-
"over",
|
|
6416
|
-
"project",
|
|
6417
|
-
"question",
|
|
6418
|
-
"questions",
|
|
6419
|
-
"request",
|
|
6420
|
-
"requests",
|
|
6421
|
-
"show",
|
|
6422
|
-
"tell",
|
|
6423
|
-
"that",
|
|
6424
|
-
"the",
|
|
6425
|
-
"there",
|
|
6426
|
-
"these",
|
|
6427
|
-
"through",
|
|
6428
|
-
"throughout",
|
|
6429
|
-
"trying",
|
|
6430
|
-
"want",
|
|
6431
|
-
"were",
|
|
6432
|
-
"what",
|
|
6433
|
-
"when",
|
|
6434
|
-
"which",
|
|
6435
|
-
"with",
|
|
6436
|
-
"would",
|
|
6437
|
-
"you"
|
|
6438
|
-
]);
|
|
6439
|
-
var CONTENT_LEXICAL_PHRASE_STOPWORDS = new Set(
|
|
6440
|
-
[...CONTENT_LEXICAL_CUE_STOPWORDS].filter(
|
|
6441
|
-
(word) => word !== "feature" && word !== "features" && word !== "implement"
|
|
6442
|
-
)
|
|
6443
|
-
);
|
|
6444
|
-
|
|
6445
|
-
// ../remnic-core/src/tmt.ts
|
|
6446
|
-
import * as fsReadModule20 from "fs/promises";
|
|
6447
|
-
const mkdir18 = fsReadModule20.mkdir;
|
|
6448
|
-
const fileReader21 = fsReadModule20["re"+"ad"+"Fi"+"le"];
|
|
6449
|
-
const writeFile18 = fsReadModule20.writeFile;
|
|
6450
|
-
const readdir14 = fsReadModule20.readdir;
|
|
6451
|
-
|
|
6452
|
-
// ../remnic-core/src/objective-state.ts
|
|
6453
|
-
import path28 from "path";
|
|
6454
|
-
import { mkdir as mkdir19, writeFile as writeFile19 } from "fs/promises";
|
|
6455
|
-
|
|
6456
|
-
// ../remnic-core/src/trust-zones.ts
|
|
6457
|
-
import path29 from "path";
|
|
6458
|
-
import { mkdir as mkdir20, writeFile as writeFile20 } from "fs/promises";
|
|
6459
|
-
|
|
6460
|
-
// ../remnic-core/src/taxonomy/taxonomy-loader.ts
|
|
6461
|
-
import * as fsReadModule21 from "fs/promises";
|
|
6462
|
-
const fileReader22 = fsReadModule21["re"+"ad"+"Fi"+"le"];
|
|
6463
|
-
const mkdir21 = fsReadModule21.mkdir;
|
|
6464
|
-
const writeFile21 = fsReadModule21.writeFile;
|
|
6465
|
-
import path30 from "path";
|
|
6466
|
-
|
|
6467
|
-
// ../remnic-core/src/harmonic-retrieval.ts
|
|
6468
|
-
import path33 from "path";
|
|
6469
|
-
|
|
6470
|
-
// ../remnic-core/src/abstraction-nodes.ts
|
|
6471
|
-
import path31 from "path";
|
|
6472
|
-
import { mkdir as mkdir22, writeFile as writeFile22 } from "fs/promises";
|
|
6473
|
-
|
|
6474
|
-
// ../remnic-core/src/cue-anchors.ts
|
|
6475
|
-
import path32 from "path";
|
|
6476
|
-
import { mkdir as mkdir23, writeFile as writeFile23 } from "fs/promises";
|
|
6477
|
-
|
|
6478
|
-
// ../remnic-core/src/commitment-ledger.ts
|
|
6479
|
-
import path34 from "path";
|
|
6480
|
-
import { mkdir as mkdir24, unlink as unlink6, writeFile as writeFile24 } from "fs/promises";
|
|
6481
|
-
|
|
6482
|
-
// ../remnic-core/src/work-product-ledger.ts
|
|
6483
|
-
import path35 from "path";
|
|
6484
|
-
import { mkdir as mkdir25, writeFile as writeFile25 } from "fs/promises";
|
|
6485
|
-
|
|
6486
|
-
// ../remnic-core/src/lcm/schema.ts
|
|
6487
|
-
import path36 from "path";
|
|
6488
|
-
import { mkdir as mkdir26 } from "fs/promises";
|
|
6489
|
-
|
|
6490
|
-
// ../remnic-core/src/explicit-capture.ts
|
|
6491
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
6492
|
-
|
|
6493
|
-
// ../remnic-core/src/conversation-index/cleanup.ts
|
|
6494
|
-
import { readdir as readdir15, rm as rm4 } from "fs/promises";
|
|
6495
|
-
import path37 from "path";
|
|
6496
|
-
|
|
6497
|
-
// ../remnic-core/src/namespaces/storage.ts
|
|
6498
|
-
import path38 from "path";
|
|
6499
|
-
import { access as access2 } from "fs/promises";
|
|
6500
|
-
|
|
6501
|
-
// ../remnic-core/src/namespaces/principal.ts
|
|
6502
|
-
function resolvePrincipal(sessionKey, config) {
|
|
6503
|
-
if (!config.namespacesEnabled) return "default";
|
|
6504
|
-
const sk = sessionKey ?? "";
|
|
6505
|
-
const mode = config.principalFromSessionKeyMode;
|
|
6506
|
-
const rules = config.principalFromSessionKeyRules ?? [];
|
|
6507
|
-
if (!sk) return "default";
|
|
6508
|
-
if (mode === "prefix") {
|
|
6509
|
-
for (const r of rules) {
|
|
6510
|
-
if (sk.startsWith(r.match)) return r.principal;
|
|
6511
|
-
}
|
|
6512
|
-
} else if (mode === "map") {
|
|
6513
|
-
for (const r of rules) {
|
|
6514
|
-
if (sk === r.match) return r.principal;
|
|
6515
|
-
}
|
|
6516
|
-
} else if (mode === "regex") {
|
|
6517
|
-
for (const r of rules) {
|
|
6518
|
-
try {
|
|
6519
|
-
const re = new RegExp(r.match);
|
|
6520
|
-
if (re.test(sk)) return r.principal;
|
|
6521
|
-
} catch {
|
|
6522
|
-
}
|
|
6523
|
-
}
|
|
6524
|
-
}
|
|
6525
|
-
const parts = sk.split(":");
|
|
6526
|
-
if (parts.length >= 2 && parts[0] === "agent") {
|
|
6527
|
-
const agentId = parts[1];
|
|
6528
|
-
if (agentId && agentId.length > 0) return agentId;
|
|
6529
|
-
}
|
|
6530
|
-
return "default";
|
|
6531
|
-
}
|
|
6532
|
-
function canReadNamespace(principal, namespace, config) {
|
|
6533
|
-
if (!config.namespacesEnabled) return true;
|
|
6534
|
-
const policy = config.namespacePolicies.find((p) => p.name === namespace);
|
|
6535
|
-
if (!policy) return namespace === config.defaultNamespace || namespace === config.sharedNamespace;
|
|
6536
|
-
return policy.readPrincipals.includes(principal) || policy.readPrincipals.includes("*");
|
|
6537
|
-
}
|
|
6538
|
-
function defaultNamespaceForPrincipal(principal, config) {
|
|
6539
|
-
if (!config.namespacesEnabled) return config.defaultNamespace;
|
|
6540
|
-
const exists = config.namespacePolicies.some((p) => p.name === principal);
|
|
6541
|
-
return exists ? principal : config.defaultNamespace;
|
|
6542
|
-
}
|
|
6543
|
-
|
|
6544
|
-
// ../remnic-core/src/coding/git-context.ts
|
|
6545
|
-
import path39 from "path";
|
|
6546
|
-
|
|
6547
|
-
// ../remnic-core/src/routing/store.ts
|
|
6548
|
-
import * as fsReadModule22 from "fs/promises";
|
|
6549
|
-
const lstat5 = fsReadModule22.lstat;
|
|
6550
|
-
const mkdir27 = fsReadModule22.mkdir;
|
|
6551
|
-
const fileReader23 = fsReadModule22["re"+"ad"+"Fi"+"le"];
|
|
6552
|
-
const realpath3 = fsReadModule22.realpath;
|
|
6553
|
-
const rename2 = fsReadModule22.rename;
|
|
6554
|
-
const rm5 = fsReadModule22.rm;
|
|
6555
|
-
const stat11 = fsReadModule22.stat;
|
|
6556
|
-
const writeFile26 = fsReadModule22.writeFile;
|
|
6557
|
-
import path40 from "path";
|
|
6558
|
-
import { createHash as createHash9 } from "crypto";
|
|
6559
|
-
|
|
6560
|
-
// ../remnic-core/src/policy-runtime.ts
|
|
6561
|
-
import path41 from "path";
|
|
6562
|
-
import * as fsReadModule23 from "fs/promises";
|
|
6563
|
-
const mkdir28 = fsReadModule23.mkdir;
|
|
6564
|
-
const fileReader24 = fsReadModule23["re"+"ad"+"Fi"+"le"];
|
|
6565
|
-
const rename3 = fsReadModule23.rename;
|
|
6566
|
-
const writeFile27 = fsReadModule23.writeFile;
|
|
6567
|
-
|
|
6568
|
-
// ../remnic-core/src/behavior-signals.ts
|
|
6569
|
-
import { createHash as createHash10 } from "crypto";
|
|
6570
|
-
|
|
6571
|
-
// ../remnic-core/src/orchestrator.ts
|
|
6572
|
-
var COMPACTION_SIGNAL_MAX_AGE_MS = 60 * 60 * 1e3;
|
|
6573
|
-
|
|
6574
|
-
// ../remnic-core/src/access-service.ts
|
|
6575
|
-
import { stat as stat15 } from "fs/promises";
|
|
6576
|
-
import * as nodeFs from "fs/promises";
|
|
6577
|
-
import { constants as fsConstants } from "fs";
|
|
6578
|
-
import { createHash as createHash14 } from "crypto";
|
|
6579
|
-
|
|
6580
|
-
// ../remnic-core/src/access-idempotency.ts
|
|
6581
|
-
import * as fsReadModule24 from "fs/promises";
|
|
6582
|
-
const mkdir30 = fsReadModule24.mkdir;
|
|
6583
|
-
const open4 = fsReadModule24.open;
|
|
6584
|
-
const fileReader26 = fsReadModule24["re"+"ad"+"Fi"+"le"];
|
|
6585
|
-
const rename4 = fsReadModule24.rename;
|
|
6586
|
-
const stat13 = fsReadModule24.stat;
|
|
6587
|
-
const unlink8 = fsReadModule24.unlink;
|
|
6588
|
-
const utimes2 = fsReadModule24.utimes;
|
|
6589
|
-
const writeFile29 = fsReadModule24.writeFile;
|
|
6590
|
-
import path43 from "path";
|
|
6591
|
-
import { createHash as createHash12 } from "crypto";
|
|
6592
|
-
|
|
6593
|
-
// ../remnic-core/src/recall-audit.ts
|
|
6594
|
-
import { appendFile as appendFile4, mkdir as mkdir31, readdir as readdir17, rm as rm6 } from "fs/promises";
|
|
6595
|
-
import path44 from "path";
|
|
6596
|
-
|
|
6597
|
-
// ../remnic-core/src/recall-audit-anomaly.ts
|
|
6598
|
-
var DEFAULT_ANOMALY_DETECTOR_CONFIG = Object.freeze({
|
|
6599
|
-
enabled: false,
|
|
6600
|
-
windowMs: 5 * 6e4,
|
|
6601
|
-
repeatQueryLimit: 5,
|
|
6602
|
-
namespaceWalkLimit: 3,
|
|
6603
|
-
highCardinalityReturnLimit: 50,
|
|
6604
|
-
rapidFireLimit: 30
|
|
6605
|
-
});
|
|
6606
|
-
|
|
6607
|
-
// ../remnic-core/src/work/storage.ts
|
|
6608
|
-
import path45 from "path";
|
|
6609
|
-
import { randomUUID as randomUUID4 } from "crypto";
|
|
6610
|
-
import * as fsReadModule25 from "fs/promises";
|
|
6611
|
-
const mkdir32 = fsReadModule25.mkdir;
|
|
6612
|
-
const readdir18 = fsReadModule25.readdir;
|
|
6613
|
-
const fileReader27 = fsReadModule25["re"+"ad"+"Fi"+"le"];
|
|
6614
|
-
const rm7 = fsReadModule25.rm;
|
|
6615
|
-
const writeFile30 = fsReadModule25.writeFile;
|
|
6616
|
-
|
|
6617
|
-
// ../remnic-core/src/cross-namespace-budget.ts
|
|
6618
|
-
var DEFAULT_CROSS_NAMESPACE_BUDGET = Object.freeze({
|
|
6619
|
-
enabled: false,
|
|
6620
|
-
windowMs: 6e4,
|
|
6621
|
-
softLimit: 10,
|
|
6622
|
-
hardLimit: 30
|
|
6623
|
-
});
|
|
6624
|
-
|
|
6625
|
-
// ../remnic-core/src/access-service.ts
|
|
6626
|
-
import * as nodePath from "path";
|
|
6627
|
-
|
|
6628
|
-
// ../remnic-core/src/briefing.ts
|
|
6629
|
-
import * as fsReadModule26 from "fs/promises";
|
|
6630
|
-
const fileReader28 = fsReadModule26["re"+"ad"+"Fi"+"le"];
|
|
6631
|
-
import os4 from "os";
|
|
6632
|
-
import path46 from "path";
|
|
6633
|
-
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
6634
|
-
var MAX_WINDOW_MS = 100 * 365 * DAY_MS;
|
|
6635
|
-
|
|
6636
|
-
// ../remnic-core/src/memory-worth-outcomes.ts
|
|
6637
|
-
import path47 from "path";
|
|
6638
|
-
|
|
6639
|
-
// ../remnic-core/src/objective-state-writers.ts
|
|
6640
|
-
import crypto2 from "crypto";
|
|
6641
|
-
|
|
6642
|
-
// ../remnic-core/src/offline-sync.ts
|
|
6643
|
-
import { createHash as createHash13, randomUUID as randomUUID5 } from "crypto";
|
|
6644
|
-
import * as fsReadModule27 from "fs/promises";
|
|
6645
|
-
const lstat6 = fsReadModule27.lstat;
|
|
6646
|
-
const mkdir33 = fsReadModule27.mkdir;
|
|
6647
|
-
const open5 = fsReadModule27.open;
|
|
6648
|
-
const readdir19 = fsReadModule27.readdir;
|
|
6649
|
-
const fileReader29 = fsReadModule27["re"+"ad"+"Fi"+"le"];
|
|
6650
|
-
const rename5 = fsReadModule27.rename;
|
|
6651
|
-
const rm8 = fsReadModule27.rm;
|
|
6652
|
-
const stat14 = fsReadModule27.stat;
|
|
6653
|
-
const unlink9 = fsReadModule27.unlink;
|
|
6654
|
-
const writeFile31 = fsReadModule27.writeFile;
|
|
6655
|
-
import path48 from "path";
|
|
6656
|
-
var OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES = 64 * 1024 * 1024;
|
|
6657
|
-
var OFFLINE_SYNC_FILE_CONTENT_TRANSFER_CHUNK_BYTES = 8 * 1024 * 1024;
|
|
6658
|
-
var OFFLINE_SYNC_APPLY_MAX_BODY_BYTES = 16 * 1024 * 1024;
|
|
6659
|
-
var OFFLINE_SYNC_UPLOAD_STAGING_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
6660
|
-
|
|
6661
|
-
// ../remnic-core/src/action-confidence.ts
|
|
6662
|
-
var ACTION_CONFIDENCE_RISK_CATEGORIES = [
|
|
6663
|
-
"low",
|
|
6664
|
-
"medium",
|
|
6665
|
-
"high",
|
|
6666
|
-
"irreversible",
|
|
6667
|
-
"restricted"
|
|
6668
|
-
];
|
|
6669
|
-
var ACTION_CONFIDENCE_CONTEXT_READINESS = [
|
|
6670
|
-
"none",
|
|
6671
|
-
"partial",
|
|
6672
|
-
"sufficient"
|
|
6673
|
-
];
|
|
6674
|
-
var ACTION_CONFIDENCE_RULE_KINDS = [
|
|
6675
|
-
"ask-before",
|
|
6676
|
-
"do-not-use-outside-this-context",
|
|
6677
|
-
"never",
|
|
6678
|
-
"requires-escalation"
|
|
6679
|
-
];
|
|
6680
|
-
|
|
6681
|
-
// ../remnic-core/src/access-http.ts
|
|
6682
|
-
import { createServer } from "http";
|
|
6683
|
-
import { randomUUID as randomUUID7, timingSafeEqual } from "crypto";
|
|
6684
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
6685
|
-
import { existsSync as existsSync4 } from "fs";
|
|
6686
|
-
import * as fsReadModule28 from "fs/promises";
|
|
6687
|
-
const fileReader32 = fsReadModule28["re"+"ad"+"Fi"+"le"];
|
|
6688
|
-
import path49 from "path";
|
|
6689
|
-
import { fileURLToPath as fileURLToPath3, URL as URL2 } from "url";
|
|
6690
|
-
|
|
6691
|
-
// ../remnic-core/src/access-mcp.ts
|
|
6692
|
-
import * as fsReadModule29 from "fs/promises";
|
|
6693
|
-
const fileReader31 = fsReadModule29["re"+"ad"+"Fi"+"le"];
|
|
6694
|
-
import { randomUUID as randomUUID6 } from "crypto";
|
|
6695
|
-
|
|
6696
|
-
// ../remnic-core/src/access-schema.ts
|
|
6697
|
-
var namespaceSchema = external_exports.string().trim().max(256).optional();
|
|
6698
|
-
var sessionKeySchema = external_exports.string().trim().min(1).max(512).optional();
|
|
6699
|
-
var idempotencyKeySchema = external_exports.string().trim().min(1).max(256).optional();
|
|
6700
|
-
var dryRunSchema = external_exports.boolean().optional();
|
|
6701
|
-
var schemaVersionSchema = external_exports.number().int().optional();
|
|
6702
|
-
var codingContextSchema = external_exports.object({
|
|
6703
|
-
projectId: external_exports.string().trim().min(1, "codingContext.projectId is required").max(128),
|
|
6704
|
-
branch: external_exports.string().trim().max(256).nullable(),
|
|
6705
|
-
rootPath: external_exports.string().trim().min(1, "codingContext.rootPath is required").max(1024),
|
|
6706
|
-
defaultBranch: external_exports.string().trim().max(256).nullable()
|
|
6707
|
-
}).nullable();
|
|
6708
|
-
var recallDisclosureSchema = external_exports.enum(["chunk", "section", "raw"]);
|
|
6709
|
-
var tagMatchSchema = external_exports.enum(["any", "all"]);
|
|
6710
|
-
var recallRequestSchema = external_exports.object({
|
|
6711
|
-
query: external_exports.string().min(1, "query is required"),
|
|
6712
|
-
sessionKey: sessionKeySchema,
|
|
6713
|
-
namespace: namespaceSchema,
|
|
6714
|
-
topK: external_exports.number().int().min(0).max(200).optional(),
|
|
6715
|
-
mode: external_exports.enum(["auto", "no_recall", "minimal", "full", "graph_mode"]).optional(),
|
|
6716
|
-
includeDebug: external_exports.boolean().optional(),
|
|
6717
|
-
idempotencyKey: idempotencyKeySchema,
|
|
6718
|
-
disclosure: recallDisclosureSchema.optional(),
|
|
6719
|
-
codingContext: codingContextSchema.optional(),
|
|
6720
|
-
/** Working directory for auto git-context resolution (issue #569). */
|
|
6721
|
-
cwd: external_exports.string().trim().min(1, "cwd must be non-empty when provided").max(2048).optional(),
|
|
6722
|
-
/**
|
|
6723
|
-
* Arbitrary project tag for non-git-based project scoping (issue #569).
|
|
6724
|
-
* Creates a coding context with `projectId: "tag:<projectTag>"`.
|
|
6725
|
-
*/
|
|
6726
|
-
projectTag: external_exports.string().trim().min(1, "projectTag must be non-empty when provided").max(256).optional(),
|
|
6727
|
-
/**
|
|
6728
|
-
* Historical recall pin (issue #680). ISO 8601 timestamp. The
|
|
6729
|
-
* schema only enforces the basic shape; the access service runs
|
|
6730
|
-
* `Date.parse` and emits a structured 400 on malformed input
|
|
6731
|
-
* (CLAUDE.md rule 51).
|
|
6732
|
-
*/
|
|
6733
|
-
asOf: external_exports.string().trim().min(1, "asOf must be a non-empty ISO 8601 timestamp").max(64).optional(),
|
|
6734
|
-
/**
|
|
6735
|
-
* Free-form recall tag filter (issue #689). When provided, recall results
|
|
6736
|
-
* whose frontmatter `tags` do not match the filter are removed before the
|
|
6737
|
-
* response is returned. Comparison is case-sensitive exact match.
|
|
6738
|
-
*/
|
|
6739
|
-
tags: external_exports.array(external_exports.string().trim().min(1).max(256)).max(50).optional(),
|
|
6740
|
-
/**
|
|
6741
|
-
* Match mode for `tags` (issue #689). Defaults to `"any"` when `tags` is
|
|
6742
|
-
* provided and `tagMatch` is omitted. Ignored when `tags` is absent.
|
|
6743
|
-
*/
|
|
6744
|
-
tagMatch: tagMatchSchema.optional(),
|
|
6745
|
-
/**
|
|
6746
|
-
* Include graph edges below `graphTraversalConfidenceFloor` for diagnostic
|
|
6747
|
-
* recall traversal (issue #681). Defaults to false.
|
|
6748
|
-
*/
|
|
6749
|
-
includeLowConfidence: external_exports.boolean().optional()
|
|
6750
|
-
});
|
|
6751
|
-
var recallExplainRequestSchema = external_exports.object({
|
|
6752
|
-
sessionKey: sessionKeySchema,
|
|
6753
|
-
namespace: namespaceSchema
|
|
6754
|
-
});
|
|
6755
|
-
var setCodingContextRequestSchema = external_exports.object({
|
|
6756
|
-
sessionKey: external_exports.string().trim().min(1, "sessionKey is required").max(512),
|
|
6757
|
-
codingContext: codingContextSchema
|
|
6758
|
-
});
|
|
6759
|
-
var messageSchema = external_exports.object({
|
|
6760
|
-
role: external_exports.enum(["user", "assistant"]),
|
|
6761
|
-
content: external_exports.string().min(1, "message content must be non-empty"),
|
|
6762
|
-
sourceFormat: external_exports.enum(["openai", "anthropic", "openclaw", "pi", "lossless-claw", "remnic"]).nullable().optional(),
|
|
6763
|
-
rawContent: external_exports.unknown().nullable().optional(),
|
|
6764
|
-
parts: external_exports.array(
|
|
6765
|
-
external_exports.object({
|
|
6766
|
-
ordinal: external_exports.number().int().min(0).nullable().optional(),
|
|
6767
|
-
kind: external_exports.enum([
|
|
6768
|
-
"text",
|
|
6769
|
-
"tool_call",
|
|
6770
|
-
"tool_result",
|
|
6771
|
-
"patch",
|
|
6772
|
-
"file_read",
|
|
6773
|
-
"file_write",
|
|
6774
|
-
"step_start",
|
|
6775
|
-
"step_finish",
|
|
6776
|
-
"snapshot",
|
|
6777
|
-
"retry"
|
|
6778
|
-
]),
|
|
6779
|
-
payload: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
6780
|
-
toolName: external_exports.string().nullable().optional(),
|
|
6781
|
-
tool_name: external_exports.string().nullable().optional(),
|
|
6782
|
-
filePath: external_exports.string().nullable().optional(),
|
|
6783
|
-
file_path: external_exports.string().nullable().optional(),
|
|
6784
|
-
createdAt: external_exports.string().nullable().optional(),
|
|
6785
|
-
created_at: external_exports.string().nullable().optional()
|
|
6786
|
-
})
|
|
6787
|
-
).nullable().optional()
|
|
6788
|
-
});
|
|
6789
|
-
var observeRequestSchema = external_exports.object({
|
|
6790
|
-
sessionKey: external_exports.string().trim().min(1, "sessionKey is required").max(512),
|
|
6791
|
-
messages: external_exports.array(messageSchema).min(1, "messages must be a non-empty array"),
|
|
6792
|
-
namespace: namespaceSchema,
|
|
6793
|
-
skipExtraction: external_exports.boolean().optional(),
|
|
6794
|
-
/** Working directory for auto git-context resolution (issue #569). */
|
|
6795
|
-
cwd: external_exports.string().trim().min(1, "cwd must be non-empty when provided").max(2048).optional(),
|
|
6796
|
-
/**
|
|
6797
|
-
* Arbitrary project tag for non-git-based project scoping (issue #569).
|
|
6798
|
-
* Creates a coding context with `projectId: "tag:<projectTag>"`.
|
|
6799
|
-
*/
|
|
6800
|
-
projectTag: external_exports.string().trim().min(1, "projectTag must be non-empty when provided").max(256).optional()
|
|
6801
|
-
});
|
|
6802
|
-
var writeContentSchema = external_exports.string().min(1, "content is required").max(5e4);
|
|
6803
|
-
var categorySchema = external_exports.enum([
|
|
6804
|
-
"fact",
|
|
6805
|
-
"preference",
|
|
6806
|
-
"correction",
|
|
6807
|
-
"entity",
|
|
6808
|
-
"decision",
|
|
6809
|
-
"relationship",
|
|
6810
|
-
"principle",
|
|
6811
|
-
"commitment",
|
|
6812
|
-
"moment",
|
|
6813
|
-
"skill",
|
|
6814
|
-
"rule",
|
|
6815
|
-
"procedure",
|
|
6816
|
-
"reasoning_trace"
|
|
6817
|
-
]).optional();
|
|
6818
|
-
var confidenceSchema = external_exports.number().min(0).max(1).optional();
|
|
6819
|
-
var tagsSchema = external_exports.array(external_exports.string().max(256)).max(50).optional();
|
|
6820
|
-
var entityRefSchema = external_exports.string().trim().max(512).optional();
|
|
6821
|
-
var ttlSchema = external_exports.string().trim().max(128).optional();
|
|
6822
|
-
var sourceReasonSchema = external_exports.string().trim().max(2e3).optional();
|
|
6823
|
-
var memoryStoreRequestSchema = external_exports.object({
|
|
6824
|
-
schemaVersion: schemaVersionSchema,
|
|
6825
|
-
idempotencyKey: idempotencyKeySchema,
|
|
6826
|
-
dryRun: dryRunSchema,
|
|
6827
|
-
sessionKey: sessionKeySchema,
|
|
6828
|
-
content: writeContentSchema,
|
|
6829
|
-
category: categorySchema,
|
|
6830
|
-
confidence: confidenceSchema,
|
|
6831
|
-
namespace: namespaceSchema,
|
|
6832
|
-
tags: tagsSchema,
|
|
6833
|
-
entityRef: entityRefSchema,
|
|
6834
|
-
ttl: ttlSchema,
|
|
6835
|
-
sourceReason: sourceReasonSchema
|
|
6836
|
-
});
|
|
6837
|
-
var reviewDispositionRequestSchema = external_exports.object({
|
|
6838
|
-
memoryId: external_exports.string().trim().min(1, "memoryId is required"),
|
|
6839
|
-
status: external_exports.enum([
|
|
6840
|
-
"active",
|
|
6841
|
-
"pending_review",
|
|
6842
|
-
"quarantined",
|
|
6843
|
-
"rejected",
|
|
6844
|
-
"superseded",
|
|
6845
|
-
"archived"
|
|
6846
|
-
]),
|
|
6847
|
-
reasonCode: external_exports.string().trim().min(1, "reasonCode is required"),
|
|
6848
|
-
namespace: namespaceSchema
|
|
6849
|
-
});
|
|
6850
|
-
var trustZonePromoteRequestSchema = external_exports.object({
|
|
6851
|
-
recordId: external_exports.string().trim().min(1, "recordId is required"),
|
|
6852
|
-
targetZone: external_exports.enum(["working", "trusted"], {
|
|
6853
|
-
errorMap: () => ({ message: "targetZone must be 'working' or 'trusted'" })
|
|
6854
|
-
}),
|
|
6855
|
-
promotionReason: external_exports.string().trim().min(1, "promotionReason is required"),
|
|
6856
|
-
recordedAt: external_exports.string().trim().optional(),
|
|
6857
|
-
summary: external_exports.string().trim().max(5e3).optional(),
|
|
6858
|
-
dryRun: dryRunSchema,
|
|
6859
|
-
namespace: namespaceSchema
|
|
6860
|
-
});
|
|
6861
|
-
var trustZoneDemoSeedRequestSchema = external_exports.object({
|
|
6862
|
-
scenario: external_exports.string().trim().max(256).optional(),
|
|
6863
|
-
recordedAt: external_exports.string().trim().optional(),
|
|
6864
|
-
dryRun: dryRunSchema,
|
|
6865
|
-
namespace: namespaceSchema
|
|
6866
|
-
});
|
|
6867
|
-
var lcmSearchRequestSchema = external_exports.object({
|
|
6868
|
-
query: external_exports.string().min(1, "query is required"),
|
|
6869
|
-
sessionKey: sessionKeySchema,
|
|
6870
|
-
namespace: namespaceSchema,
|
|
6871
|
-
limit: external_exports.number().int().min(1).max(100).optional()
|
|
6872
|
-
});
|
|
6873
|
-
var lcmCompactionFlushRequestSchema = external_exports.object({
|
|
6874
|
-
sessionKey: external_exports.string().trim().min(1, "sessionKey is required").max(512),
|
|
6875
|
-
namespace: namespaceSchema
|
|
6876
|
-
});
|
|
6877
|
-
var lcmCompactionRecordRequestSchema = external_exports.object({
|
|
6878
|
-
sessionKey: external_exports.string().trim().min(1, "sessionKey is required").max(512),
|
|
6879
|
-
namespace: namespaceSchema,
|
|
6880
|
-
tokensBefore: external_exports.number().int().min(0, "tokensBefore must be a non-negative integer"),
|
|
6881
|
-
tokensAfter: external_exports.number().int().min(0, "tokensAfter must be a non-negative integer")
|
|
6882
|
-
});
|
|
6883
|
-
var daySummaryRequestSchema = external_exports.object({
|
|
6884
|
-
memories: external_exports.string().max(1e5).optional(),
|
|
6885
|
-
sessionKey: sessionKeySchema,
|
|
6886
|
-
namespace: namespaceSchema
|
|
6887
|
-
});
|
|
6888
|
-
var capsuleTopLevelSegmentSchema = external_exports.string().trim().min(1).max(128).refine(
|
|
6889
|
-
(value) => !value.includes("/") && !value.includes("\\"),
|
|
6890
|
-
"must be a top-level directory name without path separators"
|
|
6891
|
-
);
|
|
6892
|
-
var capsulePeerIdSchema = external_exports.string().trim().min(1).max(256).refine(
|
|
6893
|
-
(value) => value !== "." && value !== ".." && !value.includes("/") && !value.includes("\\"),
|
|
6894
|
-
"must be a plain peer id without path separators"
|
|
6895
|
-
);
|
|
6896
|
-
var capsuleIsoSinceSchema = external_exports.string().trim().min(1, "since must be a non-empty ISO 8601 timestamp").max(128).refine(
|
|
6897
|
-
isValidCapsuleSince,
|
|
6898
|
-
"since must be a valid ISO 8601 timestamp with no calendar overflow"
|
|
6899
|
-
);
|
|
6900
|
-
var capsuleExportRequestSchema = external_exports.object({
|
|
6901
|
-
name: external_exports.string().trim().min(1, "name is required").max(64, "name must be 64 characters or fewer").regex(
|
|
6902
|
-
CAPSULE_ID_PATTERN,
|
|
6903
|
-
"name must be alphanumeric with single dashes (no spaces, no leading/trailing dashes)"
|
|
6904
|
-
),
|
|
6905
|
-
namespace: namespaceSchema,
|
|
6906
|
-
since: capsuleIsoSinceSchema.optional(),
|
|
6907
|
-
includeKinds: external_exports.array(capsuleTopLevelSegmentSchema).max(50).optional(),
|
|
6908
|
-
peerIds: external_exports.array(capsulePeerIdSchema).max(100).optional(),
|
|
6909
|
-
includeTranscripts: external_exports.boolean().optional(),
|
|
6910
|
-
encrypt: external_exports.boolean().optional()
|
|
6911
|
-
});
|
|
6912
|
-
var capsuleImportRequestSchema = external_exports.object({
|
|
6913
|
-
archivePath: external_exports.string().trim().min(1, "archivePath is required").max(4096),
|
|
6914
|
-
namespace: namespaceSchema,
|
|
6915
|
-
mode: external_exports.enum(["skip", "overwrite", "fork"]).optional()
|
|
6916
|
-
});
|
|
6917
|
-
var capsuleListRequestSchema = external_exports.object({
|
|
6918
|
-
namespace: namespaceSchema
|
|
6919
|
-
});
|
|
6920
|
-
var offlineSyncApplyRequestSchema = external_exports.object({
|
|
6921
|
-
namespace: namespaceSchema,
|
|
6922
|
-
changeset: external_exports.unknown()
|
|
6923
|
-
}).refine((value) => value.changeset !== void 0 && value.changeset !== null, {
|
|
6924
|
-
message: "changeset is required",
|
|
6925
|
-
path: ["changeset"]
|
|
6926
|
-
});
|
|
6927
|
-
var offlineSyncFilesRequestSchema = external_exports.object({
|
|
6928
|
-
namespace: namespaceSchema,
|
|
6929
|
-
includeTranscripts: external_exports.boolean().optional(),
|
|
6930
|
-
paths: external_exports.array(external_exports.string().trim().min(1, "path must be non-empty").max(4096)).max(5e3, "paths must contain 5000 or fewer entries")
|
|
6931
|
-
});
|
|
6932
|
-
var offlineSyncFileContentRequestSchema = external_exports.object({
|
|
6933
|
-
namespace: namespaceSchema,
|
|
6934
|
-
includeTranscripts: external_exports.boolean().optional(),
|
|
6935
|
-
path: external_exports.string().trim().min(1, "path must be non-empty").max(4096),
|
|
6936
|
-
offset: external_exports.number().int().min(0).optional(),
|
|
6937
|
-
length: external_exports.number().int().min(1).max(OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES).optional()
|
|
6938
|
-
});
|
|
6939
|
-
var nullableOptional = (schema) => schema.optional().nullable().transform((value) => value ?? void 0);
|
|
6940
|
-
var actionConfidenceRuleSchema = external_exports.object({
|
|
6941
|
-
kind: external_exports.enum(ACTION_CONFIDENCE_RULE_KINDS),
|
|
6942
|
-
description: nullableOptional(external_exports.string().trim().min(1).max(2e3)),
|
|
6943
|
-
matched: nullableOptional(external_exports.boolean())
|
|
6944
|
-
}).strict();
|
|
6945
|
-
var actionConfidenceMemorySchema = external_exports.object({
|
|
6946
|
-
source: nullableOptional(external_exports.string().trim().min(1).max(256)),
|
|
6947
|
-
created: nullableOptional(external_exports.string().trim().min(1).max(128)),
|
|
6948
|
-
updated: nullableOptional(external_exports.string().trim().min(1).max(128)),
|
|
6949
|
-
scope: nullableOptional(external_exports.string().trim().min(1).max(512)),
|
|
6950
|
-
userContextScopes: nullableOptional(external_exports.array(external_exports.string().trim().min(1).max(128)).max(50)),
|
|
6951
|
-
retrievalReason: nullableOptional(external_exports.string().trim().min(1).max(2e3)),
|
|
6952
|
-
confidence: nullableOptional(external_exports.number().min(0).max(1)),
|
|
6953
|
-
stale: nullableOptional(external_exports.boolean()),
|
|
6954
|
-
corrected: nullableOptional(external_exports.boolean()),
|
|
6955
|
-
correctionState: nullableOptional(external_exports.enum(["none", "correction", "superseded", "disputed", "forgotten"])),
|
|
6956
|
-
safeToUse: nullableOptional(external_exports.boolean()),
|
|
6957
|
-
safety: nullableOptional(external_exports.enum(["safe", "requires-review", "blocked"])),
|
|
6958
|
-
safetyReasons: nullableOptional(external_exports.array(external_exports.string().trim().min(1).max(1e3)).max(50))
|
|
6959
|
-
}).strict();
|
|
6960
|
-
var actionConfidenceRequestSchema = external_exports.object({
|
|
6961
|
-
intendedAction: nullableOptional(external_exports.string().trim().min(1).max(1e3)),
|
|
6962
|
-
confidence: nullableOptional(external_exports.number().min(0).max(1)),
|
|
6963
|
-
risk: nullableOptional(external_exports.enum(ACTION_CONFIDENCE_RISK_CATEGORIES)),
|
|
6964
|
-
contextReadiness: nullableOptional(external_exports.enum(ACTION_CONFIDENCE_CONTEXT_READINESS)),
|
|
6965
|
-
currentContextScopes: nullableOptional(external_exports.array(external_exports.string().trim().min(1).max(128)).max(50)),
|
|
6966
|
-
userRules: nullableOptional(external_exports.array(actionConfidenceRuleSchema).max(100)),
|
|
6967
|
-
retrievedMemories: nullableOptional(external_exports.array(actionConfidenceMemorySchema).max(200))
|
|
6968
|
-
}).strict();
|
|
6969
|
-
|
|
6970
|
-
// ../remnic-core/src/mcp-memory-inspector-app.ts
|
|
6971
|
-
var REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_HTML = `
|
|
6972
|
-
<div id="root" class="remnic-app">Loading Remnic memory inspector...</div>
|
|
6973
|
-
<style>
|
|
6974
|
-
:root {
|
|
6975
|
-
color-scheme: light dark;
|
|
6976
|
-
--bg: #f8faf8;
|
|
6977
|
-
--panel: #ffffff;
|
|
6978
|
-
--text: #17201b;
|
|
6979
|
-
--muted: #56635b;
|
|
6980
|
-
--line: #d8e0da;
|
|
6981
|
-
--accent: #2f7d57;
|
|
6982
|
-
--warn: #9a5b14;
|
|
6983
|
-
--bad: #9c2b2b;
|
|
6984
|
-
}
|
|
6985
|
-
@media (prefers-color-scheme: dark) {
|
|
6986
|
-
:root {
|
|
6987
|
-
--bg: #101512;
|
|
6988
|
-
--panel: #18201b;
|
|
6989
|
-
--text: #edf4ef;
|
|
6990
|
-
--muted: #a8b6ad;
|
|
6991
|
-
--line: #304036;
|
|
6992
|
-
--accent: #75c79a;
|
|
6993
|
-
--warn: #e0ad63;
|
|
6994
|
-
--bad: #f08a8a;
|
|
6995
|
-
}
|
|
6996
|
-
}
|
|
6997
|
-
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
6998
|
-
.remnic-app { padding: 14px; display: grid; gap: 12px; }
|
|
6999
|
-
.header, .section, .memory { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
|
|
7000
|
-
.title { font-size: 16px; font-weight: 650; margin: 0; }
|
|
7001
|
-
.muted { color: var(--muted); }
|
|
7002
|
-
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
|
|
7003
|
-
.pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin: 2px 4px 2px 0; color: var(--muted); }
|
|
7004
|
-
.safe { color: var(--accent); }
|
|
7005
|
-
.review { color: var(--warn); }
|
|
7006
|
-
.blocked { color: var(--bad); }
|
|
7007
|
-
.memory { display: grid; gap: 8px; }
|
|
7008
|
-
.memory-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-weight: 650; }
|
|
7009
|
-
.preview { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
7010
|
-
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
7011
|
-
button { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 6px; padding: 6px 9px; font: inherit; cursor: pointer; }
|
|
7012
|
-
button:hover { border-color: var(--accent); }
|
|
7013
|
-
pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; color: var(--muted); }
|
|
7014
|
-
</style>
|
|
7015
|
-
<script>
|
|
7016
|
-
const root = document.getElementById("root");
|
|
7017
|
-
|
|
7018
|
-
function escapeHtml(value) {
|
|
7019
|
-
return String(value ?? "").replace(/[&<>"']/g, (char) => ({
|
|
7020
|
-
"&": "&",
|
|
7021
|
-
"<": "<",
|
|
7022
|
-
">": ">",
|
|
7023
|
-
'"': """,
|
|
7024
|
-
"'": "'",
|
|
7025
|
-
}[char]));
|
|
7026
|
-
}
|
|
7027
|
-
|
|
7028
|
-
function statusClass(value) {
|
|
7029
|
-
if (value === "blocked" || value === false) return "blocked";
|
|
7030
|
-
if (value === "requires-review") return "review";
|
|
7031
|
-
return "safe";
|
|
7032
|
-
}
|
|
7033
|
-
|
|
7034
|
-
function followUp(prompt) {
|
|
7035
|
-
if (window.openai?.sendFollowUpMessage) {
|
|
7036
|
-
window.openai.sendFollowUpMessage({ prompt, scrollToBottom: true });
|
|
7037
|
-
return;
|
|
7038
|
-
}
|
|
7039
|
-
window.parent.postMessage({
|
|
7040
|
-
jsonrpc: "2.0",
|
|
7041
|
-
method: "ui/message",
|
|
7042
|
-
params: {
|
|
7043
|
-
role: "user",
|
|
7044
|
-
content: [{ type: "text", text: prompt }],
|
|
7045
|
-
},
|
|
7046
|
-
}, "*");
|
|
7047
|
-
}
|
|
7048
|
-
|
|
7049
|
-
function actionButtons(actions) {
|
|
7050
|
-
return (actions ?? []).map((action) =>
|
|
7051
|
-
'<button type="button" data-prompt="' + escapeHtml(action.followUpPrompt) + '">' +
|
|
7052
|
-
escapeHtml(action.label) +
|
|
7053
|
-
'</button>'
|
|
7054
|
-
).join("");
|
|
7055
|
-
}
|
|
7056
|
-
|
|
7057
|
-
function render(payload) {
|
|
7058
|
-
const data = payload?.structuredContent ?? payload ?? window.openai?.toolOutput ?? {};
|
|
7059
|
-
const confidence = data.actionConfidence ?? {};
|
|
7060
|
-
const memories = Array.isArray(data.memories) ? data.memories : [];
|
|
7061
|
-
root.innerHTML = [
|
|
7062
|
-
'<section class="header">',
|
|
7063
|
-
'<p class="title">Remnic Memory Inspector</p>',
|
|
7064
|
-
'<div class="muted">' + escapeHtml(data.query ?? "No query") + '</div>',
|
|
7065
|
-
'<div class="grid">',
|
|
7066
|
-
'<div><strong>Namespace</strong><br><span class="muted">' + escapeHtml(data.namespace ?? "default") + '</span></div>',
|
|
7067
|
-
'<div><strong>Decision</strong><br><span class="' + statusClass(confidence.decision) + '">' + escapeHtml(confidence.decision ?? "unknown") + '</span></div>',
|
|
7068
|
-
'<div><strong>Memories</strong><br><span class="muted">' + escapeHtml(data.memoryCount ?? memories.length) + '</span></div>',
|
|
7069
|
-
'</div>',
|
|
7070
|
-
'</section>',
|
|
7071
|
-
'<section class="section">',
|
|
7072
|
-
'<strong>Safe recall preview</strong>',
|
|
7073
|
-
'<pre>' + escapeHtml(data.safeRecallPreview ?? "") + '</pre>',
|
|
7074
|
-
'</section>',
|
|
7075
|
-
'<section class="section actions">',
|
|
7076
|
-
actionButtons(data.affordances),
|
|
7077
|
-
'</section>',
|
|
7078
|
-
memories.map((memory) => [
|
|
7079
|
-
'<article class="memory">',
|
|
7080
|
-
'<div class="memory-title"><span>' + escapeHtml(memory.id) + '</span><span class="' + statusClass(memory.safety) + '">' + escapeHtml(memory.safety ?? "safe") + '</span></div>',
|
|
7081
|
-
'<div class="preview">' + escapeHtml(memory.preview ?? "") + '</div>',
|
|
7082
|
-
'<div>',
|
|
7083
|
-
'<span class="pill">source ' + escapeHtml(memory.source ?? "unknown") + '</span>',
|
|
7084
|
-
'<span class="pill">scope ' + escapeHtml(memory.scope ?? "unknown") + '</span>',
|
|
7085
|
-
'<span class="pill">reason ' + escapeHtml(memory.retrievalReason ?? memory.servedBy ?? "unknown") + '</span>',
|
|
7086
|
-
'<span class="pill">confidence ' + escapeHtml(memory.confidence ?? "n/a") + '</span>',
|
|
7087
|
-
'</div>',
|
|
7088
|
-
'<div class="muted">' + escapeHtml((memory.safetyReasons ?? []).join("; ")) + '</div>',
|
|
7089
|
-
'</article>',
|
|
7090
|
-
].join("")).join(""),
|
|
7091
|
-
].join("");
|
|
7092
|
-
|
|
7093
|
-
root.querySelectorAll("button[data-prompt]").forEach((button) => {
|
|
7094
|
-
button.addEventListener("click", () => followUp(button.getAttribute("data-prompt") ?? ""));
|
|
7095
|
-
});
|
|
7096
|
-
}
|
|
7097
|
-
|
|
7098
|
-
render(window.openai?.toolOutput);
|
|
7099
|
-
|
|
7100
|
-
window.addEventListener("message", (event) => {
|
|
7101
|
-
if (event.source !== window.parent) return;
|
|
7102
|
-
const message = event.data;
|
|
7103
|
-
if (!message || message.jsonrpc !== "2.0") return;
|
|
7104
|
-
if (message.method === "ui/notifications/tool-result") {
|
|
7105
|
-
render(message.params);
|
|
7106
|
-
}
|
|
7107
|
-
}, { passive: true });
|
|
7108
|
-
|
|
7109
|
-
window.addEventListener("openai:set_globals", (event) => {
|
|
7110
|
-
render(event.detail?.globals?.toolOutput ?? window.openai?.toolOutput);
|
|
7111
|
-
}, { passive: true });
|
|
7112
|
-
</script>
|
|
7113
|
-
`.trim();
|
|
7114
|
-
|
|
7115
|
-
// ../remnic-core/src/access-http.ts
|
|
7116
|
-
function resolveDefaultAdminConsolePublicDir() {
|
|
7117
|
-
const thisDir = path49.dirname(fileURLToPath3(import.meta.url));
|
|
7118
|
-
const candidates = [
|
|
7119
|
-
// Standard: admin-console sibling to src/ (development layout)
|
|
7120
|
-
path49.resolve(thisDir, "../admin-console/public"),
|
|
7121
|
-
// Bundled: admin-console inside dist/ alongside the bundle
|
|
7122
|
-
path49.resolve(thisDir, "./admin-console/public"),
|
|
7123
|
-
// Package root: walk up from dist/ to the package root
|
|
7124
|
-
path49.resolve(thisDir, "../../admin-console/public")
|
|
7125
|
-
];
|
|
7126
|
-
return candidates.find((candidate) => existsSync4(candidate)) ?? candidates[0];
|
|
7127
|
-
}
|
|
7128
|
-
var defaultAdminConsolePublicDir = resolveDefaultAdminConsolePublicDir();
|
|
7129
|
-
var correlationIdStore = new AsyncLocalStorage();
|
|
7130
|
-
|
|
7131
|
-
// ../remnic-core/src/whitespace.ts
|
|
7132
|
-
function collapseWhitespace(value) {
|
|
7133
|
-
return value.replace(/\s+/g, " ").trim();
|
|
7134
|
-
}
|
|
7135
|
-
function truncateCodePointSafe(value, maxChars) {
|
|
7136
|
-
const glyphs = Array.from(value);
|
|
7137
|
-
if (maxChars <= 0) return "";
|
|
7138
|
-
if (glyphs.length <= maxChars) return value;
|
|
7139
|
-
return glyphs.slice(0, Math.max(1, maxChars)).join("").trimEnd();
|
|
7140
|
-
}
|
|
7141
|
-
|
|
7142
|
-
// ../remnic-core/src/active-memory-bridge.ts
|
|
7143
|
-
function isArtifactPath(value) {
|
|
7144
|
-
return typeof value === "string" && /(?:^|[\\/])artifacts(?:[\\/]|$)/i.test(value);
|
|
7145
|
-
}
|
|
7146
|
-
function clampLimit(value) {
|
|
7147
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return 8;
|
|
7148
|
-
return Math.max(1, Math.min(50, Math.floor(value)));
|
|
7149
|
-
}
|
|
7150
|
-
function truncateSnippet(value, maxChars) {
|
|
7151
|
-
const compact = collapseWhitespace(value);
|
|
7152
|
-
return truncateCodePointSafe(compact, maxChars);
|
|
7153
|
-
}
|
|
7154
|
-
function pickMetadata(value) {
|
|
7155
|
-
if (!value) return void 0;
|
|
7156
|
-
const metadata = {};
|
|
7157
|
-
if (typeof value.type === "string") metadata.type = value.type;
|
|
7158
|
-
if (typeof value.topic === "string") metadata.topic = value.topic;
|
|
7159
|
-
if (typeof value.updatedAt === "string") metadata.updatedAt = value.updatedAt;
|
|
7160
|
-
if (typeof value.sourceUri === "string") metadata.sourceUri = value.sourceUri;
|
|
7161
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
7162
|
-
}
|
|
7163
|
-
function resolveActiveMemoryNamespace(orchestrator, sessionKey, requestedNamespace) {
|
|
7164
|
-
const explicitNamespace = typeof requestedNamespace === "string" && requestedNamespace.trim().length > 0 ? requestedNamespace.trim() : void 0;
|
|
7165
|
-
const config = orchestrator.config;
|
|
7166
|
-
if (config?.namespacesEnabled === false) {
|
|
7167
|
-
if (typeof orchestrator.resolveSelfNamespace === "function") {
|
|
7168
|
-
return orchestrator.resolveSelfNamespace(sessionKey);
|
|
7169
|
-
}
|
|
7170
|
-
return "default";
|
|
7171
|
-
}
|
|
7172
|
-
if (!config) {
|
|
7173
|
-
if (explicitNamespace) return explicitNamespace;
|
|
7174
|
-
if (typeof orchestrator.resolveSelfNamespace === "function") {
|
|
7175
|
-
return orchestrator.resolveSelfNamespace(sessionKey);
|
|
7176
|
-
}
|
|
7177
|
-
return "default";
|
|
7178
|
-
}
|
|
7179
|
-
const principal = typeof orchestrator.resolvePrincipal === "function" ? orchestrator.resolvePrincipal(sessionKey) : resolvePrincipal(sessionKey, config);
|
|
7180
|
-
if (explicitNamespace) {
|
|
7181
|
-
if (!canReadNamespace(principal, explicitNamespace, config)) {
|
|
7182
|
-
throw new Error(`namespace ${explicitNamespace} is not readable for principal ${principal}`);
|
|
7183
|
-
}
|
|
7184
|
-
return explicitNamespace;
|
|
7185
|
-
}
|
|
7186
|
-
if (typeof orchestrator.resolveSelfNamespace === "function") {
|
|
7187
|
-
return orchestrator.resolveSelfNamespace(sessionKey);
|
|
7188
|
-
}
|
|
7189
|
-
return defaultNamespaceForPrincipal(principal, config);
|
|
7190
|
-
}
|
|
7191
|
-
async function recallForActiveMemory(orchestrator, params) {
|
|
7192
|
-
const limit = clampLimit(params.limit);
|
|
7193
|
-
const requestedResults = Math.min(200, limit + 20);
|
|
7194
|
-
const snippetMaxChars = typeof params.snippetMaxChars === "number" && Number.isFinite(params.snippetMaxChars) ? Math.max(1, Math.min(4e3, Math.floor(params.snippetMaxChars))) : 600;
|
|
7195
|
-
const namespace = resolveActiveMemoryNamespace(
|
|
7196
|
-
orchestrator,
|
|
7197
|
-
params.sessionKey,
|
|
7198
|
-
typeof params.filters?.namespace === "string" ? params.filters.namespace : void 0
|
|
7199
|
-
);
|
|
7200
|
-
const raw = await orchestrator.searchAcrossNamespaces({
|
|
7201
|
-
query: params.query,
|
|
7202
|
-
maxResults: requestedResults,
|
|
7203
|
-
namespaces: [namespace],
|
|
7204
|
-
mode: "search"
|
|
7205
|
-
});
|
|
7206
|
-
const visible = raw.filter((candidate) => !isArtifactPath(candidate.path));
|
|
7207
|
-
return {
|
|
7208
|
-
results: visible.slice(0, limit).map((candidate, index) => ({
|
|
7209
|
-
id: candidate.id ?? candidate.path ?? `memory-${index + 1}`,
|
|
7210
|
-
score: typeof candidate.score === "number" ? candidate.score : 0,
|
|
7211
|
-
text: truncateSnippet(candidate.snippet ?? candidate.text ?? "", snippetMaxChars),
|
|
7212
|
-
metadata: pickMetadata(candidate.metadata)
|
|
7213
|
-
})),
|
|
7214
|
-
truncated: visible.length > limit
|
|
7215
|
-
};
|
|
7216
|
-
}
|
|
7217
|
-
function buildActiveMemoryMetadataFromMemory(memory) {
|
|
7218
|
-
const metadata = {};
|
|
7219
|
-
if (typeof memory.frontmatter.category === "string") {
|
|
7220
|
-
const category = memory.frontmatter.category;
|
|
7221
|
-
if (category === "fact" || category === "preference") {
|
|
7222
|
-
metadata.type = category;
|
|
7223
|
-
}
|
|
7224
|
-
}
|
|
7225
|
-
if (Array.isArray(memory.frontmatter.tags) && memory.frontmatter.tags.length > 0) {
|
|
7226
|
-
metadata.topic = memory.frontmatter.tags[0];
|
|
7227
|
-
}
|
|
7228
|
-
if (typeof memory.frontmatter.updated === "string") metadata.updatedAt = memory.frontmatter.updated;
|
|
7229
|
-
if (typeof memory.frontmatter.source === "string") metadata.sourceUri = memory.frontmatter.source;
|
|
7230
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
7231
|
-
}
|
|
7232
|
-
async function getMemoryForActiveMemory(orchestrator, id, options = {}) {
|
|
7233
|
-
const namespace = resolveActiveMemoryNamespace(
|
|
7234
|
-
orchestrator,
|
|
7235
|
-
options.sessionKey,
|
|
7236
|
-
options.namespace
|
|
7237
|
-
);
|
|
7238
|
-
const storage = typeof orchestrator.getStorageForNamespace === "function" ? await orchestrator.getStorageForNamespace(namespace) : orchestrator.storage;
|
|
7239
|
-
const memory = await storage?.getMemoryById?.(id);
|
|
7240
|
-
if (!memory) return { error: "not_found" };
|
|
7241
|
-
return {
|
|
7242
|
-
id,
|
|
7243
|
-
text: collapseWhitespace(memory.content),
|
|
7244
|
-
metadata: buildActiveMemoryMetadataFromMemory(memory)
|
|
7245
|
-
};
|
|
7246
|
-
}
|
|
7247
|
-
|
|
7248
|
-
// ../remnic-core/src/binary-lifecycle/types.ts
|
|
7249
|
-
var DEFAULT_MAX_BINARY_SIZE_BYTES = 50 * 1024 * 1024;
|
|
7250
|
-
|
|
7251
|
-
// ../remnic-core/src/binary-lifecycle/backend.ts
|
|
7252
|
-
import fs3 from "fs";
|
|
7253
|
-
import fsp2 from "fs/promises";
|
|
7254
|
-
import path50 from "path";
|
|
7255
|
-
|
|
7256
|
-
// ../remnic-core/src/binary-lifecycle/scanner.ts
|
|
7257
|
-
import fsp3 from "fs/promises";
|
|
7258
|
-
import path51 from "path";
|
|
7259
|
-
|
|
7260
|
-
// ../remnic-core/src/binary-lifecycle/manifest.ts
|
|
7261
|
-
import fsp4 from "fs/promises";
|
|
7262
|
-
import path52 from "path";
|
|
7263
|
-
import crypto3 from "crypto";
|
|
7264
|
-
|
|
7265
|
-
// ../remnic-core/src/binary-lifecycle/pipeline.ts
|
|
7266
|
-
import fsp5 from "fs/promises";
|
|
7267
|
-
import path53 from "path";
|
|
7268
|
-
import crypto4 from "crypto";
|
|
7269
|
-
|
|
7270
|
-
// ../remnic-core/src/projection/index.ts
|
|
7271
|
-
import fs4 from "fs";
|
|
7272
|
-
import path55 from "path";
|
|
7273
|
-
|
|
7274
|
-
// ../remnic-core/src/utils/category-dir.ts
|
|
7275
|
-
import path54 from "path";
|
|
7276
|
-
var CATEGORY_DIR_MAP = {
|
|
7277
|
-
correction: "corrections",
|
|
7278
|
-
question: "questions",
|
|
7279
|
-
preference: "preferences",
|
|
7280
|
-
decision: "decisions",
|
|
7281
|
-
moment: "moments",
|
|
7282
|
-
commitment: "commitments",
|
|
7283
|
-
principle: "principles",
|
|
7284
|
-
rule: "rules",
|
|
7285
|
-
skill: "skills",
|
|
7286
|
-
relationship: "relationships",
|
|
7287
|
-
procedure: "procedures",
|
|
7288
|
-
reasoning_trace: "reasoning-traces"
|
|
7289
|
-
};
|
|
7290
|
-
var ALL_CATEGORY_DIRS = [
|
|
7291
|
-
"facts",
|
|
7292
|
-
...Object.values(CATEGORY_DIR_MAP)
|
|
7293
|
-
];
|
|
7294
|
-
var ALL_CATEGORY_KEYS = [
|
|
7295
|
-
"fact",
|
|
7296
|
-
...Object.keys(CATEGORY_DIR_MAP)
|
|
7297
|
-
];
|
|
7298
|
-
|
|
7299
|
-
// ../remnic-core/src/onboarding/index.ts
|
|
7300
|
-
import fs5 from "fs";
|
|
7301
|
-
import path56 from "path";
|
|
7302
|
-
|
|
7303
|
-
// ../remnic-core/src/curation/index.ts
|
|
7304
|
-
import fs6 from "fs";
|
|
7305
|
-
import path57 from "path";
|
|
7306
|
-
import crypto5 from "crypto";
|
|
7307
|
-
|
|
7308
|
-
// ../remnic-core/src/dedup/index.ts
|
|
7309
|
-
import fs7 from "fs";
|
|
7310
|
-
import path58 from "path";
|
|
7311
|
-
import crypto6 from "crypto";
|
|
7312
|
-
|
|
7313
|
-
// ../remnic-core/src/review/index.ts
|
|
7314
|
-
import fs8 from "fs";
|
|
7315
|
-
import path59 from "path";
|
|
7316
|
-
|
|
7317
|
-
// ../remnic-core/src/sync/index.ts
|
|
7318
|
-
import fs9 from "fs";
|
|
7319
|
-
import path60 from "path";
|
|
7320
|
-
import crypto7 from "crypto";
|
|
7321
|
-
|
|
7322
|
-
// ../remnic-core/src/connectors/index.ts
|
|
7323
|
-
import fs12 from "fs";
|
|
7324
|
-
import path63 from "path";
|
|
7325
|
-
import os5 from "os";
|
|
7326
|
-
import { createRequire as createRequire2 } from "module";
|
|
7327
|
-
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
7328
|
-
|
|
7329
|
-
// ../remnic-core/src/tokens.ts
|
|
7330
|
-
import fs10 from "fs";
|
|
7331
|
-
import path61 from "path";
|
|
7332
|
-
import { randomBytes as randomBytes2, randomUUID as randomUUID8 } from "crypto";
|
|
7333
|
-
|
|
7334
|
-
// ../remnic-core/src/connectors/codex-marketplace.ts
|
|
7335
|
-
import fs11 from "fs";
|
|
7336
|
-
import path62 from "path";
|
|
7337
|
-
|
|
7338
|
-
// ../remnic-core/src/spaces/index.ts
|
|
7339
|
-
import fs13 from "fs";
|
|
7340
|
-
import path64 from "path";
|
|
7341
|
-
import crypto8 from "crypto";
|
|
7342
|
-
|
|
7343
|
-
// ../remnic-core/src/memory-extension/codex-publisher.ts
|
|
7344
|
-
import fs14 from "fs";
|
|
7345
|
-
import os6 from "os";
|
|
7346
|
-
import path65 from "path";
|
|
7347
|
-
|
|
7348
|
-
// ../remnic-core/src/enrichment/audit.ts
|
|
7349
|
-
import * as fsReadModule30 from "fs/promises";
|
|
7350
|
-
const mkdir34 = fsReadModule30.mkdir;
|
|
7351
|
-
const fileReader33 = fsReadModule30["re"+"ad"+"Fi"+"le"];
|
|
7352
|
-
const appendFile5 = fsReadModule30.appendFile;
|
|
7353
|
-
import { existsSync as existsSync5 } from "fs";
|
|
7354
|
-
import path66 from "path";
|
|
7355
|
-
|
|
7356
|
-
// ../remnic-core/src/cli.ts
|
|
7357
|
-
import path90 from "path";
|
|
7358
|
-
import * as fsReadModule31 from "fs/promises";
|
|
7359
|
-
const access8 = fsReadModule31.access;
|
|
7360
|
-
const fileReader47 = fsReadModule31["re"+"ad"+"Fi"+"le"];
|
|
7361
|
-
const readdir30 = fsReadModule31.readdir;
|
|
7362
|
-
const unlink13 = fsReadModule31.unlink;
|
|
7363
|
-
import { createHash as createHash16 } from "crypto";
|
|
7364
|
-
|
|
7365
|
-
// ../remnic-core/src/transfer/export-json.ts
|
|
7366
|
-
import path67 from "path";
|
|
7367
|
-
import * as fsReadModule32 from "fs/promises";
|
|
7368
|
-
const mkdir35 = fsReadModule32.mkdir;
|
|
7369
|
-
const fileReader34 = fsReadModule32["re"+"ad"+"Fi"+"le"];
|
|
7370
|
-
|
|
7371
|
-
// ../remnic-core/src/transfer/export-md.ts
|
|
7372
|
-
import path68 from "path";
|
|
7373
|
-
import * as fsReadModule33 from "fs/promises";
|
|
7374
|
-
const mkdir36 = fsReadModule33.mkdir;
|
|
7375
|
-
const fileReader35 = fsReadModule33["re"+"ad"+"Fi"+"le"];
|
|
7376
|
-
const writeFile32 = fsReadModule33.writeFile;
|
|
7377
|
-
|
|
7378
|
-
// ../remnic-core/src/transfer/backup.ts
|
|
7379
|
-
import path69 from "path";
|
|
7380
|
-
import { mkdir as mkdir37, readdir as readdir21, rm as rm9, unlink as unlink10, writeFile as writeFile33 } from "fs/promises";
|
|
7381
|
-
import { gzipSync } from "zlib";
|
|
7382
|
-
|
|
7383
|
-
// ../remnic-core/src/transfer/export-sqlite.ts
|
|
7384
|
-
import path70 from "path";
|
|
7385
|
-
|
|
7386
|
-
// ../remnic-core/src/transfer/import-json.ts
|
|
7387
|
-
import path71 from "path";
|
|
7388
|
-
import { mkdir as mkdir38, writeFile as writeFile34 } from "fs/promises";
|
|
7389
|
-
|
|
7390
|
-
// ../remnic-core/src/transfer/import-sqlite.ts
|
|
7391
|
-
import path72 from "path";
|
|
7392
|
-
import { mkdir as mkdir39, writeFile as writeFile35 } from "fs/promises";
|
|
7393
|
-
|
|
7394
|
-
// ../remnic-core/src/transfer/import-md.ts
|
|
7395
|
-
import path73 from "path";
|
|
7396
|
-
import * as fsReadModule34 from "fs/promises";
|
|
7397
|
-
const mkdir40 = fsReadModule34.mkdir;
|
|
7398
|
-
const fileReader36 = fsReadModule34["re"+"ad"+"Fi"+"le"];
|
|
7399
|
-
const writeFile36 = fsReadModule34.writeFile;
|
|
7400
|
-
|
|
7401
|
-
// ../remnic-core/src/transfer/autodetect.ts
|
|
7402
|
-
import path74 from "path";
|
|
7403
|
-
import { stat as stat16 } from "fs/promises";
|
|
7404
|
-
|
|
7405
|
-
// ../remnic-core/src/maintenance/archive-observations.ts
|
|
7406
|
-
import path75 from "path";
|
|
7407
|
-
import * as fsReadModule35 from "fs/promises";
|
|
7408
|
-
const mkdir41 = fsReadModule35.mkdir;
|
|
7409
|
-
const readdir22 = fsReadModule35.readdir;
|
|
7410
|
-
const fileReader37 = fsReadModule35["re"+"ad"+"Fi"+"le"];
|
|
7411
|
-
const unlink11 = fsReadModule35.unlink;
|
|
7412
|
-
const writeFile37 = fsReadModule35.writeFile;
|
|
7413
|
-
|
|
7414
|
-
// ../remnic-core/src/maintenance/rebuild-memory-lifecycle-ledger.ts
|
|
7415
|
-
import path76 from "path";
|
|
7416
|
-
import { mkdir as mkdir42, rename as rename6, stat as stat17, writeFile as writeFile38 } from "fs/promises";
|
|
7417
|
-
|
|
7418
|
-
// ../remnic-core/src/maintenance/rebuild-memory-projection.ts
|
|
7419
|
-
import path77 from "path";
|
|
7420
|
-
import { mkdir as mkdir43, rename as rename7, rm as rm10, stat as stat18 } from "fs/promises";
|
|
7421
|
-
|
|
7422
|
-
// ../remnic-core/src/maintenance/rebuild-observations.ts
|
|
7423
|
-
import path79 from "path";
|
|
7424
|
-
import * as fsReadModule36 from "fs/promises";
|
|
7425
|
-
const readdir23 = fsReadModule36.readdir;
|
|
7426
|
-
const fileReader39 = fsReadModule36["re"+"ad"+"Fi"+"le"];
|
|
7427
|
-
|
|
7428
|
-
// ../remnic-core/src/maintenance/observation-ledger-utils.ts
|
|
7429
|
-
import path78 from "path";
|
|
7430
|
-
import * as fsReadModule37 from "fs/promises";
|
|
7431
|
-
const mkdir44 = fsReadModule37.mkdir;
|
|
7432
|
-
const fileReader38 = fsReadModule37["re"+"ad"+"Fi"+"le"];
|
|
7433
|
-
const writeFile39 = fsReadModule37.writeFile;
|
|
7434
|
-
|
|
7435
|
-
// ../remnic-core/src/maintenance/migrate-observations.ts
|
|
7436
|
-
import path80 from "path";
|
|
7437
|
-
import * as fsReadModule38 from "fs/promises";
|
|
7438
|
-
const readdir24 = fsReadModule38.readdir;
|
|
7439
|
-
const fileReader40 = fsReadModule38["re"+"ad"+"Fi"+"le"];
|
|
7440
|
-
|
|
7441
|
-
// ../remnic-core/src/namespaces/migrate.ts
|
|
7442
|
-
import path81 from "path";
|
|
7443
|
-
import { access as access4, mkdir as mkdir45, readdir as readdir25, rename as rename8 } from "fs/promises";
|
|
7444
|
-
|
|
7445
|
-
// ../remnic-core/src/operator-toolkit.ts
|
|
7446
|
-
import path83 from "path";
|
|
7447
|
-
import { constants as fsConstants2 } from "fs";
|
|
7448
|
-
import * as fsReadModule39 from "fs/promises";
|
|
7449
|
-
const access6 = fsReadModule39.access;
|
|
7450
|
-
const mkdir46 = fsReadModule39.mkdir;
|
|
7451
|
-
const fileReader42 = fsReadModule39["re"+"ad"+"Fi"+"le"];
|
|
7452
|
-
const readdir27 = fsReadModule39.readdir;
|
|
7453
|
-
const stat20 = fsReadModule39.stat;
|
|
7454
|
-
const unlink12 = fsReadModule39.unlink;
|
|
7455
|
-
const writeFile40 = fsReadModule39.writeFile;
|
|
7456
|
-
|
|
7457
|
-
// ../remnic-core/src/consolidation-provenance-check.ts
|
|
7458
|
-
import path82 from "path";
|
|
7459
|
-
import * as fsReadModule40 from "fs/promises";
|
|
7460
|
-
const readdir26 = fsReadModule40.readdir;
|
|
7461
|
-
const fileReader41 = fsReadModule40["re"+"ad"+"Fi"+"le"];
|
|
7462
|
-
const stat19 = fsReadModule40.stat;
|
|
7463
|
-
|
|
7464
|
-
// ../remnic-core/src/network/tailscale.ts
|
|
7465
|
-
import { stat as stat21 } from "fs/promises";
|
|
7466
|
-
|
|
7467
|
-
// ../remnic-core/src/network/webdav.ts
|
|
7468
|
-
import { createReadStream } from "fs";
|
|
7469
|
-
import { mkdir as mkdir47, readdir as readdir28, realpath as realpath5, stat as stat22 } from "fs/promises";
|
|
7470
|
-
import { createServer as createServer2 } from "http";
|
|
7471
|
-
import { timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
7472
|
-
import path84 from "path";
|
|
7473
|
-
import { pipeline } from "stream/promises";
|
|
7474
|
-
import { URL as URL3 } from "url";
|
|
7475
|
-
|
|
7476
|
-
// ../remnic-core/src/dashboard-runtime.ts
|
|
7477
|
-
import { createHash as createHash15 } from "crypto";
|
|
7478
|
-
import { createServer as createServer3 } from "http";
|
|
7479
|
-
import { watch } from "fs";
|
|
7480
|
-
import * as fsReadModule41 from "fs/promises";
|
|
7481
|
-
const fileReader44 = fsReadModule41["re"+"ad"+"Fi"+"le"];
|
|
7482
|
-
import path86 from "path";
|
|
7483
|
-
|
|
7484
|
-
// ../remnic-core/src/graph-dashboard-parser.ts
|
|
7485
|
-
import path85 from "path";
|
|
7486
|
-
import * as fsReadModule42 from "fs/promises";
|
|
7487
|
-
const fileReader43 = fsReadModule42["re"+"ad"+"Fi"+"le"];
|
|
7488
|
-
|
|
7489
|
-
// ../remnic-core/src/compat/checks.ts
|
|
7490
|
-
import * as fsReadModule43 from "fs/promises";
|
|
7491
|
-
const access7 = fsReadModule43.access;
|
|
7492
|
-
const fileReader45 = fsReadModule43["re"+"ad"+"Fi"+"le"];
|
|
7493
|
-
import path87 from "path";
|
|
7494
|
-
|
|
7495
|
-
// ../remnic-core/src/resume-bundles.ts
|
|
7496
|
-
import path88 from "path";
|
|
7497
|
-
import { mkdir as mkdir48, writeFile as writeFile41 } from "fs/promises";
|
|
7498
|
-
|
|
7499
|
-
// ../remnic-core/src/training-export/converter.ts
|
|
7500
|
-
import * as fsReadModule44 from "fs/promises";
|
|
7501
|
-
const lstat8 = fsReadModule44.lstat;
|
|
7502
|
-
const readdir29 = fsReadModule44.readdir;
|
|
7503
|
-
const fileReader46 = fsReadModule44["re"+"ad"+"Fi"+"le"];
|
|
7504
|
-
const realpath6 = fsReadModule44.realpath;
|
|
7505
|
-
import path89 from "path";
|
|
7506
|
-
|
|
7507
|
-
// ../remnic-core/src/cli.ts
|
|
7508
|
-
var webDavOperationChain = Promise.resolve();
|
|
7509
|
-
var dashboardOperationChain = Promise.resolve();
|
|
7510
|
-
var accessHttpOperationChain = Promise.resolve();
|
|
7511
|
-
|
|
7512
|
-
// ../remnic-core/src/transfer/capsule-fork.ts
|
|
7513
|
-
import * as fsReadModule45 from "fs/promises";
|
|
7514
|
-
const lstat9 = fsReadModule45.lstat;
|
|
7515
|
-
const mkdir49 = fsReadModule45.mkdir;
|
|
7516
|
-
const fileReader48 = fsReadModule45["re"+"ad"+"Fi"+"le"];
|
|
7517
|
-
const realpath7 = fsReadModule45.realpath;
|
|
7518
|
-
const writeFile42 = fsReadModule45.writeFile;
|
|
7519
|
-
import path91 from "path";
|
|
5716
|
+
// src/openclaw-tools/memory-get-tool.ts
|
|
5717
|
+
import { getMemoryForActiveMemory } from "@remnic/core";
|
|
7520
5718
|
|
|
7521
5719
|
// src/openclaw-tools/shapes.ts
|
|
7522
5720
|
var MemorySearchInputSchema = Type.Object({
|
|
@@ -7568,6 +5766,7 @@ function buildMemoryGetTool(orchestrator, options = {}) {
|
|
|
7568
5766
|
}
|
|
7569
5767
|
|
|
7570
5768
|
// src/openclaw-tools/memory-search-tool.ts
|
|
5769
|
+
import { recallForActiveMemory } from "@remnic/core";
|
|
7571
5770
|
function buildMemorySearchTool(orchestrator, options = {}) {
|
|
7572
5771
|
const recall = options.recallForActiveMemory ?? recallForActiveMemory;
|
|
7573
5772
|
return {
|
|
@@ -7624,6 +5823,24 @@ function serializeStringRecord(value) {
|
|
|
7624
5823
|
Object.entries(value ?? {}).sort(([left], [right]) => left.localeCompare(right))
|
|
7625
5824
|
);
|
|
7626
5825
|
}
|
|
5826
|
+
function normalizeAttributePairs(pairs) {
|
|
5827
|
+
return Object.entries(pairs).map(([key, value]) => [key.trim().toLowerCase(), value.trim()]).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}: ${value}`).join("; ");
|
|
5828
|
+
}
|
|
5829
|
+
function enrichSurfaceContent(content, structuredAttributes) {
|
|
5830
|
+
if (!structuredAttributes || Object.keys(structuredAttributes).length === 0) {
|
|
5831
|
+
return content;
|
|
5832
|
+
}
|
|
5833
|
+
return `${content}
|
|
5834
|
+
[Attributes: ${normalizeAttributePairs(structuredAttributes)}]`;
|
|
5835
|
+
}
|
|
5836
|
+
function stripSurfaceAttributeSuffix(content, structuredAttributes) {
|
|
5837
|
+
if (!structuredAttributes || Object.keys(structuredAttributes).length === 0) {
|
|
5838
|
+
return content;
|
|
5839
|
+
}
|
|
5840
|
+
const suffix = `
|
|
5841
|
+
[Attributes: ${normalizeAttributePairs(structuredAttributes)}]`;
|
|
5842
|
+
return content.endsWith(suffix) ? content.slice(0, -suffix.length) : content;
|
|
5843
|
+
}
|
|
7627
5844
|
function buildDreamMemoryContent(entry) {
|
|
7628
5845
|
return entry.title ? `${entry.title}
|
|
7629
5846
|
|
|
@@ -7652,31 +5869,77 @@ function findUniqueSurfaceMemoryBySlug(memories, surfaceType, slug) {
|
|
|
7652
5869
|
}
|
|
7653
5870
|
async function patchMemory(storage, memory, nextContent, patch) {
|
|
7654
5871
|
let changed = false;
|
|
7655
|
-
if (memory.content.trim() !== nextContent.trim()) {
|
|
7656
|
-
changed = await storage.updateMemory(memory.frontmatter.id, nextContent) || changed;
|
|
7657
|
-
}
|
|
7658
5872
|
const nextTags = JSON.stringify(uniqueTags(patch.tags ?? memory.frontmatter.tags ?? []));
|
|
7659
5873
|
const prevTags = JSON.stringify(uniqueTags(memory.frontmatter.tags ?? []));
|
|
5874
|
+
const nextStructuredAttributes = patch.structuredAttributes ?? memory.frontmatter.structuredAttributes;
|
|
7660
5875
|
const nextAttrs = serializeStringRecord(
|
|
7661
|
-
|
|
5876
|
+
nextStructuredAttributes
|
|
7662
5877
|
);
|
|
7663
5878
|
const prevAttrs = serializeStringRecord(memory.frontmatter.structuredAttributes);
|
|
7664
5879
|
const sourceChanged = patch.source !== void 0 && patch.source !== memory.frontmatter.source;
|
|
7665
5880
|
const memoryKindChanged = patch.memoryKind !== void 0 && patch.memoryKind !== memory.frontmatter.memoryKind;
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
5881
|
+
const metadataChanged = nextTags !== prevTags || nextAttrs !== prevAttrs || sourceChanged || memoryKindChanged;
|
|
5882
|
+
const persistedContent = enrichSurfaceContent(nextContent, nextStructuredAttributes);
|
|
5883
|
+
const existingBody = stripSurfaceAttributeSuffix(
|
|
5884
|
+
memory.content,
|
|
5885
|
+
memory.frontmatter.structuredAttributes
|
|
5886
|
+
);
|
|
5887
|
+
const contentChanged = existingBody.trim() !== nextContent.trim() || memory.content.trim() !== persistedContent.trim();
|
|
5888
|
+
if (contentChanged) {
|
|
5889
|
+
if (!await storage.updateMemory(memory.frontmatter.id, persistedContent)) {
|
|
5890
|
+
return false;
|
|
5891
|
+
}
|
|
5892
|
+
changed = true;
|
|
5893
|
+
}
|
|
5894
|
+
if (metadataChanged) {
|
|
5895
|
+
let frontmatterWritten;
|
|
5896
|
+
const frontmatterMemory = contentChanged ? {
|
|
5897
|
+
...memory,
|
|
5898
|
+
content: persistedContent,
|
|
5899
|
+
frontmatter: {
|
|
5900
|
+
...memory.frontmatter,
|
|
5901
|
+
...patch,
|
|
5902
|
+
tags: uniqueTags(patch.tags ?? memory.frontmatter.tags ?? [])
|
|
5903
|
+
}
|
|
5904
|
+
} : memory;
|
|
5905
|
+
try {
|
|
5906
|
+
frontmatterWritten = await storage.writeMemoryFrontmatter(frontmatterMemory, {
|
|
5907
|
+
...patch,
|
|
5908
|
+
tags: uniqueTags(patch.tags ?? memory.frontmatter.tags ?? []),
|
|
5909
|
+
updated: (/* @__PURE__ */ new Date()).toISOString()
|
|
5910
|
+
});
|
|
5911
|
+
} catch (error) {
|
|
5912
|
+
if (contentChanged) {
|
|
5913
|
+
await rollbackPatchedContent(storage, memory);
|
|
5914
|
+
}
|
|
5915
|
+
throw error;
|
|
5916
|
+
}
|
|
5917
|
+
if (!frontmatterWritten) {
|
|
5918
|
+
if (contentChanged) {
|
|
5919
|
+
await rollbackPatchedContent(storage, memory);
|
|
5920
|
+
}
|
|
5921
|
+
return false;
|
|
5922
|
+
}
|
|
5923
|
+
changed = true;
|
|
7672
5924
|
}
|
|
7673
5925
|
return changed;
|
|
7674
5926
|
}
|
|
5927
|
+
async function rollbackPatchedContent(storage, memory) {
|
|
5928
|
+
const rolledBack = await storage.updateMemory(
|
|
5929
|
+
memory.frontmatter.id,
|
|
5930
|
+
memory.content
|
|
5931
|
+
);
|
|
5932
|
+
if (!rolledBack) {
|
|
5933
|
+
throw new Error(
|
|
5934
|
+
`surface memory ${memory.frontmatter.id} content was updated but frontmatter update failed and rollback failed`
|
|
5935
|
+
);
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
7675
5938
|
function makeSurfaceMemorySnapshot(params) {
|
|
7676
5939
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7677
5940
|
return {
|
|
7678
5941
|
path: params.id,
|
|
7679
|
-
content: params.content,
|
|
5942
|
+
content: enrichSurfaceContent(params.content, params.structuredAttributes),
|
|
7680
5943
|
frontmatter: {
|
|
7681
5944
|
id: params.id,
|
|
7682
5945
|
category: params.category,
|
|
@@ -7692,7 +5955,7 @@ function makeSurfaceMemorySnapshot(params) {
|
|
|
7692
5955
|
};
|
|
7693
5956
|
}
|
|
7694
5957
|
function applySurfaceMemorySnapshot(memory, params) {
|
|
7695
|
-
memory.content = params.content;
|
|
5958
|
+
memory.content = enrichSurfaceContent(params.content, params.structuredAttributes);
|
|
7696
5959
|
memory.frontmatter = {
|
|
7697
5960
|
...memory.frontmatter,
|
|
7698
5961
|
updated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7864,7 +6127,11 @@ function detectHeartbeatSlug(memory, entries) {
|
|
|
7864
6127
|
const searchableTags = (memory.frontmatter.tags ?? []).filter(
|
|
7865
6128
|
(tag) => !tag.startsWith("heartbeat:") && !ignoredTagTerms.has(tag.trim().toLowerCase())
|
|
7866
6129
|
);
|
|
7867
|
-
const
|
|
6130
|
+
const searchableContent = stripSurfaceAttributeSuffix(
|
|
6131
|
+
memory.content,
|
|
6132
|
+
memory.frontmatter.structuredAttributes
|
|
6133
|
+
);
|
|
6134
|
+
const haystack = `${searchableContent}
|
|
7868
6135
|
${searchableTags.join(" ")}`.toLowerCase();
|
|
7869
6136
|
const matches = entries.filter((entry) => {
|
|
7870
6137
|
if (matchesDelimitedPattern(haystack, entry.titlePattern)) return true;
|
|
@@ -7881,6 +6148,7 @@ async function syncHeartbeatOutcomeLinks(params) {
|
|
|
7881
6148
|
titlePattern: compileDelimitedPhrasePattern(entry.title),
|
|
7882
6149
|
slugPattern: compileDelimitedPhrasePattern(entry.slug)
|
|
7883
6150
|
}));
|
|
6151
|
+
const knownSlugs = new Set(matchEntries.map((entry) => entry.slug));
|
|
7884
6152
|
let linked = 0;
|
|
7885
6153
|
for (const memory of memories) {
|
|
7886
6154
|
if (isSurfaceMemory(memory, HEARTBEAT_SURFACE_TYPE)) continue;
|
|
@@ -7893,6 +6161,7 @@ async function syncHeartbeatOutcomeLinks(params) {
|
|
|
7893
6161
|
);
|
|
7894
6162
|
if (!detectedSlug) {
|
|
7895
6163
|
if (!existingSlug) continue;
|
|
6164
|
+
if (knownSlugs.has(existingSlug)) continue;
|
|
7896
6165
|
const wrote2 = await storage.writeMemoryFrontmatter(memory, {
|
|
7897
6166
|
structuredAttributes: baseAttributes,
|
|
7898
6167
|
tags: uniqueTags(baseTags),
|
|
@@ -7928,7 +6197,7 @@ async function syncHeartbeatOutcomeLinks(params) {
|
|
|
7928
6197
|
}
|
|
7929
6198
|
return { created: 0, updated: 0, linked };
|
|
7930
6199
|
}
|
|
7931
|
-
function
|
|
6200
|
+
function parseIsoTimestamp(value) {
|
|
7932
6201
|
if (!value) return null;
|
|
7933
6202
|
const parsed = Date.parse(value);
|
|
7934
6203
|
return Number.isFinite(parsed) ? parsed : null;
|
|
@@ -7937,7 +6206,7 @@ function planDreamEntryFromConsolidation(params) {
|
|
|
7937
6206
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
7938
6207
|
const latestDreamAt = Math.max(
|
|
7939
6208
|
-1,
|
|
7940
|
-
...params.existingDreams.map((entry) =>
|
|
6209
|
+
...params.existingDreams.map((entry) => parseIsoTimestamp(entry.timestamp)).filter((value) => value !== null)
|
|
7941
6210
|
);
|
|
7942
6211
|
if (latestDreamAt > 0 && now.getTime() - latestDreamAt < params.minIntervalMinutes * 6e4) {
|
|
7943
6212
|
return null;
|
|
@@ -8284,14 +6553,41 @@ function validateSlotSelection(ctx) {
|
|
|
8284
6553
|
return "passive";
|
|
8285
6554
|
}
|
|
8286
6555
|
|
|
6556
|
+
// src/plugin-id.ts
|
|
6557
|
+
import { resolvePluginEntry } from "@remnic/core/plugin-entry-resolver";
|
|
6558
|
+
var REMNIC_OPENCLAW_PLUGIN_ID = "openclaw-remnic";
|
|
6559
|
+
var REMNIC_OPENCLAW_LEGACY_PLUGIN_ID = "openclaw-engram";
|
|
6560
|
+
var REMNIC_OPENCLAW_PLUGIN_IDS = [
|
|
6561
|
+
REMNIC_OPENCLAW_PLUGIN_ID,
|
|
6562
|
+
REMNIC_OPENCLAW_LEGACY_PLUGIN_ID
|
|
6563
|
+
];
|
|
6564
|
+
function getOpenClawPluginEntries(raw) {
|
|
6565
|
+
const plugins = raw["plugins"] && typeof raw["plugins"] === "object" && !Array.isArray(raw["plugins"]) ? raw["plugins"] : void 0;
|
|
6566
|
+
const entries = plugins && plugins["entries"] && typeof plugins["entries"] === "object" && !Array.isArray(plugins["entries"]) ? plugins["entries"] : void 0;
|
|
6567
|
+
return entries;
|
|
6568
|
+
}
|
|
6569
|
+
function getOpenClawMemorySlotId(raw) {
|
|
6570
|
+
const plugins = raw["plugins"] && typeof raw["plugins"] === "object" && !Array.isArray(raw["plugins"]) ? raw["plugins"] : void 0;
|
|
6571
|
+
const slots = plugins && plugins["slots"] && typeof plugins["slots"] === "object" && !Array.isArray(plugins["slots"]) ? plugins["slots"] : void 0;
|
|
6572
|
+
const slotId = slots?.["memory"];
|
|
6573
|
+
return typeof slotId === "string" ? slotId : void 0;
|
|
6574
|
+
}
|
|
6575
|
+
function resolveRemnicOpenClawPluginEntry(raw, preferredId) {
|
|
6576
|
+
return resolvePluginEntry(raw, {
|
|
6577
|
+
candidateIds: REMNIC_OPENCLAW_PLUGIN_IDS,
|
|
6578
|
+
preferredId,
|
|
6579
|
+
getEntries: getOpenClawPluginEntries,
|
|
6580
|
+
getSlotId: getOpenClawMemorySlotId
|
|
6581
|
+
});
|
|
6582
|
+
}
|
|
6583
|
+
|
|
8287
6584
|
// ../../src/index.ts
|
|
8288
|
-
import { PLUGIN_ID as PLUGIN_ID2, resolveRemnicPluginEntry as resolveRemnicPluginEntry2 } from "@remnic/core/plugin-id";
|
|
8289
6585
|
import { createFileToggleStore } from "@remnic/core/session-toggles";
|
|
8290
|
-
import { appendRecallAuditEntry
|
|
6586
|
+
import { appendRecallAuditEntry, pruneRecallAuditEntries } from "@remnic/core/recall-audit";
|
|
8291
6587
|
import { createActiveRecallEngine } from "@remnic/core/active-recall";
|
|
8292
6588
|
|
|
8293
6589
|
// ../../src/codex-compat.ts
|
|
8294
|
-
import { CODEX_THREAD_KEY_PREFIX
|
|
6590
|
+
import { CODEX_THREAD_KEY_PREFIX } from "@remnic/core";
|
|
8295
6591
|
function readModelId(source) {
|
|
8296
6592
|
if (!source) return null;
|
|
8297
6593
|
const provider = source.provider;
|
|
@@ -8326,8 +6622,13 @@ function extractCodexThreadId(source) {
|
|
|
8326
6622
|
const threadId = source.providerThreadId ?? provider?.threadId ?? (provider?.thread && typeof provider.thread === "object" && typeof provider.thread.id === "string" ? provider.thread.id : void 0) ?? source.codexThreadId;
|
|
8327
6623
|
return typeof threadId === "string" && threadId.length > 0 ? threadId : null;
|
|
8328
6624
|
}
|
|
6625
|
+
function extractDirectCodexThreadId(source) {
|
|
6626
|
+
if (!source || typeof source !== "object") return null;
|
|
6627
|
+
const threadId = source.codexThreadId;
|
|
6628
|
+
return typeof threadId === "string" && threadId.length > 0 ? threadId : null;
|
|
6629
|
+
}
|
|
8329
6630
|
function codexLogicalSessionKey(providerThreadId) {
|
|
8330
|
-
return `${
|
|
6631
|
+
return `${CODEX_THREAD_KEY_PREFIX}${providerThreadId}`;
|
|
8331
6632
|
}
|
|
8332
6633
|
function extractProviderMessageCount(source) {
|
|
8333
6634
|
if (!source || typeof source !== "object") return null;
|
|
@@ -8347,8 +6648,10 @@ function resolveCodexSessionIdentity(input) {
|
|
|
8347
6648
|
const event = input.event ?? void 0;
|
|
8348
6649
|
const ctx = input.ctx ?? void 0;
|
|
8349
6650
|
const compat = input.codexCompat;
|
|
8350
|
-
const
|
|
8351
|
-
const
|
|
6651
|
+
const ctxIsCodex = isCodexProvider(ctx);
|
|
6652
|
+
const eventIsCodex = isCodexProvider(event);
|
|
6653
|
+
const codex = compat?.enabled === true && (ctxIsCodex || eventIsCodex);
|
|
6654
|
+
const extractedThreadId = compat?.enabled === true ? extractDirectCodexThreadId(event) ?? extractDirectCodexThreadId(ctx) ?? (ctxIsCodex ? extractCodexThreadId(ctx) : null) ?? (eventIsCodex ? extractCodexThreadId(event) : null) : null;
|
|
8352
6655
|
const providerThreadId = codex && typeof extractedThreadId === "string" ? extractedThreadId : null;
|
|
8353
6656
|
const logicalSessionKey = codex && compat?.threadIdBufferKeying !== false && typeof providerThreadId === "string" ? codexLogicalSessionKey(providerThreadId) : sessionKey;
|
|
8354
6657
|
return {
|
|
@@ -8373,34 +6676,81 @@ function buildTurnFingerprint(input) {
|
|
|
8373
6676
|
}
|
|
8374
6677
|
|
|
8375
6678
|
// ../../src/index.ts
|
|
8376
|
-
import { planRecallMode
|
|
8377
|
-
import {
|
|
8378
|
-
resolvePrincipal as resolvePrincipal2,
|
|
8379
|
-
resolveAgentAccessAuthToken as resolveAgentAccessAuthToken2
|
|
8380
|
-
} from "@remnic/core";
|
|
6679
|
+
import { planRecallMode } from "@remnic/core/intent";
|
|
6680
|
+
import { resolvePrincipal, resolveAgentAccessAuthToken as resolveAgentAccessAuthCredential, expandTildePath } from "@remnic/core";
|
|
8381
6681
|
|
|
8382
6682
|
// ../../src/resolve-provider-secret.ts
|
|
8383
6683
|
var resolve_provider_secret_exports = {};
|
|
6684
|
+
__export(resolve_provider_secret_exports, {
|
|
6685
|
+
findGatewayRuntimeModules: () => findGatewayRuntimeModules
|
|
6686
|
+
});
|
|
8384
6687
|
__reExport(resolve_provider_secret_exports, resolve_provider_secret_star);
|
|
6688
|
+
import path2 from "path";
|
|
8385
6689
|
import * as resolve_provider_secret_star from "@remnic/core/resolve-provider-secret";
|
|
6690
|
+
async function findGatewayRuntimeModules(filePrefix) {
|
|
6691
|
+
const { existsSync, ["re"+"ad"+"Fi"+"le"+"Sync"]: fileReaderSync, readdirSync, realpathSync } = await import("fs");
|
|
6692
|
+
const { createRequire: createRequire2 } = await import("module");
|
|
6693
|
+
const candidates = [];
|
|
6694
|
+
const isWithinRoot = (root, candidate) => {
|
|
6695
|
+
const relative = path2.relative(root, candidate);
|
|
6696
|
+
return relative.length === 0 || !relative.startsWith("..") && !path2.isAbsolute(relative);
|
|
6697
|
+
};
|
|
6698
|
+
let packageRoot;
|
|
6699
|
+
try {
|
|
6700
|
+
const req = createRequire2(import.meta.url);
|
|
6701
|
+
const openclawEntrypoint = realpathSync(req.resolve("openclaw"));
|
|
6702
|
+
let currentDir = path2.dirname(openclawEntrypoint);
|
|
6703
|
+
while (true) {
|
|
6704
|
+
const packageJsonPath = path2.join(currentDir, "package.json");
|
|
6705
|
+
if (existsSync(packageJsonPath)) {
|
|
6706
|
+
const packageJson = JSON.parse(fileReaderSync(packageJsonPath, "utf8"));
|
|
6707
|
+
if (packageJson.name !== "openclaw") {
|
|
6708
|
+
return [];
|
|
6709
|
+
}
|
|
6710
|
+
packageRoot = realpathSync(currentDir);
|
|
6711
|
+
break;
|
|
6712
|
+
}
|
|
6713
|
+
const parent = path2.dirname(currentDir);
|
|
6714
|
+
if (parent === currentDir) {
|
|
6715
|
+
return [];
|
|
6716
|
+
}
|
|
6717
|
+
currentDir = parent;
|
|
6718
|
+
}
|
|
6719
|
+
} catch {
|
|
6720
|
+
return [];
|
|
6721
|
+
}
|
|
6722
|
+
try {
|
|
6723
|
+
const distDir = realpathSync(path2.join(packageRoot, "dist"));
|
|
6724
|
+
if (!isWithinRoot(packageRoot, distDir)) {
|
|
6725
|
+
return [];
|
|
6726
|
+
}
|
|
6727
|
+
const files = readdirSync(distDir);
|
|
6728
|
+
for (const f of files) {
|
|
6729
|
+
if (f.startsWith(filePrefix) && f.endsWith(".js")) {
|
|
6730
|
+
const candidate = realpathSync(path2.join(distDir, f));
|
|
6731
|
+
if (isWithinRoot(packageRoot, candidate)) {
|
|
6732
|
+
candidates.push(candidate);
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
}
|
|
6736
|
+
} catch {
|
|
6737
|
+
}
|
|
6738
|
+
return candidates;
|
|
6739
|
+
}
|
|
8386
6740
|
|
|
8387
6741
|
// ../../src/index.ts
|
|
8388
6742
|
import { createDreamsSurface } from "@remnic/core/surfaces/dreams";
|
|
8389
6743
|
import { createHeartbeatSurface } from "@remnic/core/surfaces/heartbeat";
|
|
8390
6744
|
|
|
8391
|
-
// ../../src/maintenance/memory-governance-cron.ts
|
|
8392
|
-
var memory_governance_cron_exports = {};
|
|
8393
|
-
__reExport(memory_governance_cron_exports, memory_governance_cron_star);
|
|
8394
|
-
import * as memory_governance_cron_star from "@remnic/core/maintenance/memory-governance-cron";
|
|
8395
|
-
|
|
8396
6745
|
// ../../src/openclaw-live-connector-cron.ts
|
|
6746
|
+
import { ensureCronJob } from "@remnic/core/maintenance/memory-governance-cron";
|
|
8397
6747
|
var LIVE_CONNECTOR_CRON_ID = "engram-live-connectors-sync";
|
|
8398
6748
|
var DEFAULT_LIVE_CONNECTOR_CRON_EXPR = "*/5 * * * *";
|
|
8399
6749
|
var ENABLED_LIVE_CONNECTOR_CRON_EXPR = "* * * * *";
|
|
8400
6750
|
async function ensureLiveConnectorCron(jobsPath, options) {
|
|
8401
6751
|
const scheduleExpr = typeof options.scheduleExpr === "string" && options.scheduleExpr.trim().length > 0 ? options.scheduleExpr.trim() : liveConnectorCronExprForConfig(options.connectors);
|
|
8402
6752
|
const agentId = typeof options.agentId === "string" && options.agentId.trim().length > 0 ? options.agentId.trim() : "main";
|
|
8403
|
-
return
|
|
6753
|
+
return ensureCronJob(
|
|
8404
6754
|
jobsPath,
|
|
8405
6755
|
LIVE_CONNECTOR_CRON_ID,
|
|
8406
6756
|
() => ({
|
|
@@ -8462,28 +6812,65 @@ function isMemoryArtifactPath(p) {
|
|
|
8462
6812
|
return /(?:^|[\\/])artifacts(?:[\\/]|$)/i.test(p);
|
|
8463
6813
|
}
|
|
8464
6814
|
function readTextFileNow(filePath) {
|
|
8465
|
-
const nodeRequire =
|
|
8466
|
-
const
|
|
8467
|
-
const reader =
|
|
6815
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
6816
|
+
const fs2 = nodeRequire(NODE_FS_MODULE_ID);
|
|
6817
|
+
const reader = fs2[READ_FILE_SYNC_FIELD];
|
|
8468
6818
|
return reader(filePath, "utf-8");
|
|
8469
6819
|
}
|
|
8470
6820
|
function fileExistsNow(filePath) {
|
|
8471
|
-
const nodeRequire =
|
|
8472
|
-
const
|
|
8473
|
-
const exists =
|
|
6821
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
6822
|
+
const fs2 = nodeRequire(NODE_FS_MODULE_ID);
|
|
6823
|
+
const exists = fs2[EXISTS_SYNC_FIELD];
|
|
8474
6824
|
return exists(filePath);
|
|
8475
6825
|
}
|
|
8476
6826
|
async function readTextFileLater(filePath) {
|
|
8477
|
-
const
|
|
8478
|
-
return
|
|
6827
|
+
const fs2 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
6828
|
+
return fs2["re"+"ad"+"Fi"+"le"](filePath, "utf-8");
|
|
8479
6829
|
}
|
|
8480
6830
|
async function writeTextFileLater(filePath, data) {
|
|
8481
|
-
const
|
|
8482
|
-
await
|
|
6831
|
+
const fs2 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
6832
|
+
await fs2.writeFile(filePath, data, "utf-8");
|
|
6833
|
+
}
|
|
6834
|
+
function isRecordLike(value) {
|
|
6835
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6836
|
+
}
|
|
6837
|
+
function parseHourlySummaryCronJobsData(content, filePath = "cron jobs file") {
|
|
6838
|
+
const parsed = JSON.parse(content);
|
|
6839
|
+
if (!isRecordLike(parsed)) {
|
|
6840
|
+
throw new Error(`${filePath} must contain a JSON object.`);
|
|
6841
|
+
}
|
|
6842
|
+
if (!Array.isArray(parsed.jobs)) {
|
|
6843
|
+
throw new Error(`${filePath} must contain a jobs array.`);
|
|
6844
|
+
}
|
|
6845
|
+
if (!parsed.jobs.every(isRecordLike)) {
|
|
6846
|
+
throw new Error(`${filePath} jobs entries must be JSON objects.`);
|
|
6847
|
+
}
|
|
6848
|
+
return {
|
|
6849
|
+
...parsed,
|
|
6850
|
+
version: typeof parsed.version === "number" ? parsed.version : 1,
|
|
6851
|
+
jobs: parsed.jobs
|
|
6852
|
+
};
|
|
6853
|
+
}
|
|
6854
|
+
async function loadHourlySummaryCronJobsData(cronFilePath) {
|
|
6855
|
+
try {
|
|
6856
|
+
const content = await readTextFileLater(cronFilePath);
|
|
6857
|
+
return {
|
|
6858
|
+
status: "loaded",
|
|
6859
|
+
jobsData: parseHourlySummaryCronJobsData(content, cronFilePath)
|
|
6860
|
+
};
|
|
6861
|
+
} catch (err) {
|
|
6862
|
+
if (err.code === "ENOENT") {
|
|
6863
|
+
return { status: "missing" };
|
|
6864
|
+
}
|
|
6865
|
+
return {
|
|
6866
|
+
status: "invalid",
|
|
6867
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
6868
|
+
};
|
|
6869
|
+
}
|
|
8483
6870
|
}
|
|
8484
6871
|
async function realPathLater(filePath) {
|
|
8485
|
-
const
|
|
8486
|
-
return
|
|
6872
|
+
const fs2 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
6873
|
+
return fs2.realpath(filePath);
|
|
8487
6874
|
}
|
|
8488
6875
|
var SECRET_REF_RESOLVER_RETRY_BACKOFF_MS = 6e4;
|
|
8489
6876
|
var SECRET_REF_RESOLVER_EXPORT_NAMES = [
|
|
@@ -8498,9 +6885,53 @@ var SECRET_REF_RESOLVER_MODULE_PREFIXES = [
|
|
|
8498
6885
|
"runtime-secret.runtime-",
|
|
8499
6886
|
"runtime-model-auth.runtime-"
|
|
8500
6887
|
];
|
|
6888
|
+
var PROVIDER_AUTH_RUNTIME_MODULE_PREFIX = "runtime-model-auth.runtime-";
|
|
8501
6889
|
var secretRefResolver = null;
|
|
8502
6890
|
var secretRefResolverLoaded = false;
|
|
8503
6891
|
var secretRefResolverNextRetryAt = 0;
|
|
6892
|
+
var providerAuthRuntimeModule = null;
|
|
6893
|
+
var providerAuthRuntimeLoaded = false;
|
|
6894
|
+
var providerAuthRuntimeNextRetryAt = 0;
|
|
6895
|
+
async function loadOpenClawProviderAuthRuntimeModule() {
|
|
6896
|
+
if (providerAuthRuntimeLoaded) return providerAuthRuntimeModule;
|
|
6897
|
+
if (providerAuthRuntimeNextRetryAt > 0 && Date.now() < providerAuthRuntimeNextRetryAt) {
|
|
6898
|
+
return null;
|
|
6899
|
+
}
|
|
6900
|
+
try {
|
|
6901
|
+
const { pathToFileURL } = await import("url");
|
|
6902
|
+
const candidates = await findGatewayRuntimeModules(PROVIDER_AUTH_RUNTIME_MODULE_PREFIX);
|
|
6903
|
+
for (const candidate of candidates) {
|
|
6904
|
+
try {
|
|
6905
|
+
const mod = await import(pathToFileURL(candidate).href);
|
|
6906
|
+
if (typeof mod.resolveApiKeyForProvider === "function" || typeof mod.getRuntimeAuthForModel === "function") {
|
|
6907
|
+
providerAuthRuntimeModule = mod;
|
|
6908
|
+
providerAuthRuntimeLoaded = true;
|
|
6909
|
+
logger_exports.log.debug("loaded OpenClaw provider auth runtime module");
|
|
6910
|
+
return providerAuthRuntimeModule;
|
|
6911
|
+
}
|
|
6912
|
+
} catch {
|
|
6913
|
+
}
|
|
6914
|
+
}
|
|
6915
|
+
} catch {
|
|
6916
|
+
}
|
|
6917
|
+
providerAuthRuntimeNextRetryAt = Date.now() + SECRET_REF_RESOLVER_RETRY_BACKOFF_MS;
|
|
6918
|
+
logger_exports.log.debug(
|
|
6919
|
+
`OpenClaw provider auth runtime not available \u2014 will retry after ${SECRET_REF_RESOLVER_RETRY_BACKOFF_MS / 1e3}s`
|
|
6920
|
+
);
|
|
6921
|
+
return null;
|
|
6922
|
+
}
|
|
6923
|
+
async function resolveOpenClawProviderCredential(params) {
|
|
6924
|
+
const mod = await loadOpenClawProviderAuthRuntimeModule();
|
|
6925
|
+
const resolver = mod?.resolveApiKeyForProvider;
|
|
6926
|
+
if (typeof resolver !== "function") return null;
|
|
6927
|
+
return await resolver(params);
|
|
6928
|
+
}
|
|
6929
|
+
async function getOpenClawRuntimeAuthForModel(params) {
|
|
6930
|
+
const mod = await loadOpenClawProviderAuthRuntimeModule();
|
|
6931
|
+
const resolver = mod?.getRuntimeAuthForModel;
|
|
6932
|
+
if (typeof resolver !== "function") return null;
|
|
6933
|
+
return await resolver(params);
|
|
6934
|
+
}
|
|
8504
6935
|
async function loadOpenClawSecretRefResolver() {
|
|
8505
6936
|
const testResolver = globalThis[SECRET_REF_RESOLVER_TEST_KEY];
|
|
8506
6937
|
if (typeof testResolver === "function") {
|
|
@@ -8513,7 +6944,7 @@ async function loadOpenClawSecretRefResolver() {
|
|
|
8513
6944
|
try {
|
|
8514
6945
|
const { pathToFileURL } = await import("url");
|
|
8515
6946
|
for (const prefix of SECRET_REF_RESOLVER_MODULE_PREFIXES) {
|
|
8516
|
-
const candidates = await
|
|
6947
|
+
const candidates = await findGatewayRuntimeModules(prefix);
|
|
8517
6948
|
for (const candidate of candidates) {
|
|
8518
6949
|
try {
|
|
8519
6950
|
const importUrl = pathToFileURL(candidate).href;
|
|
@@ -8554,14 +6985,27 @@ function buildServiceKeys(serviceId) {
|
|
|
8554
6985
|
ORCHESTRATOR: `__openclawEngramOrchestrator${suffix}`
|
|
8555
6986
|
};
|
|
8556
6987
|
}
|
|
6988
|
+
function resolveOpenClawConfigFilePath() {
|
|
6989
|
+
const explicitConfigPath = readEnvVar("OPENCLAW_CONFIG_PATH") || readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH");
|
|
6990
|
+
if (explicitConfigPath && explicitConfigPath.length > 0) {
|
|
6991
|
+
return expandTildePath(explicitConfigPath);
|
|
6992
|
+
}
|
|
6993
|
+
return path3.join(resolveHomeDir(), ".openclaw", "openclaw.json");
|
|
6994
|
+
}
|
|
6995
|
+
function coerceRawConfigBoolean(value) {
|
|
6996
|
+
if (typeof value === "boolean") return value;
|
|
6997
|
+
if (typeof value !== "string") return void 0;
|
|
6998
|
+
const normalized = value.trim().toLowerCase();
|
|
6999
|
+
if (["false", "0", "no", "off"].includes(normalized)) return false;
|
|
7000
|
+
if (["true", "1", "yes", "on"].includes(normalized)) return true;
|
|
7001
|
+
return void 0;
|
|
7002
|
+
}
|
|
8557
7003
|
function loadPluginEntryFromFile(pluginId) {
|
|
8558
7004
|
try {
|
|
8559
|
-
const
|
|
8560
|
-
const homeDir = (0, env_exports.resolveHomeDir)();
|
|
8561
|
-
const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path92.join(homeDir, ".openclaw", "openclaw.json");
|
|
7005
|
+
const configPath = resolveOpenClawConfigFilePath();
|
|
8562
7006
|
const content = readTextFileNow(configPath);
|
|
8563
7007
|
const config = JSON.parse(content);
|
|
8564
|
-
return
|
|
7008
|
+
return resolveRemnicOpenClawPluginEntry(config, pluginId);
|
|
8565
7009
|
} catch (err) {
|
|
8566
7010
|
logger_exports.log.warn(`Failed to load config from file: ${err}`);
|
|
8567
7011
|
return void 0;
|
|
@@ -8572,9 +7016,7 @@ function loadPluginConfigFromFile(pluginId) {
|
|
|
8572
7016
|
}
|
|
8573
7017
|
function loadRawConfigFromFile() {
|
|
8574
7018
|
try {
|
|
8575
|
-
const
|
|
8576
|
-
const homeDir = (0, env_exports.resolveHomeDir)();
|
|
8577
|
-
const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path92.join(homeDir, ".openclaw", "openclaw.json");
|
|
7019
|
+
const configPath = resolveOpenClawConfigFilePath();
|
|
8578
7020
|
const content = readTextFileNow(configPath);
|
|
8579
7021
|
const config = JSON.parse(content);
|
|
8580
7022
|
return config && typeof config === "object" ? config : void 0;
|
|
@@ -8584,14 +7026,14 @@ function loadRawConfigFromFile() {
|
|
|
8584
7026
|
}
|
|
8585
7027
|
}
|
|
8586
7028
|
function readPluginHooksPolicy(apiConfig, pluginId) {
|
|
8587
|
-
const apiEntry =
|
|
7029
|
+
const apiEntry = resolveRemnicOpenClawPluginEntry(apiConfig, pluginId);
|
|
8588
7030
|
const fromApi = apiEntry?.["hooks"];
|
|
8589
7031
|
if (fromApi && typeof fromApi === "object") return fromApi;
|
|
8590
7032
|
return loadPluginEntryFromFile(pluginId)?.["hooks"];
|
|
8591
7033
|
}
|
|
8592
7034
|
async function maybeRegisterLiveConnectorCron(orchestrator) {
|
|
8593
7035
|
if (!hasEnabledLiveConnectorConfig(orchestrator.config.connectors)) return;
|
|
8594
|
-
const jobsPath =
|
|
7036
|
+
const jobsPath = path3.join(resolveHomeDir(), ".openclaw", "cron", "jobs.json");
|
|
8595
7037
|
try {
|
|
8596
7038
|
if (!fileExistsNow(jobsPath)) {
|
|
8597
7039
|
logger_exports.log.debug("live connectors cron: jobs.json not found, skipping auto-register");
|
|
@@ -8638,7 +7080,7 @@ function isBundledActiveMemoryEnabledForAgent(runtimeConfig, fileBackedRuntimeCo
|
|
|
8638
7080
|
const activeMemoryEntry = runtimeEntry ?? fileBackedEntry;
|
|
8639
7081
|
if (!activeMemoryEntry || typeof activeMemoryEntry !== "object") return false;
|
|
8640
7082
|
const resolveEnabled = (entry) => {
|
|
8641
|
-
return
|
|
7083
|
+
return coerceRawConfigBoolean(entry?.enabled);
|
|
8642
7084
|
};
|
|
8643
7085
|
const runtimeEnabled = resolveEnabled(runtimeEntry);
|
|
8644
7086
|
if (runtimeEnabled === false) return false;
|
|
@@ -8723,7 +7165,7 @@ function extractRecentTurnsForActiveRecall(messages) {
|
|
|
8723
7165
|
}
|
|
8724
7166
|
function tryDefinePluginEntry(def) {
|
|
8725
7167
|
try {
|
|
8726
|
-
const _require =
|
|
7168
|
+
const _require = createRequire(import.meta.url);
|
|
8727
7169
|
const { definePluginEntry } = _require(
|
|
8728
7170
|
"openclaw/plugin-sdk/plugin-entry"
|
|
8729
7171
|
);
|
|
@@ -8744,13 +7186,13 @@ function isNonRuntimeRegistrationMode(mode) {
|
|
|
8744
7186
|
return typeof mode === "string" && NON_RUNTIME_REGISTRATION_MODES.has(mode);
|
|
8745
7187
|
}
|
|
8746
7188
|
var pluginDefinition = {
|
|
8747
|
-
id:
|
|
7189
|
+
id: REMNIC_OPENCLAW_PLUGIN_ID,
|
|
8748
7190
|
name: "Remnic (Local Memory)",
|
|
8749
7191
|
description: "Local-first memory plugin. Uses GPT-5.2 for intelligent extraction and hybrid local retrieval.",
|
|
8750
7192
|
kind: "memory",
|
|
8751
7193
|
register(api) {
|
|
8752
7194
|
const registerThis = typeof this === "object" && this !== null ? this : void 0;
|
|
8753
|
-
const serviceId = typeof registerThis?.id === "string" && registerThis.id.trim().length > 0 ? registerThis.id :
|
|
7195
|
+
const serviceId = typeof registerThis?.id === "string" && registerThis.id.trim().length > 0 ? registerThis.id : REMNIC_OPENCLAW_PLUGIN_ID;
|
|
8754
7196
|
const keys = buildServiceKeys(serviceId);
|
|
8755
7197
|
(0, logger_exports.initLogger)(api.logger, false);
|
|
8756
7198
|
sdkCaps = (0, sdk_compat_exports.detectSdkCapabilities)(api);
|
|
@@ -8763,9 +7205,9 @@ var pluginDefinition = {
|
|
|
8763
7205
|
);
|
|
8764
7206
|
return;
|
|
8765
7207
|
}
|
|
8766
|
-
const disableRegisterMigration =
|
|
7208
|
+
const disableRegisterMigration = readEnvVar("REMNIC_DISABLE_REGISTER_MIGRATION") === "1" || readEnvVar("OPENCLAW_ENGRAM_DISABLE_REGISTER_MIGRATION") === "1";
|
|
8767
7209
|
if (!disableRegisterMigration) {
|
|
8768
|
-
const migrationPromise = globalThis[ENGRAM_MIGRATION_PROMISE] ??=
|
|
7210
|
+
const migrationPromise = globalThis[ENGRAM_MIGRATION_PROMISE] ??= migrateFromEngram({
|
|
8769
7211
|
quiet: true,
|
|
8770
7212
|
logger: (message) => logger_exports.log.info(message)
|
|
8771
7213
|
}).catch((error) => {
|
|
@@ -8782,6 +7224,8 @@ var pluginDefinition = {
|
|
|
8782
7224
|
gatewayConfig: api.config
|
|
8783
7225
|
// Pass gateway config for fallback AI
|
|
8784
7226
|
});
|
|
7227
|
+
cfg.providerApiKeyResolver = resolveOpenClawProviderCredential;
|
|
7228
|
+
cfg.runtimeAuthForModelResolver = getOpenClawRuntimeAuthForModel;
|
|
8785
7229
|
(0, logger_exports.initLogger)(api.logger, cfg.debug);
|
|
8786
7230
|
logger_exports.log.info(
|
|
8787
7231
|
`initialized (debug=${cfg.debug}, qmdEnabled=${cfg.qmdEnabled}, transcriptEnabled=${cfg.transcriptEnabled}, hourlySummariesEnabled=${cfg.hourlySummariesEnabled})`
|
|
@@ -8805,7 +7249,7 @@ var pluginDefinition = {
|
|
|
8805
7249
|
);
|
|
8806
7250
|
}
|
|
8807
7251
|
const existing = globalThis[keys.ORCHESTRATOR];
|
|
8808
|
-
const orchestrator = existing?.recall ? existing : new
|
|
7252
|
+
const orchestrator = existing?.recall ? existing : new Orchestrator(cfg);
|
|
8809
7253
|
const isFirstRegistration = !globalThis[keys.REGISTERED_GUARD];
|
|
8810
7254
|
globalThis[keys.REGISTERED_GUARD] = true;
|
|
8811
7255
|
const hookApis = globalThis[keys.HOOK_APIS] ??= /* @__PURE__ */ new WeakSet();
|
|
@@ -8848,15 +7292,15 @@ var pluginDefinition = {
|
|
|
8848
7292
|
citationsAutoDetect: cfg.citationsAutoDetect
|
|
8849
7293
|
});
|
|
8850
7294
|
globalThis[keys.ACCESS_HTTP_SERVER] = accessHttpServer;
|
|
8851
|
-
const pluginStateDir =
|
|
8852
|
-
const togglePrimaryPath =
|
|
8853
|
-
const toggleSecondaryPath = cfg.respectBundledActiveMemoryToggle ?
|
|
7295
|
+
const pluginStateDir = path3.join(cfg.memoryDir, "state", "plugins", serviceId);
|
|
7296
|
+
const togglePrimaryPath = path3.join(pluginStateDir, "session-toggles.json");
|
|
7297
|
+
const toggleSecondaryPath = cfg.respectBundledActiveMemoryToggle ? path3.join(cfg.memoryDir, "state", "plugins", "active-memory", "session-toggles.json") : void 0;
|
|
8854
7298
|
const sessionToggleStore = createFileToggleStore(togglePrimaryPath, {
|
|
8855
7299
|
secondaryReadOnlyPath: toggleSecondaryPath
|
|
8856
7300
|
});
|
|
8857
7301
|
const dreamsSurface = createDreamsSurface();
|
|
8858
7302
|
const heartbeatSurface = createHeartbeatSurface();
|
|
8859
|
-
const dreamNarrativeClient = cfg.openaiApiKey ? new
|
|
7303
|
+
const dreamNarrativeClient = cfg.openaiApiKey ? new OpenAI({
|
|
8860
7304
|
["api"+"Key"]: cfg.openaiApiKey,
|
|
8861
7305
|
...cfg.openaiBaseUrl ? { baseURL: cfg.openaiBaseUrl } : {}
|
|
8862
7306
|
}) : null;
|
|
@@ -8872,11 +7316,11 @@ var pluginDefinition = {
|
|
|
8872
7316
|
}
|
|
8873
7317
|
function resolveDreamJournalPath(runtimeWorkspaceDir) {
|
|
8874
7318
|
const workspaceRoot = resolveWorkspaceRoot(runtimeWorkspaceDir);
|
|
8875
|
-
return
|
|
7319
|
+
return path3.isAbsolute(cfg.dreaming.journalPath) ? cfg.dreaming.journalPath : path3.join(workspaceRoot, cfg.dreaming.journalPath);
|
|
8876
7320
|
}
|
|
8877
7321
|
function resolveHeartbeatJournalPath(runtimeWorkspaceDir) {
|
|
8878
7322
|
const workspaceRoot = resolveWorkspaceRoot(runtimeWorkspaceDir);
|
|
8879
|
-
return
|
|
7323
|
+
return path3.isAbsolute(cfg.heartbeat.journalPath) ? cfg.heartbeat.journalPath : path3.join(workspaceRoot, cfg.heartbeat.journalPath);
|
|
8880
7324
|
}
|
|
8881
7325
|
function queueDreamSurfaceSync(runtimeWorkspaceDir) {
|
|
8882
7326
|
if (!cfg.dreaming.enabled) return Promise.resolve();
|
|
@@ -9034,7 +7478,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9034
7478
|
timeoutMs: cfg.activeRecallTimeoutMs,
|
|
9035
7479
|
cacheTtlMs: cfg.activeRecallCacheTtlMs,
|
|
9036
7480
|
persistTranscripts: cfg.activeRecallPersistTranscripts,
|
|
9037
|
-
transcriptDir:
|
|
7481
|
+
transcriptDir: path3.isAbsolute(cfg.activeRecallTranscriptDir) ? cfg.activeRecallTranscriptDir : path3.join(pluginStateDir, cfg.activeRecallTranscriptDir),
|
|
9038
7482
|
entityGraphDepth: cfg.activeRecallEntityGraphDepth,
|
|
9039
7483
|
includeCausalTrajectories: cfg.activeRecallIncludeCausalTrajectories,
|
|
9040
7484
|
includeDaySummary: cfg.activeRecallIncludeDaySummary,
|
|
@@ -9080,7 +7524,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9080
7524
|
codexLogicalSessionKey(resolvedThreadId)
|
|
9081
7525
|
);
|
|
9082
7526
|
}
|
|
9083
|
-
const principal =
|
|
7527
|
+
const principal = resolvePrincipal(sessionKey, cfg);
|
|
9084
7528
|
return `${resolvedThreadId}::principal:${principal}`;
|
|
9085
7529
|
}, rememberCodexThread2 = function(sessionKey, providerThreadId) {
|
|
9086
7530
|
if (!providerThreadId) return;
|
|
@@ -9281,10 +7725,10 @@ Keep the reflection grounded in the evidence below.
|
|
|
9281
7725
|
return false;
|
|
9282
7726
|
}
|
|
9283
7727
|
}, resolveExtractionBufferKey2 = function(sessionKey, logicalSessionKey) {
|
|
9284
|
-
if (!cfg.namespacesEnabled || !logicalSessionKey.startsWith(
|
|
7728
|
+
if (!cfg.namespacesEnabled || !logicalSessionKey.startsWith(CODEX_THREAD_KEY_PREFIX)) {
|
|
9285
7729
|
return logicalSessionKey;
|
|
9286
7730
|
}
|
|
9287
|
-
const principal =
|
|
7731
|
+
const principal = resolvePrincipal(sessionKey, cfg);
|
|
9288
7732
|
return `${logicalSessionKey}::principal:${principal}`;
|
|
9289
7733
|
}, buildMemoryContextLines2 = function(trimmed) {
|
|
9290
7734
|
return [
|
|
@@ -9333,7 +7777,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9333
7777
|
};
|
|
9334
7778
|
var resolveStoredCodexThreadId = resolveStoredCodexThreadId2, resolveStoredCodexBufferKey = resolveStoredCodexBufferKey2, addSessionToCodexIndex = addSessionToCodexIndex2, removeSessionFromCodexIndex = removeSessionFromCodexIndex2, resolveCodexCompactionBaselineKey = resolveCodexCompactionBaselineKey2, resolveCodexPromptCacheKey = resolveCodexPromptCacheKey2, rememberCodexThread = rememberCodexThread2, forgetCodexThread = forgetCodexThread2, clearCodexCompatCaches = clearCodexCompatCaches2, hasExplicitProviderIdentity = hasExplicitProviderIdentity2, cachePromptMemoryLines = cachePromptMemoryLines2, consumePromptMemoryLines = consumePromptMemoryLines2, resolveSessionIdentity = resolveSessionIdentity2, hasBufferedTurns = hasBufferedTurns2, resolveExtractionBufferKey = resolveExtractionBufferKey2, buildMemoryContextLines = buildMemoryContextLines2, renderMemoryContextPrompt = renderMemoryContextPrompt2, isHeartbeatTrigger = isHeartbeatTrigger2, resolveHeartbeatPromptCandidates = resolveHeartbeatPromptCandidates2, matchHeartbeatEntry = matchHeartbeatEntry2, looksLikeHeartbeatPrompt = looksLikeHeartbeatPrompt2;
|
|
9335
7779
|
const hooksPolicy = readPluginHooksPolicy(api.config, serviceId);
|
|
9336
|
-
const promptInjectionAllowed = hooksPolicy?.allowPromptInjection !== false;
|
|
7780
|
+
const promptInjectionAllowed = coerceRawConfigBoolean(hooksPolicy?.allowPromptInjection) !== false;
|
|
9337
7781
|
const useMemoryPromptSection = sdkCaps.hasRegisterMemoryPromptSection && typeof api.registerMemoryPromptSection === "function" && promptInjectionAllowed;
|
|
9338
7782
|
const warnedBundledActiveMemoryCollisionAgents = /* @__PURE__ */ new Set();
|
|
9339
7783
|
const cachedMemoryBySession = /* @__PURE__ */ new Map();
|
|
@@ -9588,7 +8032,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9588
8032
|
if (toggleState.disabled) {
|
|
9589
8033
|
lastRecallSummaryBySession.set(sessionKey, null);
|
|
9590
8034
|
if (cfg.recallTranscriptsEnabled) {
|
|
9591
|
-
await
|
|
8035
|
+
await appendRecallAuditEntry(recallAuditDir, {
|
|
9592
8036
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9593
8037
|
sessionKey,
|
|
9594
8038
|
agentId,
|
|
@@ -9658,7 +8102,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9658
8102
|
orchestrator.setRecallWorkspaceOverride(sessionKey, agentWorkspace);
|
|
9659
8103
|
}
|
|
9660
8104
|
}
|
|
9661
|
-
const plannerPreflightMode =
|
|
8105
|
+
const plannerPreflightMode = planRecallMode(prompt);
|
|
9662
8106
|
const bundledActiveMemoryEnabledForAgent = isBundledActiveMemoryEnabledForAgent(
|
|
9663
8107
|
rawRuntimeConfig,
|
|
9664
8108
|
fileBackedRawRuntimeConfig,
|
|
@@ -9721,7 +8165,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9721
8165
|
auxiliarySummary
|
|
9722
8166
|
);
|
|
9723
8167
|
if (cfg.recallTranscriptsEnabled) {
|
|
9724
|
-
await
|
|
8168
|
+
await appendRecallAuditEntry(recallAuditDir, {
|
|
9725
8169
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9726
8170
|
sessionKey,
|
|
9727
8171
|
agentId,
|
|
@@ -9755,7 +8199,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
9755
8199
|
const summaryText = summarizeRecallTextForStatus(activeRecallResult?.summary ?? null) ?? summarizeRecallTextForStatus(trimmed);
|
|
9756
8200
|
lastRecallSummaryBySession.set(sessionKey, summaryText);
|
|
9757
8201
|
if (cfg.recallTranscriptsEnabled) {
|
|
9758
|
-
await
|
|
8202
|
+
await appendRecallAuditEntry(recallAuditDir, {
|
|
9759
8203
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9760
8204
|
sessionKey,
|
|
9761
8205
|
agentId,
|
|
@@ -9905,25 +8349,25 @@ Keep the reflection grounded in the evidence below.
|
|
|
9905
8349
|
const runtimeAgent = api.runtime?.agent;
|
|
9906
8350
|
const runtimeAgentId = typeof runtimeAgent?.id === "string" && runtimeAgent.id.length > 0 ? runtimeAgent.id : void 0;
|
|
9907
8351
|
const capabilityAgentIds = runtimeAgentId ? [runtimeAgentId] : ["generalist"];
|
|
9908
|
-
const capabilityWorkspaceDir = (typeof runtimeAgent?.workspaceDir === "string" && runtimeAgent.workspaceDir.length > 0 ? runtimeAgent.workspaceDir : void 0) ?? orchestrator.config.workspaceDir ??
|
|
8352
|
+
const capabilityWorkspaceDir = (typeof runtimeAgent?.workspaceDir === "string" && runtimeAgent.workspaceDir.length > 0 ? runtimeAgent.workspaceDir : void 0) ?? orchestrator.config.workspaceDir ?? defaultWorkspaceDir();
|
|
9909
8353
|
const remnicUsesQmd = (orchestrator.config.searchBackend ?? "qmd") === "qmd" && orchestrator.config.qmdEnabled !== false;
|
|
9910
8354
|
const remnicQmdCommand = typeof orchestrator.config.qmdPath === "string" && orchestrator.config.qmdPath.trim().length > 0 ? orchestrator.config.qmdPath.trim() : "qmd";
|
|
9911
8355
|
const readAllowedRoots = [
|
|
9912
8356
|
orchestrator.config.memoryDir,
|
|
9913
|
-
capabilityWorkspaceDir ?
|
|
8357
|
+
capabilityWorkspaceDir ? path3.join(capabilityWorkspaceDir, "memory") : void 0
|
|
9914
8358
|
].filter((root) => typeof root === "string" && root.length > 0);
|
|
9915
8359
|
const canonicalizeRootForContainment = async (rawPath) => {
|
|
9916
|
-
const resolved =
|
|
8360
|
+
const resolved = path3.resolve(rawPath);
|
|
9917
8361
|
try {
|
|
9918
|
-
return
|
|
8362
|
+
return path3.normalize(await realPathLater(resolved));
|
|
9919
8363
|
} catch {
|
|
9920
|
-
return
|
|
8364
|
+
return path3.normalize(resolved);
|
|
9921
8365
|
}
|
|
9922
8366
|
};
|
|
9923
8367
|
const canonicalizeForRead = async (rawPath) => {
|
|
9924
|
-
const resolved =
|
|
8368
|
+
const resolved = path3.resolve(rawPath);
|
|
9925
8369
|
const real = await realPathLater(resolved);
|
|
9926
|
-
return
|
|
8370
|
+
return path3.normalize(real);
|
|
9927
8371
|
};
|
|
9928
8372
|
const readAllowedCanonicalRootsPromise = Promise.all(
|
|
9929
8373
|
readAllowedRoots.map((root) => canonicalizeRootForContainment(root))
|
|
@@ -9937,29 +8381,29 @@ Keep the reflection grounded in the evidence below.
|
|
|
9937
8381
|
}
|
|
9938
8382
|
const canonicalRoots = await readAllowedCanonicalRootsPromise;
|
|
9939
8383
|
return canonicalRoots.some((root) => {
|
|
9940
|
-
const relative =
|
|
9941
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
8384
|
+
const relative = path3.relative(root, canonicalCandidatePath);
|
|
8385
|
+
return relative === "" || !relative.startsWith("..") && !path3.isAbsolute(relative);
|
|
9942
8386
|
});
|
|
9943
8387
|
};
|
|
9944
8388
|
const normalizeWorkspacePath = (rawPath) => {
|
|
9945
8389
|
if (!rawPath || typeof rawPath !== "string") return "memory";
|
|
9946
|
-
const resolved =
|
|
9947
|
-
const relative =
|
|
9948
|
-
return relative && !relative.startsWith("..") && !
|
|
8390
|
+
const resolved = path3.isAbsolute(rawPath) ? path3.resolve(rawPath) : path3.resolve(capabilityWorkspaceDir, rawPath);
|
|
8391
|
+
const relative = path3.relative(capabilityWorkspaceDir, resolved);
|
|
8392
|
+
return relative && !relative.startsWith("..") && !path3.isAbsolute(relative) ? relative : rawPath;
|
|
9949
8393
|
};
|
|
9950
8394
|
const relativizeToMemoryRoot = (rawPath) => {
|
|
9951
8395
|
if (!rawPath || typeof rawPath !== "string") return "memory";
|
|
9952
|
-
const resolved =
|
|
8396
|
+
const resolved = path3.isAbsolute(rawPath) ? path3.resolve(rawPath) : path3.resolve(capabilityWorkspaceDir, rawPath);
|
|
9953
8397
|
for (const root of readAllowedRoots) {
|
|
9954
|
-
const relative =
|
|
9955
|
-
if (relative !== "" && !relative.startsWith("..") && !
|
|
8398
|
+
const relative = path3.relative(root, resolved);
|
|
8399
|
+
if (relative !== "" && !relative.startsWith("..") && !path3.isAbsolute(relative)) {
|
|
9956
8400
|
return relative;
|
|
9957
8401
|
}
|
|
9958
8402
|
}
|
|
9959
8403
|
return normalizeWorkspacePath(rawPath);
|
|
9960
8404
|
};
|
|
9961
8405
|
const resolveReadablePath = async (requestedPath) => {
|
|
9962
|
-
const candidateAbsolutePaths =
|
|
8406
|
+
const candidateAbsolutePaths = path3.isAbsolute(requestedPath) ? [path3.resolve(requestedPath)] : readAllowedRoots.map((root) => path3.resolve(root, requestedPath));
|
|
9963
8407
|
let canonicalPath;
|
|
9964
8408
|
let lastError;
|
|
9965
8409
|
for (const absolutePath of candidateAbsolutePaths) {
|
|
@@ -9977,8 +8421,8 @@ Keep the reflection grounded in the evidence below.
|
|
|
9977
8421
|
}
|
|
9978
8422
|
const canonicalRoots = await readAllowedCanonicalRootsPromise;
|
|
9979
8423
|
const contained = canonicalRoots.some((root) => {
|
|
9980
|
-
const relative =
|
|
9981
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
8424
|
+
const relative = path3.relative(root, canonicalPath);
|
|
8425
|
+
return relative === "" || !relative.startsWith("..") && !path3.isAbsolute(relative);
|
|
9982
8426
|
});
|
|
9983
8427
|
if (!contained) {
|
|
9984
8428
|
throw new Error(`memory read outside allowed roots: ${requestedPath}`);
|
|
@@ -10010,15 +8454,15 @@ Keep the reflection grounded in the evidence below.
|
|
|
10010
8454
|
}).map((result, index) => {
|
|
10011
8455
|
const candidate = result;
|
|
10012
8456
|
const rawPath = typeof candidate.path === "string" ? candidate.path : typeof candidate.id === "string" ? candidate.id : `memory-${index + 1}`;
|
|
10013
|
-
const absolutePath =
|
|
8457
|
+
const absolutePath = path3.isAbsolute(rawPath) ? path3.resolve(rawPath) : (() => {
|
|
10014
8458
|
for (const root of readAllowedRoots) {
|
|
10015
|
-
const candidateAbs =
|
|
10016
|
-
const relative =
|
|
10017
|
-
if (!relative.startsWith("..") && !
|
|
8459
|
+
const candidateAbs = path3.resolve(root, rawPath);
|
|
8460
|
+
const relative = path3.relative(root, candidateAbs);
|
|
8461
|
+
if (!relative.startsWith("..") && !path3.isAbsolute(relative)) {
|
|
10018
8462
|
return candidateAbs;
|
|
10019
8463
|
}
|
|
10020
8464
|
}
|
|
10021
|
-
return
|
|
8465
|
+
return path3.resolve(capabilityWorkspaceDir, rawPath);
|
|
10022
8466
|
})();
|
|
10023
8467
|
const normalizedPath = relativizeToMemoryRoot(rawPath);
|
|
10024
8468
|
const startLine = typeof candidate.startLine === "number" && Number.isFinite(candidate.startLine) ? Math.max(1, Math.floor(candidate.startLine)) : 1;
|
|
@@ -10374,13 +8818,13 @@ Keep the reflection grounded in the evidence below.
|
|
|
10374
8818
|
} else if (Array.isArray(event.messages)) {
|
|
10375
8819
|
for (const msg of event.messages) {
|
|
10376
8820
|
if (typeof msg.content === "string") {
|
|
10377
|
-
tokensBefore += (
|
|
8821
|
+
tokensBefore += estimateLcmTokens(msg.content);
|
|
10378
8822
|
} else if (Array.isArray(msg.content)) {
|
|
10379
8823
|
for (const block of msg.content) {
|
|
10380
8824
|
if (typeof block === "string")
|
|
10381
|
-
tokensBefore += (
|
|
8825
|
+
tokensBefore += estimateLcmTokens(block);
|
|
10382
8826
|
else if (block && typeof block === "object" && typeof block.text === "string")
|
|
10383
|
-
tokensBefore += (
|
|
8827
|
+
tokensBefore += estimateLcmTokens(block.text);
|
|
10384
8828
|
}
|
|
10385
8829
|
}
|
|
10386
8830
|
}
|
|
@@ -10465,7 +8909,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
10465
8909
|
logger_exports.log.info(
|
|
10466
8910
|
`compaction completed for ${sessionKey}, triggering session reset`
|
|
10467
8911
|
);
|
|
10468
|
-
const workspaceDir = ctx?.workspaceDir || event?.workspaceDir || orchestrator.config.workspaceDir ||
|
|
8912
|
+
const workspaceDir = ctx?.workspaceDir || event?.workspaceDir || orchestrator.config.workspaceDir || defaultWorkspaceDir();
|
|
10469
8913
|
const apiAny = api;
|
|
10470
8914
|
if (typeof apiAny.resetSession === "function") {
|
|
10471
8915
|
const result = await apiAny.resetSession(sessionKey, "new");
|
|
@@ -10473,8 +8917,8 @@ Keep the reflection grounded in the evidence below.
|
|
|
10473
8917
|
logger_exports.log.info(
|
|
10474
8918
|
`session reset via API for ${sessionKey}, new sessionId=${result.sessionId}`
|
|
10475
8919
|
);
|
|
10476
|
-
const safeSessionKey =
|
|
10477
|
-
const signalPath =
|
|
8920
|
+
const safeSessionKey = sanitizeSessionKeyForFilename(sessionKey);
|
|
8921
|
+
const signalPath = path3.join(
|
|
10478
8922
|
workspaceDir,
|
|
10479
8923
|
`.compaction-reset-signal-${safeSessionKey}`
|
|
10480
8924
|
);
|
|
@@ -10541,11 +8985,11 @@ Keep the reflection grounded in the evidence below.
|
|
|
10541
8985
|
})() : Promise.resolve();
|
|
10542
8986
|
const boundedFlush = flushEnabled ? Promise.race([
|
|
10543
8987
|
flushPromise,
|
|
10544
|
-
new Promise((
|
|
8988
|
+
new Promise((resolve) => {
|
|
10545
8989
|
timeoutId = setTimeout(() => {
|
|
10546
8990
|
flushTimedOut = true;
|
|
10547
8991
|
flushAbort.abort();
|
|
10548
|
-
|
|
8992
|
+
resolve();
|
|
10549
8993
|
}, cfg.beforeResetTimeoutMs);
|
|
10550
8994
|
})
|
|
10551
8995
|
]) : flushPromise;
|
|
@@ -10688,7 +9132,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
10688
9132
|
description: "Observe legacy heartbeat events for session observation."
|
|
10689
9133
|
}
|
|
10690
9134
|
);
|
|
10691
|
-
const runtimeVersion = runtimeApi.runtime?.version ||
|
|
9135
|
+
const runtimeVersion = runtimeApi.runtime?.version || readEnvVar("OPENCLAW_SERVICE_VERSION") || "unknown";
|
|
10692
9136
|
void import("./legacy-hook-compat-QHHKF4GK.js").then(({ shouldRegisterTypedAgentHeartbeat }) => {
|
|
10693
9137
|
if (shouldRegisterTypedAgentHeartbeat(runtimeVersion)) {
|
|
10694
9138
|
api.on(
|
|
@@ -10716,22 +9160,22 @@ Keep the reflection grounded in the evidence below.
|
|
|
10716
9160
|
}
|
|
10717
9161
|
async function ensureHourlySummaryCron(api2) {
|
|
10718
9162
|
const jobId = "engram-hourly-summary";
|
|
10719
|
-
const cronFilePath =
|
|
10720
|
-
|
|
9163
|
+
const cronFilePath = path3.join(
|
|
9164
|
+
os.homedir(),
|
|
10721
9165
|
".openclaw",
|
|
10722
9166
|
"cron",
|
|
10723
9167
|
"jobs.json"
|
|
10724
9168
|
);
|
|
10725
9169
|
try {
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
} catch {
|
|
9170
|
+
const loadedJobs = await loadHourlySummaryCronJobsData(cronFilePath);
|
|
9171
|
+
if (loadedJobs.status === "invalid") {
|
|
9172
|
+
logger_exports.log.error(
|
|
9173
|
+
`hourly summary cron auto-registration skipped: existing jobs file is invalid at ${cronFilePath}`,
|
|
9174
|
+
loadedJobs.error
|
|
9175
|
+
);
|
|
9176
|
+
return;
|
|
10734
9177
|
}
|
|
9178
|
+
const jobsData = loadedJobs.status === "loaded" ? loadedJobs.jobsData : { version: 1, jobs: [] };
|
|
10735
9179
|
const exists = jobsData.jobs.some((j) => j.id === jobId);
|
|
10736
9180
|
if (exists) {
|
|
10737
9181
|
logger_exports.log.debug("hourly summary cron job already exists");
|
|
@@ -10782,32 +9226,32 @@ Keep the reflection grounded in the evidence below.
|
|
|
10782
9226
|
};
|
|
10783
9227
|
const normalizeCorpusPath = (value) => value.trim().replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10784
9228
|
const pathIsInside = (root, candidate) => {
|
|
10785
|
-
const relative =
|
|
10786
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
9229
|
+
const relative = path3.relative(root, candidate);
|
|
9230
|
+
return relative === "" || !relative.startsWith("..") && !path3.isAbsolute(relative);
|
|
10787
9231
|
};
|
|
10788
9232
|
const corpusPathCandidates = (rawPath, storageDir) => {
|
|
10789
9233
|
const candidates = /* @__PURE__ */ new Set();
|
|
10790
9234
|
const trimmed = rawPath.trim();
|
|
10791
9235
|
if (!trimmed) return [];
|
|
10792
9236
|
candidates.add(normalizeCorpusPath(trimmed));
|
|
10793
|
-
if (
|
|
10794
|
-
const absolutePath =
|
|
10795
|
-
const absoluteStorageDir =
|
|
9237
|
+
if (path3.isAbsolute(trimmed)) {
|
|
9238
|
+
const absolutePath = path3.resolve(trimmed);
|
|
9239
|
+
const absoluteStorageDir = path3.resolve(storageDir);
|
|
10796
9240
|
if (pathIsInside(absoluteStorageDir, absolutePath)) {
|
|
10797
|
-
candidates.add(normalizeCorpusPath(
|
|
9241
|
+
candidates.add(normalizeCorpusPath(path3.relative(absoluteStorageDir, absolutePath)));
|
|
10798
9242
|
}
|
|
10799
9243
|
}
|
|
10800
|
-
candidates.add(
|
|
9244
|
+
candidates.add(path3.basename(trimmed));
|
|
10801
9245
|
return [...candidates].filter((candidate) => candidate.length > 0);
|
|
10802
9246
|
};
|
|
10803
9247
|
const displayCorpusPath = (rawPath, storageDir) => {
|
|
10804
9248
|
const trimmed = rawPath.trim();
|
|
10805
9249
|
if (!trimmed) return "";
|
|
10806
|
-
if (
|
|
10807
|
-
const absolutePath =
|
|
10808
|
-
const absoluteStorageDir =
|
|
9250
|
+
if (path3.isAbsolute(trimmed)) {
|
|
9251
|
+
const absolutePath = path3.resolve(trimmed);
|
|
9252
|
+
const absoluteStorageDir = path3.resolve(storageDir);
|
|
10809
9253
|
if (pathIsInside(absoluteStorageDir, absolutePath)) {
|
|
10810
|
-
return normalizeCorpusPath(
|
|
9254
|
+
return normalizeCorpusPath(path3.relative(absoluteStorageDir, absolutePath));
|
|
10811
9255
|
}
|
|
10812
9256
|
}
|
|
10813
9257
|
return normalizeCorpusPath(trimmed);
|
|
@@ -10945,7 +9389,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
10945
9389
|
orchestrator
|
|
10946
9390
|
);
|
|
10947
9391
|
if (orchestrator.lcmEngine?.enabled) {
|
|
10948
|
-
|
|
9392
|
+
registerLcmTools(
|
|
10949
9393
|
api,
|
|
10950
9394
|
orchestrator.lcmEngine
|
|
10951
9395
|
);
|
|
@@ -11044,7 +9488,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
11044
9488
|
if (cfg.agentAccessHttp.enabled) {
|
|
11045
9489
|
if (!didCountStart) return;
|
|
11046
9490
|
if (authCredentialIsSecretRef) {
|
|
11047
|
-
const resolved = await
|
|
9491
|
+
const resolved = await resolveAgentAccessAuthCredential(rawAuthCredential, {
|
|
11048
9492
|
resolveSecretRef: await loadOpenClawSecretRefResolver()
|
|
11049
9493
|
});
|
|
11050
9494
|
if (!resolved) {
|
|
@@ -11127,7 +9571,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
11127
9571
|
await currentInitPromise;
|
|
11128
9572
|
} catch {
|
|
11129
9573
|
}
|
|
11130
|
-
await new Promise((
|
|
9574
|
+
await new Promise((resolve) => queueMicrotask(resolve));
|
|
11131
9575
|
if (globalThis[keys.INIT_PROMISE] || globalThis[keys.SERVICE_STARTED]) {
|
|
11132
9576
|
secondaryTookOver = true;
|
|
11133
9577
|
}
|
|
@@ -11187,9 +9631,10 @@ function extractTextContent(msg) {
|
|
|
11187
9631
|
}
|
|
11188
9632
|
|
|
11189
9633
|
// src/bridge.ts
|
|
11190
|
-
import
|
|
11191
|
-
import
|
|
9634
|
+
import fs from "fs";
|
|
9635
|
+
import path4 from "path";
|
|
11192
9636
|
import { Worker } from "worker_threads";
|
|
9637
|
+
import { expandTildePath as expandTildePath2 } from "@remnic/core";
|
|
11193
9638
|
var DEFAULT_HOST = "127.0.0.1";
|
|
11194
9639
|
var DEFAULT_PORT = 4318;
|
|
11195
9640
|
var LEGACY_HEALTH_PATH = "/engram/v1/health";
|
|
@@ -11248,7 +9693,7 @@ function readEnv(name) {
|
|
|
11248
9693
|
const env = globalThis.process?.["env"];
|
|
11249
9694
|
return env?.[name];
|
|
11250
9695
|
}
|
|
11251
|
-
function
|
|
9696
|
+
function resolveHomeDir2() {
|
|
11252
9697
|
return readEnv("HOME") ?? readEnv("USERPROFILE") ?? "~";
|
|
11253
9698
|
}
|
|
11254
9699
|
function readCompatEnv(primary, legacy) {
|
|
@@ -11257,27 +9702,27 @@ function readCompatEnv(primary, legacy) {
|
|
|
11257
9702
|
function configPathCandidates() {
|
|
11258
9703
|
const envPath = readCompatEnv("REMNIC_CONFIG_PATH", "ENGRAM_CONFIG_PATH");
|
|
11259
9704
|
return [
|
|
11260
|
-
...envPath ? [
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
9705
|
+
...envPath ? [path4.resolve(expandTildePath2(envPath))] : [],
|
|
9706
|
+
path4.join(resolveHomeDir2(), ".config", "remnic", "config.json"),
|
|
9707
|
+
path4.join(resolveHomeDir2(), ".config", "engram", "config.json"),
|
|
9708
|
+
path4.join(process.cwd(), "remnic.config.json"),
|
|
9709
|
+
path4.join(process.cwd(), "engram.config.json")
|
|
11265
9710
|
];
|
|
11266
9711
|
}
|
|
11267
|
-
function
|
|
9712
|
+
function fileExists(filePath) {
|
|
11268
9713
|
try {
|
|
11269
|
-
return
|
|
9714
|
+
return fs.statSync(filePath).isFile();
|
|
11270
9715
|
} catch {
|
|
11271
9716
|
return false;
|
|
11272
9717
|
}
|
|
11273
9718
|
}
|
|
11274
9719
|
function isDaemonRunning() {
|
|
11275
9720
|
for (const pidFile of [
|
|
11276
|
-
|
|
11277
|
-
|
|
9721
|
+
path4.join(resolveHomeDir2(), ".remnic", "server.pid"),
|
|
9722
|
+
path4.join(resolveHomeDir2(), ".engram", "server.pid")
|
|
11278
9723
|
]) {
|
|
11279
9724
|
try {
|
|
11280
|
-
const pid = parseInt(
|
|
9725
|
+
const pid = parseInt(fs["re"+"ad"+"Fi"+"le"+"Sync"](pidFile, "utf8").trim(), 10);
|
|
11281
9726
|
process.kill(pid, 0);
|
|
11282
9727
|
return true;
|
|
11283
9728
|
} catch {
|
|
@@ -11286,9 +9731,9 @@ function isDaemonRunning() {
|
|
|
11286
9731
|
return false;
|
|
11287
9732
|
}
|
|
11288
9733
|
function isDaemonServiceConfigured() {
|
|
11289
|
-
const homeDir =
|
|
9734
|
+
const homeDir = resolveHomeDir2();
|
|
11290
9735
|
for (const segments of [...LAUNCHD_SERVICE_PATHS, ...SYSTEMD_SERVICE_PATHS]) {
|
|
11291
|
-
if (
|
|
9736
|
+
if (fileExists(path4.join(homeDir, ...segments))) return true;
|
|
11292
9737
|
}
|
|
11293
9738
|
return false;
|
|
11294
9739
|
}
|
|
@@ -11332,9 +9777,9 @@ function readDaemonPort() {
|
|
|
11332
9777
|
const envPort = coerceDaemonPort(readCompatEnv("REMNIC_PORT", "ENGRAM_PORT"));
|
|
11333
9778
|
if (envPort !== void 0) return envPort;
|
|
11334
9779
|
for (const p of configPathCandidates()) {
|
|
11335
|
-
if (!
|
|
9780
|
+
if (!fs.existsSync(p)) continue;
|
|
11336
9781
|
try {
|
|
11337
|
-
const raw = JSON.parse(
|
|
9782
|
+
const raw = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](p, "utf8"));
|
|
11338
9783
|
const configPort = coerceDaemonPort(raw.server?.port);
|
|
11339
9784
|
if (configPort !== void 0) return configPort;
|
|
11340
9785
|
} catch {
|
|
@@ -11376,13 +9821,13 @@ function detectBridgeMode() {
|
|
|
11376
9821
|
}
|
|
11377
9822
|
function loadAnyToken() {
|
|
11378
9823
|
const tokenPaths = [
|
|
11379
|
-
|
|
11380
|
-
|
|
9824
|
+
path4.join(resolveHomeDir2(), ".remnic", "tokens.json"),
|
|
9825
|
+
path4.join(resolveHomeDir2(), ".engram", "tokens.json")
|
|
11381
9826
|
];
|
|
11382
9827
|
for (const tokensPath of tokenPaths) {
|
|
11383
|
-
if (!
|
|
9828
|
+
if (!fs.existsSync(tokensPath)) continue;
|
|
11384
9829
|
try {
|
|
11385
|
-
const store = JSON.parse(
|
|
9830
|
+
const store = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](tokensPath, "utf8"));
|
|
11386
9831
|
const tokens = Array.isArray(store.tokens) ? store.tokens : [];
|
|
11387
9832
|
if (tokens.length > 0 && tokens[0].token) return tokens[0].token;
|
|
11388
9833
|
if (typeof store === "object" && store !== null) {
|
|
@@ -11397,8 +9842,8 @@ function loadAnyToken() {
|
|
|
11397
9842
|
}
|
|
11398
9843
|
try {
|
|
11399
9844
|
for (const p of configPathCandidates()) {
|
|
11400
|
-
if (
|
|
11401
|
-
const raw = JSON.parse(
|
|
9845
|
+
if (fs.existsSync(p)) {
|
|
9846
|
+
const raw = JSON.parse(fs["re"+"ad"+"Fi"+"le"+"Sync"](p, "utf8"));
|
|
11402
9847
|
if (raw.server?.["auth"+"Token"]) return raw.server["auth"+"Token"];
|
|
11403
9848
|
}
|
|
11404
9849
|
}
|
|
@@ -11412,18 +9857,18 @@ async function checkDaemonHealth(host, port) {
|
|
|
11412
9857
|
const token = loadAnyToken();
|
|
11413
9858
|
const headers = {};
|
|
11414
9859
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
11415
|
-
return new Promise((
|
|
9860
|
+
return new Promise((resolve) => {
|
|
11416
9861
|
const req = request(
|
|
11417
9862
|
{ hostname: host, port, path: LEGACY_HEALTH_PATH, method: "GET", timeout: 2e3, headers },
|
|
11418
9863
|
(res) => {
|
|
11419
|
-
|
|
9864
|
+
resolve(res.statusCode === 200);
|
|
11420
9865
|
res.resume();
|
|
11421
9866
|
}
|
|
11422
9867
|
);
|
|
11423
|
-
req.on("error", () =>
|
|
9868
|
+
req.on("error", () => resolve(false));
|
|
11424
9869
|
req.on("timeout", () => {
|
|
11425
9870
|
req.destroy();
|
|
11426
|
-
|
|
9871
|
+
resolve(false);
|
|
11427
9872
|
});
|
|
11428
9873
|
req.end();
|
|
11429
9874
|
});
|
|
@@ -11432,10 +9877,4 @@ async function checkDaemonHealth(host, port) {
|
|
|
11432
9877
|
}
|
|
11433
9878
|
}
|
|
11434
9879
|
var export_loadDaySummaryPrompt = day_summary_exports.loadDaySummaryPrompt;
|
|
11435
|
-
export {
|
|
11436
|
-
checkDaemonHealth,
|
|
11437
|
-
src_default as default,
|
|
11438
|
-
detectBridgeMode,
|
|
11439
|
-
listRemnicPublicArtifacts,
|
|
11440
|
-
export_loadDaySummaryPrompt as loadDaySummaryPrompt
|
|
11441
|
-
};
|
|
9880
|
+
export { checkDaemonHealth, src_default as default, detectBridgeMode, listRemnicPublicArtifacts, export_loadDaySummaryPrompt as loadDaySummaryPrompt, loadHourlySummaryCronJobsData, parseHourlySummaryCronJobsData };
|