orquesta-cli 0.1.22 → 0.1.23

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/cli.js CHANGED
@@ -30,6 +30,7 @@ program
30
30
  .option('--debug', 'Enable debug logging')
31
31
  .option('--llm-log', 'Enable LLM logging')
32
32
  .option('--eval', 'Evaluation mode: read JSON from stdin, output NDJSON events')
33
+ .option('--login', 'Sign in to Orquesta via browser (no token paste required)')
33
34
  .option('--token <token>', 'Connect to Orquesta dashboard with CLI token')
34
35
  .option('--project <projectId>', 'Select project ID when connecting with token')
35
36
  .option('--switch-project [projectId]', 'Switch to a different project')
@@ -67,6 +68,14 @@ program
67
68
  const success = await switchProject(projectId);
68
69
  process.exit(success ? 0 : 1);
69
70
  }
71
+ if (options.login) {
72
+ const { browserLogin } = await import('./setup/browser-login.js');
73
+ const result = await browserLogin();
74
+ if (!result.success) {
75
+ console.error(chalk.red(result.error || 'Login failed'));
76
+ process.exit(1);
77
+ }
78
+ }
70
79
  if (options.token) {
71
80
  const result = await connectWithToken(options.token, options.project);
72
81
  if (!result.connected) {
@@ -0,0 +1,5 @@
1
+ export declare function browserLogin(): Promise<{
2
+ success: boolean;
3
+ error?: string;
4
+ }>;
5
+ //# sourceMappingURL=browser-login.d.ts.map
@@ -0,0 +1,90 @@
1
+ import { spawn } from 'child_process';
2
+ import { randomUUID } from 'crypto';
3
+ import chalk from 'chalk';
4
+ import { configManager } from '../core/config/config-manager.js';
5
+ import { syncOrquestaConfigs } from '../orquesta/config-sync.js';
6
+ import { logger } from '../utils/logger.js';
7
+ const ORQUESTA_API = process.env['ORQUESTA_API_URL'] || 'https://getorquesta.com';
8
+ const WS_URL = process.env['ORQUESTA_WS_URL']?.replace(/^wss?:\/\//, 'https://') || 'https://ws.orquesta.live';
9
+ const POLL_INTERVAL_MS = 2000;
10
+ const TIMEOUT_MS = 5 * 60 * 1000;
11
+ function openBrowser(url) {
12
+ const opener = process.platform === 'darwin' ? 'open' :
13
+ process.platform === 'win32' ? 'start' :
14
+ 'xdg-open';
15
+ try {
16
+ const child = spawn(opener, [url], { detached: true, stdio: 'ignore', shell: process.platform === 'win32' });
17
+ child.unref();
18
+ return true;
19
+ }
20
+ catch (err) {
21
+ logger.debug('Failed to open browser', { err });
22
+ return false;
23
+ }
24
+ }
25
+ async function pollOnce(sessionId) {
26
+ try {
27
+ const res = await fetch(`${WS_URL}/auth/result/${sessionId}`);
28
+ if (res.status !== 200)
29
+ return null;
30
+ const data = await res.json();
31
+ if (!data.token || !data.organizationId)
32
+ return null;
33
+ return {
34
+ token: data.token,
35
+ organizationId: data.organizationId,
36
+ organizationName: data.organizationName || 'Unknown',
37
+ };
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ export async function browserLogin() {
44
+ const sessionId = randomUUID();
45
+ const url = `${ORQUESTA_API}/cli/auth?session=${sessionId}`;
46
+ console.log();
47
+ console.log(chalk.cyan('Logging in to Orquesta…'));
48
+ console.log();
49
+ const opened = openBrowser(url);
50
+ if (opened) {
51
+ console.log(chalk.dim('Opened your browser. If nothing happened, copy this URL:'));
52
+ }
53
+ else {
54
+ console.log(chalk.yellow('Could not open a browser automatically. Open this URL on any device:'));
55
+ }
56
+ console.log(' ' + chalk.cyan(url));
57
+ console.log();
58
+ console.log(chalk.dim('Waiting for authorization…'));
59
+ const deadline = Date.now() + TIMEOUT_MS;
60
+ await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));
61
+ while (Date.now() < deadline) {
62
+ const hit = await pollOnce(sessionId);
63
+ if (hit) {
64
+ await configManager.setOrquestaConfig({
65
+ token: hit.token,
66
+ organizationId: hit.organizationId,
67
+ organizationName: hit.organizationName,
68
+ projectId: undefined,
69
+ projectName: undefined,
70
+ autoSync: true,
71
+ connectedAt: new Date().toISOString(),
72
+ });
73
+ console.log();
74
+ console.log(chalk.green(`✓ Logged in as ${hit.organizationName}`));
75
+ try {
76
+ const sync = await syncOrquestaConfigs();
77
+ if (sync.success) {
78
+ console.log(chalk.dim(` Synced ${sync.added + sync.updated} endpoint(s) from the dashboard.`));
79
+ }
80
+ }
81
+ catch (err) {
82
+ logger.debug('Initial sync after login failed', { err });
83
+ }
84
+ return { success: true };
85
+ }
86
+ await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));
87
+ }
88
+ return { success: false, error: 'Timed out waiting for authorization (5 min).' };
89
+ }
90
+ //# sourceMappingURL=browser-login.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orquesta-cli",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Orquesta CLI - AI-powered coding assistant with team collaboration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",