buildvia-agent-runner 1.0.0 → 1.0.1
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/auth.js +28 -4
- package/bin/buildvia-agent.js +1 -1
- package/package.json +1 -1
package/auth.js
CHANGED
|
@@ -17,11 +17,30 @@ const config = new Conf({
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const DEFAULT_WORKSPACE_URL = 'https://buildvia-preview.preview.emergentagent.com';
|
|
21
|
+
const WORKSPACE_ALIASES = {
|
|
22
|
+
sandbox: 'https://buildvia-preview.preview.emergentagent.com',
|
|
23
|
+
prod: 'https://techila.ai'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function normalizeWorkspaceUrl(workspaceUrl) {
|
|
21
27
|
if (!workspaceUrl) {
|
|
22
|
-
|
|
28
|
+
return process.env.BUILDVIA_WORKSPACE_URL || DEFAULT_WORKSPACE_URL;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (WORKSPACE_ALIASES[workspaceUrl]) {
|
|
32
|
+
return WORKSPACE_ALIASES[workspaceUrl];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (/^https?:\/\//.test(workspaceUrl)) {
|
|
36
|
+
return workspaceUrl;
|
|
23
37
|
}
|
|
24
|
-
|
|
38
|
+
|
|
39
|
+
return `https://${workspaceUrl}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function login(workspaceUrl) {
|
|
43
|
+
workspaceUrl = normalizeWorkspaceUrl(workspaceUrl).replace(/\/$/, '');
|
|
25
44
|
|
|
26
45
|
console.log(chalk.cyan('\nStarting device authorization flow...\n'));
|
|
27
46
|
|
|
@@ -33,7 +52,12 @@ export async function login(workspaceUrl) {
|
|
|
33
52
|
});
|
|
34
53
|
|
|
35
54
|
if (!deviceCodeRes.ok) {
|
|
36
|
-
|
|
55
|
+
const endpoint = `${workspaceUrl}/api/agent-runner/device-code`;
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Failed to request device code from ${endpoint}: ${deviceCodeRes.statusText}. ` +
|
|
58
|
+
`Check that your workspace URL is correct and that the app exposes /api/agent-runner/device-code. ` +
|
|
59
|
+
`Use 'buildvia-agent login sandbox' or 'buildvia-agent login prod' if you want the built-in app URLs.`
|
|
60
|
+
);
|
|
37
61
|
}
|
|
38
62
|
|
|
39
63
|
const { deviceCode, userCode, verificationUrl, interval } = await deviceCodeRes.json();
|
package/bin/buildvia-agent.js
CHANGED
|
@@ -19,7 +19,7 @@ program
|
|
|
19
19
|
// Login command
|
|
20
20
|
program
|
|
21
21
|
.command('login [workspace-url]')
|
|
22
|
-
.description('Authenticate to your Buildvia workspace')
|
|
22
|
+
.description('Authenticate to your Buildvia workspace (default: preview sandbox). Use alias sandbox or prod.')
|
|
23
23
|
.action(async (workspaceUrl) => {
|
|
24
24
|
try {
|
|
25
25
|
await login(workspaceUrl);
|