@opencorelabs/lucidity 0.2.0 → 0.3.0
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 +29 -34
- package/bin/lucidity.js +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/index.js +25 -8
- package/dist/mcp/clients.d.ts +21 -0
- package/dist/mcp/clients.d.ts.map +1 -0
- package/dist/mcp/clients.js +193 -0
- package/dist/mcp/config.d.ts +2 -1
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/paired.d.ts +2 -0
- package/dist/mcp/paired.d.ts.map +1 -0
- package/dist/mcp/paired.js +20 -0
- package/dist/mcp/pairedConfig.d.ts +3 -0
- package/dist/mcp/pairedConfig.d.ts.map +1 -0
- package/dist/mcp/pairedConfig.js +33 -0
- package/dist/setup/page.d.ts +3 -0
- package/dist/setup/page.d.ts.map +1 -0
- package/dist/setup/page.js +120 -0
- package/dist/setup/server.d.ts +26 -0
- package/dist/setup/server.d.ts.map +1 -0
- package/dist/setup/server.js +398 -0
- package/package.json +1 -1
- package/src/config.ts +3 -0
- package/src/index.ts +41 -24
- package/src/mcp/clients.ts +269 -0
- package/src/mcp/config.ts +2 -1
- package/src/mcp/paired.ts +22 -0
- package/src/mcp/pairedConfig.ts +44 -0
- package/src/setup/page.ts +122 -0
- package/src/setup/server.ts +483 -0
- package/vendor/mcp-server/README.md +125 -48
- package/vendor/mcp-server/dist/index.js +11 -5
- package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/comments.js +16 -1
- package/vendor/mcp-server/dist/tools/memory.d.ts +2 -2
- package/vendor/mcp-server/dist/tools/memory.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/memory.js +24 -14
- package/vendor/mcp-server/dist/tools/milestones.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/milestones.js +30 -0
- package/vendor/mcp-server/dist/tools/notes.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/notes.js +30 -5
- package/vendor/mcp-server/dist/tools/projects.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/projects.js +15 -0
- package/vendor/mcp-server/dist/tools/queries.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/queries.js +27 -2
- package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/tasks.js +37 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +19 -6
- package/vendor/mcp-server/src/tools/comments.ts +19 -1
- package/vendor/mcp-server/src/tools/memory.ts +26 -12
- package/vendor/mcp-server/src/tools/milestones.ts +36 -0
- package/vendor/mcp-server/src/tools/notes.ts +35 -4
- package/vendor/mcp-server/src/tools/projects.ts +18 -0
- package/vendor/mcp-server/src/tools/queries.ts +30 -0
- package/vendor/mcp-server/src/tools/tasks.ts +44 -0
- package/vendor/shared/dist/brandArtwork.d.ts +4 -0
- package/vendor/shared/dist/brandArtwork.d.ts.map +1 -0
- package/vendor/shared/dist/brandArtwork.js +7 -0
- package/vendor/shared/dist/index.d.ts +1 -0
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +1 -0
- package/vendor/shared/dist/setupAppearance.d.ts +6 -0
- package/vendor/shared/dist/setupAppearance.d.ts.map +1 -0
- package/vendor/shared/dist/setupAppearance.js +17 -0
- package/vendor/shared/src/brandArtwork.ts +7 -0
- package/vendor/shared/src/index.ts +1 -0
- package/vendor/shared/src/setupAppearance.ts +32 -0
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ on your machine for scheduled briefings and interactive chat.
|
|
|
9
9
|
Requires Node.js 22 or newer.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install -g @opencorelabs/lucidity
|
|
13
|
-
lucidity
|
|
12
|
+
npm install -g @opencorelabs/lucidity@0.3.0
|
|
13
|
+
lucidity setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The package includes the CLI, daemon, MCP server, and their internal libraries.
|
|
@@ -18,6 +18,16 @@ It also provides the `lucidity-daemon` and `lucidity-mcp` commands.
|
|
|
18
18
|
|
|
19
19
|
## MCP server
|
|
20
20
|
|
|
21
|
+
After connecting your account with `lucidity setup`, select **Use Lucidity in
|
|
22
|
+
Claude Code** and/or **Use Lucidity in Codex** to add the tools automatically.
|
|
23
|
+
You can select both; each client keeps its own account and subscription.
|
|
24
|
+
For an already configured computer, run `lucidity setup` again for the app choices,
|
|
25
|
+
or run `lucidity setup-mcp` to connect detected clients. No token copying is needed.
|
|
26
|
+
Open a new client session afterward and approve any tool permissions it requests.
|
|
27
|
+
See [automatic setup and recovery](https://github.com/opencore-x/lucidity/blob/main/docs/automatic-client-mcp.md).
|
|
28
|
+
|
|
29
|
+
### Manual setup for other MCP clients
|
|
30
|
+
|
|
21
31
|
Generate an API key in the Lucidity app under **Settings → API Key**. Configure
|
|
22
32
|
your MCP client to launch `lucidity mcp` with that key in `LUCIDITY_API_KEY`.
|
|
23
33
|
For clients using JSON configuration:
|
|
@@ -67,40 +77,25 @@ background installation, `status`, and `uninstall` currently support macOS only.
|
|
|
67
77
|
Closing the terminal or sleeping the computer makes its AI features unavailable.
|
|
68
78
|
Core mobile data remains available through the hosted API.
|
|
69
79
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{
|
|
77
|
-
"apiKey": "luc_your_api_key_here",
|
|
78
|
-
"apiUrl": "https://api.lucidity.my",
|
|
79
|
-
"chatProvider": "codex",
|
|
80
|
-
"codeProvider": "codex",
|
|
81
|
-
"delivery": "stdout",
|
|
82
|
-
"reflect": false,
|
|
83
|
-
"weeklyReview": false
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Use `"claude"` for both provider fields if you authenticated Claude instead. Model
|
|
88
|
-
selection stays within the chosen provider; Lucidity does not fall back to API
|
|
89
|
-
billing or automatically switch providers. Provider subscription allowance still
|
|
90
|
-
applies, including scheduled work such as the daily briefing.
|
|
80
|
+
Run `lucidity setup` to open the guided page. Sign in at `lucidity.my` and approve
|
|
81
|
+
this computer, then select an authenticated provider. If you use both Claude and
|
|
82
|
+
Codex, keep both provider logins on the computer; Lucid uses the provider selected
|
|
83
|
+
for each conversation. The optional client checkboxes can connect Lucidity's MCP
|
|
84
|
+
tools to both apps regardless of that default.
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
Review task access and scheduled work, which start off, then finish setup to start
|
|
87
|
+
the foreground agent. No API key or JSON editing is needed. The connection is saved
|
|
88
|
+
under your user profile in `.lucidity/config.json`; keep it private.
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
lucidity --deliver stdout
|
|
98
|
-
|
|
90
|
+
Keep the terminal open on Windows. Use Ctrl+C to stop the agent and
|
|
91
|
+
`lucidity --deliver stdout` to start it again. On the phone, use the same Lucidity
|
|
92
|
+
account and open **Connect a computer** to see the computer and provider status.
|
|
93
|
+
AI uses the selected provider's subscription allowance; Lucidity does not switch
|
|
94
|
+
providers or fall back to API billing automatically.
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
requires a service restart.
|
|
96
|
+
Existing configured users can run `lucidity setup-mcp claude codex` to register both
|
|
97
|
+
clients without pairing again or starting another daemon. Manual configuration for
|
|
98
|
+
advanced or self-hosted setups remains in the daemon guide.
|
|
104
99
|
|
|
105
100
|
On macOS, `lucidity install` registers and starts a background agent at login.
|
|
106
101
|
Use `lucidity status`, `lucidity chat`, and `lucidity uninstall` to manage it.
|
|
@@ -126,7 +121,7 @@ npm run verify:npm -- --local
|
|
|
126
121
|
This builds the agent and its workspace dependencies, vendors the internal
|
|
127
122
|
libraries as local file dependencies with a private Zod 3 copy for MCP, writes the publishable archive to `dist/npm/`, and verifies the CLI
|
|
128
123
|
and MCP server from isolated global and local installations. Publish that
|
|
129
|
-
archive with `npm publish dist/npm/opencorelabs-lucidity-0.
|
|
124
|
+
archive with `npm publish dist/npm/opencorelabs-lucidity-0.3.0.tgz --access public`.
|
|
130
125
|
The private workspace packages do not need separate npm publications.
|
|
131
126
|
|
|
132
127
|
The package workflow globally and locally installs the same archive on Windows, macOS, and Linux using
|
package/bin/lucidity.js
CHANGED
|
@@ -12,6 +12,8 @@ if (args.includes('--version') || args.includes('-v')) {
|
|
|
12
12
|
Usage: lucidity [command] [options]
|
|
13
13
|
|
|
14
14
|
Commands:
|
|
15
|
+
setup Open guided computer setup in your browser
|
|
16
|
+
setup-mcp [claude] [codex] Connect Lucidity tools to your AI apps
|
|
15
17
|
mcp Run the MCP server over stdio
|
|
16
18
|
install Install and start the macOS background agent
|
|
17
19
|
uninstall Remove the macOS background agent
|
package/dist/config.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface Capabilities {
|
|
|
42
42
|
connected: boolean;
|
|
43
43
|
}
|
|
44
44
|
export interface DaemonConfig {
|
|
45
|
+
/** Master switch for proactive jobs. Existing installations retain their behavior. */
|
|
46
|
+
scheduledWork?: boolean;
|
|
45
47
|
chatProvider?: 'claude' | 'codex';
|
|
46
48
|
codeProvider?: 'claude' | 'codex';
|
|
47
49
|
/** Lucidity API key, `luc_…`. */
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,aAAa,EACb,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM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;;qFAEqF;AACrF,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAoB,GAC/B,WAAW,GAAG,SAAS,CAWzB;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,iBAAiB,GACvB,iBAAiB,CAWnB;AAkBD;;sEAEsE;AACtE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,YAAY,CAYd;AAED;mEACmE;AACnE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,SAAS,CAQX;AAED;;;;oDAIoD;AACpD,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC7C,GAAG,EAAE,MAAM,CAAC;CACb;AACD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,GACnB,eAAe,GAAG,SAAS,CAc7B;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,MAAM,EAAE,CASV;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,SAAS,EAAE,CAmBb"}
|
package/dist/config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,6 +28,8 @@ import { listAllowlist } from './coding/discover.js';
|
|
|
28
28
|
import { resolveRepo } from './coding/repos.js';
|
|
29
29
|
import { watchBranches } from './coding/branchWatch.js';
|
|
30
30
|
import { sweepStaleRequests } from './sweepStale.js';
|
|
31
|
+
import { runSetup } from './setup/server.js';
|
|
32
|
+
import { runClientSetup } from './mcp/clients.js';
|
|
31
33
|
const KNOWN_JOBS = ['briefing', 'weekly-review', 'extraction'];
|
|
32
34
|
/** How often the journal sweep runs. Four hours keeps a morning capture from waiting for
|
|
33
35
|
* tomorrow while staying well inside a day's worth of model calls. */
|
|
@@ -59,6 +61,15 @@ function parseArgs(argv) {
|
|
|
59
61
|
}
|
|
60
62
|
async function main() {
|
|
61
63
|
const args = parseArgs(process.argv.slice(2));
|
|
64
|
+
if (args.command === 'setup-mcp') {
|
|
65
|
+
await runClientSetup(process.argv.slice(3));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (args.command === 'setup') {
|
|
69
|
+
if (!(await runSetup()))
|
|
70
|
+
return;
|
|
71
|
+
args.command = undefined;
|
|
72
|
+
}
|
|
62
73
|
// Service-management commands (manage the launchd agent; handled before config
|
|
63
74
|
// so `status`/`uninstall` work even without a valid config).
|
|
64
75
|
switch (args.command) {
|
|
@@ -148,15 +159,19 @@ async function main() {
|
|
|
148
159
|
}
|
|
149
160
|
// Default mode: run the scheduler in the foreground.
|
|
150
161
|
const scheduler = new Scheduler();
|
|
151
|
-
const briefingJob =
|
|
152
|
-
|
|
162
|
+
const briefingJob = config.scheduledWork !== false
|
|
163
|
+
? scheduler.scheduleDaily(config.briefingTime, () => void runJob('briefing', queue, () => runBriefing(config, executor, deliverer, attention)), { timezone: config.timezone })
|
|
164
|
+
: undefined;
|
|
165
|
+
if (config.scheduledWork !== false && config.weeklyReview) {
|
|
153
166
|
scheduler.scheduleWeekly(config.weeklyReviewDay, config.weeklyReviewTime, () => void runJob('weekly-review', queue, () => runWeeklyReview(config, executor, deliverer)), { timezone: config.timezone });
|
|
154
167
|
}
|
|
155
168
|
// The journal sweep. Through the day rather than at a moment: something said at 9am
|
|
156
169
|
// shouldn't wait for tomorrow's briefing to be read, and the batch is capped, so a quiet
|
|
157
170
|
// week catching up costs the same as a busy one. It delivers nothing — this is the step
|
|
158
171
|
// that makes the briefing and the weekly review better, not another thing to read.
|
|
159
|
-
|
|
172
|
+
if (config.scheduledWork !== false) {
|
|
173
|
+
scheduler.scheduleEveryHours(EXTRACTION_INTERVAL_HOURS, () => void runJob('extraction', queue, () => runExtraction(config, executor)), { timezone: config.timezone });
|
|
174
|
+
}
|
|
160
175
|
// Interactive chat server (lite local gateway): loopback + token auth.
|
|
161
176
|
const chatServer = createChatServer({
|
|
162
177
|
config,
|
|
@@ -177,9 +192,11 @@ async function main() {
|
|
|
177
192
|
// Nag about procurement requests that have stopped moving. Just after the
|
|
178
193
|
// briefing rather than overnight, so the nudge lands when someone is at a desk
|
|
179
194
|
// and can act on it — a 3am notification is one you scroll past at 9.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
195
|
+
if (config.scheduledWork !== false) {
|
|
196
|
+
scheduler.scheduleDaily('09:30', () => void sweepStaleRequests(config.apiKey), {
|
|
197
|
+
timezone: config.timezone,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
183
200
|
// Room client (free path): dial the hosted relay so the phone can reach Lucid,
|
|
184
201
|
// serving ask/briefing/journal through the shared harness. Best-effort — it
|
|
185
202
|
// reconnects on its own and never takes the daemon down.
|
|
@@ -302,7 +319,7 @@ async function main() {
|
|
|
302
319
|
})
|
|
303
320
|
: null;
|
|
304
321
|
const tz = config.timezone ? ` ${config.timezone}` : '';
|
|
305
|
-
const next = briefingJob
|
|
322
|
+
const next = briefingJob?.nextRun();
|
|
306
323
|
const weekly = config.weeklyReview
|
|
307
324
|
? `; weekly review ${config.weeklyReviewTime} (day ${config.weeklyReviewDay})`
|
|
308
325
|
: '';
|
|
@@ -318,7 +335,7 @@ async function main() {
|
|
|
318
335
|
// Package pins keep the SDK, native runtime, and protocol contract aligned.
|
|
319
336
|
const runtimeVersions = `Claude Agent SDK ${CLAUDE_AGENT_SDK_VERSION}; Codex ${CODEX_RUNTIME_VERSION}`;
|
|
320
337
|
console.error(`[daemon] Lucid daemon started. Briefing ${config.briefingTime}${tz} → ${deliverer.name}${weekly}. ` +
|
|
321
|
-
`Next briefing: ${next ? next.toISOString() : '
|
|
338
|
+
`Scheduled work: ${config.scheduledWork !== false ? 'on' : 'off'}. Next briefing: ${next ? next.toISOString() : 'none'}. Chat on 127.0.0.1:${config.chatPort}. ` +
|
|
322
339
|
`Room dialing ${config.apiUrl}. ${tools}.${shell} ${runtimeVersions}.`);
|
|
323
340
|
const shutdown = () => {
|
|
324
341
|
console.error('[daemon] shutting down.');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const CLIENT_IDS: readonly ["claude", "codex"];
|
|
2
|
+
export type ClientId = (typeof CLIENT_IDS)[number];
|
|
3
|
+
export interface ClientStatus {
|
|
4
|
+
id: ClientId;
|
|
5
|
+
label: string;
|
|
6
|
+
status: 'available' | 'configured' | 'missing' | 'conflict' | 'error';
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientSetupOptions {
|
|
10
|
+
configPath?: string;
|
|
11
|
+
home?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
/** Alternate executable entry for isolated installation checks. */
|
|
14
|
+
launcherPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createClientSetup(options?: ClientSetupOptions): {
|
|
17
|
+
inspect: () => Promise<ClientStatus[]>;
|
|
18
|
+
configure: (ids: ClientId[]) => Promise<ClientStatus[]>;
|
|
19
|
+
};
|
|
20
|
+
export declare function runClientSetup(argv: string[]): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/mcp/clients.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,UAAU,8BAA+B,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;IACtE,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAiCD,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB;mBAkHtC,OAAO,CAAC,YAAY,EAAE,CAAC;qBAGnB,QAAQ,EAAE,KAAG,OAAO,CAAC,YAAY,EAAE,CAAC;EAsEnE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,iBAgBlD"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, } from 'node:fs';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { CONFIG_PATH } from '../config.js';
|
|
9
|
+
import { pairedMcpEnvironment } from './pairedConfig.js';
|
|
10
|
+
export const CLIENT_IDS = ['claude', 'codex'];
|
|
11
|
+
const labels = { claude: 'Claude Code', codex: 'Codex' };
|
|
12
|
+
const execute = promisify(execFile);
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const runtimeRequire = createRequire(require.resolve('@lucidity/runtime'));
|
|
15
|
+
/** Always use the tested, bundled official CLI; no shell or npm shim execution. */
|
|
16
|
+
function clientCommand(id) {
|
|
17
|
+
if (id === 'codex')
|
|
18
|
+
return {
|
|
19
|
+
command: process.execPath,
|
|
20
|
+
prefix: [runtimeRequire.resolve('@openai/codex/bin/codex.js')],
|
|
21
|
+
};
|
|
22
|
+
const sdk = runtimeRequire.resolve('@anthropic-ai/claude-agent-sdk');
|
|
23
|
+
const musl = process.platform === 'linux' &&
|
|
24
|
+
!process.report.getReport().header.glibcVersionRuntime
|
|
25
|
+
? '-musl'
|
|
26
|
+
: '';
|
|
27
|
+
const native = createRequire(sdk).resolve(`@anthropic-ai/claude-agent-sdk-${process.platform}-${process.arch}${musl}/package.json`);
|
|
28
|
+
return {
|
|
29
|
+
command: join(dirname(native), process.platform === 'win32' ? 'claude.exe' : 'claude'),
|
|
30
|
+
prefix: [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function createClientSetup(options = {}) {
|
|
34
|
+
const home = options.home ?? homedir();
|
|
35
|
+
const env = options.env ?? process.env;
|
|
36
|
+
const configPath = resolve(options.configPath ?? CONFIG_PATH);
|
|
37
|
+
const claudeConfig = env.CLAUDE_CONFIG_DIR
|
|
38
|
+
? join(resolve(env.CLAUDE_CONFIG_DIR), '.claude.json')
|
|
39
|
+
: join(home, '.claude.json');
|
|
40
|
+
const codexHome = resolve(env.CODEX_HOME ?? join(home, '.codex'));
|
|
41
|
+
const launcher = options.launcherPath ??
|
|
42
|
+
fileURLToPath(new URL('../../dist/mcp/paired.js', import.meta.url));
|
|
43
|
+
const args = [launcher, '--config', configPath];
|
|
44
|
+
const detected = (id) => existsSync(id === 'claude' ? claudeConfig : codexHome) ||
|
|
45
|
+
(env.PATH ?? env.Path ?? '')
|
|
46
|
+
.split(delimiter)
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.some((dir) => (process.platform === 'win32'
|
|
49
|
+
? ['.exe', '.cmd', '.bat', '']
|
|
50
|
+
: ['']).some((ext) => existsSync(join(dir, id + ext))));
|
|
51
|
+
const run = async (id, argv) => {
|
|
52
|
+
const { command, prefix } = clientCommand(id);
|
|
53
|
+
const childEnv = { ...env, DISABLE_AUTOUPDATER: '1' };
|
|
54
|
+
const { stdout } = await execute(command, [...prefix, ...argv], {
|
|
55
|
+
cwd: home,
|
|
56
|
+
env: childEnv,
|
|
57
|
+
timeout: 15000,
|
|
58
|
+
maxBuffer: 1024 * 1024,
|
|
59
|
+
windowsHide: true,
|
|
60
|
+
});
|
|
61
|
+
return stdout;
|
|
62
|
+
};
|
|
63
|
+
const result = (id, status, message) => ({ id, label: labels[id], status, message });
|
|
64
|
+
const matches = (entry) => entry.command === process.execPath &&
|
|
65
|
+
JSON.stringify(entry.args) === JSON.stringify(args) &&
|
|
66
|
+
(!entry.env || Object.keys(entry.env).length === 0) &&
|
|
67
|
+
(!entry.env_vars ||
|
|
68
|
+
(Array.isArray(entry.env_vars) && entry.env_vars.length === 0)) &&
|
|
69
|
+
(!entry.type || entry.type === 'stdio');
|
|
70
|
+
async function inspectOne(id) {
|
|
71
|
+
if (!detected(id))
|
|
72
|
+
return result(id, 'missing', `Open ${labels[id]} once after installing it, then check again.`);
|
|
73
|
+
try {
|
|
74
|
+
let entry;
|
|
75
|
+
let present = false;
|
|
76
|
+
let enabled = true;
|
|
77
|
+
if (id === 'claude') {
|
|
78
|
+
const config = existsSync(claudeConfig)
|
|
79
|
+
? JSON.parse(readFileSync(claudeConfig, 'utf8'))
|
|
80
|
+
: {};
|
|
81
|
+
if (!config ||
|
|
82
|
+
typeof config !== 'object' ||
|
|
83
|
+
Array.isArray(config) ||
|
|
84
|
+
(config.mcpServers !== undefined &&
|
|
85
|
+
(!config.mcpServers ||
|
|
86
|
+
typeof config.mcpServers !== 'object' ||
|
|
87
|
+
Array.isArray(config.mcpServers))))
|
|
88
|
+
throw new Error('Invalid config');
|
|
89
|
+
present = Object.hasOwn(config.mcpServers ?? {}, 'lucidity');
|
|
90
|
+
if (present)
|
|
91
|
+
entry = config.mcpServers.lucidity;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const list = JSON.parse(await run(id, ['mcp', 'list', '--json']));
|
|
95
|
+
if (!Array.isArray(list))
|
|
96
|
+
throw new Error('Invalid list');
|
|
97
|
+
const existing = list.find((e) => e?.name === 'lucidity');
|
|
98
|
+
if (existing) {
|
|
99
|
+
present = true;
|
|
100
|
+
entry = existing.transport;
|
|
101
|
+
enabled = existing.enabled !== false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!present)
|
|
105
|
+
return result(id, 'available', 'Add your Lucidity tasks, projects and comments.');
|
|
106
|
+
if (entry && typeof entry === 'object' && matches(entry) && enabled)
|
|
107
|
+
return result(id, 'configured', 'Settings saved. Open a new session to use Lucidity.');
|
|
108
|
+
return result(id, 'conflict', 'A different or disabled Lucidity connection already exists. Your settings have been kept.');
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Native CLI errors can quote config values. Never return their stdout/stderr.
|
|
112
|
+
return result(id, 'error', `Could not read ${labels[id]} settings. Check its MCP settings, then try again.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function inspect() {
|
|
116
|
+
return Promise.all(CLIENT_IDS.map(inspectOne));
|
|
117
|
+
}
|
|
118
|
+
async function configure(ids) {
|
|
119
|
+
pairedMcpEnvironment(configPath);
|
|
120
|
+
if (!existsSync(launcher))
|
|
121
|
+
throw new Error('Build or reinstall Lucidity before connecting your AI apps.');
|
|
122
|
+
const lock = join(dirname(configPath), 'mcp-setup.lock');
|
|
123
|
+
mkdirSync(dirname(lock), { recursive: true, mode: 0o700 });
|
|
124
|
+
if (existsSync(lock)) {
|
|
125
|
+
const pid = Number(readFileSync(lock, 'utf8'));
|
|
126
|
+
if (Number.isInteger(pid) && pid > 0) {
|
|
127
|
+
try {
|
|
128
|
+
process.kill(pid, 0);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error.code === 'ESRCH')
|
|
132
|
+
unlinkSync(lock);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
writeFileSync(lock, String(process.pid), { flag: 'wx', mode: 0o600 });
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
throw new Error('MCP setup is already running. Wait for it to finish, then try again.');
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const results = [];
|
|
144
|
+
for (const id of [...new Set(ids)]) {
|
|
145
|
+
const before = await inspectOne(id);
|
|
146
|
+
if (before.status !== 'available') {
|
|
147
|
+
results.push(before);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
await run(id, [
|
|
152
|
+
'mcp',
|
|
153
|
+
'add',
|
|
154
|
+
...(id === 'claude' ? ['--scope', 'user'] : []),
|
|
155
|
+
'lucidity',
|
|
156
|
+
'--',
|
|
157
|
+
process.execPath,
|
|
158
|
+
...args,
|
|
159
|
+
]);
|
|
160
|
+
const after = await inspectOne(id);
|
|
161
|
+
results.push(after.status === 'configured'
|
|
162
|
+
? after
|
|
163
|
+
: result(id, 'error', `Could not confirm ${labels[id]} settings. Check again before retrying.`));
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
results.push(result(id, 'error', `Could not save ${labels[id]} settings. Check its MCP settings, then run lucidity setup-mcp ${id}.`));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return results;
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
unlinkSync(lock);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { inspect, configure };
|
|
176
|
+
}
|
|
177
|
+
export async function runClientSetup(argv) {
|
|
178
|
+
if (argv.some((id) => !CLIENT_IDS.includes(id)))
|
|
179
|
+
throw new Error('Usage: lucidity setup-mcp [claude] [codex]');
|
|
180
|
+
const setup = createClientSetup();
|
|
181
|
+
const selected = argv.length
|
|
182
|
+
? argv
|
|
183
|
+
: (await setup.inspect())
|
|
184
|
+
.filter((c) => c.status !== 'missing')
|
|
185
|
+
.map((c) => c.id);
|
|
186
|
+
if (!selected.length)
|
|
187
|
+
throw new Error('Install and open Claude Code or Codex first, then run lucidity setup-mcp again.');
|
|
188
|
+
const results = await setup.configure(selected);
|
|
189
|
+
for (const row of results)
|
|
190
|
+
console.error(`${row.label}: ${row.message}`);
|
|
191
|
+
if (results.some((row) => row.status !== 'configured'))
|
|
192
|
+
process.exitCode = 1;
|
|
193
|
+
}
|
package/dist/mcp/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DaemonConfig } from '../config.js';
|
|
2
|
-
/**
|
|
2
|
+
/** Scoped MCP wiring for the daemon's Claude/Codex chat turns.
|
|
3
|
+
* Client registration is handled separately by guided setup. */
|
|
3
4
|
export interface McpWiring {
|
|
4
5
|
/** Path to the hermetic MCP config JSON (`--mcp-config`). */
|
|
5
6
|
configPath: string;
|
package/dist/mcp/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7D
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7D;gEACgE;AAChE,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAuClF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paired.d.ts","sourceRoot":"","sources":["../../src/mcp/paired.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pairedMcpEnvironment } from './pairedConfig.js';
|
|
2
|
+
// A dedicated stdio entry, independent of the running daemon and AI subscription.
|
|
3
|
+
// Both arguments and client config contain only the path to the saved connection.
|
|
4
|
+
try {
|
|
5
|
+
const [flag, configPath, ...extra] = process.argv.slice(2);
|
|
6
|
+
if (flag !== '--config' || !configPath || extra.length) {
|
|
7
|
+
throw new Error('Run lucidity setup-mcp to configure this MCP connection.');
|
|
8
|
+
}
|
|
9
|
+
Object.assign(process.env, pairedMcpEnvironment(configPath));
|
|
10
|
+
// Connecting task tools does not also grant access to local notes or memory.
|
|
11
|
+
delete process.env.LUCIDITY_NOTES_PATH;
|
|
12
|
+
delete process.env.LUCIDITY_VAULT_PATH;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.error(error instanceof Error
|
|
16
|
+
? error.message
|
|
17
|
+
: 'Lucidity connection is unavailable.');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
await import('@lucidity/mcp-server');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairedConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/pairedConfig.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsCxB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
/** Read at server startup so client settings never contain a credential. */
|
|
3
|
+
export function pairedMcpEnvironment(configPath) {
|
|
4
|
+
let config;
|
|
5
|
+
try {
|
|
6
|
+
config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
throw new Error('Run lucidity setup to connect your account first.');
|
|
10
|
+
}
|
|
11
|
+
if (typeof config?.apiKey !== 'string' ||
|
|
12
|
+
!/^luc_[a-zA-Z0-9_]+$/.test(config.apiKey)) {
|
|
13
|
+
throw new Error('Your Lucidity connection is missing. Run lucidity setup.');
|
|
14
|
+
}
|
|
15
|
+
let url;
|
|
16
|
+
try {
|
|
17
|
+
url = new URL(config.apiUrl ?? 'https://api.lucidity.my');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error('Your Lucidity API address is invalid. Check its settings.');
|
|
21
|
+
}
|
|
22
|
+
if (url.username ||
|
|
23
|
+
url.password ||
|
|
24
|
+
url.pathname !== '/' ||
|
|
25
|
+
url.search ||
|
|
26
|
+
url.hash ||
|
|
27
|
+
(url.protocol !== 'https:' &&
|
|
28
|
+
!(url.protocol === 'http:' &&
|
|
29
|
+
['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))) {
|
|
30
|
+
throw new Error('Lucidity requires an HTTPS API address or a local development server.');
|
|
31
|
+
}
|
|
32
|
+
return { LUCIDITY_API_KEY: config.apiKey, LUCIDITY_API_URL: url.origin };
|
|
33
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const setupScript = "\nlet token = new URLSearchParams(location.hash.slice(1)).get('session');\nif (token) { sessionStorage.setItem('luciditySetupSession', token); history.replaceState(null, '', '/'); }\ntoken = token || sessionStorage.getItem('luciditySetupSession');\nconst content = document.getElementById('stage');\nconst error = document.getElementById('error');\nlet state = {}, selected = sessionStorage.getItem('luciditySetupProvider'), timer, busy = false, revision = 0;\nlet choices = {tasks:false, scheduledWork:false, clients:[]};\ntry { choices = {...choices, ...JSON.parse(sessionStorage.getItem('luciditySetupChoices') || '{}')}; } catch {}\nconst escape = s => String(s).replace(/[&<>\"']/g, c => ({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));\nfunction showError(e) { error.textContent = e.message || 'Something went wrong. Please try again.'; error.hidden = false; }\nasync function request(path, body) {\n const response = await fetch('/api/' + path, {method:'POST',headers:{'Content-Type':'application/json','X-Setup-Token':token || ''},body:JSON.stringify(body || {})});\n const value = await response.json();\n if(!response.ok) throw new Error(value.error || 'Please try again.');\n return value;\n}\nfunction render(step, html) {\n revision++; clearTimeout(timer); error.hidden = true;\n document.querySelectorAll('.steps li').forEach((li,i) => { li.className = i === step ? 'active' : i < step ? 'done' : ''; li.toggleAttribute('aria-current', i === step); li.querySelector('b').textContent = i < step ? '\u2713' : String(i+1); });\n content.innerHTML = '<div class=\"section\">' + html + '</div>';\n const title = content.querySelector('h1'); if(title) { title.tabIndex = -1; title.focus({preventScroll:true}); }\n}\nfunction button(id, fn) { document.getElementById(id).onclick = async () => { if(busy) return; busy = true; const b = document.getElementById(id); b.disabled = true; error.hidden = true; try { await fn(); } catch(e) { showError(e); } finally { busy = false; if(b.isConnected) b.disabled = false; } }; }\nfunction welcome() {\n render(0, '<p class=\"eyebrow\">A good place to begin</p><h1>Your ideas.<br>A little more reach.</h1><p class=\"lead\">Connect this computer to bring AI conversations and a helping hand to Lucidity on your phone.</p>' + document.getElementById('art').innerHTML + '<div class=\"actions\"><button class=\"primary\" id=\"begin\">Let\u2019s get connected <span aria-hidden=\"true\">\u2192</span></button></div><p class=\"fine\" style=\"margin-top:18px\">Your tasks already work on their own. This adds the AI.</p>');\n button('begin', async () => { state = await request('begin'); connect(); });\n}\nfunction connect() {\n render(1, '<p class=\"eyebrow\">Connect your account</p><h1>Same you.<br>New possibilities.</h1><p class=\"lead\">Open Lucidity in a new tab, sign in, and confirm this computer. We\u2019ll take care of the connection.</p><div class=\"card\"><strong>' + escape(state.name) + '</strong><p class=\"code\">' + escape(state.code.match(/.{1,4}/g).join(' ')) + '</p></div><div class=\"actions\"><a class=\"primary\" href=\"' + escape(state.approvalUrl) + '\" target=\"_blank\" rel=\"noopener noreferrer\">Connect my account <span aria-hidden=\"true\">\u2197</span></a></div><p class=\"status\" style=\"margin-top:22px\" role=\"status\"><span class=\"dot\"></span>Waiting for your approval</p><p class=\"fine\">Keep this window open. The request expires in 10 minutes.</p><button class=\"secondary\" id=\"new\">Start a new request</button>');\n button('new', async () => { revision++; clearTimeout(timer); state = await request('begin', {restart:true}); connect(); });\n poll();\n}\nasync function poll() {\n const expected = revision;\n try {\n const value = await request('poll');\n if(expected !== revision) return;\n if(value.status === 'approved') { state.account = value.account; return providers(); }\n if(value.status === 'denied') { showError(new Error('This request was declined. Start a new request when you\u2019re ready.')); return; }\n error.hidden = true;\n } catch(e) { if(expected !== revision) return; showError(e); if(/expired|already used/i.test(e.message)) return; }\n timer = setTimeout(poll, 3000);\n}\nasync function providers() {\n render(2, '<p class=\"eyebrow\">Choose your AI</p><h1>A familiar<br>helping hand.</h1><p class=\"lead\">Use the subscription you already have. Lucid will use this provider for chat and coding.</p><p class=\"fine\">Connected as ' + escape(state.account.email) + '</p><div id=\"providers\"><p class=\"status\" role=\"status\"><span class=\"dot\"></span>Checking this computer\u2026</p></div><div class=\"actions\"><button class=\"primary\" id=\"continue\" disabled>Continue <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"refresh\">Check again</button></div><p class=\"fine\" style=\"margin-top:18px\">Checking sign-in does not use a model or confirm remaining allowance.</p>');\n button('refresh', refreshProviders);\n button('continue', async () => preferences());\n try { await refreshProviders(); } catch(e) { showError(e); }\n}\nasync function refreshProviders() {\n const expected = revision;\n const result = await request('providers');\n if(expected !== revision) return;\n const box = document.getElementById('providers'); box.innerHTML = '';\n for (const p of result.providers) {\n const ready = p.auth === 'authenticated';\n const card = document.createElement('button'); card.className = 'card choice'; card.type = 'button';\n card.setAttribute('aria-pressed', String(selected === p.id));\n card.innerHTML = '<span class=\"badge ' + (ready ? 'good' : '') + '\">' + (ready ? 'Signed in' : 'Needs attention') + '</span><strong>' + escape(p.label) + '</strong><p>' + (ready ? 'Your existing login is ready to use.' : escape(p.message)) + '</p>';\n card.onclick = () => { selected = p.id; sessionStorage.setItem('luciditySetupProvider', selected); box.querySelectorAll('button').forEach(b => b.setAttribute('aria-pressed','false')); card.setAttribute('aria-pressed','true'); document.getElementById('continue').disabled = !ready; };\n box.append(card);\n if(selected === p.id) document.getElementById('continue').disabled = !ready;\n }\n}\nfunction clientResults(rows) {\n return rows.map(c => '<div class=\"card\"><span class=\"badge ' + (c.status === 'configured' ? 'good' : '') + '\">' + (c.status === 'configured' ? 'Added' : 'Needs attention') + '</span><strong>' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></div>').join('');\n}\nasync function clientChoices() {\n const expected = revision;\n const result = await request('clients');\n if(expected !== revision) return;\n const box = document.getElementById('clients');\n box.innerHTML = '';\n for(const c of result.clients) {\n const available = c.status === 'available';\n const card = document.createElement('label'); card.className = 'card checkrow';\n card.innerHTML = '<input type=\"checkbox\" value=\"' + escape(c.id) + '\" ' + (!available ? 'disabled ' : '') + '><span><strong>Use Lucidity in ' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></span>';\n const input = card.querySelector('input');\n input.checked = c.status === 'configured' || (available && Array.isArray(choices.clients) && choices.clients.includes(c.id));\n input.onchange = () => { choices.clients = selectedClients(); sessionStorage.setItem('luciditySetupChoices', JSON.stringify(choices)); };\n box.append(card);\n }\n}\nfunction selectedClients() { return Array.from(document.querySelectorAll('#clients input:checked:not(:disabled)')).map(input => input.value); }\nconst clientSection = '<h2>Bring your tasks along.</h2><p>Access your Lucidity tasks, projects and comments in your own AI conversations. We\u2019ll add the connection for you.</p><div id=\"clients\"><p class=\"status\" role=\"status\">Checking your apps\u2026</p></div><p class=\"fine\">Your AI app may ask you to approve its tools. Local files and memories are not shared by this connection.</p>';\nasync function existingClients() {\n render(3, '<p class=\"eyebrow\">Already connected</p><h1>Lucidity, wherever<br>you think.</h1><p class=\"lead\">Add Lucidity to the AI apps you use on this computer. Your account is already connected.</p>' + clientSection + '<div class=\"actions\"><button class=\"primary\" id=\"add-clients\">Connect selected apps <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"refresh-clients\">Check again</button></div><div id=\"client-results\" aria-live=\"polite\"></div>');\n button('refresh-clients', clientChoices);\n button('add-clients', async () => {\n const selected = selectedClients();\n if(!selected.length) throw new Error('Choose an available app to connect.');\n const result = await request('configure-clients', {clients:selected});\n document.getElementById('client-results').innerHTML = clientResults(result.clients);\n await clientChoices();\n });\n await clientChoices();\n}\nasync function preferences() {\n render(3, '<p class=\"eyebrow\">Make it yours</p><h1>A little help.<br>On your terms.</h1><p class=\"lead\">Choose what Lucid can help with.</p><label class=\"card checkrow\"><input type=\"checkbox\" id=\"tasks\"><span><strong>Help with my tasks</strong><p>Let Lucid read and change your tasks, projects and comments when you ask.</p></span></label><label class=\"card checkrow\"><input type=\"checkbox\" id=\"schedules\"><span><strong>A daily rhythm</strong><p>Enable the 8am briefing, weekly review, journal processing and reminders. AI jobs use your provider allowance.</p></span></label><p class=\"fine\">Local folders and repositories stay private until you grant access.</p>' + clientSection + '<div class=\"notice\">For this preview, keep the terminal open while using AI. Closing your browser is fine. Background startup comes next.</div><div class=\"actions\"><button class=\"primary\" id=\"finish\">Finish setup <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"back\">Back</button></div>');\n for(const [id, field] of [['tasks','tasks'],['schedules','scheduledWork']]) { const input=document.getElementById(id); input.checked=choices[field] === true; input.onchange=()=>{choices[field]=input.checked;sessionStorage.setItem('luciditySetupChoices',JSON.stringify(choices));}; }\n button('back', providers);\n button('finish', async () => {\n const result = await request('finish', {provider:selected,tasks:document.getElementById('tasks').checked,scheduledWork:document.getElementById('schedules').checked,clients:selectedClients()});\n render(4, '<div class=\"seal\" aria-hidden=\"true\">\u2713</div><p class=\"eyebrow\">Setup complete</p><h1>A clearer day<br>starts here.</h1><p class=\"lead\">Your account and preferences are saved. Lucidity is starting on this computer.</p><div class=\"card\"><strong>Open Lucidity on your phone</strong><p>Go to Connect a computer. Once it shows this computer as ready, send your first message.</p></div>' + clientResults(result.clients || []) + '<p class=\"fine\">You can close this browser window. Keep the terminal open for AI to remain available.</p>');\n document.getElementById('cancel').hidden = true;\n });\n try { await clientChoices(); } catch(e) { document.getElementById('clients').textContent = 'Could not check your apps. You can add them later with lucidity setup-mcp.'; }\n}\nbutton('cancel', async () => { revision++; clearTimeout(timer); await request('cancel'); render(0,'<h1>See you when<br>you\u2019re ready.</h1><p class=\"lead\">Setup has stopped. You can keep using Lucidity on your phone and connect this computer later.</p>'); document.getElementById('cancel').hidden = true; });\n(async () => {\n try { state = await request('state'); if(state.existing) { await existingClients(); } else if(state.code) connect(); else welcome(); }\n catch(e) { showError(e); }\n})();\n";
|
|
2
|
+
export declare function localSetupPage(nonce: string): string;
|
|
3
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/setup/page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,gvXAkHvB,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAG3C"}
|