@totalreclaw/totalreclaw 3.3.12-rc.9 → 3.3.12
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/SKILL.md +33 -27
- package/api-client.ts +17 -9
- package/batch-gate.ts +42 -0
- package/billing-cache.ts +72 -23
- package/claims-helper.ts +2 -1
- package/config.ts +95 -13
- 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 +54 -24
- package/dist/claims-helper.js +2 -1
- package/dist/config.js +91 -13
- 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/fs-helpers.js +75 -379
- package/dist/import-adapters/gemini-adapter.js +29 -159
- package/dist/index.js +864 -2631
- package/dist/memory-runtime.js +459 -0
- package/dist/native-memory.js +123 -0
- package/dist/onboarding-cli.js +4 -8
- package/dist/pair-cli-relay.js +1 -8
- 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 +348 -290
- package/dist/tool-gating.js +39 -26
- package/dist/tools.js +367 -0
- package/dist/tr-cli-export-helper.js +3 -3
- package/dist/tr-cli.js +65 -156
- 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/fs-helpers.ts +93 -458
- package/import-adapters/gemini-adapter.ts +38 -183
- package/index.ts +912 -2917
- package/memory-runtime.ts +723 -0
- package/native-memory.ts +196 -0
- package/onboarding-cli.ts +3 -9
- package/openclaw.plugin.json +5 -17
- package/package.json +6 -3
- package/pair-cli-relay.ts +0 -9
- 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 +367 -307
- package/tool-gating.ts +39 -26
- package/tools.ts +499 -0
- package/tr-cli-export-helper.ts +3 -3
- package/tr-cli.ts +69 -182
- package/trajectory-poller.ts +162 -10
- package/vault-crypto.ts +705 -0
- package/auto-pair-on-load.ts +0 -308
- package/dist/auto-pair-on-load.js +0 -197
- package/dist/pair-pending-injection.js +0 -125
- package/pair-pending-injection.ts +0 -205
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
import { BaseImportAdapter } from './base-adapter.js';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
function parseTimestamp(raw) {
|
|
18
|
-
const m = raw.match(/^(\d{1,2})\s+(\w{3})\s+(\d{4}),\s+(\d{2}):(\d{2}):(\d{2})\s+/);
|
|
19
|
-
if (!m || MONTHS[m[2]] === undefined)
|
|
20
|
-
return undefined;
|
|
21
|
-
const d = new Date(Date.UTC(+m[3], MONTHS[m[2]], +m[1], +m[4], +m[5], +m[6]));
|
|
22
|
-
return d.toISOString();
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
// All Gemini format parsing (MyActivity.json, legacy HTML, Saved-info paste)
|
|
6
|
+
// lives in the shared Rust core (`@totalreclaw/core` WASM) so the logic —
|
|
7
|
+
// including the locale-robust, lossless timestamp handling — is identical across
|
|
8
|
+
// every client (Python/Hermes via PyO3, TS via WASM). This adapter is a thin
|
|
9
|
+
// shim: it owns only file I/O + the size/RAM preflight, then delegates parsing.
|
|
10
|
+
const requireWasm = createRequire(import.meta.url);
|
|
11
|
+
let _wasm = null;
|
|
12
|
+
function getWasm() {
|
|
13
|
+
if (!_wasm)
|
|
14
|
+
_wasm = requireWasm('@totalreclaw/core');
|
|
15
|
+
return _wasm;
|
|
23
16
|
}
|
|
24
|
-
// ── HTML Helpers ─────────────────────────────────────────────────────────────
|
|
25
|
-
function decodeEntities(t) {
|
|
26
|
-
return t.replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&')
|
|
27
|
-
.replace(/</g, '<').replace(/>/g, '>').replace(/ /g, ' ');
|
|
28
|
-
}
|
|
29
|
-
function stripHTML(html) {
|
|
30
|
-
return html.replace(/<br\s*\/?>/gi, '\n').replace(/<\/p>/gi, '\n')
|
|
31
|
-
.replace(/<\/li>/gi, '\n').replace(/<\/h[1-6]>/gi, '\n')
|
|
32
|
-
.replace(/<hr\s*\/?>/gi, '\n---\n').replace(/<[^>]+>/g, '')
|
|
33
|
-
.replace(/\n{3,}/g, '\n\n').trim();
|
|
34
|
-
}
|
|
35
|
-
// ── Gemini Adapter ───────────────────────────────────────────────────────────
|
|
36
17
|
export class GeminiAdapter extends BaseImportAdapter {
|
|
37
18
|
source = 'gemini';
|
|
38
19
|
displayName = 'Google Gemini';
|
|
@@ -69,147 +50,36 @@ export class GeminiAdapter extends BaseImportAdapter {
|
|
|
69
50
|
}
|
|
70
51
|
else {
|
|
71
52
|
errors.push('Gemini import requires either content or file_path. ' +
|
|
72
|
-
'Export from Google Takeout: takeout.google.com →
|
|
73
|
-
'Provide the "My Activity.html" file path.');
|
|
53
|
+
'Export from Google Takeout: takeout.google.com → "My Activity" → "Gemini Apps". ' +
|
|
54
|
+
'Provide the "My Activity.html" (or MyActivity.json) file path, or paste your Saved info.');
|
|
74
55
|
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
75
56
|
}
|
|
76
57
|
if (onProgress) {
|
|
77
|
-
onProgress({ current: 0, total: 0, phase: 'parsing', message: 'Parsing Gemini
|
|
78
|
-
}
|
|
79
|
-
// Parse HTML into entries
|
|
80
|
-
const entries = this.parseHTML(content);
|
|
81
|
-
if (entries.length === 0) {
|
|
82
|
-
warnings.push('No conversation entries found in the HTML file.');
|
|
83
|
-
return { facts: [], chunks: [], totalMessages: 0, warnings, errors };
|
|
58
|
+
onProgress({ current: 0, total: 0, phase: 'parsing', message: 'Parsing Gemini export...' });
|
|
84
59
|
}
|
|
85
|
-
//
|
|
86
|
-
const
|
|
60
|
+
// Delegate ALL format parsing to the shared core.
|
|
61
|
+
const result = getWasm().parseGemini(content);
|
|
87
62
|
if (onProgress) {
|
|
88
63
|
onProgress({
|
|
89
|
-
current:
|
|
90
|
-
total:
|
|
64
|
+
current: result.chunks.length,
|
|
65
|
+
total: result.chunks.length,
|
|
91
66
|
phase: 'parsing',
|
|
92
|
-
message: `Parsed ${
|
|
67
|
+
message: `Parsed ${result.total_messages} messages into ${result.chunks.length} chunks`,
|
|
93
68
|
});
|
|
94
69
|
}
|
|
95
|
-
// Build conversation chunks from sessions
|
|
96
|
-
const chunks = [];
|
|
97
|
-
let totalMessages = 0;
|
|
98
|
-
for (const session of sessions) {
|
|
99
|
-
const messages = [];
|
|
100
|
-
for (const entry of session) {
|
|
101
|
-
if (entry.userPrompt)
|
|
102
|
-
messages.push({ role: 'user', text: entry.userPrompt });
|
|
103
|
-
if (entry.aiResponse)
|
|
104
|
-
messages.push({ role: 'assistant', text: entry.aiResponse });
|
|
105
|
-
}
|
|
106
|
-
if (messages.length === 0)
|
|
107
|
-
continue;
|
|
108
|
-
totalMessages += messages.length;
|
|
109
|
-
const timestamp = session[0].timestampISO;
|
|
110
|
-
// Sub-chunk large sessions
|
|
111
|
-
for (let i = 0; i < messages.length; i += CHUNK_SIZE) {
|
|
112
|
-
const batch = messages.slice(i, i + CHUNK_SIZE);
|
|
113
|
-
const chunkIdx = Math.floor(i / CHUNK_SIZE) + 1;
|
|
114
|
-
const totalChunks = Math.ceil(messages.length / CHUNK_SIZE);
|
|
115
|
-
const title = totalChunks > 1
|
|
116
|
-
? `Gemini session (part ${chunkIdx}/${totalChunks})`
|
|
117
|
-
: 'Gemini session';
|
|
118
|
-
chunks.push({ title, messages: batch, timestamp });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
70
|
return {
|
|
122
71
|
facts: [],
|
|
123
|
-
chunks,
|
|
124
|
-
totalMessages,
|
|
125
|
-
warnings,
|
|
126
|
-
errors,
|
|
72
|
+
chunks: result.chunks,
|
|
73
|
+
totalMessages: result.total_messages,
|
|
74
|
+
warnings: [...warnings, ...result.warnings],
|
|
75
|
+
errors: [...errors, ...result.errors],
|
|
127
76
|
source_metadata: {
|
|
128
|
-
format:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
date_range: {
|
|
134
|
-
earliest: entries[0]?.timestampISO,
|
|
135
|
-
latest: entries[entries.length - 1]?.timestampISO,
|
|
136
|
-
},
|
|
77
|
+
format: result.format,
|
|
78
|
+
chunks_count: result.chunks.length,
|
|
79
|
+
total_messages: result.total_messages,
|
|
80
|
+
...(result.records_count ? { records_count: result.records_count } : {}),
|
|
81
|
+
...(result.skipped ? { skipped_non_gemini: result.skipped } : {}),
|
|
137
82
|
},
|
|
138
83
|
};
|
|
139
84
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Parse Gemini Takeout HTML into structured entries.
|
|
142
|
-
*
|
|
143
|
-
* Each outer-cell div contains: "Prompted USER_TEXT<br>TIMESTAMP<br>RESPONSE_HTML"
|
|
144
|
-
* all within one content-cell.
|
|
145
|
-
*/
|
|
146
|
-
parseHTML(html) {
|
|
147
|
-
const entries = [];
|
|
148
|
-
const cellPattern = /<div class="outer-cell[^"]*">([\s\S]*?)(?=<div class="outer-cell|$)/g;
|
|
149
|
-
let match;
|
|
150
|
-
while ((match = cellPattern.exec(html)) !== null) {
|
|
151
|
-
const cell = match[1];
|
|
152
|
-
// Only process "Prompted" entries (skip canvas, feedback)
|
|
153
|
-
const promptedIdx = cell.indexOf('Prompted\u00a0');
|
|
154
|
-
if (promptedIdx === -1)
|
|
155
|
-
continue;
|
|
156
|
-
// Extract timestamp
|
|
157
|
-
const tsMatch = cell.match(/(\d{1,2}\s+\w{3}\s+\d{4},\s+\d{2}:\d{2}:\d{2}\s+\w+)/);
|
|
158
|
-
if (!tsMatch)
|
|
159
|
-
continue;
|
|
160
|
-
const timestampISO = parseTimestamp(tsMatch[1]);
|
|
161
|
-
if (!timestampISO)
|
|
162
|
-
continue;
|
|
163
|
-
// Split on timestamp to separate user prompt from AI response
|
|
164
|
-
const afterPrompted = cell.substring(promptedIdx + 'Prompted\u00a0'.length);
|
|
165
|
-
const tsPattern = /(\d{1,2}\s+\w{3}\s+\d{4},\s+\d{2}:\d{2}:\d{2}\s+\w+)/;
|
|
166
|
-
const tsIdx = afterPrompted.search(tsPattern);
|
|
167
|
-
let userPrompt = '';
|
|
168
|
-
let aiResponse = '';
|
|
169
|
-
if (tsIdx > 0) {
|
|
170
|
-
userPrompt = stripHTML(decodeEntities(afterPrompted.substring(0, tsIdx))).trim();
|
|
171
|
-
const tsInner = afterPrompted.match(tsPattern);
|
|
172
|
-
if (tsInner) {
|
|
173
|
-
const afterTs = afterPrompted.substring(tsIdx + tsInner[0].length)
|
|
174
|
-
.replace(/^\s*<br\s*\/?>\s*/i, '');
|
|
175
|
-
const endDiv = afterTs.search(/<\/div>\s*<div class="content-cell/);
|
|
176
|
-
const rawResp = endDiv !== -1 ? afterTs.substring(0, endDiv) : afterTs;
|
|
177
|
-
aiResponse = stripHTML(decodeEntities(rawResp)).trim();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (userPrompt.length < 3 && aiResponse.length < 3)
|
|
181
|
-
continue;
|
|
182
|
-
entries.push({
|
|
183
|
-
userPrompt,
|
|
184
|
-
aiResponse,
|
|
185
|
-
timestampISO,
|
|
186
|
-
timestampUnix: Math.floor(new Date(timestampISO).getTime() / 1000),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
// Sort chronologically (HTML is newest-first)
|
|
190
|
-
entries.sort((a, b) => a.timestampUnix - b.timestampUnix);
|
|
191
|
-
return entries;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Group entries into pseudo-sessions by temporal proximity.
|
|
195
|
-
*/
|
|
196
|
-
groupSessions(entries) {
|
|
197
|
-
if (entries.length === 0)
|
|
198
|
-
return [];
|
|
199
|
-
const sessions = [];
|
|
200
|
-
let current = [entries[0]];
|
|
201
|
-
for (let i = 1; i < entries.length; i++) {
|
|
202
|
-
const gap = entries[i].timestampUnix - entries[i - 1].timestampUnix;
|
|
203
|
-
if (gap > SESSION_GAP_MINUTES * 60) {
|
|
204
|
-
sessions.push(current);
|
|
205
|
-
current = [entries[i]];
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
current.push(entries[i]);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
if (current.length > 0)
|
|
212
|
-
sessions.push(current);
|
|
213
|
-
return sessions;
|
|
214
|
-
}
|
|
215
85
|
}
|