@kvell007/embed-labs-cli 0.1.0-alpha.14 → 0.1.0-alpha.16
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/dist/index.js +51 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1352,27 +1352,45 @@ function isApiResponse(value) {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
async function bridgeGet(path) {
|
|
1354
1354
|
const response = await fetch(`${DEFAULT_BRIDGE_URL}${path}`, {
|
|
1355
|
-
headers: bridgeHeaders()
|
|
1355
|
+
headers: bridgeHeaders("GET", path, "")
|
|
1356
1356
|
});
|
|
1357
1357
|
return await response.json();
|
|
1358
1358
|
}
|
|
1359
1359
|
async function bridgePost(path, body) {
|
|
1360
|
+
const bodyText = JSON.stringify(body);
|
|
1360
1361
|
const response = await fetch(`${DEFAULT_BRIDGE_URL}${path}`, {
|
|
1361
1362
|
method: "POST",
|
|
1362
|
-
headers: bridgeHeaders({ "content-type": "application/json" }),
|
|
1363
|
-
body:
|
|
1363
|
+
headers: bridgeHeaders("POST", path, bodyText, { "content-type": "application/json" }),
|
|
1364
|
+
body: bodyText
|
|
1364
1365
|
});
|
|
1365
1366
|
return await response.json();
|
|
1366
1367
|
}
|
|
1367
|
-
function bridgeHeaders(base = {}) {
|
|
1368
|
+
function bridgeHeaders(method, path, bodyText, base = {}) {
|
|
1368
1369
|
const token = process.env.EMBED_BRIDGE_TOKEN?.trim();
|
|
1369
1370
|
if (!token) {
|
|
1370
1371
|
return base;
|
|
1371
1372
|
}
|
|
1372
|
-
|
|
1373
|
+
const headers = {
|
|
1373
1374
|
...base,
|
|
1374
1375
|
authorization: `Bearer ${token}`
|
|
1375
1376
|
};
|
|
1377
|
+
addBridgeRequestSignature(headers, method, path, bodyText, token);
|
|
1378
|
+
return headers;
|
|
1379
|
+
}
|
|
1380
|
+
function addBridgeRequestSignature(headers, method, pathWithQuery, bodyText, token) {
|
|
1381
|
+
if (process.env.EMBED_BRIDGE_SIGNING === "0") {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
const timestamp = String(Math.floor(Date.now() / 1000));
|
|
1385
|
+
const nonce = randomBytes(16).toString("hex");
|
|
1386
|
+
const bodySha256 = createHash("sha256").update(bodyText).digest("hex");
|
|
1387
|
+
const keyId = createHash("sha256").update(token).digest("hex").slice(0, 16);
|
|
1388
|
+
const canonical = cloudRequestCanonicalString(method, pathWithQuery, timestamp, nonce, bodySha256);
|
|
1389
|
+
headers["x-embed-key-id"] = keyId;
|
|
1390
|
+
headers["x-embed-timestamp"] = timestamp;
|
|
1391
|
+
headers["x-embed-nonce"] = nonce;
|
|
1392
|
+
headers["x-embed-body-sha256"] = bodySha256;
|
|
1393
|
+
headers["x-embed-signature"] = createHmac("sha256", token).update(canonical).digest("hex");
|
|
1376
1394
|
}
|
|
1377
1395
|
async function cloudGet(path) {
|
|
1378
1396
|
return await cloudRequest("GET", path);
|
|
@@ -1896,7 +1914,7 @@ async function cleanupLegacyCodexPluginRemnants(targetRoot) {
|
|
|
1896
1914
|
];
|
|
1897
1915
|
legacyPaths.push(...await discoverLegacyCodexCachePaths(targetRoot));
|
|
1898
1916
|
if (resolve(targetRoot) === resolve(defaultCodexPluginRoot())) {
|
|
1899
|
-
legacyPaths.push(join(defaultCodexHome(), ".tmp", "plugins"), join(defaultCodexHome(), ".tmp", "plugins.sha"), join(defaultCodexHome(), "memories", "skills", "dbt-agent-live-board-ops"), join(defaultCodexHome(), "memories", "skills", "dbt-agent-platform-plugin-maintenance"));
|
|
1917
|
+
legacyPaths.push(join(defaultCodexHome(), ".tmp", "plugins"), join(defaultCodexHome(), ".tmp", "plugins.sha"), join(defaultCodexHome(), "skills", "dbt-agent"), join(defaultCodexHome(), "skills", "development-board-toolchain-dev"), join(defaultCodexHome(), "memories", "skills", "dbt-agent-live-board-ops"), join(defaultCodexHome(), "memories", "skills", "dbt-agent-platform-plugin-maintenance"));
|
|
1900
1918
|
}
|
|
1901
1919
|
for (const candidate of legacyPaths) {
|
|
1902
1920
|
try {
|
|
@@ -2023,6 +2041,8 @@ async function cleanupLegacyCodexTextFile(filePath, warnings) {
|
|
|
2023
2041
|
function isLegacyCodexHistoryMention(line) {
|
|
2024
2042
|
return line.includes("plugin://dbt-agent@plugins")
|
|
2025
2043
|
|| line.includes("plugin://dbt-agent@embed-labs")
|
|
2044
|
+
|| line.includes("development-board-toolchain-dev")
|
|
2045
|
+
|| line.includes("development-board-toolchain")
|
|
2026
2046
|
|| /dbt-agent/i.test(line);
|
|
2027
2047
|
}
|
|
2028
2048
|
function removeLegacyCodexConfigTables(text) {
|
|
@@ -2085,6 +2105,7 @@ async function cleanupLegacyOpenCodePluginRemnants(targetRoot, globalInstall) {
|
|
|
2085
2105
|
];
|
|
2086
2106
|
if (globalInstall) {
|
|
2087
2107
|
legacyPaths.push(join(targetRoot, "plugins", "embed-labs.js"));
|
|
2108
|
+
legacyPaths.push(...await discoverLegacyOpenCodeBackupPaths(targetRoot, warnings));
|
|
2088
2109
|
}
|
|
2089
2110
|
for (const candidate of legacyPaths) {
|
|
2090
2111
|
try {
|
|
@@ -2103,6 +2124,30 @@ async function cleanupLegacyOpenCodePluginRemnants(targetRoot, globalInstall) {
|
|
|
2103
2124
|
...(warnings.length > 0 ? { warnings } : {})
|
|
2104
2125
|
};
|
|
2105
2126
|
}
|
|
2127
|
+
async function discoverLegacyOpenCodeBackupPaths(targetRoot, warnings) {
|
|
2128
|
+
const paths = [];
|
|
2129
|
+
try {
|
|
2130
|
+
const entries = await readdir(targetRoot, { withFileTypes: true });
|
|
2131
|
+
for (const entry of entries) {
|
|
2132
|
+
if (!entry.isFile() || !entry.name.includes(".bak"))
|
|
2133
|
+
continue;
|
|
2134
|
+
const filePath = join(targetRoot, entry.name);
|
|
2135
|
+
try {
|
|
2136
|
+
const current = await readFile(filePath, "utf8");
|
|
2137
|
+
if (current.includes("dbt-agent") || current.includes("development-board-toolchain")) {
|
|
2138
|
+
paths.push(filePath);
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
catch (error) {
|
|
2142
|
+
warnings.push(`Could not inspect legacy OpenCode backup ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
catch {
|
|
2147
|
+
return paths;
|
|
2148
|
+
}
|
|
2149
|
+
return paths;
|
|
2150
|
+
}
|
|
2106
2151
|
function legacyOpenCodeCleanupWarning(cleanup) {
|
|
2107
2152
|
const parts = [];
|
|
2108
2153
|
if (cleanup.legacy_removed_paths.length > 0) {
|