drift-ml 0.1.12 → 0.1.13
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/bin/drift.js +43 -3
- package/package.json +1 -1
package/bin/drift.js
CHANGED
|
@@ -17,7 +17,10 @@ const http = require("http");
|
|
|
17
17
|
const isWindows = process.platform === "win32";
|
|
18
18
|
const ENGINE_PORT = process.env.DRIFT_ENGINE_PORT || "8000";
|
|
19
19
|
// Pinned tag: draft releases are invisible to /releases/latest.
|
|
20
|
-
const
|
|
20
|
+
const ENGINE_TAG = "v0.1.1";
|
|
21
|
+
const GITHUB_REPO = "lakshitsachdeva/intent2model";
|
|
22
|
+
const ENGINE_BASE_URL = process.env.DRIFT_ENGINE_BASE_URL || `https://github.com/${GITHUB_REPO}/releases/download/${ENGINE_TAG}`;
|
|
23
|
+
const GITHUB_API_RELEASE = `https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${ENGINE_TAG}`;
|
|
21
24
|
const HEALTH_URL = `http://127.0.0.1:${ENGINE_PORT}/health`;
|
|
22
25
|
const HEALTH_TIMEOUT_MS = 2000;
|
|
23
26
|
const HEALTH_POLL_MS = 500;
|
|
@@ -62,10 +65,44 @@ function fetchOk(url) {
|
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
const API_HEADERS = { "User-Agent": "Drift-Engine-Launcher/1.0", Accept: "application/vnd.github+json" };
|
|
69
|
+
const DOWNLOAD_HEADERS = {
|
|
70
|
+
"User-Agent": "Drift-Engine-Launcher/1.0",
|
|
71
|
+
Accept: "application/octet-stream",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Resolve GitHub release asset to API download URL (browser_download_url returns 404 for scripts).
|
|
75
|
+
function getGitHubAssetUrl(assetName) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
const req = https.get(GITHUB_API_RELEASE, { headers: API_HEADERS }, (res) => {
|
|
78
|
+
if (res.statusCode !== 200) {
|
|
79
|
+
reject(new Error(`Release not found: ${res.statusCode}`));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let body = "";
|
|
83
|
+
res.on("data", (chunk) => { body += chunk; });
|
|
84
|
+
res.on("end", () => {
|
|
85
|
+
try {
|
|
86
|
+
const data = JSON.parse(body);
|
|
87
|
+
const asset = (data.assets || []).find((a) => a.name === assetName);
|
|
88
|
+
if (!asset || !asset.url) {
|
|
89
|
+
reject(new Error(`Asset not found: ${assetName}`));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
resolve(asset.url);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
reject(e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
req.on("error", reject);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
65
102
|
function downloadFile(url, destPath) {
|
|
66
103
|
return new Promise((resolve, reject) => {
|
|
67
104
|
const client = url.startsWith("https") ? https : http;
|
|
68
|
-
const req = client.get(url, (res) => {
|
|
105
|
+
const req = client.get(url, { headers: DOWNLOAD_HEADERS }, (res) => {
|
|
69
106
|
const redirect = res.statusCode >= 301 && res.statusCode <= 302 && res.headers.location;
|
|
70
107
|
if (redirect) {
|
|
71
108
|
downloadFile(redirect, destPath).then(resolve).catch(reject);
|
|
@@ -117,7 +154,10 @@ async function ensureEngine() {
|
|
|
117
154
|
const { plat, arch } = getPlatformKey();
|
|
118
155
|
const ext = isWindows ? ".exe" : "";
|
|
119
156
|
const asset = `drift-engine-${plat}-${arch}${ext}`;
|
|
120
|
-
const
|
|
157
|
+
const isDefaultGitHub = !process.env.DRIFT_ENGINE_BASE_URL;
|
|
158
|
+
const url = isDefaultGitHub
|
|
159
|
+
? await getGitHubAssetUrl(asset)
|
|
160
|
+
: `${ENGINE_BASE_URL.replace(/\/$/, "")}/${asset}`;
|
|
121
161
|
process.stderr.write(`drift: Downloading engine (${asset})...\n`);
|
|
122
162
|
try {
|
|
123
163
|
await downloadFile(url, binPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drift-ml",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Drift — terminal-first, chat-based AutoML. Same engine as the web app. On first run: downloads and starts the engine locally (never exposes engine source).",
|
|
5
5
|
"bin": {
|
|
6
6
|
"drift": "./bin/drift.js"
|