@synkro-sh/cli 1.6.70 → 1.6.72
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/bootstrap.js +63 -10
- package/dist/bootstrap.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -9687,11 +9687,12 @@ function captureClaudeSetupToken() {
|
|
|
9687
9687
|
reject(new Error(`claude setup-token exited with code ${code}`));
|
|
9688
9688
|
return;
|
|
9689
9689
|
}
|
|
9690
|
+
const stripToToken = (s) => s.replace(/\x1B\[[0-9;?]*[a-zA-Z]/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/[\s\x00-\x1F\x7F]/g, "");
|
|
9690
9691
|
const yellowRe = /\x1B\[38;2;255;193;7m([^\x1B]*)/g;
|
|
9691
9692
|
let yellow = "";
|
|
9692
9693
|
let m;
|
|
9693
9694
|
while ((m = yellowRe.exec(raw)) !== null) yellow += m[1];
|
|
9694
|
-
const
|
|
9695
|
+
const yToken = stripToToken(yellow);
|
|
9695
9696
|
let lineMatch = "";
|
|
9696
9697
|
const clean = raw.replace(/\x1B\[[0-9;?]*[a-zA-Z]/g, "").replace(/\x1B\][^\x07]*\x07/g, "");
|
|
9697
9698
|
const lines = clean.split("\n").map((l) => l.trim());
|
|
@@ -9703,13 +9704,13 @@ function captureClaudeSetupToken() {
|
|
|
9703
9704
|
lineMatch = tok;
|
|
9704
9705
|
break;
|
|
9705
9706
|
}
|
|
9706
|
-
const
|
|
9707
|
-
const
|
|
9708
|
-
if (!
|
|
9709
|
-
reject(new Error(`Could not
|
|
9707
|
+
const valid = (t) => /^sk-ant-oat01-[A-Za-z0-9_-]{40,}$/.test(t);
|
|
9708
|
+
const token = valid(yToken) ? yToken : valid(lineMatch) ? lineMatch : "";
|
|
9709
|
+
if (!token) {
|
|
9710
|
+
reject(new Error(`Could not capture a full token from claude setup-token output (file=${raw.length}b, yellow=${yellow.length}b, yToken=${yToken.length}b)`));
|
|
9710
9711
|
return;
|
|
9711
9712
|
}
|
|
9712
|
-
resolve4(
|
|
9713
|
+
resolve4(token);
|
|
9713
9714
|
});
|
|
9714
9715
|
});
|
|
9715
9716
|
}
|
|
@@ -10053,6 +10054,7 @@ var init_setupGithub = __esm({
|
|
|
10053
10054
|
var install_exports = {};
|
|
10054
10055
|
__export(install_exports, {
|
|
10055
10056
|
detectGitRepo: () => detectGitRepo2,
|
|
10057
|
+
getOrMintCloudToken: () => getOrMintCloudToken,
|
|
10056
10058
|
installCommand: () => installCommand,
|
|
10057
10059
|
parseArgs: () => parseArgs,
|
|
10058
10060
|
reconcileDeployLocation: () => reconcileDeployLocation,
|
|
@@ -10384,7 +10386,7 @@ function writeConfigEnv(opts) {
|
|
|
10384
10386
|
`SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
|
|
10385
10387
|
`SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
|
|
10386
10388
|
`SYNKRO_INFERENCE=${shellQuoteSingle(safeInference)}`,
|
|
10387
|
-
`SYNKRO_VERSION=${shellQuoteSingle("1.6.
|
|
10389
|
+
`SYNKRO_VERSION=${shellQuoteSingle("1.6.72")}`
|
|
10388
10390
|
];
|
|
10389
10391
|
if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle(safeSynkroBin)}`);
|
|
10390
10392
|
if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
|
|
@@ -10404,6 +10406,38 @@ function writeConfigEnv(opts) {
|
|
|
10404
10406
|
writeFileSync8(CONFIG_PATH2, lines.join("\n"), "utf-8");
|
|
10405
10407
|
chmodSync2(CONFIG_PATH2, 384);
|
|
10406
10408
|
}
|
|
10409
|
+
function jwtExpired(token) {
|
|
10410
|
+
try {
|
|
10411
|
+
const p = JSON.parse(Buffer.from(token.split(".")[1], "base64url").toString("utf-8"));
|
|
10412
|
+
if (!p?.exp) return true;
|
|
10413
|
+
return Date.now() > p.exp * 1e3 - 5 * 60 * 1e3;
|
|
10414
|
+
} catch {
|
|
10415
|
+
return true;
|
|
10416
|
+
}
|
|
10417
|
+
}
|
|
10418
|
+
async function getOrMintCloudToken(gatewayUrl) {
|
|
10419
|
+
assertGatewayAllowed(gatewayUrl);
|
|
10420
|
+
let stored = "";
|
|
10421
|
+
try {
|
|
10422
|
+
stored = readFileSync10(CLOUD_JWT_PATH, "utf-8").trim();
|
|
10423
|
+
} catch {
|
|
10424
|
+
}
|
|
10425
|
+
if (stored && !jwtExpired(stored)) return stored;
|
|
10426
|
+
await refreshToken().catch(() => false);
|
|
10427
|
+
const jwt2 = getAccessToken();
|
|
10428
|
+
if (!jwt2) throw new Error("Not authenticated \u2014 run `synkro login`");
|
|
10429
|
+
const resp = await fetch(`${gatewayUrl}/api/v1/cli/cloud-token`, {
|
|
10430
|
+
method: "POST",
|
|
10431
|
+
headers: { Authorization: `Bearer ${jwt2}`, "Content-Type": "application/json" }
|
|
10432
|
+
});
|
|
10433
|
+
if (!resp.ok) {
|
|
10434
|
+
const t = await resp.text().catch(() => "");
|
|
10435
|
+
throw new Error(`cloud-token mint failed (${resp.status}): ${t.slice(0, 200)}`);
|
|
10436
|
+
}
|
|
10437
|
+
const { token } = await resp.json();
|
|
10438
|
+
writeFileSync8(CLOUD_JWT_PATH, token + "\n", { mode: 384 });
|
|
10439
|
+
return token;
|
|
10440
|
+
}
|
|
10407
10441
|
async function provisionCloudContainer(opts) {
|
|
10408
10442
|
let setupToken;
|
|
10409
10443
|
try {
|
|
@@ -10430,10 +10464,16 @@ async function provisionCloudContainer(opts) {
|
|
|
10430
10464
|
} catch {
|
|
10431
10465
|
}
|
|
10432
10466
|
}
|
|
10467
|
+
let cloudJwt = opts.jwt;
|
|
10468
|
+
try {
|
|
10469
|
+
cloudJwt = await getOrMintCloudToken(opts.gatewayUrl);
|
|
10470
|
+
} catch (e) {
|
|
10471
|
+
console.warn(` (cloud token unavailable, using session token: ${e.message})`);
|
|
10472
|
+
}
|
|
10433
10473
|
try {
|
|
10434
10474
|
const resp = await fetch(`${opts.gatewayUrl}/api/v1/cli/cloud-provision`, {
|
|
10435
10475
|
method: "POST",
|
|
10436
|
-
headers: { "Authorization": `Bearer ${
|
|
10476
|
+
headers: { "Authorization": `Bearer ${cloudJwt}`, "Content-Type": "application/json" },
|
|
10437
10477
|
body: JSON.stringify({
|
|
10438
10478
|
org_id: opts.orgId,
|
|
10439
10479
|
user_id: opts.userId,
|
|
@@ -10520,6 +10560,16 @@ async function verifyCloudGrader(jwt2) {
|
|
|
10520
10560
|
return false;
|
|
10521
10561
|
}
|
|
10522
10562
|
console.log(` \u2713 ${healthy} Claude worker(s) healthy`);
|
|
10563
|
+
console.log(" Running smoke grade (a worker scores a known-risky edit; up to 120s)...");
|
|
10564
|
+
const started = Date.now();
|
|
10565
|
+
const ticker = setInterval(() => {
|
|
10566
|
+
const secs = Math.round((Date.now() - started) / 1e3);
|
|
10567
|
+
process.stdout.write(`\r \u2026grading (${secs}s elapsed) `);
|
|
10568
|
+
}, 1e3);
|
|
10569
|
+
const stopTicker = () => {
|
|
10570
|
+
clearInterval(ticker);
|
|
10571
|
+
process.stdout.write("\r\x1B[2K");
|
|
10572
|
+
};
|
|
10523
10573
|
try {
|
|
10524
10574
|
const probe = 'Grade this edit. File: t.py. Change: os.system(request.args["cmd"])';
|
|
10525
10575
|
const r = await fetch(`${base}/grade/submit`, {
|
|
@@ -10528,6 +10578,7 @@ async function verifyCloudGrader(jwt2) {
|
|
|
10528
10578
|
body: JSON.stringify({ role: "grade-edit", payload: probe, content: probe, agent_kind: "claude_code" }),
|
|
10529
10579
|
signal: AbortSignal.timeout(12e4)
|
|
10530
10580
|
});
|
|
10581
|
+
stopTicker();
|
|
10531
10582
|
const raw = await r.text();
|
|
10532
10583
|
let body = {};
|
|
10533
10584
|
try {
|
|
@@ -10551,6 +10602,7 @@ async function verifyCloudGrader(jwt2) {
|
|
|
10551
10602
|
await printWorkerDebug(base, jwt2);
|
|
10552
10603
|
return false;
|
|
10553
10604
|
} catch (e) {
|
|
10605
|
+
stopTicker();
|
|
10554
10606
|
const reason = e?.name === "TimeoutError" ? "the grade never returned within 120s (worker hung \u2014 usually claude auth)" : `the request failed (${e?.message || "network"})`;
|
|
10555
10607
|
console.warn(` \u2717 smoke grade FAILED: ${reason}.`);
|
|
10556
10608
|
console.warn(" The container is provisioned but a grade does not complete; re-run `synkro install` \u2192 cloud.\n");
|
|
@@ -11871,7 +11923,7 @@ async function syncTranscriptsBulk(gatewayUrl, token, repo) {
|
|
|
11871
11923
|
}
|
|
11872
11924
|
return { sessions: totalSessions, messages: totalMessages };
|
|
11873
11925
|
}
|
|
11874
|
-
var SYNKRO_DIR5, HOOKS_DIR, BIN_DIR, CONFIG_PATH2, MCP_STDIO_PROXY_SRC, OFFSETS_DIR;
|
|
11926
|
+
var SYNKRO_DIR5, HOOKS_DIR, BIN_DIR, CONFIG_PATH2, MCP_STDIO_PROXY_SRC, OFFSETS_DIR, CLOUD_JWT_PATH;
|
|
11875
11927
|
var init_install = __esm({
|
|
11876
11928
|
"cli/commands/install.ts"() {
|
|
11877
11929
|
"use strict";
|
|
@@ -12005,6 +12057,7 @@ rl.on('line', async (line) => {
|
|
|
12005
12057
|
});
|
|
12006
12058
|
`;
|
|
12007
12059
|
OFFSETS_DIR = join10(SYNKRO_DIR5, ".transcript-offsets");
|
|
12060
|
+
CLOUD_JWT_PATH = join10(SYNKRO_DIR5, ".cloud-jwt");
|
|
12008
12061
|
}
|
|
12009
12062
|
});
|
|
12010
12063
|
|
|
@@ -13978,7 +14031,7 @@ var args = process.argv.slice(2);
|
|
|
13978
14031
|
var cmd = args[0] || "";
|
|
13979
14032
|
var subArgs = args.slice(1);
|
|
13980
14033
|
function printVersion() {
|
|
13981
|
-
console.log("1.6.
|
|
14034
|
+
console.log("1.6.72");
|
|
13982
14035
|
}
|
|
13983
14036
|
function printHelp2() {
|
|
13984
14037
|
console.log(`Synkro CLI \u2014 runtime safety for AI coding agents
|