@totalreclaw/totalreclaw 3.3.12-rc.2 → 3.3.12-rc.21
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/CHANGELOG.md +26 -0
- package/SKILL.md +34 -249
- package/api-client.ts +17 -9
- package/batch-gate.ts +42 -0
- package/billing-cache.ts +25 -20
- package/claims-helper.ts +7 -1
- package/config.ts +54 -12
- package/consolidation.ts +6 -13
- package/contradiction-sync.ts +19 -14
- package/credential-provider.ts +184 -0
- package/crypto.ts +27 -160
- package/dist/api-client.js +17 -9
- package/dist/batch-gate.js +40 -0
- package/dist/billing-cache.js +19 -21
- package/dist/claims-helper.js +7 -1
- package/dist/config.js +54 -12
- package/dist/consolidation.js +6 -15
- package/dist/contradiction-sync.js +15 -15
- package/dist/credential-provider.js +145 -0
- package/dist/crypto.js +17 -137
- package/dist/download-ux.js +11 -7
- package/dist/embedder-loader.js +266 -0
- package/dist/embedding.js +36 -3
- package/dist/entry.js +123 -0
- package/dist/extractor.js +134 -0
- package/dist/fs-helpers.js +116 -241
- package/dist/import-adapters/chatgpt-adapter.js +14 -0
- package/dist/import-adapters/claude-adapter.js +14 -0
- package/dist/import-adapters/gemini-adapter.js +43 -159
- package/dist/import-adapters/mcp-memory-adapter.js +14 -0
- package/dist/import-state-manager.js +100 -0
- package/dist/index.js +1130 -2520
- package/dist/llm-client.js +69 -1
- package/dist/memory-runtime.js +459 -0
- package/dist/native-memory.js +123 -0
- package/dist/onboarding-cli.js +3 -2
- package/dist/pair-cli.js +1 -1
- package/dist/pair-crypto.js +16 -358
- package/dist/pair-http.js +147 -4
- package/dist/relay.js +140 -0
- package/dist/reranker.js +13 -8
- package/dist/semantic-dedup.js +5 -7
- package/dist/skill-register.js +97 -0
- package/dist/subgraph-search.js +3 -1
- package/dist/subgraph-store.js +315 -282
- package/dist/tool-gating.js +39 -26
- package/dist/tools.js +367 -0
- package/dist/tr-cli-export-helper.js +103 -0
- package/dist/tr-cli.js +220 -127
- package/dist/trajectory-poller.js +155 -9
- package/dist/vault-crypto.js +551 -0
- package/download-ux.ts +12 -6
- package/embedder-loader.ts +293 -1
- package/embedding.ts +43 -3
- package/entry.ts +132 -0
- package/extractor.ts +167 -0
- package/fs-helpers.ts +166 -292
- package/import-adapters/chatgpt-adapter.ts +18 -0
- package/import-adapters/claude-adapter.ts +18 -0
- package/import-adapters/gemini-adapter.ts +56 -183
- package/import-adapters/mcp-memory-adapter.ts +18 -0
- package/import-adapters/types.ts +1 -1
- package/import-state-manager.ts +139 -0
- package/index.ts +1432 -3002
- package/llm-client.ts +74 -1
- package/memory-runtime.ts +723 -0
- package/native-memory.ts +196 -0
- package/onboarding-cli.ts +3 -2
- package/openclaw.plugin.json +5 -17
- package/package.json +7 -4
- package/pair-cli.ts +1 -1
- package/pair-crypto.ts +41 -483
- package/pair-http.ts +194 -5
- package/postinstall.mjs +138 -0
- package/relay.ts +172 -0
- package/reranker.ts +13 -8
- package/semantic-dedup.ts +5 -6
- package/skill-register.ts +146 -0
- package/skill.json +1 -1
- package/subgraph-search.ts +3 -1
- package/subgraph-store.ts +334 -299
- package/tool-gating.ts +39 -26
- package/tools.ts +499 -0
- package/tr-cli-export-helper.ts +138 -0
- package/tr-cli.ts +263 -133
- package/trajectory-poller.ts +162 -10
- package/vault-crypto.ts +705 -0
package/dist/fs-helpers.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import fs from 'node:fs';
|
|
30
30
|
import path from 'node:path';
|
|
31
|
+
import { envHomeDir } from './entry.js';
|
|
31
32
|
// ---------------------------------------------------------------------------
|
|
32
33
|
// MEMORY.md header ensure
|
|
33
34
|
// ---------------------------------------------------------------------------
|
|
@@ -82,8 +83,7 @@ export function ensureMemoryHeaderFile(workspace, header, markerSubstring = 'Tot
|
|
|
82
83
|
* covers the OpenClaw plugin sandbox case where the loaded module
|
|
83
84
|
* lives at `<pluginRoot>/dist/index.js` while `package.json` lives
|
|
84
85
|
* at `<pluginRoot>/package.json` (3.3.4-rc.1 fix — without this
|
|
85
|
-
* walk-up,
|
|
86
|
-
* all RC-gated logic that depends on the version string fails
|
|
86
|
+
* walk-up, version-dependent logic gets `version=unknown` and fails
|
|
87
87
|
* silently in production OpenClaw deployments).
|
|
88
88
|
* - Returns the `version` field, or `null` on any I/O / parse error.
|
|
89
89
|
*
|
|
@@ -471,157 +471,15 @@ export function wipePartialInstall(pluginRootDir) {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
// ---------------------------------------------------------------------------
|
|
474
|
-
// Plugin load manifest (.loaded.json / .error.json) — 3.
|
|
474
|
+
// Plugin load manifest (.loaded.json / .error.json) — RETIRED Phase 3.4
|
|
475
475
|
// ---------------------------------------------------------------------------
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
* - `cat ~/.openclaw/extensions/totalreclaw/.loaded.json` shows
|
|
484
|
-
* `{loadedAt, tools, version}` after every successful gateway start.
|
|
485
|
-
* - `cat ~/.openclaw/extensions/totalreclaw/.error.json` shows
|
|
486
|
-
* `{loadedAt, error, stack}` if register() threw.
|
|
487
|
-
* - Both are overwritten on each register() call so the agent can rely
|
|
488
|
-
* on the timestamp matching the most recent gateway start.
|
|
489
|
-
*
|
|
490
|
-
* Why these MUST be synchronous writes (same constraint as
|
|
491
|
-
* `registerHttpRoute` per the comment in index.ts around the route
|
|
492
|
-
* registration site): the SDK loader treats register() returning as the
|
|
493
|
-
* signal to freeze the registries. An async `fs.promises.writeFile` would
|
|
494
|
-
* settle one microtask AFTER the loader has moved on, so the manifest
|
|
495
|
-
* could miss tools that registered late OR drop entirely if the gateway
|
|
496
|
-
* exits before the microtask runs. `writeFileSync` is the only safe choice.
|
|
497
|
-
*/
|
|
498
|
-
export const PLUGIN_LOADED_MANIFEST = '.loaded.json';
|
|
499
|
-
export const PLUGIN_ERROR_MANIFEST = '.error.json';
|
|
500
|
-
/**
|
|
501
|
-
* Resolve the plugin root dir from the loaded module's directory. The plugin
|
|
502
|
-
* is shipped with `dist/index.js` as the entry, so `import.meta.url` resolves
|
|
503
|
-
* to `<root>/dist/`. We walk up one level to put the manifests next to
|
|
504
|
-
* `package.json`. Defensive: if the caller already passed the root (no
|
|
505
|
-
* trailing `dist`), we still return a sensible path.
|
|
506
|
-
*/
|
|
507
|
-
function resolvePluginRootForManifest(pluginDir) {
|
|
508
|
-
const base = path.basename(pluginDir);
|
|
509
|
-
return base === 'dist' ? path.resolve(pluginDir, '..') : pluginDir;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Write the success manifest. SYNCHRONOUS — the SDK freezes the plugin
|
|
513
|
-
* registries the moment register() returns; `fs.promises.writeFile` would
|
|
514
|
-
* race that freeze and the manifest could miss late tool registrations or
|
|
515
|
-
* never land at all if the process exits before the microtask runs.
|
|
516
|
-
*
|
|
517
|
-
* Best-effort: returns `true` on success, `false` on any I/O error. Never
|
|
518
|
-
* throws — failing to write the manifest is a diagnostic loss, not a
|
|
519
|
-
* correctness loss, so we don't propagate.
|
|
520
|
-
*
|
|
521
|
-
* The manifest is written at mode 0644 (world-readable). It contains no
|
|
522
|
-
* secrets — only a timestamp, the (publicly known) tool names, and the
|
|
523
|
-
* plugin version. Cleared first so a stale `.error.json` from a previous
|
|
524
|
-
* failed boot doesn't survive a successful boot.
|
|
525
|
-
*/
|
|
526
|
-
/**
|
|
527
|
-
* Read the existing `.loaded.json` manifest for diagnostic surfaces
|
|
528
|
-
* (3.3.7-rc.1 — issue #216). Returns `null` if the manifest is
|
|
529
|
-
* missing, unreadable, or malformed. Best-effort: never throws.
|
|
530
|
-
*
|
|
531
|
-
* Scanner note: this helper lives in fs-helpers.ts (where all fs.*
|
|
532
|
-
* operations are consolidated) so the diagnostic slash command in
|
|
533
|
-
* `index.ts` doesn't have to introduce a fresh `readFileSync` call —
|
|
534
|
-
* the OpenClaw scanner whole-file rule disallows fs.read* next to the
|
|
535
|
-
* outbound-request trigger markers that index.ts already has in its
|
|
536
|
-
* on-chain submission code paths.
|
|
537
|
-
*/
|
|
538
|
-
export function readPluginLoadedManifest(pluginDir) {
|
|
539
|
-
try {
|
|
540
|
-
const root = resolvePluginRootForManifest(pluginDir);
|
|
541
|
-
const loadedPath = path.join(root, PLUGIN_LOADED_MANIFEST);
|
|
542
|
-
if (!fs.existsSync(loadedPath))
|
|
543
|
-
return null;
|
|
544
|
-
const raw = fs.readFileSync(loadedPath, 'utf-8');
|
|
545
|
-
const parsed = JSON.parse(raw);
|
|
546
|
-
if (typeof parsed.loadedAt !== 'number' || !Array.isArray(parsed.tools) || typeof parsed.version !== 'string') {
|
|
547
|
-
return null;
|
|
548
|
-
}
|
|
549
|
-
return parsed;
|
|
550
|
-
}
|
|
551
|
-
catch {
|
|
552
|
-
return null;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
export function writePluginManifest(pluginDir, manifest) {
|
|
556
|
-
try {
|
|
557
|
-
const root = resolvePluginRootForManifest(pluginDir);
|
|
558
|
-
if (!fs.existsSync(root))
|
|
559
|
-
return false;
|
|
560
|
-
const loadedPath = path.join(root, PLUGIN_LOADED_MANIFEST);
|
|
561
|
-
const errorPath = path.join(root, PLUGIN_ERROR_MANIFEST);
|
|
562
|
-
// Best-effort error-file cleanup — a successful boot supersedes any
|
|
563
|
-
// prior failure marker. If the unlink fails (e.g. permission), the
|
|
564
|
-
// .loaded.json timestamp still tells the agent which is current.
|
|
565
|
-
try {
|
|
566
|
-
if (fs.existsSync(errorPath))
|
|
567
|
-
fs.unlinkSync(errorPath);
|
|
568
|
-
}
|
|
569
|
-
catch {
|
|
570
|
-
// Swallow — best-effort.
|
|
571
|
-
}
|
|
572
|
-
// 3.3.7-rc.1 (issue #216) — derive bootCount by reading the prior
|
|
573
|
-
// manifest. Lets the user grep `.loaded.json` after a container
|
|
574
|
-
// restart to verify register() actually ran. If the prior manifest
|
|
575
|
-
// is unreadable we start at 1.
|
|
576
|
-
let priorBootCount = 0;
|
|
577
|
-
try {
|
|
578
|
-
if (fs.existsSync(loadedPath)) {
|
|
579
|
-
const prior = JSON.parse(fs.readFileSync(loadedPath, 'utf-8'));
|
|
580
|
-
if (typeof prior.bootCount === 'number' && Number.isFinite(prior.bootCount)) {
|
|
581
|
-
priorBootCount = prior.bootCount;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
catch {
|
|
586
|
-
// Swallow — if the prior manifest is corrupt we just start the counter fresh.
|
|
587
|
-
}
|
|
588
|
-
const enriched = {
|
|
589
|
-
...manifest,
|
|
590
|
-
bootCount: priorBootCount + 1,
|
|
591
|
-
bootAt: new Date(manifest.loadedAt).toISOString(),
|
|
592
|
-
pid: process.pid,
|
|
593
|
-
};
|
|
594
|
-
fs.writeFileSync(loadedPath, JSON.stringify(enriched, null, 2));
|
|
595
|
-
return true;
|
|
596
|
-
}
|
|
597
|
-
catch {
|
|
598
|
-
return false;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Write the error manifest. SYNCHRONOUS for the same reason as
|
|
603
|
-
* `writePluginManifest`. Called from the try/catch surrounding the
|
|
604
|
-
* register() body so the agent has a filesystem signal that the plugin
|
|
605
|
-
* registered AT LEAST attempted to load and failed in a specific way.
|
|
606
|
-
*
|
|
607
|
-
* Does NOT clear `.loaded.json` from a prior successful boot — keeping
|
|
608
|
-
* the older success marker around lets the agent see "last good boot was
|
|
609
|
-
* X, current boot failed at Y" without spelunking logs. The newer
|
|
610
|
-
* `.error.json` timestamp wins as "current state".
|
|
611
|
-
*/
|
|
612
|
-
export function writePluginError(pluginDir, error) {
|
|
613
|
-
try {
|
|
614
|
-
const root = resolvePluginRootForManifest(pluginDir);
|
|
615
|
-
if (!fs.existsSync(root))
|
|
616
|
-
return false;
|
|
617
|
-
const errorPath = path.join(root, PLUGIN_ERROR_MANIFEST);
|
|
618
|
-
fs.writeFileSync(errorPath, JSON.stringify(error, null, 2));
|
|
619
|
-
return true;
|
|
620
|
-
}
|
|
621
|
-
catch {
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
476
|
+
// The 3.3.2-rc.1 `.loaded.json` / `.error.json` manifest machinery (writer
|
|
477
|
+
// + reader + schema) was fully removed in Phase 3.4. Phase 3.1 already
|
|
478
|
+
// dropped the `writePluginManifest` call from register(); 3.4 retires the
|
|
479
|
+
// remaining reader (`readPluginLoadedManifest`) + the error-path writer
|
|
480
|
+
// (`writePluginError`) + the schema types now that no production path
|
|
481
|
+
// references them. The gateway log is the source of truth for register()
|
|
482
|
+
// failures; `/totalreclaw diag` reports pid + in-memory version only.
|
|
625
483
|
/**
|
|
626
484
|
* Drop the `.tr-partial-install` marker into `pluginRootDir`. Idempotent
|
|
627
485
|
* (overwrites any existing marker) and best-effort — returns `true` on
|
|
@@ -933,14 +791,11 @@ export function resolveOnboardingState(credentialsPath, statePath) {
|
|
|
933
791
|
* Auto-patch `~/.openclaw/openclaw.json` with the entries required by
|
|
934
792
|
* OpenClaw 2026.5.x for clean operation (issues #225 + #226 + verbosity):
|
|
935
793
|
*
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
* crash loop ("plugins.slots.memory: plugin not found: totalreclaw")
|
|
942
|
-
* that survives container restarts until `openclaw plugins install`
|
|
943
|
-
* repopulates the install record.
|
|
794
|
+
* NOTE (rc.20, #402): this helper no longer writes `plugins.slots.memory`
|
|
795
|
+
* (OpenClaw 2026.6.8 claims the memory slot natively on install/enable) nor
|
|
796
|
+
* `plugins.installs` (the former Fix #6 self-heal — its record reader
|
|
797
|
+
* discards the whole installs map if any entry fails schema validation).
|
|
798
|
+
* Pre-existing values of both are left untouched. The remaining fixes are:
|
|
944
799
|
*
|
|
945
800
|
* 2. `plugins.entries.totalreclaw.hooks.allowConversationAccess = true`
|
|
946
801
|
* Grant the plugin access to `agent_end` and `before_agent_start`
|
|
@@ -954,15 +809,11 @@ export function resolveOnboardingState(credentialsPath, statePath) {
|
|
|
954
809
|
* this to "off" on first run for a clean UX. Existing explicit values
|
|
955
810
|
* ("partial", "block", "progress") are preserved.
|
|
956
811
|
*
|
|
957
|
-
* 4
|
|
958
|
-
*
|
|
959
|
-
*
|
|
960
|
-
*
|
|
961
|
-
*
|
|
962
|
-
* `bundledDiscovery: "compat"` restores the looser behavior so allow-
|
|
963
|
-
* listed non-bundled plugins load. Without this fix, users with
|
|
964
|
-
* telegram or any model provider configured before TR install (which
|
|
965
|
-
* populates allow) get a silent plugin-skip on every gateway boot.
|
|
812
|
+
* Fix #4 (`plugins.bundledDiscovery="compat"`) and Fix #5 (appending
|
|
813
|
+
* "totalreclaw" to `plugins.allow`) were RETIRED together in rc.20 (#402):
|
|
814
|
+
* native install manages the allowlist, and TR growing it was the only
|
|
815
|
+
* thing that forced strict-allowlist mode (the sole reason the compat
|
|
816
|
+
* workaround existed). Pre-existing values of both keys are left untouched.
|
|
966
817
|
*
|
|
967
818
|
* Design constraints
|
|
968
819
|
* ------------------
|
|
@@ -984,8 +835,11 @@ export function resolveOnboardingState(credentialsPath, statePath) {
|
|
|
984
835
|
* @param configPath Absolute path to `openclaw.json`.
|
|
985
836
|
* Defaults to `<home>/.openclaw/openclaw.json`.
|
|
986
837
|
*/
|
|
987
|
-
export function patchOpenClawConfig(configPath
|
|
988
|
-
|
|
838
|
+
export function patchOpenClawConfig(configPath,
|
|
839
|
+
// Retained on the signature (register() passes it) but no longer consumed:
|
|
840
|
+
// the Fix #6 install-record self-heal it fed was retired in rc.20 (#402).
|
|
841
|
+
pluginVersion) {
|
|
842
|
+
const home = envHomeDir();
|
|
989
843
|
const target = configPath ?? path.join(home, '.openclaw', 'openclaw.json');
|
|
990
844
|
// `'skipped'` when the config file is absent — this host may not be
|
|
991
845
|
// running OpenClaw, or may use a non-standard config location.
|
|
@@ -1000,50 +854,44 @@ export function patchOpenClawConfig(configPath) {
|
|
|
1000
854
|
cfg.plugins = {};
|
|
1001
855
|
}
|
|
1002
856
|
let mutated = false;
|
|
1003
|
-
// --- Fix #
|
|
1004
|
-
//
|
|
1005
|
-
// DEFENSIVE GATE (3.3.9-rc.4 — 2026-05-05): only write the slot when
|
|
1006
|
-
// the plugin is genuinely INSTALLED (`plugins.installs.totalreclaw`
|
|
1007
|
-
// present with a `version`). Writing the slot unconditionally
|
|
1008
|
-
// produced a startup crash loop on Pedro's pop-os QA host on
|
|
1009
|
-
// 2026-05-05 — after a config reset, `plugins.installs.totalreclaw`
|
|
1010
|
-
// was missing but a previously-written `slots.memory = "totalreclaw"`
|
|
1011
|
-
// had survived. OpenClaw's startup validator refuses to start with
|
|
857
|
+
// --- Fix #6 (installs self-heal) RETIRED in rc.20 (#402) ---
|
|
1012
858
|
//
|
|
1013
|
-
//
|
|
1014
|
-
//
|
|
1015
|
-
//
|
|
859
|
+
// patchOpenClawConfig used to fabricate a `plugins.installs.totalreclaw`
|
|
860
|
+
// record (version/spec/source:"self-heal"/installedAt) whenever a version
|
|
861
|
+
// was passed and no record existed. Removed because it was inert at best
|
|
862
|
+
// and harmful at worst on OpenClaw 2026.6.8:
|
|
863
|
+
// (a) the record reader validates the WHOLE installs map against a
|
|
864
|
+
// schema where `source` must be a valid PluginInstallSource — the
|
|
865
|
+
// fabricated `source:"self-heal"` (and any source-less record) fails
|
|
866
|
+
// safeParse, discarding the ENTIRE installs map at load; and
|
|
867
|
+
// (b) the native installer never persists install records into
|
|
868
|
+
// openclaw.json (it strips them via withoutPluginInstallRecords and
|
|
869
|
+
// commits to the SQLite index, which always wins on merge).
|
|
870
|
+
// So the plugin no longer writes `plugins.installs` at all; a pre-existing
|
|
871
|
+
// record is left byte-identical. `pluginVersion` is retained on the
|
|
872
|
+
// signature (register() passes it) but is no longer consumed here.
|
|
873
|
+
void pluginVersion;
|
|
874
|
+
// --- Fix #5 (plugins.allow self-append) RETIRED in rc.20 (#402) ---
|
|
1016
875
|
//
|
|
1017
|
-
//
|
|
1018
|
-
//
|
|
1019
|
-
// `
|
|
1020
|
-
//
|
|
1021
|
-
//
|
|
1022
|
-
//
|
|
1023
|
-
//
|
|
1024
|
-
//
|
|
876
|
+
// patchOpenClawConfig used to append "totalreclaw" to a non-empty
|
|
877
|
+
// `plugins.allow`. Removed as a pair with Fix #4 (below): OpenClaw's native
|
|
878
|
+
// `persistPluginInstall` already calls `addInstalledPluginToAllowlist`, and
|
|
879
|
+
// an empty/absent allowlist means allow-all (no write needed). TR
|
|
880
|
+
// unconditionally growing an allowlist was the very thing that flipped
|
|
881
|
+
// hosts into strict-allowlist enforcement — which then required the Fix #4
|
|
882
|
+
// `bundledDiscovery:"compat"` workaround. Dropping both lets native install
|
|
883
|
+
// own the allowlist; existing hosts keep whatever is already on disk.
|
|
884
|
+
// --- Fix #1 (memory-slot write) RETIRED in rc.20 (#402) ---
|
|
1025
885
|
//
|
|
1026
|
-
//
|
|
1027
|
-
//
|
|
1028
|
-
//
|
|
1029
|
-
//
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
&& installEntry !== null
|
|
1036
|
-
&& typeof installEntry.version === 'string'
|
|
1037
|
-
&& installEntry.version.length > 0;
|
|
1038
|
-
if (pluginIsInstalled) {
|
|
1039
|
-
if (typeof cfg.plugins.slots !== 'object' || cfg.plugins.slots === null) {
|
|
1040
|
-
cfg.plugins.slots = {};
|
|
1041
|
-
}
|
|
1042
|
-
if (cfg.plugins.slots.memory !== 'totalreclaw') {
|
|
1043
|
-
cfg.plugins.slots.memory = 'totalreclaw';
|
|
1044
|
-
mutated = true;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
886
|
+
// patchOpenClawConfig used to write `plugins.slots.memory = "totalreclaw"`
|
|
887
|
+
// (install-gated, to dodge a startup crash loop). OpenClaw 2026.6.8 now
|
|
888
|
+
// claims the memory slot NATIVELY during `plugins install`/`enable` (its
|
|
889
|
+
// persistPluginInstall "slot selection" phase), so the hand-written write
|
|
890
|
+
// was redundant on the good path and twice failed in production. The
|
|
891
|
+
// plugin no longer touches the memory slot — a pre-existing value is left
|
|
892
|
+
// byte-identical. Fix numbering below is preserved for continuity with the
|
|
893
|
+
// #225/#226 history. The Fix #6 install-record self-heal was retired
|
|
894
|
+
// above too (rc.20, #402).
|
|
1047
895
|
// --- Fix #2: plugins.entries.totalreclaw.hooks.allowConversationAccess = true ---
|
|
1048
896
|
if (typeof cfg.plugins.entries !== 'object' || cfg.plugins.entries === null) {
|
|
1049
897
|
cfg.plugins.entries = {};
|
|
@@ -1086,36 +934,15 @@ export function patchOpenClawConfig(configPath) {
|
|
|
1086
934
|
}
|
|
1087
935
|
}
|
|
1088
936
|
}
|
|
1089
|
-
// --- Fix #4
|
|
1090
|
-
//
|
|
1091
|
-
// OpenClaw 2026.5.x: when `plugins.allow` is populated (any non-empty
|
|
1092
|
-
// array), the gateway's plugin loader switches into strict-allowlist
|
|
1093
|
-
// mode. In strict mode, NON-BUNDLED plugins like totalreclaw are
|
|
1094
|
-
// silently rejected even when listed in `plugins.allow`, unless
|
|
1095
|
-
// `plugins.bundledDiscovery = "compat"` is explicitly set. Pedro's
|
|
1096
|
-
// 2026-05-07 QA on pop-os surfaced this — the gateway booted with only
|
|
1097
|
-
// the bundled providers (telegram, device-pair) and skipped totalreclaw
|
|
1098
|
-
// despite it being in the allow list. `openclaw doctor --fix` cures it
|
|
1099
|
-
// by setting `bundledDiscovery: "compat"`, but users shouldn't need
|
|
1100
|
-
// to run doctor manually for the plugin to load.
|
|
1101
|
-
//
|
|
1102
|
-
// Fix: when `plugins.allow` is a non-empty array AND
|
|
1103
|
-
// `plugins.bundledDiscovery` is unset, set it to "compat". If the user
|
|
1104
|
-
// explicitly chose "allowlist" (the stricter mode), preserve their
|
|
1105
|
-
// choice — only first-run defaults are touched.
|
|
937
|
+
// --- Fix #4 (plugins.bundledDiscovery="compat") RETIRED in rc.20 (#402) ---
|
|
1106
938
|
//
|
|
1107
|
-
//
|
|
1108
|
-
//
|
|
1109
|
-
//
|
|
1110
|
-
//
|
|
1111
|
-
//
|
|
1112
|
-
//
|
|
1113
|
-
|
|
1114
|
-
if (cfg.plugins.bundledDiscovery === undefined) {
|
|
1115
|
-
cfg.plugins.bundledDiscovery = 'compat';
|
|
1116
|
-
mutated = true;
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
939
|
+
// patchOpenClawConfig used to set `plugins.bundledDiscovery = "compat"`
|
|
940
|
+
// whenever `plugins.allow` was populated, to keep non-bundled totalreclaw
|
|
941
|
+
// loadable under strict-allowlist mode. Retired as a pair with Fix #5: the
|
|
942
|
+
// ONLY reason a host was in strict-allowlist mode was that TR itself grew
|
|
943
|
+
// the allowlist (Fix #5). With Fix #5 gone, native install manages the
|
|
944
|
+
// allowlist and this compat workaround is unnecessary. An existing
|
|
945
|
+
// `bundledDiscovery` value on disk is left untouched.
|
|
1119
946
|
if (!mutated)
|
|
1120
947
|
return 'unchanged';
|
|
1121
948
|
// Write back with 2-space indent to match OpenClaw's own write style.
|
|
@@ -1126,3 +953,51 @@ export function patchOpenClawConfig(configPath) {
|
|
|
1126
953
|
return 'error';
|
|
1127
954
|
}
|
|
1128
955
|
}
|
|
956
|
+
const TMPFS_PREFIXES = ['/tmp/', '/dev/shm/', '/run/', '/var/run/'];
|
|
957
|
+
export function checkCredentialsFileMode(credPath, logger) {
|
|
958
|
+
let stat;
|
|
959
|
+
try {
|
|
960
|
+
stat = fs.statSync(credPath);
|
|
961
|
+
}
|
|
962
|
+
catch (err) {
|
|
963
|
+
const code = err.code;
|
|
964
|
+
if (code === 'ENOENT')
|
|
965
|
+
return 'ok';
|
|
966
|
+
logger.warn(`TotalReclaw: could not stat credentials file (${code ?? String(err)}); skipping permission check`);
|
|
967
|
+
return 'stat_error';
|
|
968
|
+
}
|
|
969
|
+
const mode = stat.mode & 0o777;
|
|
970
|
+
if (mode > 0o600) {
|
|
971
|
+
const modeStr = '0' + mode.toString(8);
|
|
972
|
+
logger.error(`TotalReclaw: STARTUP REFUSED — credentials file has insecure permissions (${modeStr}).\n` +
|
|
973
|
+
` File: ${credPath}\n` +
|
|
974
|
+
` Fix: chmod 600 "${credPath}"\n` +
|
|
975
|
+
` Then restart your OpenClaw gateway.\n` +
|
|
976
|
+
` Current mode ${modeStr} allows other OS users to read your recovery phrase.`);
|
|
977
|
+
return 'insecure';
|
|
978
|
+
}
|
|
979
|
+
try {
|
|
980
|
+
const real = fs.realpathSync(credPath);
|
|
981
|
+
for (const prefix of TMPFS_PREFIXES) {
|
|
982
|
+
if (real.startsWith(prefix)) {
|
|
983
|
+
logger.warn(`TotalReclaw: credentials file is on a volatile/shared path (${real}). ` +
|
|
984
|
+
`It may be lost on reboot or be readable by other processes. ` +
|
|
985
|
+
`Consider moving it to a persistent private directory and updating TOTALRECLAW_CREDENTIALS_PATH.`);
|
|
986
|
+
return 'warned';
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
catch {
|
|
991
|
+
// realpathSync can fail on unusual mounts — not actionable here
|
|
992
|
+
}
|
|
993
|
+
return 'ok';
|
|
994
|
+
}
|
|
995
|
+
// ---------------------------------------------------------------------------
|
|
996
|
+
// Pair-pending sentinel — RETIRED Phase 3.4
|
|
997
|
+
// ---------------------------------------------------------------------------
|
|
998
|
+
// The 3.3.13 `~/.totalreclaw/.pair-pending.json` sentinel + its utilities
|
|
999
|
+
// (loadPairPendingFile / writePairPendingFile / deletePairPendingFile /
|
|
1000
|
+
// defaultPairPendingPath / PairPendingFile) were removed in Phase 3.4.
|
|
1001
|
+
// Pairing is now user-initiated QR (`tr pair` CLI / the pair HTTP route)
|
|
1002
|
+
// per the native-integration design — the auto-pair-on-load state machine
|
|
1003
|
+
// that wrote + consumed this sentinel is gone.
|
|
@@ -17,6 +17,20 @@ export class ChatGPTAdapter extends BaseImportAdapter {
|
|
|
17
17
|
else if (input.file_path) {
|
|
18
18
|
try {
|
|
19
19
|
const resolvedPath = input.file_path.replace(/^~/, os.homedir());
|
|
20
|
+
const fileStat = fs.statSync(resolvedPath);
|
|
21
|
+
const fileSizeMB = fileStat.size / (1024 * 1024);
|
|
22
|
+
if (fileSizeMB > 500) {
|
|
23
|
+
errors.push(`File is too large to import: ${fileSizeMB.toFixed(1)}MB exceeds the 500MB cap. ` +
|
|
24
|
+
'Split the file into smaller chunks and import each separately.');
|
|
25
|
+
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
26
|
+
}
|
|
27
|
+
const freeMem = os.freemem();
|
|
28
|
+
if (freeMem < fileStat.size * 2) {
|
|
29
|
+
errors.push(`Not enough free memory: ${(freeMem / (1024 * 1024)).toFixed(0)}MB available, ` +
|
|
30
|
+
`~${Math.ceil(fileStat.size * 2 / (1024 * 1024))}MB needed (2× file size). ` +
|
|
31
|
+
'Close other applications or split the file.');
|
|
32
|
+
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
33
|
+
}
|
|
20
34
|
content = fs.readFileSync(resolvedPath, 'utf-8');
|
|
21
35
|
}
|
|
22
36
|
catch (e) {
|
|
@@ -29,6 +29,20 @@ export class ClaudeAdapter extends BaseImportAdapter {
|
|
|
29
29
|
else if (input.file_path) {
|
|
30
30
|
try {
|
|
31
31
|
const resolvedPath = input.file_path.replace(/^~/, os.homedir());
|
|
32
|
+
const fileStat = fs.statSync(resolvedPath);
|
|
33
|
+
const fileSizeMB = fileStat.size / (1024 * 1024);
|
|
34
|
+
if (fileSizeMB > 500) {
|
|
35
|
+
errors.push(`File is too large to import: ${fileSizeMB.toFixed(1)}MB exceeds the 500MB cap. ` +
|
|
36
|
+
'Split the file into smaller chunks and import each separately.');
|
|
37
|
+
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
38
|
+
}
|
|
39
|
+
const freeMem = os.freemem();
|
|
40
|
+
if (freeMem < fileStat.size * 2) {
|
|
41
|
+
errors.push(`Not enough free memory: ${(freeMem / (1024 * 1024)).toFixed(0)}MB available, ` +
|
|
42
|
+
`~${Math.ceil(fileStat.size * 2 / (1024 * 1024))}MB needed (2× file size). ` +
|
|
43
|
+
'Close other applications or split the file.');
|
|
44
|
+
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
45
|
+
}
|
|
32
46
|
content = fs.readFileSync(resolvedPath, 'utf-8');
|
|
33
47
|
}
|
|
34
48
|
catch (e) {
|