@ogment-ai/cli 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -50,14 +50,6 @@ Default device-code login.
50
50
  ogment auth login
51
51
  ```
52
52
 
53
- ### `ogment auth login --browser`
54
-
55
- Fallback browser callback flow.
56
-
57
- ```bash
58
- ogment auth login --browser
59
- ```
60
-
61
53
  ### `ogment auth login --api-key <key>`
62
54
 
63
55
  Last-resort path for CI/unattended setups.
@@ -119,7 +111,6 @@ ogment status
119
111
  --api-key <key> API key override
120
112
  --human Human-readable output
121
113
  --quiet Suppress non-essential output
122
- --non-interactive Disable interactive behavior
123
114
  --yes Assume yes for confirmations
124
115
  ```
125
116
 
@@ -7,7 +7,6 @@ export declare const cliCommands: {
7
7
  readonly help: () => string;
8
8
  readonly login: () => string;
9
9
  readonly loginWithApiKeyRedacted: () => string;
10
- readonly loginWithBrowser: () => string;
11
10
  readonly logout: () => string;
12
11
  readonly status: () => string;
13
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW;;6BAEV,MAAM;8BACL,MAAM;gDACY,MAAM;yCACb,MAAM;+BAChB,MAAM;+BACN,MAAM;;;gCAGL,MAAM;oCACA,MAAM,KAAG,MAAM;oCACf,4BAA4B,KAAG,MAAM;kCAOvC,MAAM,YAAY,MAAM,WAAW;YAAE,OAAO,EAAE,OAAO,CAAA;SAAE,KAAG,MAAM;;mCAM7D,MAAM,GAAG,IAAI,KAAG,MAAM;;mCAQxB,MAAM,KAAG,MAAM;sCACZ,MAAM,KAAG,MAAM;iCACpB,MAAM,KAAG,MAAM;0CACN,MAAM,SAAS,MAAM,KAAG,MAAM;;;gCAK1C,MAAM;wCACE,MAAM,EAAE;6BAYnB,MAAM;;;gCAGH,MAAM;;CAEb,CAAC"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW;;6BAEV,MAAM;8BACL,MAAM;gDACY,MAAM;+BACvB,MAAM;+BACN,MAAM;;;gCAGL,MAAM;oCACA,MAAM,KAAG,MAAM;oCACf,4BAA4B,KAAG,MAAM;kCAOvC,MAAM,YAAY,MAAM,WAAW;YAAE,OAAO,EAAE,OAAO,CAAA;SAAE,KAAG,MAAM;;mCAM7D,MAAM,GAAG,IAAI,KAAG,MAAM;;mCAQxB,MAAM,KAAG,MAAM;sCACZ,MAAM,KAAG,MAAM;iCACpB,MAAM,KAAG,MAAM;0CACN,MAAM,SAAS,MAAM,KAAG,MAAM;;;gCAK1C,MAAM;wCACE,MAAM,EAAE;6BAYnB,MAAM;;;gCAGH,MAAM;;CAEb,CAAC"}
@@ -3,7 +3,6 @@ export const cliCommands = {
3
3
  help: () => "ogment auth --help",
4
4
  login: () => "ogment auth login",
5
5
  loginWithApiKeyRedacted: () => "ogment auth login --api-key <redacted>",
6
- loginWithBrowser: () => "ogment auth login --browser",
7
6
  logout: () => "ogment auth logout",
8
7
  status: () => "ogment auth status",
9
8
  },
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/cli/execute.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,KAAK,QAAQ,EAOd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,QAAQ,EAAoB,MAAM,yBAAyB,CAAC;AAY1E,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAsB5C,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBAET,QAAQ,EAAE,QAAQ;CAItC;AA0pBD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,EAChB,YAAY,aAAa,KACxB,OAAO,CAAC,IAAI,CAMd,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,QAuBzD,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/cli/execute.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,KAAK,QAAQ,EAOd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,QAAQ,EAAoB,MAAM,yBAAyB,CAAC;AAY1E,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAsB5C,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBAET,QAAQ,EAAE,QAAQ;CAItC;AAooBD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,EAChB,YAAY,aAAa,KACxB,OAAO,CAAC,IAAI,CAMd,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,QAuBzD,CAAC"}
@@ -114,14 +114,6 @@ const runLoginFlow = async (runtime, mode, apiKey) => {
114
114
  invokedCommand: cliCommands.auth.loginWithApiKeyRedacted(),
115
115
  };
116
116
  }
117
- if (mode === "browser") {
118
- return {
119
- commandOptions: {
120
- mode: "browser",
121
- },
122
- invokedCommand: cliCommands.auth.loginWithBrowser(),
123
- };
124
- }
125
117
  const deviceCommand = cliCommands.auth.login();
126
118
  return {
127
119
  commandOptions: {
@@ -189,21 +181,10 @@ const runLoginFlow = async (runtime, mode, apiKey) => {
189
181
  });
190
182
  };
191
183
  const executeAuthLoginInvocation = async (runtime, invocation) => {
192
- if (invocation.browser && invocation.apiKey !== undefined) {
193
- throw new ValidationError({
194
- details: "--browser with --api-key",
195
- message: "Use only one login mode: default device, --browser, or --api-key.",
196
- recovery: { command: cliCommands.auth.login() },
197
- });
198
- }
199
184
  if (invocation.apiKey !== undefined) {
200
185
  await runLoginFlow(runtime, "api_key", invocation.apiKey);
201
186
  return;
202
187
  }
203
- if (invocation.browser) {
204
- await runLoginFlow(runtime, "browser");
205
- return;
206
- }
207
188
  await runLoginFlow(runtime, "device");
208
189
  };
209
190
  const executeAuthStatusInvocation = async (runtime) => {
@@ -1,6 +1,5 @@
1
1
  export interface AuthLoginInvocation {
2
2
  apiKey: string | undefined;
3
- browser: boolean;
4
3
  kind: "auth_login";
5
4
  }
6
5
  export interface AuthStatusInvocation {
@@ -1 +1 @@
1
- {"version":3,"file":"invocations.d.ts","sourceRoot":"","sources":["../../src/cli/invocations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAA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oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgC,MAAM,WAAW,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAA2C,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CAC5C;AA0BD,eAAO,MAAM,aAAa,GACxB,SAAS,OAAO,EAChB,YAAY,mBAAmB,KAC9B,qBA+LF,CAAC"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgC,MAAM,WAAW,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAA2C,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CAC5C;AA0BD,eAAO,MAAM,aAAa,GACxB,SAAS,OAAO,EAChB,YAAY,mBAAmB,KAC9B,qBAsLF,CAAC"}
@@ -71,7 +71,6 @@ export const createProgram = (runtime, parseState) => {
71
71
  .option("--human", "Render output for humans")
72
72
  .option("--quiet", "Suppress non-essential output")
73
73
  .optionsGroup("Automation Options:")
74
- .option("--non-interactive", "Disable interactive behavior")
75
74
  .option("--yes", "Assume yes for any confirmation")
76
75
  .hook("preAction", (thisCommand) => {
77
76
  const options = asGlobalOptions(thisCommand);
@@ -88,24 +87,16 @@ export const createProgram = (runtime, parseState) => {
88
87
  if (error) {
89
88
  return "";
90
89
  }
91
- return [
92
- "",
93
- "Examples:",
94
- " $ ogment auth login",
95
- " $ ogment auth login --browser",
96
- " $ ogment auth status",
97
- ].join("\n");
90
+ return ["", "Examples:", " $ ogment auth login", " $ ogment auth status"].join("\n");
98
91
  });
99
92
  authCommand
100
93
  .command("login")
101
94
  .summary("Login with device flow (default)")
102
95
  .description("Authenticate with Ogment using device flow (recommended)")
103
- .option("--browser", "Fallback: use browser callback flow")
104
- .action((options, command) => {
96
+ .action((_, command) => {
105
97
  const { apiKey } = asGlobalOptions(command);
106
98
  setInvocation({
107
99
  apiKey,
108
- browser: options.browser === true,
109
100
  kind: "auth_login",
110
101
  });
111
102
  });
@@ -6,7 +6,6 @@ export interface GlobalCliOptions {
6
6
  apiKey: string | undefined;
7
7
  debug: boolean | undefined;
8
8
  human: boolean | undefined;
9
- nonInteractive: boolean | undefined;
10
9
  quiet: boolean | undefined;
11
10
  yes: boolean | undefined;
12
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/cli/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,wBAAwB,CAAC;AAK9E,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG1E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,cAAc,E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ChC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,KAAG,gBAgBlD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,gBAAgB,KAAG,iBAOlE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,iBASpE,CAAC"}
@@ -1,4 +1,3 @@
1
- import { createBrowserOpener } from "../infra/browser.js";
2
1
  import { createFileCredentialsStore } from "../infra/credentials.js";
3
2
  import { createRuntimeConfig } from "../infra/env.js";
4
3
  import { createHttpClient } from "../infra/http.js";
@@ -15,7 +14,6 @@ export const createRuntime = () => {
15
14
  credentialsPath: runtimeConfig.credentialsPath,
16
15
  });
17
16
  const httpClient = createHttpClient();
18
- const browserOpener = createBrowserOpener();
19
17
  const services = {
20
18
  account: createAccountService({
21
19
  baseUrl: runtimeConfig.baseUrl,
@@ -23,7 +21,6 @@ export const createRuntime = () => {
23
21
  }),
24
22
  auth: createAuthService({
25
23
  baseUrl: runtimeConfig.baseUrl,
26
- browserOpener,
27
24
  credentialsStore,
28
25
  envApiKey: runtimeConfig.envApiKey,
29
26
  httpClient,
@@ -60,7 +57,6 @@ export const asGlobalOptions = (command) => {
60
57
  apiKey: options.apiKey,
61
58
  debug: options.debug,
62
59
  human: options.human,
63
- nonInteractive: options.nonInteractive,
64
60
  quiet: options.quiet,
65
61
  yes: options.yes,
66
62
  };
@@ -69,7 +65,6 @@ export const mapGlobalOutputOptions = (options) => {
69
65
  return {
70
66
  debug: options.debug,
71
67
  human: options.human,
72
- nonInteractive: options.nonInteractive,
73
68
  quiet: options.quiet,
74
69
  yes: options.yes,
75
70
  };
@@ -79,7 +74,6 @@ export const parseOutputOptionsFromArgv = (argv) => {
79
74
  return {
80
75
  debug: hasFlag("--debug"),
81
76
  human: hasFlag("--human"),
82
- nonInteractive: hasFlag("--non-interactive"),
83
77
  quiet: hasFlag("--quiet"),
84
78
  yes: hasFlag("--yes"),
85
79
  };
@@ -7,14 +7,11 @@ interface DeviceAuthLoginCommandOptions {
7
7
  mode: "device";
8
8
  onPending?: (info: LoginPendingInfo) => void;
9
9
  }
10
- interface BrowserAuthLoginCommandOptions {
11
- mode: "browser";
12
- }
13
10
  interface ApiKeyAuthLoginCommandOptions {
14
11
  apiKey: string;
15
12
  mode: "apiKey";
16
13
  }
17
- export type AuthLoginCommandOptions = ApiKeyAuthLoginCommandOptions | BrowserAuthLoginCommandOptions | DeviceAuthLoginCommandOptions;
14
+ export type AuthLoginCommandOptions = ApiKeyAuthLoginCommandOptions | DeviceAuthLoginCommandOptions;
18
15
  export declare const runAuthLoginCommand: (context: CommandContext, options: AuthLoginCommandOptions) => Promise<ResultType<LoginSuccess, LoginError>>;
19
16
  export declare const runAuthStatusCommand: (context: CommandContext) => Promise<ResultType<AuthStatusSuccess, UnexpectedError>>;
20
17
  export declare const runAuthLogoutCommand: (context: CommandContext) => Promise<ResultType<LogoutSuccess, UnexpectedError>>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,UAAU,6BAA6B;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9C;AAED,UAAU,8BAA8B;IACtC,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,UAAU,6BAA6B;IACrC,MAAM,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AAS,uBAAuB,KAC/B,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAgB9C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,cAAc,KACtB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAExD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,cAAc,KACtB,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAEpD,CAAC"}
@@ -4,18 +4,10 @@ export const runAuthLoginCommand = async (context, options) => {
4
4
  return {
5
5
  apiKey: options.apiKey,
6
6
  mode: "apiKey",
7
- nonInteractive: context.output.nonInteractive,
8
- };
9
- }
10
- if (options.mode === "browser") {
11
- return {
12
- mode: "browser",
13
- nonInteractive: context.output.nonInteractive,
14
7
  };
15
8
  }
16
9
  return {
17
10
  mode: "device",
18
- nonInteractive: context.output.nonInteractive,
19
11
  ...(options.onPending === undefined ? {} : { onPending: options.onPending }),
20
12
  };
21
13
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/infra/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpG,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACxC,IAAI,IAAI,MAAM,CAAC,WAAW,GAAG,IAAI,EAAE,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,eAAe,CAA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IAC/B,cAAc,CAAC,EAAE,OAAO,YAAY,CAAC;IACrC,YAAY,CAAC,EAAE,OAAO,UAAU,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,aAAa,CAAC;CACxC;AA8BD,eAAO,MAAM,0BAA0B,GAAI,MAAM,oBAAoB,KAAG,gBAyDvE,CAAC"}
@@ -20,13 +20,6 @@ const normalizeCredentials = (value) => {
20
20
  }
21
21
  return credentials;
22
22
  }
23
- if (typeof parsed.value.accessToken === "string" && parsed.value.accessToken.length > 0) {
24
- const credentials = { apiKey: parsed.value.accessToken };
25
- if (typeof parsed.value.agentName === "string") {
26
- credentials.agentName = parsed.value.agentName;
27
- }
28
- return credentials;
29
- }
30
23
  return null;
31
24
  };
32
25
  export const createFileCredentialsStore = (deps) => {
@@ -5,7 +5,6 @@ export interface OutputInitOptions {
5
5
  debug?: boolean | undefined;
6
6
  human: boolean | undefined;
7
7
  json?: boolean | undefined;
8
- nonInteractive: boolean | undefined;
9
8
  quiet: boolean | undefined;
10
9
  yes: boolean | undefined;
11
10
  }
@@ -35,7 +34,6 @@ export declare class OutputManager {
35
34
  constructor(deps?: OutputManagerDeps);
36
35
  configure(options: OutputInitOptions): void;
37
36
  get mode(): OutputMode;
38
- get nonInteractive(): boolean;
39
37
  get debug(): boolean;
40
38
  error(error: AppError, options: EnvelopeOptions): CliErrorEnvelope;
41
39
  parseError(payload: CliParseErrorPayload, options: EnvelopeOptions): CliErrorEnvelope;
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/output/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,iBAAi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AY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED,UAAU,cAAe,SAAQ,eAAe;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA6BD,qBAAa,aAAa;;gBAOL,IAAI,GAAE,iBAAsB;IAUxC,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAWlD,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED,IAAW,KAAK,IAAI,OAAO,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB;IAoBlE,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB;IAmBrF,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ3B,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI1B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAuBlD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAGxC"}
@@ -22,14 +22,11 @@ const mergeNextActions = (recovery, contextActions) => {
22
22
  };
23
23
  export class OutputManager {
24
24
  #envelopeBuilder;
25
- #isTty;
26
25
  #mode;
27
26
  #debug = false;
28
- #nonInteractive = false;
29
27
  #stderr;
30
28
  #stdout;
31
29
  constructor(deps = {}) {
32
- this.#isTty = deps.isTty ?? Boolean(process.stdout.isTTY);
33
30
  this.#stderr = deps.stderr ?? process.stderr;
34
31
  this.#stdout = deps.stdout ?? process.stdout;
35
32
  this.#mode = "json";
@@ -48,16 +45,11 @@ export class OutputManager {
48
45
  else {
49
46
  this.#mode = "json";
50
47
  }
51
- this.#nonInteractive =
52
- options.nonInteractive === true || options.yes === true || this.#isTty === false;
53
48
  this.#debug = options.debug === true;
54
49
  }
55
50
  get mode() {
56
51
  return this.#mode;
57
52
  }
58
- get nonInteractive() {
59
- return this.#nonInteractive;
60
- }
61
53
  get debug() {
62
54
  return this.#debug;
63
55
  }
@@ -1,6 +1,4 @@
1
- import { createServer } from "node:http";
2
1
  import type { Result as ResultType } from "better-result";
3
- import type { BrowserOpener } from "../infra/browser.js";
4
2
  import type { CredentialsStore } from "../infra/credentials.js";
5
3
  import type { HttpClient } from "../infra/http.js";
6
4
  import { AuthError, RemoteRequestError, UnexpectedError, ValidationError } from "../shared/errors.js";
@@ -9,21 +7,15 @@ export interface LoginPendingInfo {
9
7
  userCode: string;
10
8
  verificationUri: string;
11
9
  }
12
- interface BaseLoginOptions {
13
- nonInteractive: boolean;
14
- }
15
- interface DeviceLoginOptions extends BaseLoginOptions {
10
+ interface DeviceLoginOptions {
16
11
  mode: "device";
17
12
  onPending?: (info: LoginPendingInfo) => void;
18
13
  }
19
- interface BrowserLoginOptions extends BaseLoginOptions {
20
- mode: "browser";
21
- }
22
- interface ApiKeyLoginOptions extends BaseLoginOptions {
14
+ interface ApiKeyLoginOptions {
23
15
  apiKey: string;
24
16
  mode: "apiKey";
25
17
  }
26
- export type LoginOptions = ApiKeyLoginOptions | BrowserLoginOptions | DeviceLoginOptions;
18
+ export type LoginOptions = ApiKeyLoginOptions | DeviceLoginOptions;
27
19
  export type LoginError = AuthError | RemoteRequestError | UnexpectedError | ValidationError;
28
20
  export type ResolveApiKeyError = AuthError | UnexpectedError;
29
21
  export interface AuthService {
@@ -34,12 +26,8 @@ export interface AuthService {
34
26
  }
35
27
  interface AuthServiceDeps {
36
28
  baseUrl: string;
37
- browserOpener: BrowserOpener;
38
29
  credentialsStore: CredentialsStore;
39
- createServerFn?: typeof createServer;
40
- detectEnvironment?: () => string;
41
30
  envApiKey: string | undefined;
42
- hostnameFn?: () => string;
43
31
  httpClient: HttpClient;
44
32
  now?: () => number;
45
33
  sleep?: (milliseconds: number) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,gBAAgB;IACxB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,UAAU,kBAAmB,SAAQ,gBAAgB;IACnD,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9C;AAED,UAAU,mBAAoB,SAAQ,gBAAgB;IACpD,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,UAAU,kBAAmB,SAAQ,gBAAgB;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,Q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C,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC,CAAC;CAC1F;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AA6BD,eAAO,MAAM,iBAAiB,GAAI,MAAM,eAAe,KAAG,WA+TzD,CAAC"}
@@ -1,16 +1,9 @@
1
- import { createHash, randomBytes } from "node:crypto";
2
- import { on } from "node:events";
3
- import { createServer } from "node:http";
4
- import { hostname } from "node:os";
5
1
  import { Result } from "better-result";
6
- import { detectExecutionEnvironment } from "../infra/env.js";
7
2
  import { readResponseText } from "../infra/http.js";
8
- import { CLI_CLIENT_NAME, CLI_REDIRECT_HOST } from "../shared/constants.js";
9
3
  import { ERROR_CODE } from "../shared/error-codes.js";
10
4
  import { AuthError, RemoteRequestError, UnexpectedError, ValidationError, } from "../shared/errors.js";
11
5
  import { parseWithSchema } from "../shared/guards.js";
12
- import { browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, } from "../shared/schemas.js";
13
- const CALLBACK_TIMEOUT_MILLISECONDS = 5 * 60 * 1000;
6
+ import { deviceCodeStartSchema, deviceTokenApprovedSchema } from "../shared/schemas.js";
14
7
  const defaultSleep = async (milliseconds) => {
15
8
  await new Promise((resolve) => {
16
9
  setTimeout(resolve, milliseconds);
@@ -29,222 +22,12 @@ const toPendingPayload = (payload) => {
29
22
  }
30
23
  return null;
31
24
  };
32
- const generateCodeVerifier = () => {
33
- return randomBytes(32).toString("base64url");
34
- };
35
- const generateCodeChallenge = (verifier) => {
36
- return createHash("sha256").update(verifier).digest("base64url");
37
- };
38
- const closeServer = async (server) => {
39
- await Result.tryPromise({
40
- catch: () => undefined,
41
- try: async () => {
42
- await new Promise((resolve) => {
43
- server.close(() => {
44
- resolve();
45
- });
46
- });
47
- },
48
- });
49
- Result.try({
50
- catch: () => undefined,
51
- try: () => {
52
- server.unref();
53
- },
54
- });
55
- };
56
- const successPage = (agentName) => {
57
- return `<!DOCTYPE html>
58
- <html lang="en">
59
- <head><meta charset="utf-8"><title>Ogment - Agent configured</title></head>
60
- <body>
61
- <h1>Agent configured</h1>
62
- <p>Agent ${agentName} is now active. You can close this tab.</p>
63
- </body>
64
- </html>`;
65
- };
66
- const errorPage = (message) => {
67
- return `<!DOCTYPE html>
68
- <html lang="en">
69
- <head><meta charset="utf-8"><title>Ogment - Login failed</title></head>
70
- <body>
71
- <h1>Login failed</h1>
72
- <p>${message}</p>
73
- </body>
74
- </html>`;
75
- };
76
- const startCallbackServerWithPort = async (createServerFn) => {
77
- return Result.tryPromise({
78
- catch: (cause) => new UnexpectedError({
79
- cause,
80
- message: "Failed to start local callback server",
81
- }),
82
- try: async () => {
83
- return new Promise((resolve, reject) => {
84
- const server = createServerFn();
85
- const onError = (error) => {
86
- server.removeListener("error", onError);
87
- reject(error);
88
- };
89
- server.once("error", onError);
90
- server.listen(0, CLI_REDIRECT_HOST, () => {
91
- server.removeListener("error", onError);
92
- const address = server.address();
93
- if (address === null || typeof address === "string") {
94
- reject(new Error("Could not resolve callback server port"));
95
- return;
96
- }
97
- resolve({
98
- port: address.port,
99
- server,
100
- });
101
- });
102
- });
103
- },
104
- });
105
- };
106
- const waitForOAuthCallback = async (server, port) => {
107
- const abortController = new AbortController();
108
- const timeout = setTimeout(() => {
109
- abortController.abort();
110
- }, CALLBACK_TIMEOUT_MILLISECONDS);
111
- timeout.unref();
112
- try {
113
- for await (const event of on(server, "request", { signal: abortController.signal })) {
114
- const request = event[0];
115
- const response = event[1];
116
- const url = new URL(request.url ?? "/", `http://${CLI_REDIRECT_HOST}:${port}`);
117
- if (url.pathname !== "/callback") {
118
- continue;
119
- }
120
- const oauthError = url.searchParams.get("error");
121
- if (oauthError !== null) {
122
- response.writeHead(200, {
123
- "Content-Type": "text/html; charset=utf-8",
124
- });
125
- response.end(errorPage(`OAuth error: ${oauthError}`));
126
- return Result.err(new AuthError({
127
- code: ERROR_CODE.authInvalidCredentials,
128
- message: `OAuth error: ${oauthError}`,
129
- recovery: { command: "ogment auth login --browser" },
130
- }));
131
- }
132
- const code = url.searchParams.get("code");
133
- if (typeof code !== "string" || code.length === 0) {
134
- response.writeHead(400, {
135
- "Content-Type": "text/html; charset=utf-8",
136
- });
137
- response.end(errorPage("No authorization code received."));
138
- return Result.err(new AuthError({
139
- code: ERROR_CODE.authInvalidCredentials,
140
- message: "No authorization code in callback",
141
- recovery: { command: "ogment auth login --browser" },
142
- }));
143
- }
144
- return Result.ok({
145
- code,
146
- response,
147
- state: url.searchParams.get("state") ?? "",
148
- });
149
- }
150
- }
151
- catch (error) {
152
- if (error instanceof Error && error.name === "AbortError") {
153
- return Result.err(new AuthError({
154
- code: ERROR_CODE.authInvalidCredentials,
155
- message: "Login timed out. No callback received within 5 minutes.",
156
- recovery: { command: "ogment auth login --browser" },
157
- }));
158
- }
159
- return Result.err(new AuthError({
160
- code: ERROR_CODE.authInvalidCredentials,
161
- message: "Failed while waiting for OAuth callback.",
162
- recovery: { command: "ogment auth login --browser" },
163
- }));
164
- }
165
- finally {
166
- clearTimeout(timeout);
167
- }
168
- return Result.err(new AuthError({
169
- code: ERROR_CODE.authInvalidCredentials,
170
- message: "Login timed out. No callback received within 5 minutes.",
171
- recovery: { command: "ogment auth login --browser" },
172
- }));
173
- };
174
- const waitForAgentCallback = async (server, port) => {
175
- const abortController = new AbortController();
176
- const timeout = setTimeout(() => {
177
- abortController.abort();
178
- }, CALLBACK_TIMEOUT_MILLISECONDS);
179
- timeout.unref();
180
- try {
181
- for await (const event of on(server, "request", { signal: abortController.signal })) {
182
- const request = event[0];
183
- const response = event[1];
184
- const url = new URL(request.url ?? "/", `http://${CLI_REDIRECT_HOST}:${port}`);
185
- if (url.pathname !== "/agent-callback") {
186
- continue;
187
- }
188
- const parsedCallback = parseWithSchema(browserAgentCallbackSchema, Object.fromEntries(url.searchParams.entries()), "agent callback");
189
- if (Result.isError(parsedCallback)) {
190
- response.writeHead(400, {
191
- "Content-Type": "text/html; charset=utf-8",
192
- });
193
- response.end(errorPage("No exchange code received."));
194
- return Result.err(new AuthError({
195
- code: ERROR_CODE.authInvalidCredentials,
196
- message: "No exchange code in callback",
197
- recovery: { command: "ogment auth login --browser" },
198
- }));
199
- }
200
- const agentName = parsedCallback.value.agent_name ?? "CLI Agent";
201
- response.writeHead(200, {
202
- "Content-Type": "text/html; charset=utf-8",
203
- });
204
- response.end(successPage(agentName));
205
- return Result.ok({
206
- agentName,
207
- exchangeCode: parsedCallback.value.exchange_code,
208
- });
209
- }
210
- }
211
- catch (error) {
212
- if (error instanceof Error && error.name === "AbortError") {
213
- return Result.err(new AuthError({
214
- code: ERROR_CODE.authInvalidCredentials,
215
- message: "Agent selection timed out.",
216
- recovery: { command: "ogment auth login --browser" },
217
- }));
218
- }
219
- return Result.err(new AuthError({
220
- code: ERROR_CODE.authInvalidCredentials,
221
- message: "Failed while waiting for agent callback.",
222
- recovery: { command: "ogment auth login --browser" },
223
- }));
224
- }
225
- finally {
226
- clearTimeout(timeout);
227
- }
228
- return Result.err(new AuthError({
229
- code: ERROR_CODE.authInvalidCredentials,
230
- message: "Agent selection timed out.",
231
- recovery: { command: "ogment auth login --browser" },
232
- }));
233
- };
234
25
  const deviceCodeUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/device/code`;
235
26
  const deviceTokenUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/device/token`;
236
27
  const revokeUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/cli/revoke-self`;
237
- const oauthAuthorizeUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/authorize`;
238
- const oauthRegisterUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/register`;
239
- const oauthTokenUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/token`;
240
- const cliExchangeUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/cli/exchange`;
241
- const agentSelectUrl = (baseUrl) => `${baseUrl}/cli/agent-select`;
242
28
  export const createAuthService = (deps) => {
243
29
  const now = deps.now ?? Date.now;
244
30
  const sleep = deps.sleep ?? defaultSleep;
245
- const createServerFn = deps.createServerFn ?? createServer;
246
- const detectEnvironment = deps.detectEnvironment ?? detectExecutionEnvironment;
247
- const hostnameFn = deps.hostnameFn ?? hostname;
248
31
  const requestRemote = async (input, init) => {
249
32
  return deps.httpClient.request(input, init);
250
33
  };
@@ -368,248 +151,6 @@ export const createAuthService = (deps) => {
368
151
  recovery: { command: "ogment auth login" },
369
152
  }));
370
153
  };
371
- const loginWithBrowser = async () => {
372
- const callbackServerResult = await startCallbackServerWithPort(createServerFn);
373
- if (Result.isError(callbackServerResult)) {
374
- return callbackServerResult;
375
- }
376
- const { port, server } = callbackServerResult.value;
377
- const redirectUri = `http://${CLI_REDIRECT_HOST}:${port}/callback`;
378
- const registerResponse = await requestRemote(oauthRegisterUrl(deps.baseUrl), {
379
- body: JSON.stringify({
380
- client_name: CLI_CLIENT_NAME,
381
- grant_types: ["authorization_code"],
382
- redirect_uris: [redirectUri],
383
- response_types: ["code"],
384
- token_endpoint_auth_method: "client_secret_post",
385
- }),
386
- headers: {
387
- "Content-Type": "application/json",
388
- },
389
- method: "POST",
390
- });
391
- if (Result.isError(registerResponse)) {
392
- await closeServer(server);
393
- return registerResponse;
394
- }
395
- if (!registerResponse.value.ok) {
396
- const body = await readResponseText(registerResponse.value);
397
- await closeServer(server);
398
- return Result.err(new RemoteRequestError({
399
- body,
400
- httpStatus: registerResponse.value.status,
401
- message: "Client registration failed",
402
- operation: "auth/browser/register",
403
- raw: body,
404
- source: "http",
405
- }));
406
- }
407
- const registerPayload = await Result.tryPromise({
408
- catch: () => new RemoteRequestError({
409
- httpStatus: registerResponse.value.status,
410
- message: "Failed to parse client registration payload",
411
- operation: "auth/browser/register",
412
- source: "http",
413
- }),
414
- try: async () => registerResponse.value.json(),
415
- });
416
- if (Result.isError(registerPayload)) {
417
- await closeServer(server);
418
- return registerPayload;
419
- }
420
- const parsedClient = parseWithSchema(oauthClientRegistrationSchema, registerPayload.value, "oauth client registration response");
421
- if (Result.isError(parsedClient)) {
422
- await closeServer(server);
423
- return parsedClient;
424
- }
425
- const codeVerifier = generateCodeVerifier();
426
- const codeChallenge = generateCodeChallenge(codeVerifier);
427
- const state = randomBytes(16).toString("hex");
428
- const authorizeUrl = new URL(oauthAuthorizeUrl(deps.baseUrl));
429
- authorizeUrl.searchParams.set("client_id", parsedClient.value.client_id);
430
- authorizeUrl.searchParams.set("redirect_uri", redirectUri);
431
- authorizeUrl.searchParams.set("response_type", "code");
432
- authorizeUrl.searchParams.set("code_challenge", codeChallenge);
433
- authorizeUrl.searchParams.set("code_challenge_method", "S256");
434
- authorizeUrl.searchParams.set("state", state);
435
- const oauthCallbackPromise = waitForOAuthCallback(server, port);
436
- const openResult = await deps.browserOpener.open(authorizeUrl.toString());
437
- if (Result.isError(openResult)) {
438
- await closeServer(server);
439
- return openResult;
440
- }
441
- const oauthCallbackResult = await oauthCallbackPromise;
442
- if (Result.isError(oauthCallbackResult)) {
443
- await closeServer(server);
444
- return oauthCallbackResult;
445
- }
446
- if (oauthCallbackResult.value.state !== state) {
447
- oauthCallbackResult.value.response.writeHead(302, {
448
- Location: "about:blank",
449
- });
450
- oauthCallbackResult.value.response.end();
451
- await closeServer(server);
452
- return Result.err(new AuthError({
453
- code: ERROR_CODE.authInvalidCredentials,
454
- message: "OAuth state mismatch - possible CSRF attack.",
455
- recovery: { command: "ogment auth login --browser" },
456
- }));
457
- }
458
- const tokenBody = new URLSearchParams({
459
- client_id: parsedClient.value.client_id,
460
- code: oauthCallbackResult.value.code,
461
- code_verifier: codeVerifier,
462
- grant_type: "authorization_code",
463
- redirect_uri: redirectUri,
464
- });
465
- if (typeof parsedClient.value.client_secret === "string" &&
466
- parsedClient.value.client_secret.length > 0) {
467
- tokenBody.set("client_secret", parsedClient.value.client_secret);
468
- }
469
- const tokenResponse = await requestRemote(oauthTokenUrl(deps.baseUrl), {
470
- body: tokenBody.toString(),
471
- headers: {
472
- "Content-Type": "application/x-www-form-urlencoded",
473
- },
474
- method: "POST",
475
- });
476
- if (Result.isError(tokenResponse)) {
477
- await closeServer(server);
478
- return tokenResponse;
479
- }
480
- if (!tokenResponse.value.ok) {
481
- const body = await readResponseText(tokenResponse.value);
482
- await closeServer(server);
483
- return Result.err(new RemoteRequestError({
484
- body,
485
- httpStatus: tokenResponse.value.status,
486
- message: "Token exchange failed",
487
- operation: "auth/browser/token",
488
- raw: body,
489
- source: "http",
490
- }));
491
- }
492
- const tokenPayload = await Result.tryPromise({
493
- catch: () => new RemoteRequestError({
494
- httpStatus: tokenResponse.value.status,
495
- message: "Failed to parse token payload",
496
- operation: "auth/browser/token",
497
- source: "http",
498
- }),
499
- try: async () => tokenResponse.value.json(),
500
- });
501
- if (Result.isError(tokenPayload)) {
502
- await closeServer(server);
503
- return tokenPayload;
504
- }
505
- const parsedToken = parseWithSchema(oauthTokenSchema, tokenPayload.value, "oauth token response");
506
- if (Result.isError(parsedToken)) {
507
- await closeServer(server);
508
- return parsedToken;
509
- }
510
- const pickerUrl = new URL(agentSelectUrl(deps.baseUrl));
511
- pickerUrl.searchParams.set("token", parsedToken.value.access_token);
512
- pickerUrl.searchParams.set("callback", `http://${CLI_REDIRECT_HOST}:${port}/agent-callback`);
513
- pickerUrl.searchParams.set("env", detectEnvironment());
514
- pickerUrl.searchParams.set("host", hostnameFn());
515
- oauthCallbackResult.value.response.writeHead(302, {
516
- Location: pickerUrl.toString(),
517
- });
518
- oauthCallbackResult.value.response.end();
519
- const agentCallbackResult = await waitForAgentCallback(server, port);
520
- await closeServer(server);
521
- if (Result.isError(agentCallbackResult)) {
522
- return agentCallbackResult;
523
- }
524
- const exchangeRequestPayload = {
525
- exchange_code: agentCallbackResult.value.exchangeCode,
526
- };
527
- const parsedExchangeRequestPayload = parseWithSchema(cliExchangeRequestSchema, exchangeRequestPayload, "browser exchange request");
528
- if (Result.isError(parsedExchangeRequestPayload)) {
529
- return parsedExchangeRequestPayload;
530
- }
531
- const exchangeResponse = await requestRemote(cliExchangeUrl(deps.baseUrl), {
532
- body: JSON.stringify(parsedExchangeRequestPayload.value),
533
- headers: {
534
- "Content-Type": "application/json",
535
- },
536
- method: "POST",
537
- });
538
- if (Result.isError(exchangeResponse)) {
539
- return exchangeResponse;
540
- }
541
- if (!exchangeResponse.value.ok) {
542
- const body = await readResponseText(exchangeResponse.value);
543
- const parsedExchangeErrorPayload = Result.try({
544
- catch: () => null,
545
- try: () => JSON.parse(body),
546
- });
547
- if (Result.isOk(parsedExchangeErrorPayload)) {
548
- const parsedExchangeError = parseWithSchema(cliExchangeErrorSchema, parsedExchangeErrorPayload.value, "browser exchange error response");
549
- if (Result.isOk(parsedExchangeError)) {
550
- const exchangeErrorCode = parsedExchangeError.value.error;
551
- if (exchangeErrorCode === "expired_exchange_code") {
552
- return Result.err(new AuthError({
553
- code: ERROR_CODE.authDeviceExpired,
554
- message: "Browser login code expired. Run `ogment auth login --browser` again.",
555
- recovery: { command: "ogment auth login --browser" },
556
- }));
557
- }
558
- if (exchangeErrorCode === "invalid_exchange_code") {
559
- return Result.err(new AuthError({
560
- code: ERROR_CODE.authInvalidCredentials,
561
- message: "Invalid browser login code. Run `ogment auth login --browser` again.",
562
- recovery: { command: "ogment auth login --browser" },
563
- }));
564
- }
565
- if (exchangeErrorCode === "authorization_pending") {
566
- return Result.err(new AuthError({
567
- code: ERROR_CODE.authDevicePending,
568
- message: "Browser login authorization is still pending.",
569
- recovery: { command: "ogment auth login --browser" },
570
- retryable: true,
571
- }));
572
- }
573
- }
574
- }
575
- return Result.err(new RemoteRequestError({
576
- body,
577
- httpStatus: exchangeResponse.value.status,
578
- message: "Failed to exchange browser login code",
579
- operation: "auth/browser/exchange",
580
- raw: body,
581
- source: "http",
582
- }));
583
- }
584
- const exchangePayload = await Result.tryPromise({
585
- catch: () => new RemoteRequestError({
586
- httpStatus: exchangeResponse.value.status,
587
- message: "Failed to parse browser exchange payload",
588
- operation: "auth/browser/exchange",
589
- source: "http",
590
- }),
591
- try: async () => exchangeResponse.value.json(),
592
- });
593
- if (Result.isError(exchangePayload)) {
594
- return exchangePayload;
595
- }
596
- const parsedExchangePayload = parseWithSchema(cliExchangeSuccessSchema, exchangePayload.value, "browser exchange response");
597
- if (Result.isError(parsedExchangePayload)) {
598
- return parsedExchangePayload;
599
- }
600
- const saveResult = deps.credentialsStore.save({
601
- agentName: parsedExchangePayload.value.data.name,
602
- apiKey: parsedExchangePayload.value.data.apiKey,
603
- });
604
- if (Result.isError(saveResult)) {
605
- return saveResult;
606
- }
607
- return Result.ok({
608
- agentName: parsedExchangePayload.value.data.name,
609
- loggedIn: true,
610
- outcome: "authenticated",
611
- });
612
- };
613
154
  return {
614
155
  login: async (options) => {
615
156
  if (options.mode === "apiKey" && options.apiKey.length > 0) {
@@ -633,13 +174,6 @@ export const createAuthService = (deps) => {
633
174
  recovery: { command: "ogment auth login --api-key <key>" },
634
175
  }));
635
176
  }
636
- if (options.nonInteractive && options.mode === "browser") {
637
- return Result.err(new ValidationError({
638
- code: ERROR_CODE.validationInvalidInput,
639
- message: "Use `ogment auth login` in non-interactive mode.",
640
- recovery: { command: "ogment auth login" },
641
- }));
642
- }
643
177
  const stored = deps.credentialsStore.load();
644
178
  if (Result.isError(stored)) {
645
179
  return stored;
@@ -651,10 +185,7 @@ export const createAuthService = (deps) => {
651
185
  outcome: "already_authenticated",
652
186
  });
653
187
  }
654
- if (options.mode === "device") {
655
- return loginWithDevice(options);
656
- }
657
- return loginWithBrowser();
188
+ return loginWithDevice(options);
658
189
  },
659
190
  logout: async () => {
660
191
  const stored = deps.credentialsStore.load();
@@ -1,7 +1,5 @@
1
1
  export declare const APP_NAME = "ogment";
2
2
  export declare const APP_DESCRIPTION = "Ogment CLI - secure your AI agents' SaaS credentials";
3
3
  export declare const DEFAULT_OGMENT_BASE_URL = "https://dashboard.ogment.ai";
4
- export declare const CLI_CLIENT_NAME = "Ogment CLI";
5
- export declare const CLI_REDIRECT_HOST = "127.0.0.1";
6
4
  export declare const VERSION: string;
7
5
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,WAAW,CAAC;AACjC,eAAO,MAAM,eAAe,yDAAyD,CAAC;AAEtF,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AACrE,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAQ7C,eAAO,MAAM,OAAO,QAAsB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,WAAW,CAAC;AACjC,eAAO,MAAM,eAAe,yDAAyD,CAAC;AAEtF,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAQrE,eAAO,MAAM,OAAO,QAAsB,CAAC"}
@@ -2,7 +2,5 @@ import { readFileSync } from "node:fs";
2
2
  export const APP_NAME = "ogment";
3
3
  export const APP_DESCRIPTION = "Ogment CLI - secure your AI agents' SaaS credentials";
4
4
  export const DEFAULT_OGMENT_BASE_URL = "https://dashboard.ogment.ai";
5
- export const CLI_CLIENT_NAME = "Ogment CLI";
6
- export const CLI_REDIRECT_HOST = "127.0.0.1";
7
5
  const packageJson = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
8
6
  export const VERSION = packageJson.version;
@@ -1,8 +1,7 @@
1
- import { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema } from "@ogment-ai/cli-contract/v1";
1
+ import { accountMeSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, orgServerSchema, organizationSchema } from "@ogment-ai/cli-contract/v1";
2
2
  import { z } from "zod";
3
- export { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, };
3
+ export { accountMeSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, orgServerSchema, organizationSchema, };
4
4
  export declare const credentialsFileSchema: z.ZodObject<{
5
- accessToken: z.ZodOptional<z.ZodString>;
6
5
  agentName: z.ZodOptional<z.ZodString>;
7
6
  apiKey: z.ZodOptional<z.ZodString>;
8
7
  }, z.core.$strip>;
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/shared/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,CAAC;AAIF,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/shared/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,GACnB,CAAC;AAIF,eAAO,MAAM,qBAAqB;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC"}
@@ -1,9 +1,8 @@
1
- import { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, } from "@ogment-ai/cli-contract/v1";
1
+ import { accountMeSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, orgServerSchema, organizationSchema, } from "@ogment-ai/cli-contract/v1";
2
2
  import { z } from "zod";
3
- export { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, };
3
+ export { accountMeSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, orgServerSchema, organizationSchema, };
4
4
  const jsonObjectSchema = z.record(z.string(), z.unknown());
5
5
  export const credentialsFileSchema = z.object({
6
- accessToken: z.string().min(1).optional(),
7
6
  agentName: z.string().optional(),
8
7
  apiKey: z.string().min(1).optional(),
9
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogment-ai/cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Ogment Vault CLI — secure your AI agents' SaaS credentials",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,6 @@
19
19
  "mcp",
20
20
  "ai",
21
21
  "vault",
22
- "oauth",
23
22
  "cli",
24
23
  "model-context-protocol",
25
24
  "agent",
@@ -40,10 +39,9 @@
40
39
  },
41
40
  "dependencies": {
42
41
  "@modelcontextprotocol/sdk": "^1.27.0",
43
- "@ogment-ai/cli-contract": "0.5.0",
42
+ "@ogment-ai/cli-contract": "0.6.0",
44
43
  "better-result": "^2.7.0",
45
44
  "commander": "^14.0.3",
46
- "open": "^11.0.0",
47
45
  "zod": "^4.3.6"
48
46
  },
49
47
  "devDependencies": {
@@ -1,12 +0,0 @@
1
- import open from "open";
2
- import { Result } from "better-result";
3
- import { UnexpectedError } from "../shared/errors.js";
4
- export interface BrowserOpener {
5
- open(url: string): Promise<Result<void, UnexpectedError>>;
6
- }
7
- interface BrowserOpenerDeps {
8
- openFn?: typeof open;
9
- }
10
- export declare const createBrowserOpener: (deps?: BrowserOpenerDeps) => BrowserOpener;
11
- export {};
12
- //# sourceMappingURL=browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/infra/browser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;CAC3D;AAED,UAAU,iBAAiB;IACzB,MAAM,CAAC,EAAE,OAAO,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAM,iBAAsB,KAAG,aAkBlE,CAAC"}
@@ -1,20 +0,0 @@
1
- import open from "open";
2
- import { Result } from "better-result";
3
- import { UnexpectedError } from "../shared/errors.js";
4
- export const createBrowserOpener = (deps = {}) => {
5
- const openFn = deps.openFn ?? open;
6
- return {
7
- open: async (url) => {
8
- return Result.tryPromise({
9
- catch: (cause) => new UnexpectedError({
10
- cause,
11
- message: "Failed to open browser for authentication",
12
- }),
13
- try: async () => {
14
- const childProcess = await openFn(url);
15
- childProcess.unref();
16
- },
17
- });
18
- },
19
- };
20
- };