@kmugalkhod/lightcode 0.1.0 → 0.1.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.
- package/cli.js +1 -1
- package/lightcode.cjs +40 -0
- package/package.json +1 -1
- package/server.js +2 -1
package/cli.js
CHANGED
package/lightcode.cjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
const { spawnSync } = require("child_process");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const fs = require("fs");
|
|
9
|
+
const os = require("os");
|
|
9
10
|
|
|
10
11
|
// Check if Bun is available
|
|
11
12
|
try {
|
|
@@ -30,6 +31,44 @@ try {
|
|
|
30
31
|
process.exit(1);
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
// On Windows, inject system root certificates into Bun via NODE_EXTRA_CA_CERTS.
|
|
35
|
+
// Bun uses its own TLS stack and does not read the Windows certificate store,
|
|
36
|
+
// so corporate SSL proxies (which install their CA into Windows) are invisible
|
|
37
|
+
// to Bun unless we forward the certs explicitly.
|
|
38
|
+
if (process.platform === "win32" && !process.env.NODE_EXTRA_CA_CERTS) {
|
|
39
|
+
try {
|
|
40
|
+
const tmpPem = path.join(os.tmpdir(), "lightcode-win-ca.pem");
|
|
41
|
+
const tmpPs1 = path.join(os.tmpdir(), "lightcode-win-ca.ps1");
|
|
42
|
+
const escapedPem = tmpPem.replace(/\\/g, "\\\\");
|
|
43
|
+
const script = [
|
|
44
|
+
"$pem = ''",
|
|
45
|
+
"foreach ($store in @('Root', 'CA')) {",
|
|
46
|
+
" try {",
|
|
47
|
+
" foreach ($cert in (Get-ChildItem -Path \"Cert:\\LocalMachine\\$store\" -ErrorAction Stop)) {",
|
|
48
|
+
" $b64 = [Convert]::ToBase64String($cert.RawData)",
|
|
49
|
+
" $pem += \"-----BEGIN CERTIFICATE-----\\n\"",
|
|
50
|
+
" for ($i = 0; $i -lt $b64.Length; $i += 64) {",
|
|
51
|
+
" $pem += $b64.Substring($i, [Math]::Min(64, $b64.Length - $i)) + \"\\n\"",
|
|
52
|
+
" }",
|
|
53
|
+
" $pem += \"-----END CERTIFICATE-----\\n\"",
|
|
54
|
+
" }",
|
|
55
|
+
" } catch {}",
|
|
56
|
+
"}",
|
|
57
|
+
"[IO.File]::WriteAllText('" + escapedPem + "', $pem, [Text.Encoding]::ASCII)",
|
|
58
|
+
].join("\n");
|
|
59
|
+
fs.writeFileSync(tmpPs1, script, "utf8");
|
|
60
|
+
const r = spawnSync("powershell", [
|
|
61
|
+
"-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", tmpPs1,
|
|
62
|
+
], { stdio: "pipe" });
|
|
63
|
+
try { fs.unlinkSync(tmpPs1); } catch {}
|
|
64
|
+
if (r.status === 0 && fs.existsSync(tmpPem) && fs.statSync(tmpPem).size > 0) {
|
|
65
|
+
process.env.NODE_EXTRA_CA_CERTS = tmpPem;
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
// cert export failed — Bun uses its own bundled roots
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
33
72
|
// Get the directory of this launcher and find cli.js next to it
|
|
34
73
|
const launcherDir = path.dirname(process.argv[1]);
|
|
35
74
|
const cliPath = path.join(launcherDir, "cli.js");
|
|
@@ -45,6 +84,7 @@ try {
|
|
|
45
84
|
const args = process.argv.slice(2);
|
|
46
85
|
const result = spawnSync("bun", [cliPath, ...args], {
|
|
47
86
|
stdio: "inherit",
|
|
87
|
+
env: process.env,
|
|
48
88
|
});
|
|
49
89
|
process.exit(result.status || 0);
|
|
50
90
|
} catch (error) {
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -5382,7 +5382,8 @@ async function validatePersistedMessages(persistedMessages) {
|
|
|
5382
5382
|
messages: hydratePersistedMessages(persistedMessages)
|
|
5383
5383
|
});
|
|
5384
5384
|
if (!validationResult.success) {
|
|
5385
|
-
|
|
5385
|
+
console.error(`Persisted chat history failed validation, starting fresh: ${validationResult.error.message}`);
|
|
5386
|
+
return [];
|
|
5386
5387
|
}
|
|
5387
5388
|
return validationResult.data;
|
|
5388
5389
|
}
|