@standardagents/cli 0.37.3 → 0.37.5
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 +74 -27
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -175,14 +175,14 @@ async function waitForCliAuthCompletion(wsUrl, expiresAt) {
|
|
|
175
175
|
} catch {
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
|
-
const
|
|
178
|
+
const compatibilityPoll = setInterval(() => {
|
|
179
179
|
if (settled) return;
|
|
180
180
|
sendWsPoll(ws);
|
|
181
|
-
},
|
|
181
|
+
}, 5e3);
|
|
182
182
|
const timer = setTimeout(() => {
|
|
183
183
|
if (settled) return;
|
|
184
184
|
settled = true;
|
|
185
|
-
clearInterval(
|
|
185
|
+
clearInterval(compatibilityPoll);
|
|
186
186
|
closeSocket();
|
|
187
187
|
reject(new Error('Authentication timed out. Run "agents login" to restart.'));
|
|
188
188
|
}, timeoutMs);
|
|
@@ -190,7 +190,7 @@ async function waitForCliAuthCompletion(wsUrl, expiresAt) {
|
|
|
190
190
|
if (settled) return;
|
|
191
191
|
settled = true;
|
|
192
192
|
clearTimeout(timer);
|
|
193
|
-
clearInterval(
|
|
193
|
+
clearInterval(compatibilityPoll);
|
|
194
194
|
closeSocket();
|
|
195
195
|
fn();
|
|
196
196
|
};
|
|
@@ -254,7 +254,7 @@ function getScaffoldStandardAgentsVersion() {
|
|
|
254
254
|
if (process.env.STANDARDAGENTS_WORKSPACE === "1") {
|
|
255
255
|
return "workspace:*";
|
|
256
256
|
}
|
|
257
|
-
return "0.37.
|
|
257
|
+
return "0.37.5";
|
|
258
258
|
}
|
|
259
259
|
function findViteConfig(cwd) {
|
|
260
260
|
const candidates = ["vite.config.ts", "vite.config.js", "vite.config.mts", "vite.config.mjs"];
|
|
@@ -997,6 +997,8 @@ async function selectInitAuthModeWithInk(context = {}) {
|
|
|
997
997
|
}
|
|
998
998
|
|
|
999
999
|
// src/commands/init.ts
|
|
1000
|
+
var PlatformAuthWsTransportError = class extends Error {
|
|
1001
|
+
};
|
|
1000
1002
|
var DEFAULT_PLATFORM_ENDPOINT = "https://api.standardagents.ai";
|
|
1001
1003
|
var DEFAULT_ONBOARDING_URL = "https://platform.standardagents.ai/projects/new";
|
|
1002
1004
|
var KNOWN_PLATFORM_ONBOARDING_URLS = {
|
|
@@ -1552,7 +1554,7 @@ async function ensurePlatformAuth(options, quietLogs = false, context = {}) {
|
|
|
1552
1554
|
return { connected: true, mode: "standardagents" };
|
|
1553
1555
|
}
|
|
1554
1556
|
function getCliVersion() {
|
|
1555
|
-
return "0.37.
|
|
1557
|
+
return "0.37.5";
|
|
1556
1558
|
}
|
|
1557
1559
|
function getSipVersion() {
|
|
1558
1560
|
return "1.0.1";
|
|
@@ -1952,51 +1954,96 @@ async function waitForPlatformProjectStatus(statusUrl, expiresAt, options = {})
|
|
|
1952
1954
|
}
|
|
1953
1955
|
throw new Error("Timed out waiting for platform project creation");
|
|
1954
1956
|
}
|
|
1955
|
-
function waitForPlatformProjectWs(wsUrl, expiresAt) {
|
|
1957
|
+
function waitForPlatformProjectWs(wsUrl, expiresAt, options = {}) {
|
|
1956
1958
|
return new Promise((resolve, reject) => {
|
|
1957
1959
|
const WebSocketCtor = globalThis.WebSocket;
|
|
1958
1960
|
if (!WebSocketCtor) {
|
|
1959
|
-
reject(new
|
|
1961
|
+
reject(new PlatformAuthWsTransportError("This Node.js runtime does not provide WebSocket support"));
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
let socket;
|
|
1965
|
+
try {
|
|
1966
|
+
socket = new WebSocketCtor(wsUrl);
|
|
1967
|
+
} catch (error) {
|
|
1968
|
+
reject(new PlatformAuthWsTransportError(
|
|
1969
|
+
`Platform auth websocket could not open: ${error instanceof Error ? error.message : String(error)}`
|
|
1970
|
+
));
|
|
1960
1971
|
return;
|
|
1961
1972
|
}
|
|
1962
|
-
|
|
1973
|
+
let settled = false;
|
|
1974
|
+
let lastProgressKey = "";
|
|
1963
1975
|
const timeout = setTimeout(() => {
|
|
1976
|
+
settled = true;
|
|
1964
1977
|
socket.close();
|
|
1965
1978
|
reject(new Error("Timed out waiting for platform project creation"));
|
|
1966
1979
|
}, Math.max(1e3, expiresAt - Date.now()));
|
|
1980
|
+
const settle = (fn) => {
|
|
1981
|
+
if (settled) return;
|
|
1982
|
+
settled = true;
|
|
1983
|
+
clearTimeout(timeout);
|
|
1984
|
+
socket.close();
|
|
1985
|
+
fn();
|
|
1986
|
+
};
|
|
1967
1987
|
socket.addEventListener("open", () => {
|
|
1968
|
-
|
|
1988
|
+
try {
|
|
1989
|
+
socket.send(JSON.stringify({ type: "ready" }));
|
|
1990
|
+
} catch {
|
|
1991
|
+
settle(() => reject(new PlatformAuthWsTransportError("Platform auth websocket could not send ready")));
|
|
1992
|
+
}
|
|
1969
1993
|
});
|
|
1970
1994
|
socket.addEventListener("message", (event) => {
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1995
|
+
if (typeof event.data !== "string") {
|
|
1996
|
+
settle(() => reject(new PlatformAuthWsTransportError("Platform auth websocket sent a non-text frame")));
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
let message;
|
|
2000
|
+
try {
|
|
2001
|
+
message = JSON.parse(event.data);
|
|
2002
|
+
} catch {
|
|
2003
|
+
settle(() => reject(new PlatformAuthWsTransportError("Platform auth websocket sent invalid JSON")));
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
if (message.type === "progress" && message.progress?.message) {
|
|
2007
|
+
const progress = message.progress;
|
|
2008
|
+
const progressKey = `${progress.status}:${progress.message}:${progress.updated_at}`;
|
|
2009
|
+
if (progressKey !== lastProgressKey) {
|
|
2010
|
+
lastProgressKey = progressKey;
|
|
2011
|
+
options.onProgress?.(progress);
|
|
2012
|
+
}
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
const project = message.project;
|
|
2016
|
+
if (message.type === "authenticated" && project) {
|
|
2017
|
+
settle(() => resolve(project));
|
|
1977
2018
|
} else if (message.type === "expired" || message.type === "cancelled") {
|
|
1978
|
-
|
|
1979
|
-
socket.close();
|
|
1980
|
-
reject(new Error(
|
|
2019
|
+
settle(() => reject(new Error(
|
|
1981
2020
|
message.type === "expired" ? "Onboarding session expired. Run the init command again to start a new session." : "Onboarding was cancelled in the browser. Run the init command again when you are ready."
|
|
1982
|
-
));
|
|
2021
|
+
)));
|
|
1983
2022
|
} else if (message.command || message.bootstrap_code) {
|
|
1984
|
-
|
|
1985
|
-
socket.close();
|
|
1986
|
-
reject(new Error(LEGACY_BOOTSTRAP_RESPONSE_MESSAGE));
|
|
2023
|
+
settle(() => reject(new Error(LEGACY_BOOTSTRAP_RESPONSE_MESSAGE)));
|
|
1987
2024
|
}
|
|
1988
2025
|
});
|
|
1989
2026
|
socket.addEventListener("error", () => {
|
|
1990
|
-
|
|
1991
|
-
|
|
2027
|
+
settle(() => reject(new PlatformAuthWsTransportError("Platform auth websocket failed")));
|
|
2028
|
+
});
|
|
2029
|
+
socket.addEventListener("close", () => {
|
|
2030
|
+
settle(() => reject(new PlatformAuthWsTransportError("Platform auth websocket closed before completion")));
|
|
1992
2031
|
});
|
|
1993
2032
|
});
|
|
1994
2033
|
}
|
|
1995
2034
|
function waitForPlatformProject(session, onProgress) {
|
|
2035
|
+
if (session.ws_url) {
|
|
2036
|
+
return waitForPlatformProjectWs(session.ws_url, session.expires_at, { onProgress }).catch((error) => {
|
|
2037
|
+
if (error instanceof PlatformAuthWsTransportError && session.status_url && Date.now() < session.expires_at) {
|
|
2038
|
+
return waitForPlatformProjectStatus(session.status_url, session.expires_at, { onProgress });
|
|
2039
|
+
}
|
|
2040
|
+
throw error;
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
1996
2043
|
if (session.status_url) {
|
|
1997
2044
|
return waitForPlatformProjectStatus(session.status_url, session.expires_at, { onProgress });
|
|
1998
2045
|
}
|
|
1999
|
-
return
|
|
2046
|
+
return Promise.reject(new Error("Platform auth session provided no ws_url or status_url"));
|
|
2000
2047
|
}
|
|
2001
2048
|
function upsertEnvLine(lines, key, value) {
|
|
2002
2049
|
return [
|
|
@@ -5700,7 +5747,7 @@ async function settleStdinForInitHandoff(stdin = process.stdin) {
|
|
|
5700
5747
|
}
|
|
5701
5748
|
}
|
|
5702
5749
|
var program = new Command();
|
|
5703
|
-
program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.37.
|
|
5750
|
+
program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.37.5");
|
|
5704
5751
|
program.command("init [project-name]").description("Create a new Standard Agents project").option("-y, --yes", "Skip prompts and use defaults").option("--local", "Use local project scaffolding instead of browser platform onboarding").option("--cli", "Use classic line-by-line CLI prompts instead of the TUI wizard").option("--api-url <url>", "Standard Agents platform API URL").option("--endpoint <url>", "Platform API endpoint for auth/bootstrap exchange").option("--package-manager <manager>", "Package manager for generated project: npm, pnpm, yarn, or bun").option("--template <template>", "Vite template to use", "vanilla-ts").option("--workspace", "Install @standardagents packages as workspace:* (local pnpm workspace development)").option("--no-dev", "Clone and configure the project without starting the dev server").addOption(new Option("--bootstrap <code>", "Exchange a web onboarding bootstrap code")).action(init);
|
|
5705
5752
|
program.command("login").description("Authenticate this machine (or use --bootstrap for project bootstrap auth)").option("--bootstrap <code>", "Bootstrap code from web onboarding").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").option("--no-open", "Do not auto-open browser URL").action(login);
|
|
5706
5753
|
program.command("logout").description("Clear stored StandardAgents auth and local org-scoped project auth").option("--org <org-id-or-slug>", "Org ID or slug to logout (defaults to active org)").option("--endpoint <url>", "Platform API endpoint (default: https://api.standardagents.ai)").action(logout);
|