total-recall-brain 3.25.1 → 3.25.2

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.
@@ -17,7 +17,7 @@
17
17
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
18
18
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
19
19
  <title>Total Recall — Portable Memory</title>
20
- <script type="module" crossorigin src="/assets/index-DWCNvgnv.js"></script>
20
+ <script type="module" crossorigin src="/assets/index-wFSsoOKK.js"></script>
21
21
  <link rel="stylesheet" crossorigin href="/assets/index-C7_Xpk27.css">
22
22
  </head>
23
23
  <body>
@@ -1,4 +1,4 @@
1
- import { get, post } from './_base';
1
+ import { get, post, apiFetch, API_BASE } from './_base';
2
2
 
3
3
  export interface MeshInterfaceSummary {
4
4
  name: string;
@@ -278,6 +278,31 @@ export interface EnrollResult {
278
278
  }
279
279
 
280
280
  /** Enrollment state of this node on the mesh control server. */
281
+ export interface RegisteredNode {
282
+ success: boolean;
283
+ user?: string;
284
+ message: string;
285
+ node?: { id: string | null; name: string | null; ip_addresses: string[]; online: boolean } | null;
286
+ }
287
+
288
+ /**
289
+ * Approve a device that registered interactively.
290
+ *
291
+ * iOS has no other option: the upstream Tailscale app refuses pre-auth keys
292
+ * against a custom control server, so a phone always ends up on headscale's
293
+ * "run this on the server" page waiting for approval.
294
+ */
295
+ export async function registerNode(authId: string, user?: string): Promise<RegisteredNode> {
296
+ const res = await apiFetch(`${API_BASE}/api/mesh/register-node`, {
297
+ method: 'POST',
298
+ headers: { 'Content-Type': 'application/json' },
299
+ body: JSON.stringify({ auth_id: authId, ...(user ? { user } : {}) }),
300
+ });
301
+ const data = await res.json().catch(() => ({}));
302
+ if (!res.ok) throw new Error(data.message || `register failed: ${res.status}`);
303
+ return data as RegisteredNode;
304
+ }
305
+
281
306
  export async function fetchEnrollmentStatus(): Promise<EnrollmentStatus> {
282
307
  return get('/api/mesh/enrollment');
283
308
  }
@@ -37,7 +37,7 @@ describe('TailnetEnroll', () => {
37
37
  expect((await screen.findByTestId('enroll-login-server')).textContent).toContain(
38
38
  'https://control.example.org',
39
39
  );
40
- expect(screen.getByText(/On a phone/i)).toBeTruthy();
40
+ expect(screen.getByText('On a phone (iOS)')).toBeTruthy();
41
41
  expect(mintPreAuthKey).not.toHaveBeenCalled();
42
42
  });
43
43
 
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { QRCodeSVG } from 'qrcode.react';
3
- import { fetchNodes, fetchEnrollmentStatus, mintPreAuthKey } from '../api/mesh';
3
+ import { fetchNodes, fetchEnrollmentStatus, mintPreAuthKey, registerNode } from '../api/mesh';
4
4
  import type { MeshNode, PreAuthKey } from '../api/mesh';
5
5
 
6
6
  /**
@@ -25,6 +25,9 @@ export function TailnetEnroll() {
25
25
  // config, not a property of a key. Reading it only off a minted key meant the
26
26
  // URL stayed invisible until a 15-minute countdown was already running.
27
27
  const [controlServer, setControlServer] = useState<string | null>(null);
28
+ const [authId, setAuthId] = useState('');
29
+ const [approving, setApproving] = useState(false);
30
+ const [approved, setApproved] = useState<string | null>(null);
28
31
 
29
32
  useEffect(() => {
30
33
  fetchNodes()
@@ -61,6 +64,26 @@ export function TailnetEnroll() {
61
64
  }
62
65
  };
63
66
 
67
+ const approve = async () => {
68
+ setApproving(true);
69
+ setError(null);
70
+ setApproved(null);
71
+ try {
72
+ // Accept a pasted whole command as well as a bare id — the device shows
73
+ // the id inside `headscale nodes register --user X --key <id>`, and
74
+ // making someone extract a substring by hand is a needless failure.
75
+ const match = authId.match(/hskey-authreq-[A-Za-z0-9._-]+/);
76
+ const res = await registerNode(match ? match[0] : authId.trim());
77
+ setApproved(res.message);
78
+ setAuthId('');
79
+ setNodes(await fetchNodes().catch(() => nodes));
80
+ } catch (e) {
81
+ setError(e instanceof Error ? e.message : 'could not approve device');
82
+ } finally {
83
+ setApproving(false);
84
+ }
85
+ };
86
+
64
87
  const expired = secondsLeft !== null && secondsLeft <= 0;
65
88
  const loginServer = controlServer ?? minted?.login_server ?? null;
66
89
  // `complete` is the resolver's own verdict: false when the login account is
@@ -105,6 +128,48 @@ export function TailnetEnroll() {
105
128
  </div>
106
129
  </div>
107
130
 
131
+ {/*
132
+ Approving an interactively-registered device is the ONLY route that
133
+ works for iOS: the upstream Tailscale app refuses a pre-auth key when
134
+ pointed at a custom control server, so a phone always lands on
135
+ headscale's "run this command on the server" page. Until this panel
136
+ existed, finishing that required SSH and a CLI -- on the machine you
137
+ are not holding.
138
+ */}
139
+ <div
140
+ data-testid="enroll-approve"
141
+ style={{ margin: '0 0 12px', padding: 12, borderRadius: 8, border: '1px solid var(--border)' }}
142
+ >
143
+ <strong style={{ fontSize: 12 }}>Device waiting for approval?</strong>
144
+ <p style={{ fontSize: 12, opacity: 0.75, margin: '4px 0 8px' }}>
145
+ If a device shows “run the command below in the headscale server”, paste that whole line
146
+ (or just the <code>hskey-authreq-…</code> part) here.
147
+ </p>
148
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
149
+ <input
150
+ type="text"
151
+ value={authId}
152
+ onChange={(e) => setAuthId(e.target.value)}
153
+ placeholder="hskey-authreq-…"
154
+ data-testid="enroll-authid"
155
+ style={{ flex: 1, minWidth: 220, fontFamily: 'var(--font-mono)', fontSize: 12 }}
156
+ />
157
+ <button
158
+ type="button"
159
+ onClick={approve}
160
+ disabled={approving || !authId.trim()}
161
+ data-testid="enroll-approve-btn"
162
+ >
163
+ {approving ? 'Approving…' : 'Approve device'}
164
+ </button>
165
+ </div>
166
+ {approved && (
167
+ <p data-testid="enroll-approved" style={{ fontSize: 12, color: '#10b981', margin: '8px 0 0' }}>
168
+ {approved}
169
+ </p>
170
+ )}
171
+ </div>
172
+
108
173
  <details open style={{ fontSize: 12 }}>
109
174
  <summary style={{ cursor: 'pointer', fontWeight: 600 }}>On a phone (iOS)</summary>
110
175
  <ol style={{ paddingLeft: 18, lineHeight: 1.7, marginBottom: 6 }}>
@@ -119,12 +184,20 @@ export function TailnetEnroll() {
119
184
  <strong>Alternate Coordination Server URL</strong>.
120
185
  </li>
121
186
  <li>
122
- <strong>If this device was ever signed into Tailscale's own service, turn on “Reset Keychain”.</strong>{' '}
123
- Skipping this is the usual reason the app keeps going back to the public login.
187
+ <strong>Turn on “Reset Keychain”.</strong> Treat this as required, not optional. The app keeps
188
+ its node key in the iOS keychain and will otherwise replay an old registration id forever —
189
+ force-quitting does not clear it, and the server rejects the stale id every time while the
190
+ phone keeps showing a page that looks perfectly valid.
124
191
  </li>
125
192
  <li>Force-quit Tailscale from the app switcher, then reopen it — the setting is read at launch.</li>
126
193
  <li>Tap the plain <strong>Sign in</strong> option (not SSO). It should open this control server's page.</li>
127
- <li>Authenticate with the key below.</li>
194
+ <li>
195
+ The page will say <em>“run the command below in the headscale server”</em>. That is expected —
196
+ copy the line it shows and paste it into <strong>Device waiting for approval?</strong> above.
197
+ <strong> Do not use the enrollment key below on a phone:</strong> the Tailscale iOS app does not
198
+ accept pre-auth keys against a custom control server, so interactive sign-in plus approval here
199
+ is the only route that works.
200
+ </li>
128
201
  </ol>
129
202
  <p style={{ opacity: 0.75, margin: 0 }}>
130
203
  The in-app route — account icon → <strong>Log in…</strong> → options menu →{' '}
@@ -139,7 +212,8 @@ export function TailnetEnroll() {
139
212
  <li>Install Tailscale from Google Play and make sure it is signed out.</li>
140
213
  <li>Open the app, tap the account icon, then <strong>Log in…</strong>.</li>
141
214
  <li>Open the top-right options menu → <strong>Use custom coordination server</strong>.</li>
142
- <li>Enter the control server above, then authenticate with the key below.</li>
215
+ <li>Enter the control server above. If it accepts the key below, use it; if it shows a
216
+ “run this command” page instead, approve it above like iOS.</li>
143
217
  </ol>
144
218
  </details>
145
219
  </div>
@@ -164,7 +238,7 @@ export function TailnetEnroll() {
164
238
  Ephemeral (drops off the list when offline)
165
239
  </label>
166
240
  <button type="button" onClick={mint} disabled={busy} data-testid="enroll-mint" style={{ cursor: busy ? 'wait' : 'pointer' }}>
167
- {busy ? 'Minting…' : minted ? 'Mint another key' : 'Get enrollment key'}
241
+ {busy ? 'Minting…' : minted ? 'Mint another key' : 'Get enrollment key (computers)'}
168
242
  </button>
169
243
  </div>
170
244
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total-recall-brain",
3
- "version": "3.25.1",
3
+ "version": "3.25.2",
4
4
  "description": "Personal AI system — database-free, SSSS-powered intelligence engine deployable to any POSIX host.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -135,16 +135,30 @@ function writePreservingInjectedBlock(srcFile, dstFile) {
135
135
  return 'updated';
136
136
  }
137
137
 
138
+ // Per-brain state a template must NEVER overwrite. memory-vault was always
139
+ // here; the rest were not, and a sync across repos would have destroyed one
140
+ // repo's 7 queued research topics and its 68-line skills catalog. If a file
141
+ // records what THIS brain has done, it is state, not a template.
142
+ const STATE_DIRS = new Set([
143
+ 'memory-vault', 'memory-derived', 'memory-inbox', 'sessions', 'logs',
144
+ 'scheduler', 'config', 'backups', 'browser-profile', 'skills-registry',
145
+ '.snapshots', '.git', 'node_modules',
146
+ ]);
147
+ const STATE_FILES = new Set([
148
+ 'research-queue.jsonl', 'daemon.pid', '.extension-connected', 'graph.canvas',
149
+ ]);
150
+
138
151
  function walk(dir) {
139
152
  const out = [];
140
153
  for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
141
154
  const p = path.join(dir, e.name);
142
155
  if (e.isDirectory()) {
143
- // memory-vault is the user's own memory. A template must never overwrite it.
144
- if (e.name === 'memory-vault' || e.name === 'memory-derived' || e.name === 'sessions') continue;
145
- if (e.name === '.git' || e.name === 'node_modules') continue;
156
+ if (STATE_DIRS.has(e.name)) continue;
146
157
  out.push(...walk(p));
147
- } else out.push(p);
158
+ } else {
159
+ if (STATE_FILES.has(e.name) || e.name.endsWith('.enc')) continue;
160
+ out.push(p);
161
+ }
148
162
  }
149
163
  return out;
150
164
  }
@@ -351,6 +351,10 @@
351
351
  "method": "POST",
352
352
  "path": "/api/mesh/preauthkey"
353
353
  },
354
+ {
355
+ "method": "POST",
356
+ "path": "/api/mesh/register-node"
357
+ },
354
358
  {
355
359
  "method": "GET",
356
360
  "path": "/api/network/audit"
@@ -16,7 +16,15 @@ import {
16
16
  readSshConfig,
17
17
  resolveNodeAccess,
18
18
  } from '../../core/mesh-access.mjs';
19
- import { createHeadscalePreAuthKey, resolveHeadscaleConfig } from '../../core/headscale-client.mjs';
19
+ import {
20
+ createHeadscalePreAuthKey,
21
+ resolveHeadscaleConfig,
22
+ resolveHeadscaleUser,
23
+ headscaleFetch,
24
+ } from '../../core/headscale-client.mjs';
25
+
26
+ // headscale rejects anything else with a 500; validate up front instead.
27
+ const AUTH_REQUEST_PREFIX = 'hskey-authreq-';
20
28
  import { throttledFetch } from '../../core/throttled-fetch.mjs';
21
29
  import { defaultVaultRoot } from '../../core/vfs-documents.mjs';
22
30
  import {
@@ -304,6 +312,63 @@ router.post('/api/mesh/preauthkey', requireAuth, requireScope('config:write'), a
304
312
  }
305
313
  });
306
314
 
315
+ /**
316
+ * POST /api/mesh/register-node
317
+ * Approve a device that registered interactively.
318
+ *
319
+ * This is the ONLY path that works for iOS. The upstream Tailscale iOS app
320
+ * does not accept a pre-auth key when pointed at a custom control server, so a
321
+ * phone always lands on headscale's "run this command on the server" page and
322
+ * waits for server-side approval. Without this endpoint that approval was only
323
+ * reachable over SSH + CLI, which is exactly the machine the user is not
324
+ * holding.
325
+ *
326
+ * Body: { auth_id, user? }
327
+ */
328
+ router.post('/api/mesh/register-node', requireAuth, requireScope('config:write'), async (req, res) => {
329
+ try {
330
+ const authId = String(req.body?.auth_id || '').trim();
331
+ if (!authId) {
332
+ return res.status(400).json({ success: false, message: 'auth_id is required (the hskey-authreq-… value shown on the device)' });
333
+ }
334
+ // Fail with the fix rather than passing a malformed id through to a 500.
335
+ if (!authId.startsWith(AUTH_REQUEST_PREFIX)) {
336
+ return res.status(400).json({
337
+ success: false,
338
+ message: `that does not look like a registration id — expected it to start with "${AUTH_REQUEST_PREFIX}". `
339
+ + 'Copy the whole value from the device screen, not the surrounding command.',
340
+ });
341
+ }
342
+
343
+ const user = await resolveHeadscaleUser(BRAIN_DIR, req.body?.user);
344
+ const query = `?user=${encodeURIComponent(user)}&key=${encodeURIComponent(authId)}`;
345
+ const result = await headscaleFetch(`/api/v1/node/register${query}`, { method: 'POST' }, BRAIN_DIR);
346
+ const node = (typeof result === 'string' ? JSON.parse(result) : result)?.node ?? null;
347
+
348
+ res.json({
349
+ success: true,
350
+ user,
351
+ node: node && {
352
+ id: node.id ?? null,
353
+ name: node.name ?? node.givenName ?? null,
354
+ ip_addresses: node.ipAddresses ?? [],
355
+ online: node.online ?? false,
356
+ },
357
+ message: node?.name ? `${node.name} joined the tailnet.` : 'Device registered.',
358
+ });
359
+ } catch (err) {
360
+ const msg = String(err?.message || '');
361
+ // headscale answers 500 for an expired/unknown id; say so in those terms.
362
+ const stale = /not found|expired|invalid/i.test(msg);
363
+ res.status(stale ? 409 : 500).json({
364
+ success: false,
365
+ message: stale
366
+ ? 'That registration id is no longer valid — it expires quickly. Reopen sign-in on the device to get a fresh one.'
367
+ : msg || 'could not register device',
368
+ });
369
+ }
370
+ });
371
+
307
372
  /**
308
373
  * This host's I/O capability profile for agent UI generation
309
374
  * (screen, touch, mic, speaker, keyboard, camera, headless, …).
@@ -1,7 +0,0 @@
1
- {"id":"7478a515-ea8e-4360-93b8-a10cf0642d88","topic":"npm Registry API documentation and developer endpoints","status":"pending","priority":"medium","notes":"Consult official npm documentation for registry APIs, authentication, and package metadata without using raw key strings.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:58:08.631Z","updated_at":"2026-08-18T20:58:08.631Z","completed_at":null,"summary":{"id":"7478a515-ea8e-4360-93b8-a10cf0642d88","topic":"npm Registry API documentation and developer endpoints","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:58:08.631Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
2
- {"id":"f9757282-dad8-4c3b-b44d-c796555468c5","topic":"Supabase Client, Auth, and REST APIs","status":"pending","priority":"medium","notes":"Use official Supabase documentation to understand authentication, database, and storage API surfaces.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:57:04.280Z","updated_at":"2026-08-18T20:57:04.280Z","completed_at":null,"summary":{"id":"f9757282-dad8-4c3b-b44d-c796555468c5","topic":"Supabase Client, Auth, and REST APIs","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:57:04.280Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
3
- {"id":"e196b27d-c799-4e60-88d0-585c479b6053","topic":"Supabase Database, Auth, Storage, and Management APIs","status":"pending","priority":"medium","notes":"Consult official Supabase documentation for REST API, SDK, and platform integration; do not use raw secret key string.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:56:34.347Z","updated_at":"2026-08-18T20:56:34.347Z","completed_at":null,"summary":{"id":"e196b27d-c799-4e60-88d0-585c479b6053","topic":"Supabase Database, Auth, Storage, and Management APIs","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:56:34.347Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
4
- {"id":"f6c787c9-212c-4468-a276-5af7d7d78dbc","topic":"Supabase REST API and Client SDKs","status":"pending","priority":"medium","notes":"Use official Supabase documentation for client SDKs, REST API, Database, and Auth endpoints. Do not search using raw key values.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:56:21.400Z","updated_at":"2026-08-18T20:56:21.400Z","completed_at":null,"summary":{"id":"f6c787c9-212c-4468-a276-5af7d7d78dbc","topic":"Supabase REST API and Client SDKs","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:56:21.400Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
5
- {"id":"c95b76a3-9bd3-42fd-8c37-0765cabef6a8","topic":"Documenso document signing and template REST API","status":"pending","priority":"medium","notes":"Consult official Documenso documentation for REST API endpoints, document signing workflows, and API key authentication. Do not query using the raw key string.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:55:37.372Z","updated_at":"2026-08-18T20:55:37.372Z","completed_at":null,"summary":{"id":"c95b76a3-9bd3-42fd-8c37-0765cabef6a8","topic":"Documenso document signing and template REST API","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:55:37.372Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
6
- {"id":"9b1f9703-76c3-4743-916a-a3340c2b74f4","topic":"Claude Code messaging API and CLI integration","status":"pending","priority":"medium","notes":"Consult official Anthropic Claude Code documentation for API and integration details; do not use the raw key string.","node_slug":null,"research_phase":"acquisition","created_at":"2026-08-18T20:55:25.048Z","updated_at":"2026-08-18T20:55:25.048Z","completed_at":null,"summary":{"id":"9b1f9703-76c3-4743-916a-a3340c2b74f4","topic":"Claude Code messaging API and CLI integration","status":"pending","phase":"acquisition","last_updated":"2026-08-18T20:55:25.048Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}
7
- {"id":"0efa65c2-0231-4267-a304-e0285e50011e","topic":"Total Recall repository improvement research: SSSS validated write pipeline, filesystem-native memory engines, local-first semantic indexing, Express 5 API hardening, 2026 agent memory architecture patterns","status":"pending","priority":"high","notes":"Queued from repo-wide analysis request on 2026-06-01. Focus on current best practices and meta-patterns for filesystem-native memory OS, validated operation envelopes, append-only logs, cache invalidation, research queue architecture, and secure local-first AI tools.","node_slug":null,"research_phase":"acquisition","created_at":"2026-06-01T06:07:40.102Z","updated_at":"2026-06-01T06:07:40.126Z","completed_at":null,"summary":{"id":"0efa65c2-0231-4267-a304-e0285e50011e","topic":"Total Recall repository improvement research: SSSS validated write pipeline, filesystem-native memory engines, local-first semantic indexing, Express 5 API hardening, 2026 agent memory architecture patterns","status":"pending","phase":"acquisition","last_updated":"2026-06-01T06:07:40.126Z","conclusions":[],"ongoing_directions":["Research project is enqueued / in progress in phase: acquisition"],"sources_count":0}}