@totalreclaw/mcp-server 3.6.0-rc.2 → 3.6.1-rc.1
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 +1 -1
- package/SKILL.md +1 -1
- package/dist/credential-activation.d.ts +80 -0
- package/dist/credential-activation.d.ts.map +1 -0
- package/dist/credential-activation.js +254 -0
- package/dist/credential-activation.js.map +1 -0
- package/dist/dispatch.d.ts +10 -2
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +17 -4
- package/dist/dispatch.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -48
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +4 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +3 -3
- package/dist/recall-top-k.d.ts +6 -1
- package/dist/recall-top-k.d.ts.map +1 -1
- package/dist/recall-top-k.js +10 -2
- package/dist/recall-top-k.js.map +1 -1
- package/dist/tools/import-from.d.ts.map +1 -1
- package/dist/tools/import-from.js +11 -14
- package/dist/tools/import-from.js.map +1 -1
- package/dist/tools/pair.d.ts +22 -12
- package/dist/tools/pair.d.ts.map +1 -1
- package/dist/tools/pair.js +42 -12
- package/dist/tools/pair.js.map +1 -1
- package/dist/tools/status.d.ts +6 -0
- package/dist/tools/status.d.ts.map +1 -1
- package/dist/tools/status.js +9 -0
- package/dist/tools/status.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ See the [IronClaw setup guide](../docs/guides/ironclaw-setup.md) for the full wa
|
|
|
81
81
|
|
|
82
82
|
### 2. Set up your account in the browser
|
|
83
83
|
|
|
84
|
-
Restart your MCP client, then ask your agent: *"Set up TotalReclaw."* It calls `totalreclaw_pair` and gives you a link and a 6-digit PIN. Open the link in any browser, on this computer or your phone. The page creates your 12-word recovery phrase, or takes the one you already have. Your phrase never goes through the chat and is never written into your MCP config. The link works for about 10 minutes; if it stops working, ask your agent for a new one. When the page says "You're all set",
|
|
84
|
+
Restart your MCP client, then ask your agent: *"Set up TotalReclaw."* It calls `totalreclaw_pair` and gives you a link and a 6-digit PIN. Open the link in any browser, on this computer or your phone. The page creates your 12-word recovery phrase, or takes the one you already have. Your phrase never goes through the chat and is never written into your MCP config. The link works for about 10 minutes; if it stops working, ask your agent for a new one. When the page says "You're all set", TotalReclaw works in the same chat right away; no second restart. (If a memory tool still says it is not set up, fully quit and reopen your MCP client once.) Full walkthrough: [Claude Desktop setup guide](../docs/guides/claude-desktop-setup.md).
|
|
85
85
|
|
|
86
86
|
> **Save your recovery phrase somewhere safe.** It's the only way to recover your encrypted memories.
|
|
87
87
|
|
package/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: totalreclaw
|
|
3
3
|
description: "End-to-end encrypted, decentralized memory for OpenClaw via the totalreclaw MCP server. Set up an account once, then call totalreclaw__totalreclaw_remember and totalreclaw__totalreclaw_recall instead of writing to MEMORY.md / USER.md / local files. Trigger on 'install TotalReclaw', 'set up TotalReclaw', 'restore my recovery phrase', or any user statement that contains a preference / fact / decision / commitment about themselves."
|
|
4
|
-
version: 3.6.
|
|
4
|
+
version: 3.6.1
|
|
5
5
|
author: TotalReclaw Team
|
|
6
6
|
license: MIT
|
|
7
7
|
homepage: https://totalreclaw.xyz
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed-mode credential activation (startup + hot reload).
|
|
3
|
+
*
|
|
4
|
+
* Until 3.6.1 the MCP server read credentials.json once, in `main()`, so a
|
|
5
|
+
* pairing that finished while the host app was running left every memory tool
|
|
6
|
+
* returning `not_configured` until the user quit and reopened the app. This
|
|
7
|
+
* module holds the one activation routine both paths now share:
|
|
8
|
+
*
|
|
9
|
+
* - `activate('startup')`: what `main()` always did. A credential that fails
|
|
10
|
+
* validation is FATAL (the error is rethrown, the process exits loudly).
|
|
11
|
+
* - Trigger A, `reloadAfterPair()`: `totalreclaw_pair` wrote the file in this
|
|
12
|
+
* process. Re-resolves from disk and, on a confirmed replace, swaps the
|
|
13
|
+
* running server to the new account.
|
|
14
|
+
* - Trigger B, `tryReload()`: called by the dispatcher on a tool call while
|
|
15
|
+
* the server is unconfigured. One `statSync`; activates only when the file
|
|
16
|
+
* appeared or changed since the last attempt (another process, e.g. Claude
|
|
17
|
+
* Code or Hermes, paired). Never swaps a configured server.
|
|
18
|
+
*
|
|
19
|
+
* Phrase safety: nothing here receives, holds or logs a recovery phrase. The
|
|
20
|
+
* credential is always re-read from disk through `resolveCredential`, the same
|
|
21
|
+
* validated path as startup. Log lines carry only the Smart Account address
|
|
22
|
+
* (already logged at startup) and fixed text; error text from a failed
|
|
23
|
+
* validation goes to stderr exactly as it did at startup and never into a tool
|
|
24
|
+
* response.
|
|
25
|
+
*
|
|
26
|
+
* Self-hosted mode is out of scope: every reload entry point is a no-op there.
|
|
27
|
+
*/
|
|
28
|
+
import { type ResolvedCredential } from './subgraph/credentials.js';
|
|
29
|
+
import type { UnusableCredentials } from './dispatch.js';
|
|
30
|
+
export type ActivationPhase = 'startup' | 'reload';
|
|
31
|
+
export interface ActivatorDeps<S> {
|
|
32
|
+
/** credentials.json path; only `stat`ed here (to detect a change). */
|
|
33
|
+
credentialsPath: string;
|
|
34
|
+
/** TOTALRECLAW_SELF_HOSTED=true: reload is a no-op. */
|
|
35
|
+
isSelfHosted: () => boolean;
|
|
36
|
+
/** `resolveManagedCredential()` — the existing validated reader. */
|
|
37
|
+
resolveCredential: () => ResolvedCredential | undefined;
|
|
38
|
+
initFromBundle: (bundle: Extract<ResolvedCredential, {
|
|
39
|
+
kind: 'bundle';
|
|
40
|
+
}>['bundle']) => Promise<S>;
|
|
41
|
+
initFromMnemonic: (mnemonic: string) => Promise<S>;
|
|
42
|
+
/** True when a resolved mnemonic is valid for managed mode (`detectServerMode`). */
|
|
43
|
+
isUsableMnemonic: (mnemonic: string) => boolean;
|
|
44
|
+
/** Smart Account address of a state, for log lines. */
|
|
45
|
+
ownerAddress: (state: S) => string;
|
|
46
|
+
getState: () => S | null;
|
|
47
|
+
/**
|
|
48
|
+
* Install the result. `next === null` means unconfigured. `hadState` says a
|
|
49
|
+
* configured state was running before, so the caller must reset every
|
|
50
|
+
* per-account module value (the account may be changing).
|
|
51
|
+
*/
|
|
52
|
+
commit: (next: S | null, info: {
|
|
53
|
+
phase: ActivationPhase;
|
|
54
|
+
hadState: boolean;
|
|
55
|
+
}) => void;
|
|
56
|
+
getUnusable: () => UnusableCredentials | undefined;
|
|
57
|
+
setUnusable: (u: UnusableCredentials | undefined) => void;
|
|
58
|
+
/** stderr logger (default `console.error`). */
|
|
59
|
+
log?: (msg: string) => void;
|
|
60
|
+
/** Clock in ms (default `Date.now`); injected by tests. */
|
|
61
|
+
now?: () => number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* After an `activation_failed` (init threw, e.g. the relay is down), Trigger B
|
|
65
|
+
* retries at most once per this interval. Each attempt can take many seconds
|
|
66
|
+
* (billing lookup retries + register), so retrying on every tool call would
|
|
67
|
+
* stall every call during an outage. A changed file (new signature) and a
|
|
68
|
+
* finished pairing (Trigger A) run at once, regardless.
|
|
69
|
+
*/
|
|
70
|
+
export declare const ACTIVATION_RETRY_COOLDOWN_MS = 10000;
|
|
71
|
+
export interface CredentialActivator {
|
|
72
|
+
/** Startup activation; rethrows a fatal credential error. */
|
|
73
|
+
activate(phase: 'startup'): Promise<void>;
|
|
74
|
+
/** Trigger A. Never throws. */
|
|
75
|
+
reloadAfterPair(): Promise<void>;
|
|
76
|
+
/** Trigger B. Never throws. Resolves when no activation is running. */
|
|
77
|
+
tryReload(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
export declare function createCredentialActivator<S>(deps: ActivatorDeps<S>): CredentialActivator;
|
|
80
|
+
//# sourceMappingURL=credential-activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-activation.d.ts","sourceRoot":"","sources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,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,+BAA+B;IAC/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,uEAAuE;IACvE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAwBD,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAmKxF"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Managed-mode credential activation (startup + hot reload).
|
|
4
|
+
*
|
|
5
|
+
* Until 3.6.1 the MCP server read credentials.json once, in `main()`, so a
|
|
6
|
+
* pairing that finished while the host app was running left every memory tool
|
|
7
|
+
* returning `not_configured` until the user quit and reopened the app. This
|
|
8
|
+
* module holds the one activation routine both paths now share:
|
|
9
|
+
*
|
|
10
|
+
* - `activate('startup')`: what `main()` always did. A credential that fails
|
|
11
|
+
* validation is FATAL (the error is rethrown, the process exits loudly).
|
|
12
|
+
* - Trigger A, `reloadAfterPair()`: `totalreclaw_pair` wrote the file in this
|
|
13
|
+
* process. Re-resolves from disk and, on a confirmed replace, swaps the
|
|
14
|
+
* running server to the new account.
|
|
15
|
+
* - Trigger B, `tryReload()`: called by the dispatcher on a tool call while
|
|
16
|
+
* the server is unconfigured. One `statSync`; activates only when the file
|
|
17
|
+
* appeared or changed since the last attempt (another process, e.g. Claude
|
|
18
|
+
* Code or Hermes, paired). Never swaps a configured server.
|
|
19
|
+
*
|
|
20
|
+
* Phrase safety: nothing here receives, holds or logs a recovery phrase. The
|
|
21
|
+
* credential is always re-read from disk through `resolveCredential`, the same
|
|
22
|
+
* validated path as startup. Log lines carry only the Smart Account address
|
|
23
|
+
* (already logged at startup) and fixed text; error text from a failed
|
|
24
|
+
* validation goes to stderr exactly as it did at startup and never into a tool
|
|
25
|
+
* response.
|
|
26
|
+
*
|
|
27
|
+
* Self-hosted mode is out of scope: every reload entry point is a no-op there.
|
|
28
|
+
*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
+
}) : function(o, v) {
|
|
43
|
+
o["default"] = v;
|
|
44
|
+
});
|
|
45
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
46
|
+
var ownKeys = function(o) {
|
|
47
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48
|
+
var ar = [];
|
|
49
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
58
|
+
__setModuleDefault(result, mod);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.ACTIVATION_RETRY_COOLDOWN_MS = void 0;
|
|
64
|
+
exports.createCredentialActivator = createCredentialActivator;
|
|
65
|
+
const fs = __importStar(require("node:fs"));
|
|
66
|
+
const credentials_js_1 = require("./subgraph/credentials.js");
|
|
67
|
+
/**
|
|
68
|
+
* After an `activation_failed` (init threw, e.g. the relay is down), Trigger B
|
|
69
|
+
* retries at most once per this interval. Each attempt can take many seconds
|
|
70
|
+
* (billing lookup retries + register), so retrying on every tool call would
|
|
71
|
+
* stall every call during an outage. A changed file (new signature) and a
|
|
72
|
+
* finished pairing (Trigger A) run at once, regardless.
|
|
73
|
+
*/
|
|
74
|
+
exports.ACTIVATION_RETRY_COOLDOWN_MS = 10_000;
|
|
75
|
+
const INVALID_CREDENTIALS_MESSAGE = 'The credentials file at ~/.totalreclaw/credentials.json could not be validated, so TotalReclaw ' +
|
|
76
|
+
'did not load it (the reason is in the MCP server log). Nothing from the file is used and the ' +
|
|
77
|
+
'file is untouched. Fixing or restoring the file, then calling any TotalReclaw tool again, ' +
|
|
78
|
+
'retries; so does restarting the app.';
|
|
79
|
+
const ACTIVATION_FAILED_MESSAGE = 'TotalReclaw found a credentials file but could not start with it just now (the reason is in the ' +
|
|
80
|
+
'MCP server log). Nothing is stored or read until it works. Calling any TotalReclaw tool again ' +
|
|
81
|
+
'after about 10 seconds retries; so does restarting the app.';
|
|
82
|
+
function fileSignature(credentialsPath) {
|
|
83
|
+
try {
|
|
84
|
+
const st = fs.statSync(credentialsPath);
|
|
85
|
+
return `${st.mtimeMs}:${st.size}`;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return 'absent';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function createCredentialActivator(deps) {
|
|
92
|
+
const log = deps.log ?? ((m) => console.error(m));
|
|
93
|
+
const now = deps.now ?? (() => Date.now());
|
|
94
|
+
/** Signature of credentials.json at the start of the last attempt. */
|
|
95
|
+
let lastSignature;
|
|
96
|
+
/** Time of the last `activation_failed` attempt; cleared on any other outcome. */
|
|
97
|
+
let lastFailureAt;
|
|
98
|
+
let inFlight = null;
|
|
99
|
+
let rerunRequested = false;
|
|
100
|
+
async function activateOnce(phase) {
|
|
101
|
+
const hadState = deps.getState() !== null;
|
|
102
|
+
// Taken BEFORE reading, so a write that lands mid-activation is seen as a
|
|
103
|
+
// change on the next call instead of being masked.
|
|
104
|
+
lastSignature = fileSignature(deps.credentialsPath);
|
|
105
|
+
lastFailureAt = undefined;
|
|
106
|
+
const drop = () => {
|
|
107
|
+
// A replace that cannot be activated must not leave the old account
|
|
108
|
+
// running while credentials.json (shared with other clients) says
|
|
109
|
+
// another one. Go unconfigured; a restart is the recovery.
|
|
110
|
+
if (hadState)
|
|
111
|
+
deps.commit(null, { phase, hadState });
|
|
112
|
+
};
|
|
113
|
+
let credential;
|
|
114
|
+
try {
|
|
115
|
+
credential = deps.resolveCredential();
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (err instanceof credentials_js_1.UnsupportedCredentialsError) {
|
|
119
|
+
// Not evidence of tampering: a credential from another client or a
|
|
120
|
+
// newer version. Unconfigured, reason on every tool call. Nothing in
|
|
121
|
+
// the file is used.
|
|
122
|
+
deps.setUnusable({ reason: err.reason, message: err.message });
|
|
123
|
+
drop();
|
|
124
|
+
log(phase === 'startup'
|
|
125
|
+
? `TotalReclaw MCP server started (unconfigured): ${err.message}`
|
|
126
|
+
: `TotalReclaw MCP: credentials reload: unconfigured: ${err.message}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
130
|
+
if (phase === 'startup') {
|
|
131
|
+
// Loud, actionable, FATAL — never a silent downgrade (see
|
|
132
|
+
// derived-bundle-v1.md §3.2). Behaviour unchanged from 3.6.0.
|
|
133
|
+
log(`TotalReclaw MCP: fatal credential error: ${msg}`);
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
// Mid-session: do not crash the process, do not use anything from the
|
|
137
|
+
// file, do not fall back to another source. Say why on every tool call.
|
|
138
|
+
deps.setUnusable({ reason: 'invalid_credentials', message: INVALID_CREDENTIALS_MESSAGE });
|
|
139
|
+
drop();
|
|
140
|
+
log(`TotalReclaw MCP: credentials reload failed validation, staying unconfigured: ${msg}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
let next = null;
|
|
145
|
+
let how = '';
|
|
146
|
+
if (credential?.kind === 'bundle') {
|
|
147
|
+
next = await deps.initFromBundle(credential.bundle);
|
|
148
|
+
how = 'managed service, bundle-mode';
|
|
149
|
+
}
|
|
150
|
+
else if (credential?.kind === 'mnemonic' && deps.isUsableMnemonic(credential.mnemonic)) {
|
|
151
|
+
next = await deps.initFromMnemonic(credential.mnemonic);
|
|
152
|
+
how = 'managed service';
|
|
153
|
+
}
|
|
154
|
+
if (next) {
|
|
155
|
+
deps.setUnusable(undefined);
|
|
156
|
+
deps.commit(next, { phase, hadState });
|
|
157
|
+
log(phase === 'startup'
|
|
158
|
+
? `TotalReclaw MCP server started (${how}, owner: ${deps.ownerAddress(next)})`
|
|
159
|
+
: `TotalReclaw MCP: credentials loaded without a restart (${how}, owner: ${deps.ownerAddress(next)})`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// Nothing usable. Keep a previously recorded unusable reason only at
|
|
163
|
+
// startup (where it was just set above); on reload the file changed, so
|
|
164
|
+
// the old reason no longer applies.
|
|
165
|
+
deps.setUnusable(undefined);
|
|
166
|
+
drop();
|
|
167
|
+
if (phase === 'startup') {
|
|
168
|
+
log('TotalReclaw MCP server started (unconfigured — ask the assistant to run totalreclaw_pair to set up an account)');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (phase === 'startup')
|
|
173
|
+
throw err;
|
|
174
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
175
|
+
deps.setUnusable({ reason: 'activation_failed', message: ACTIVATION_FAILED_MESSAGE });
|
|
176
|
+
drop();
|
|
177
|
+
// Possibly transient (network): Trigger B retries after the cooldown.
|
|
178
|
+
lastFailureAt = now();
|
|
179
|
+
log(`TotalReclaw MCP: credentials reload could not start the account, staying unconfigured: ${msg}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Single flight. `force` (Trigger A) re-runs once if a run is already going. */
|
|
183
|
+
function run(phase, force) {
|
|
184
|
+
if (inFlight) {
|
|
185
|
+
if (force)
|
|
186
|
+
rerunRequested = true;
|
|
187
|
+
return inFlight;
|
|
188
|
+
}
|
|
189
|
+
const p = (async () => {
|
|
190
|
+
try {
|
|
191
|
+
do {
|
|
192
|
+
rerunRequested = false;
|
|
193
|
+
await activateOnce(phase);
|
|
194
|
+
} while (rerunRequested);
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
inFlight = null;
|
|
198
|
+
}
|
|
199
|
+
})();
|
|
200
|
+
inFlight = p;
|
|
201
|
+
return p;
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
activate(phase) {
|
|
205
|
+
return run(phase, false);
|
|
206
|
+
},
|
|
207
|
+
async reloadAfterPair() {
|
|
208
|
+
if (deps.isSelfHosted())
|
|
209
|
+
return;
|
|
210
|
+
try {
|
|
211
|
+
await run('reload', true);
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
log(`TotalReclaw MCP: credentials reload failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
async tryReload() {
|
|
218
|
+
if (deps.isSelfHosted())
|
|
219
|
+
return;
|
|
220
|
+
if (inFlight) {
|
|
221
|
+
try {
|
|
222
|
+
await inFlight;
|
|
223
|
+
}
|
|
224
|
+
catch { /* reported by the run itself */ }
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// Trigger B never swaps a configured server.
|
|
228
|
+
if (deps.getState() !== null)
|
|
229
|
+
return;
|
|
230
|
+
const sig = fileSignature(deps.credentialsPath);
|
|
231
|
+
if (sig === 'absent') {
|
|
232
|
+
// The file is gone: a stored reason or failure no longer applies.
|
|
233
|
+
// Report plain not_configured.
|
|
234
|
+
if (deps.getUnusable())
|
|
235
|
+
deps.setUnusable(undefined);
|
|
236
|
+
lastFailureAt = undefined;
|
|
237
|
+
lastSignature = sig;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (sig === lastSignature) {
|
|
241
|
+
const cooledDown = lastFailureAt !== undefined && now() - lastFailureAt >= exports.ACTIVATION_RETRY_COOLDOWN_MS;
|
|
242
|
+
if (!cooledDown)
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
await run('reload', false);
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
log(`TotalReclaw MCP: credentials reload failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=credential-activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-activation.js","sourceRoot":"","sources":["../src/credential-activation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EH,8DAmKC;AA9OD,4CAA8B;AAE9B,8DAAiG;AAiCjG;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,MAAM,CAAC;AAWnD,MAAM,2BAA2B,GAC/B,iGAAiG;IACjG,+FAA+F;IAC/F,4FAA4F;IAC5F,sCAAsC,CAAC;AAEzC,MAAM,yBAAyB,GAC7B,kGAAkG;IAClG,gGAAgG;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AQ,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,gCAAgC,CAAC,CAAC;gBAClE,OAAO;YACT,CAAC;YACD,6CAA6C;YAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI;gBAAE,OAAO;YACrC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAChD,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACrB,kEAAkE;gBAClE,+BAA+B;gBAC/B,IAAI,IAAI,CAAC,WAAW,EAAE;oBAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBACpD,aAAa,GAAG,SAAS,CAAC;gBAC1B,aAAa,GAAG,GAAG,CAAC;gBACpB,OAAO;YACT,CAAC;YACD,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;gBAC1B,MAAM,UAAU,GACd,aAAa,KAAK,SAAS,IAAI,GAAG,EAAE,GAAG,aAAa,IAAI,oCAA4B,CAAC;gBACvF,IAAI,CAAC,UAAU;oBAAE,OAAO;YAC1B,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,CAAC,+CAA+C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACzG,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* 1. `totalreclaw_setup` → removed-tool envelope (phrase-safety, 3.2.1).
|
|
19
19
|
* 2. `totalreclaw_support` → available in every mode (incl. unconfigured).
|
|
20
20
|
* 3. `totalreclaw_pair` → available in every mode (incl. unconfigured).
|
|
21
|
-
* 4. unconfigured mode →
|
|
21
|
+
* 4. unconfigured mode → (3.6.1: try a credentials hot-load first) not-configured
|
|
22
|
+
* envelope for everything else.
|
|
22
23
|
* 5. resolve the mode bundle, look up the handler, apply the policy, and
|
|
23
24
|
* wrap the whole thing in the shared quota → auth → generic error funnel.
|
|
24
25
|
*/
|
|
@@ -84,6 +85,13 @@ export interface DispatchDeps {
|
|
|
84
85
|
* instead of the generic setup guidance.
|
|
85
86
|
*/
|
|
86
87
|
getUnusableCredentials?: () => UnusableCredentials | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Trigger B of the credential hot-load (3.6.1): called on a tool call while
|
|
90
|
+
* unconfigured, before the not-configured envelope. Picks up a credentials
|
|
91
|
+
* file written by another process (or one that changed since startup)
|
|
92
|
+
* without a host restart. A no-op in self-hosted mode; never throws.
|
|
93
|
+
*/
|
|
94
|
+
tryReload?: () => Promise<void>;
|
|
87
95
|
}
|
|
88
96
|
/** Response for the removed `totalreclaw_setup` tool (phrase-safety, 3.2.1). */
|
|
89
97
|
export declare function setupRemovedResponse(): ToolResponse;
|
|
@@ -93,7 +101,7 @@ export declare function setupRemovedResponse(): ToolResponse;
|
|
|
93
101
|
* read (see `UnsupportedCredentialsError` in `subgraph/credentials.ts`).
|
|
94
102
|
*/
|
|
95
103
|
export interface UnusableCredentials {
|
|
96
|
-
reason: 'keychain_wrapped' | 'unknown_version';
|
|
104
|
+
reason: 'keychain_wrapped' | 'unknown_version' | 'invalid_credentials' | 'activation_failed';
|
|
97
105
|
message: string;
|
|
98
106
|
}
|
|
99
107
|
/** Response when a tool is called before the server is configured. */
|
package/dist/dispatch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KA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O,CAAC;IACzC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IACrC,yEAAyE;IACzE,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,mBAAmB,GAAG,SAAS,CAAC;IAC/D;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,IAAI,YAAY,CAenD;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;IAC7F,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,QAAQ,CAAC,EAAE,mBAAmB,GAAG,YAAY,CA+BlF;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAK9D;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAQjE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,YAAY,GACjB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAyDxD"}
|
package/dist/dispatch.js
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* 1. `totalreclaw_setup` → removed-tool envelope (phrase-safety, 3.2.1).
|
|
20
20
|
* 2. `totalreclaw_support` → available in every mode (incl. unconfigured).
|
|
21
21
|
* 3. `totalreclaw_pair` → available in every mode (incl. unconfigured).
|
|
22
|
-
* 4. unconfigured mode →
|
|
22
|
+
* 4. unconfigured mode → (3.6.1: try a credentials hot-load first) not-configured
|
|
23
|
+
* envelope for everything else.
|
|
23
24
|
* 5. resolve the mode bundle, look up the handler, apply the policy, and
|
|
24
25
|
* wrap the whole thing in the shared quota → auth → generic error funnel.
|
|
25
26
|
*/
|
|
@@ -119,8 +120,9 @@ function notConfiguredResponse(unusable) {
|
|
|
119
120
|
error: 'not_configured',
|
|
120
121
|
message: 'TotalReclaw is not set up yet. Call totalreclaw_pair now: it returns a link and a PIN. ' +
|
|
121
122
|
'Give both to the user; they open the link in a browser and create or enter their recovery ' +
|
|
122
|
-
'phrase there, never in chat. When the page says
|
|
123
|
-
'
|
|
123
|
+
'phrase there, never in chat. When the page says "You\'re all set", try the memory tool again: ' +
|
|
124
|
+
'it works in this chat without a restart. Only if it still returns not_configured, ask ' +
|
|
125
|
+
'the user to fully quit and reopen this app.',
|
|
124
126
|
}),
|
|
125
127
|
}],
|
|
126
128
|
isError: true,
|
|
@@ -159,7 +161,18 @@ function createCallToolHandler(deps) {
|
|
|
159
161
|
if (name === 'totalreclaw_pair')
|
|
160
162
|
return deps.handlePair(args);
|
|
161
163
|
// 4. Unconfigured: everything else returns setup guidance.
|
|
162
|
-
|
|
164
|
+
let mode = deps.getMode();
|
|
165
|
+
if (mode === 'unconfigured' && deps.tryReload) {
|
|
166
|
+
// The credentials may have been written since startup (e.g. by another
|
|
167
|
+
// client). One stat; activates only if the file changed.
|
|
168
|
+
try {
|
|
169
|
+
await deps.tryReload();
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// Reported by the reload itself; fall through to the envelope.
|
|
173
|
+
}
|
|
174
|
+
mode = deps.getMode();
|
|
175
|
+
}
|
|
163
176
|
if (mode === 'unconfigured')
|
|
164
177
|
return notConfiguredResponse(deps.getUnusableCredentials?.());
|
|
165
178
|
// 5. Configured dispatch, wrapped in the shared quota → auth → generic funnel.
|
package/dist/dispatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispat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AO,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC1E,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5D,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAyLA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,CAAC"}
|