@meistrari/tela-cli 0.7.50 → 0.7.52
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 +30 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1562,10 +1562,12 @@ var require_auth2 = __commonJS({
|
|
|
1562
1562
|
payload = null;
|
|
1563
1563
|
}
|
|
1564
1564
|
if (!response.ok) {
|
|
1565
|
+
const summary = payload?.error ?? `Tela data-token exchange failed with status ${response.status}.`;
|
|
1566
|
+
const isStaleSession = isStaleCredentialStatus(response.status) || isStaleTokenMessage(summary);
|
|
1565
1567
|
throw (0, errors_1.createUserFacingError)({
|
|
1566
1568
|
code: "data_token_exchange_failed",
|
|
1567
|
-
summary:
|
|
1568
|
-
fixes: ["Sign in with Dock again if the saved session is stale."],
|
|
1569
|
+
summary: isStaleSession ? "Tela workspace connection expired. Connect the workspace again, then rerun setup." : summary,
|
|
1570
|
+
fixes: isStaleSession ? ["Reconnect the Tela environment in Dock to refresh the saved workspace credential."] : ["Sign in with Dock again if the saved session is stale."],
|
|
1569
1571
|
evidence: responseText ? [responseText] : []
|
|
1570
1572
|
});
|
|
1571
1573
|
}
|
|
@@ -1608,7 +1610,18 @@ var require_auth2 = __commonJS({
|
|
|
1608
1610
|
fixes: ["Run the command through `tela agent ...` so local-config context resolution can run first."]
|
|
1609
1611
|
});
|
|
1610
1612
|
}
|
|
1611
|
-
|
|
1613
|
+
try {
|
|
1614
|
+
credential = await (0, tela_local_config_1.refreshUserSessionCredential)(resolvedEnvironment, credentialRef, credential, credentials);
|
|
1615
|
+
} catch (error) {
|
|
1616
|
+
if (isStaleWorkspaceConnectionError(error)) {
|
|
1617
|
+
throw (0, errors_1.createUserFacingError)({
|
|
1618
|
+
code: "workspace_connection_expired",
|
|
1619
|
+
summary: "Tela workspace connection expired. Connect the workspace again, then rerun setup.",
|
|
1620
|
+
fixes: ["Reconnect the Tela environment in Dock to refresh the saved workspace credential."]
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
throw error;
|
|
1624
|
+
}
|
|
1612
1625
|
config.credential = credential;
|
|
1613
1626
|
}
|
|
1614
1627
|
if (!credential.accessToken) {
|
|
@@ -1620,6 +1633,20 @@ var require_auth2 = __commonJS({
|
|
|
1620
1633
|
}
|
|
1621
1634
|
return await exchangeDataToken(config, credential.accessToken, fetchFn);
|
|
1622
1635
|
}
|
|
1636
|
+
function isStaleWorkspaceConnectionError(error) {
|
|
1637
|
+
if (!error || typeof error !== "object")
|
|
1638
|
+
return false;
|
|
1639
|
+
const code = String(error.code ?? "");
|
|
1640
|
+
const status = Number(error.status ?? 0);
|
|
1641
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1642
|
+
return code === "resource_not_found" || isStaleCredentialStatus(status) || isStaleTokenMessage(message);
|
|
1643
|
+
}
|
|
1644
|
+
function isStaleCredentialStatus(status) {
|
|
1645
|
+
return status === 401 || status === 404;
|
|
1646
|
+
}
|
|
1647
|
+
function isStaleTokenMessage(message) {
|
|
1648
|
+
return /refresh token not found|token not found|token expired|expired token|invalid[_\s-]?token|token[_\s-]?invalid|invalid[_\s-]?grant/i.test(message);
|
|
1649
|
+
}
|
|
1623
1650
|
async function buildAgentApiHeaders(config, options = {}) {
|
|
1624
1651
|
const dataToken = await resolveAgentApiDataToken(config, options);
|
|
1625
1652
|
return {
|