@lucenaone/coder 1.1.0 → 1.1.3
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/package.json +1 -1
- package/src/agent.js +9 -6
- package/src/main.js +12 -12
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -124,16 +124,14 @@ export class LucenaAgent {
|
|
|
124
124
|
|
|
125
125
|
// ── Listen for browser connect events ──
|
|
126
126
|
// When the browser connects, push the pre-built index immediately
|
|
127
|
-
const connectRef = ref(this.db, `tunnels/${this.tunnelId}/meta/browserConnected`);
|
|
128
127
|
onChildAdded(ref(this.db, `tunnels/${this.tunnelId}/browserConnect`), async (snapshot) => {
|
|
129
128
|
const data = snapshot.val();
|
|
130
129
|
if (!data) return;
|
|
131
130
|
remove(snapshot.ref);
|
|
132
131
|
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.pushIndexSnapshot(index);
|
|
132
|
+
// Index is guaranteed ready (awaited in start()), push immediately
|
|
133
|
+
if (this.indexData) {
|
|
134
|
+
this.pushIndexSnapshot(this.indexData);
|
|
137
135
|
}
|
|
138
136
|
});
|
|
139
137
|
|
|
@@ -152,6 +150,11 @@ export class LucenaAgent {
|
|
|
152
150
|
|
|
153
151
|
this.startWatcher();
|
|
154
152
|
this.connected = true;
|
|
153
|
+
|
|
154
|
+
// ── Wait for indexing to finish before opening the browser ──
|
|
155
|
+
// This guarantees the snapshot is ready the instant the browser connects
|
|
156
|
+
await this.indexPromise;
|
|
157
|
+
|
|
155
158
|
return this.tunnelId;
|
|
156
159
|
}
|
|
157
160
|
|
|
@@ -373,4 +376,4 @@ export class LucenaAgent {
|
|
|
373
376
|
|
|
374
377
|
this.connected = false;
|
|
375
378
|
}
|
|
376
|
-
}
|
|
379
|
+
}
|
package/src/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/main.js — CLI entry point for the Lucena agent
|
|
2
2
|
import { LucenaAgent } from './agent.js';
|
|
3
3
|
import { basename } from 'path';
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
// Standard ANSI Terminal Colors
|
|
7
7
|
const c = {
|
|
@@ -42,8 +42,6 @@ export async function main() {
|
|
|
42
42
|
console.log(` ${c.cyan}📍 Scoped to:${c.reset} ${cwd}`);
|
|
43
43
|
console.log(` ${c.yellow}🛡️ Safe Mode:${c.reset} ON by default (All edits require approval)`);
|
|
44
44
|
console.log(` ${c.dim}Optionally switch to YOLO on LucenaCoder.com${c.reset}\n`);
|
|
45
|
-
console.log(` ${c.dim}⏳ Indexing workspace...${c.reset}`);
|
|
46
|
-
console.log(` Starting tunnel...`);
|
|
47
45
|
|
|
48
46
|
const agent = new LucenaAgent(cwd);
|
|
49
47
|
|
|
@@ -58,7 +56,7 @@ export async function main() {
|
|
|
58
56
|
|
|
59
57
|
try {
|
|
60
58
|
const tunnelId = await agent.start();
|
|
61
|
-
console.log(
|
|
59
|
+
console.log(` ${c.green}✔ Tunnel active!${c.reset}\n`);
|
|
62
60
|
|
|
63
61
|
const idLabel = "Tunnel ID:";
|
|
64
62
|
const boxWidth = idLabel.length + tunnelId.length + 5;
|
|
@@ -69,17 +67,19 @@ export async function main() {
|
|
|
69
67
|
console.log(` ${c.dim}└${border}┘${c.reset}`);
|
|
70
68
|
|
|
71
69
|
const webUrl = `https://lucenacoder.com/?tunnel=${tunnelId}`;
|
|
72
|
-
console.log(`\n ${c.dim}Opening browser to your workspace...${c.reset}`);
|
|
73
70
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
const urlLabel = "URL:";
|
|
72
|
+
const urlBoxWidth = urlLabel.length + webUrl.length + 5;
|
|
73
|
+
const urlBorder = '─'.repeat(urlBoxWidth);
|
|
74
|
+
|
|
75
|
+
console.log(`\n ${c.dim}┌${urlBorder}┐${c.reset}`);
|
|
76
|
+
console.log(` ${c.dim}│${c.reset} ${c.dim}${urlLabel}${c.reset} ${c.cyan}${webUrl}${c.reset} ${c.dim}│${c.reset}`);
|
|
77
|
+
console.log(` ${c.dim}└${urlBorder}┘${c.reset}`);
|
|
79
78
|
|
|
80
|
-
console.log(`\n ${c.dim}
|
|
79
|
+
console.log(`\n ${c.dim}Open the URL above in your browser to connect.${c.reset}`);
|
|
80
|
+
console.log(` ${c.dim}Press Ctrl+C to disconnect${c.reset}\n`);
|
|
81
81
|
} catch (err) {
|
|
82
82
|
console.error(`\n ${c.yellow}✖ Failed to start tunnel: ${err.message}${c.reset}\n`);
|
|
83
83
|
process.exit(1);
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|