@openclawbrain/openclaw 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/extension/index.js +17 -1
- package/dist/extension/index.js.map +1 -1
- package/dist/src/attachment-truth.d.ts +34 -0
- package/dist/src/attachment-truth.js +215 -0
- package/dist/src/attachment-truth.js.map +1 -0
- package/dist/src/cli.js +428 -42
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +25 -1
- package/dist/src/index.js +141 -53
- package/dist/src/index.js.map +1 -1
- package/dist/src/local-session-passive-learning.js +1 -1
- package/dist/src/local-session-passive-learning.js.map +1 -1
- package/dist/src/openclaw-hook-truth.d.ts +25 -0
- package/dist/src/openclaw-hook-truth.js +154 -0
- package/dist/src/openclaw-hook-truth.js.map +1 -0
- package/dist/src/semantic-metadata.d.ts +2 -1
- package/dist/src/semantic-metadata.js +31 -2
- package/dist/src/semantic-metadata.js.map +1 -1
- package/extension/index.ts +19 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -103,7 +103,6 @@ Keep `install` as the front-door lifecycle command:
|
|
|
103
103
|
|
|
104
104
|
- `openclawbrain install` is the default attach path. On many-profile hosts, pass `--openclaw-home <path>` or set `OPENCLAW_HOME` so the target profile is explicit instead of guessed.
|
|
105
105
|
- `openclawbrain install` now writes only the real profile hook and activation state. It no longer creates `BRAIN.md` or rewrites `AGENTS.md`.
|
|
106
|
-
- for the `0.3.2` semantic/gating structure wave, use a fresh activation root or `uninstall --purge-data` plus reinstall when you want the new structure cleanly; in-place upgrade keeps existing learned material and does not rewrite it retroactively
|
|
107
106
|
- `openclawbrain detach --openclaw-home <path>` removes only the OpenClaw profile hook. It preserves OpenClawBrain activation data and now says so plainly in both human output and JSON.
|
|
108
107
|
- `openclawbrain uninstall --openclaw-home <path> --keep-data|--purge-data` removes the profile hook and forces the operator to pick the data outcome explicitly.
|
|
109
108
|
- `--restart <never|safe|external>` is guidance only for detach/uninstall. The default `safe` guidance stays conservative: restart the running OpenClaw profile before expecting hook-state changes to take effect; otherwise the next launch picks them up.
|
package/dist/extension/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - Missing activation root → fail-open with console.warn
|
|
11
11
|
*/
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
|
-
import { compileRuntimeContext } from "@openclawbrain/openclaw";
|
|
13
|
+
import { compileRuntimeContext, recordOpenClawProfileRuntimeLoadProof } from "@openclawbrain/openclaw";
|
|
14
14
|
import { createBeforePromptBuildHandler, isActivationRootPlaceholder, validateExtensionRegistrationApi } from "./runtime-guard.js";
|
|
15
15
|
const ACTIVATION_ROOT = "__ACTIVATION_ROOT__";
|
|
16
16
|
const EXTENSION_ENTRY_PATH = fileURLToPath(import.meta.url);
|
|
@@ -67,6 +67,22 @@ export default function register(api) {
|
|
|
67
67
|
reportDiagnostic,
|
|
68
68
|
debug: (message) => console.debug(message)
|
|
69
69
|
}), { priority: 5 });
|
|
70
|
+
if (!isActivationRootPlaceholder(ACTIVATION_ROOT)) {
|
|
71
|
+
try {
|
|
72
|
+
recordOpenClawProfileRuntimeLoadProof({
|
|
73
|
+
activationRoot: ACTIVATION_ROOT,
|
|
74
|
+
extensionEntryPath: EXTENSION_ENTRY_PATH
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
79
|
+
void reportDiagnostic({
|
|
80
|
+
key: `runtime-load-proof:${detail}`,
|
|
81
|
+
once: true,
|
|
82
|
+
message: `[openclawbrain] runtime load proof failed: ${detail}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
70
86
|
announceStartupBreadcrumb();
|
|
71
87
|
}
|
|
72
88
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../extension/index.ts"],"names":[],"mappings":"AAA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awHomeInspection } from "./openclaw-home-layout.js";
|
|
2
|
+
declare const ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT: "openclaw_profile_runtime_load_proofs.v1";
|
|
3
|
+
export interface OpenClawProfileRuntimeLoadProofRecordV1 {
|
|
4
|
+
openclawHome: string;
|
|
5
|
+
profileId: string | null;
|
|
6
|
+
profileSource: OpenClawHomeInspection["profileSource"];
|
|
7
|
+
loadedAt: string;
|
|
8
|
+
extensionEntryPath: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OpenClawProfileRuntimeLoadProofsV1 {
|
|
11
|
+
contract: typeof ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT;
|
|
12
|
+
runtimeOwner: "openclaw";
|
|
13
|
+
activationRoot: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
profiles: OpenClawProfileRuntimeLoadProofRecordV1[];
|
|
16
|
+
}
|
|
17
|
+
export interface OpenClawProfileRuntimeLoadProofSetV1 {
|
|
18
|
+
path: string;
|
|
19
|
+
proofs: OpenClawProfileRuntimeLoadProofsV1 | null;
|
|
20
|
+
error: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function resolveAttachmentRuntimeLoadProofsPath(activationRoot: string): string;
|
|
23
|
+
export declare function listOpenClawProfileRuntimeLoadProofs(activationRoot: string): OpenClawProfileRuntimeLoadProofSetV1;
|
|
24
|
+
export declare function recordOpenClawProfileRuntimeLoadProof(input: {
|
|
25
|
+
activationRoot: string;
|
|
26
|
+
extensionEntryPath: string;
|
|
27
|
+
loadedAt?: string | null;
|
|
28
|
+
}): OpenClawProfileRuntimeLoadProofRecordV1;
|
|
29
|
+
export declare function clearOpenClawProfileRuntimeLoadProof(input: {
|
|
30
|
+
activationRoot: string;
|
|
31
|
+
openclawHome: string;
|
|
32
|
+
clearedAt?: string | null;
|
|
33
|
+
}): boolean;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { inspectOpenClawHome } from "./openclaw-home-layout.js";
|
|
4
|
+
const ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT = "openclaw_profile_runtime_load_proofs.v1";
|
|
5
|
+
const ATTACHMENT_TRUTH_DIRNAME = "attachment-truth";
|
|
6
|
+
const ATTACHMENT_RUNTIME_LOAD_PROOFS_BASENAME = "runtime-load-proofs.json";
|
|
7
|
+
function toErrorMessage(error) {
|
|
8
|
+
return error instanceof Error ? error.message : String(error);
|
|
9
|
+
}
|
|
10
|
+
function canonicalizeFilesystemPath(filePath) {
|
|
11
|
+
const resolvedPath = path.resolve(filePath);
|
|
12
|
+
try {
|
|
13
|
+
return realpathSync(resolvedPath);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return resolvedPath;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function normalizeIsoTimestamp(value, fieldName, fallbackValue) {
|
|
20
|
+
const candidate = value ?? fallbackValue;
|
|
21
|
+
if (candidate === undefined || candidate === null || candidate.trim().length === 0) {
|
|
22
|
+
throw new Error(`${fieldName} is required`);
|
|
23
|
+
}
|
|
24
|
+
if (Number.isNaN(Date.parse(candidate))) {
|
|
25
|
+
throw new Error(`${fieldName} must be an ISO timestamp`);
|
|
26
|
+
}
|
|
27
|
+
return new Date(candidate).toISOString();
|
|
28
|
+
}
|
|
29
|
+
function readRecord(value) {
|
|
30
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function validateRuntimeLoadProofRecord(value, index) {
|
|
36
|
+
const record = readRecord(value);
|
|
37
|
+
if (record === null) {
|
|
38
|
+
throw new Error(`profiles[${index}] must be an object`);
|
|
39
|
+
}
|
|
40
|
+
const openclawHome = typeof record.openclawHome === "string" && record.openclawHome.trim().length > 0
|
|
41
|
+
? canonicalizeFilesystemPath(record.openclawHome)
|
|
42
|
+
: null;
|
|
43
|
+
const profileId = record.profileId === null ? null : typeof record.profileId === "string" && record.profileId.trim().length > 0
|
|
44
|
+
? record.profileId.trim()
|
|
45
|
+
: undefined;
|
|
46
|
+
const profileSource = record.profileSource === "openclaw_json_profile" ||
|
|
47
|
+
record.profileSource === "openclaw_json_single_profile_key" ||
|
|
48
|
+
record.profileSource === "directory_name" ||
|
|
49
|
+
record.profileSource === "none"
|
|
50
|
+
? record.profileSource
|
|
51
|
+
: null;
|
|
52
|
+
const extensionEntryPath = typeof record.extensionEntryPath === "string" && record.extensionEntryPath.trim().length > 0
|
|
53
|
+
? canonicalizeFilesystemPath(record.extensionEntryPath)
|
|
54
|
+
: null;
|
|
55
|
+
const loadedAt = typeof record.loadedAt === "string" && record.loadedAt.trim().length > 0
|
|
56
|
+
? normalizeIsoTimestamp(record.loadedAt, `profiles[${index}].loadedAt`)
|
|
57
|
+
: null;
|
|
58
|
+
if (openclawHome === null) {
|
|
59
|
+
throw new Error(`profiles[${index}].openclawHome must be a non-empty string`);
|
|
60
|
+
}
|
|
61
|
+
if (profileId === undefined) {
|
|
62
|
+
throw new Error(`profiles[${index}].profileId must be null or a non-empty string`);
|
|
63
|
+
}
|
|
64
|
+
if (profileSource === null) {
|
|
65
|
+
throw new Error(`profiles[${index}].profileSource must be a supported OpenClaw profile source`);
|
|
66
|
+
}
|
|
67
|
+
if (extensionEntryPath === null) {
|
|
68
|
+
throw new Error(`profiles[${index}].extensionEntryPath must be a non-empty string`);
|
|
69
|
+
}
|
|
70
|
+
if (loadedAt === null) {
|
|
71
|
+
throw new Error(`profiles[${index}].loadedAt must be a non-empty ISO timestamp`);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
openclawHome,
|
|
75
|
+
profileId,
|
|
76
|
+
profileSource,
|
|
77
|
+
extensionEntryPath,
|
|
78
|
+
loadedAt
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function validateRuntimeLoadProofs(activationRoot, value) {
|
|
82
|
+
const record = readRecord(value);
|
|
83
|
+
if (record === null) {
|
|
84
|
+
throw new Error("runtime load proof file must contain an object");
|
|
85
|
+
}
|
|
86
|
+
if (record.contract !== ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT) {
|
|
87
|
+
throw new Error(`runtime load proof contract must be ${ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT}`);
|
|
88
|
+
}
|
|
89
|
+
if (record.runtimeOwner !== "openclaw") {
|
|
90
|
+
throw new Error("runtime load proof runtimeOwner must be openclaw");
|
|
91
|
+
}
|
|
92
|
+
if (typeof record.activationRoot !== "string" || record.activationRoot.trim().length === 0) {
|
|
93
|
+
throw new Error("runtime load proof activationRoot must be a non-empty string");
|
|
94
|
+
}
|
|
95
|
+
const resolvedActivationRoot = path.resolve(record.activationRoot);
|
|
96
|
+
if (resolvedActivationRoot !== activationRoot) {
|
|
97
|
+
throw new Error(`runtime load proof activationRoot mismatch: expected ${activationRoot}, received ${resolvedActivationRoot}`);
|
|
98
|
+
}
|
|
99
|
+
const updatedAt = typeof record.updatedAt === "string" && record.updatedAt.trim().length > 0
|
|
100
|
+
? normalizeIsoTimestamp(record.updatedAt, "updatedAt")
|
|
101
|
+
: null;
|
|
102
|
+
if (updatedAt === null) {
|
|
103
|
+
throw new Error("runtime load proof updatedAt must be a non-empty ISO timestamp");
|
|
104
|
+
}
|
|
105
|
+
if (!Array.isArray(record.profiles)) {
|
|
106
|
+
throw new Error("runtime load proof profiles must be an array");
|
|
107
|
+
}
|
|
108
|
+
const profiles = record.profiles.map((entry, index) => validateRuntimeLoadProofRecord(entry, index));
|
|
109
|
+
return {
|
|
110
|
+
contract: ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT,
|
|
111
|
+
runtimeOwner: "openclaw",
|
|
112
|
+
activationRoot,
|
|
113
|
+
updatedAt,
|
|
114
|
+
profiles
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function buildEmptyRuntimeLoadProofs(activationRoot, updatedAt) {
|
|
118
|
+
return {
|
|
119
|
+
contract: ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT,
|
|
120
|
+
runtimeOwner: "openclaw",
|
|
121
|
+
activationRoot,
|
|
122
|
+
updatedAt,
|
|
123
|
+
profiles: []
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function writeRuntimeLoadProofs(proofPath, proofs) {
|
|
127
|
+
mkdirSync(path.dirname(proofPath), { recursive: true });
|
|
128
|
+
writeFileSync(proofPath, `${JSON.stringify(proofs, null, 2)}\n`, "utf8");
|
|
129
|
+
}
|
|
130
|
+
function deriveOpenClawHomeFromExtensionEntryPath(extensionEntryPath) {
|
|
131
|
+
return canonicalizeFilesystemPath(path.resolve(path.dirname(canonicalizeFilesystemPath(extensionEntryPath)), "..", ".."));
|
|
132
|
+
}
|
|
133
|
+
export function resolveAttachmentRuntimeLoadProofsPath(activationRoot) {
|
|
134
|
+
return path.join(path.resolve(activationRoot), ATTACHMENT_TRUTH_DIRNAME, ATTACHMENT_RUNTIME_LOAD_PROOFS_BASENAME);
|
|
135
|
+
}
|
|
136
|
+
export function listOpenClawProfileRuntimeLoadProofs(activationRoot) {
|
|
137
|
+
const resolvedActivationRoot = path.resolve(activationRoot);
|
|
138
|
+
const proofPath = resolveAttachmentRuntimeLoadProofsPath(resolvedActivationRoot);
|
|
139
|
+
if (!existsSync(proofPath)) {
|
|
140
|
+
return {
|
|
141
|
+
path: proofPath,
|
|
142
|
+
proofs: null,
|
|
143
|
+
error: null
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const parsed = JSON.parse(readFileSync(proofPath, "utf8"));
|
|
148
|
+
return {
|
|
149
|
+
path: proofPath,
|
|
150
|
+
proofs: validateRuntimeLoadProofs(resolvedActivationRoot, parsed),
|
|
151
|
+
error: null
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
path: proofPath,
|
|
157
|
+
proofs: null,
|
|
158
|
+
error: toErrorMessage(error)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export function recordOpenClawProfileRuntimeLoadProof(input) {
|
|
163
|
+
const activationRoot = path.resolve(input.activationRoot);
|
|
164
|
+
const loadedAt = normalizeIsoTimestamp(input.loadedAt, "loadedAt", new Date().toISOString());
|
|
165
|
+
const extensionEntryPath = canonicalizeFilesystemPath(input.extensionEntryPath);
|
|
166
|
+
const openclawHome = deriveOpenClawHomeFromExtensionEntryPath(extensionEntryPath);
|
|
167
|
+
const inspection = inspectOpenClawHome(openclawHome);
|
|
168
|
+
const loadedProofs = listOpenClawProfileRuntimeLoadProofs(activationRoot);
|
|
169
|
+
if (loadedProofs.error !== null) {
|
|
170
|
+
throw new Error(`runtime load proof file ${loadedProofs.path} is unreadable: ${loadedProofs.error}`);
|
|
171
|
+
}
|
|
172
|
+
const nextRecord = {
|
|
173
|
+
openclawHome: canonicalizeFilesystemPath(openclawHome),
|
|
174
|
+
profileId: inspection.profileId,
|
|
175
|
+
profileSource: inspection.profileSource,
|
|
176
|
+
loadedAt,
|
|
177
|
+
extensionEntryPath
|
|
178
|
+
};
|
|
179
|
+
const nextProofs = loadedProofs.proofs === null
|
|
180
|
+
? buildEmptyRuntimeLoadProofs(activationRoot, loadedAt)
|
|
181
|
+
: {
|
|
182
|
+
...loadedProofs.proofs,
|
|
183
|
+
updatedAt: loadedAt,
|
|
184
|
+
profiles: [...loadedProofs.proofs.profiles]
|
|
185
|
+
};
|
|
186
|
+
nextProofs.profiles = nextProofs.profiles
|
|
187
|
+
.filter((record) => canonicalizeFilesystemPath(record.openclawHome) !== nextRecord.openclawHome)
|
|
188
|
+
.concat(nextRecord)
|
|
189
|
+
.sort((left, right) => left.openclawHome.localeCompare(right.openclawHome));
|
|
190
|
+
writeRuntimeLoadProofs(loadedProofs.path, nextProofs);
|
|
191
|
+
return nextRecord;
|
|
192
|
+
}
|
|
193
|
+
export function clearOpenClawProfileRuntimeLoadProof(input) {
|
|
194
|
+
const activationRoot = path.resolve(input.activationRoot);
|
|
195
|
+
const clearedAt = normalizeIsoTimestamp(input.clearedAt, "clearedAt", new Date().toISOString());
|
|
196
|
+
const openclawHome = canonicalizeFilesystemPath(input.openclawHome);
|
|
197
|
+
const loadedProofs = listOpenClawProfileRuntimeLoadProofs(activationRoot);
|
|
198
|
+
if (loadedProofs.error !== null) {
|
|
199
|
+
throw new Error(`runtime load proof file ${loadedProofs.path} is unreadable: ${loadedProofs.error}`);
|
|
200
|
+
}
|
|
201
|
+
if (loadedProofs.proofs === null) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const filteredProfiles = loadedProofs.proofs.profiles.filter((record) => canonicalizeFilesystemPath(record.openclawHome) !== openclawHome);
|
|
205
|
+
if (filteredProfiles.length === loadedProofs.proofs.profiles.length) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
writeRuntimeLoadProofs(loadedProofs.path, {
|
|
209
|
+
...loadedProofs.proofs,
|
|
210
|
+
updatedAt: clearedAt,
|
|
211
|
+
profiles: filteredProfiles
|
|
212
|
+
});
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=attachment-truth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-truth.js","sourceRoot":"","sources":["../../src/attachment-truth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAA+B,MAAM,2BAA2B,CAAC;AAE7F,MAAM,uCAAuC,GAAG,yCAAkD,CAAC;AACnG,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AACpD,MAAM,uCAAuC,GAAG,0BAA0B,CAAC;AAwB3E,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