@ogment-ai/cli 0.3.5 → 0.4.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.
Files changed (72) hide show
  1. package/README.md +72 -76
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +521 -247
  5. package/dist/commands/auth.d.ts +22 -0
  6. package/dist/commands/auth.d.ts.map +1 -0
  7. package/dist/commands/auth.js +29 -0
  8. package/dist/commands/catalog.d.ts +29 -0
  9. package/dist/commands/catalog.d.ts.map +1 -0
  10. package/dist/commands/catalog.js +151 -0
  11. package/dist/commands/invoke.d.ts +17 -0
  12. package/dist/commands/invoke.d.ts.map +1 -0
  13. package/dist/commands/invoke.js +123 -0
  14. package/dist/commands/{info.d.ts → status.d.ts} +4 -4
  15. package/dist/commands/status.d.ts.map +1 -0
  16. package/dist/commands/{info.js → status.js} +1 -1
  17. package/dist/output/envelope.d.ts +19 -0
  18. package/dist/output/envelope.d.ts.map +1 -0
  19. package/dist/output/envelope.js +51 -0
  20. package/dist/output/manager.d.ts +16 -3
  21. package/dist/output/manager.d.ts.map +1 -1
  22. package/dist/output/manager.js +27 -29
  23. package/dist/services/account.d.ts.map +1 -1
  24. package/dist/services/account.js +18 -2
  25. package/dist/services/auth.d.ts +14 -3
  26. package/dist/services/auth.d.ts.map +1 -1
  27. package/dist/services/auth.js +119 -15
  28. package/dist/services/info.d.ts.map +1 -1
  29. package/dist/services/info.js +11 -10
  30. package/dist/services/mcp.d.ts.map +1 -1
  31. package/dist/services/mcp.js +24 -23
  32. package/dist/shared/constants.d.ts +0 -1
  33. package/dist/shared/constants.d.ts.map +1 -1
  34. package/dist/shared/constants.js +0 -1
  35. package/dist/shared/error-codes.d.ts +28 -0
  36. package/dist/shared/error-codes.d.ts.map +1 -0
  37. package/dist/shared/error-codes.js +25 -0
  38. package/dist/shared/errors.d.ts +100 -9
  39. package/dist/shared/errors.d.ts.map +1 -1
  40. package/dist/shared/errors.js +101 -0
  41. package/dist/shared/exit-codes.d.ts +8 -5
  42. package/dist/shared/exit-codes.d.ts.map +1 -1
  43. package/dist/shared/exit-codes.js +31 -14
  44. package/dist/shared/guards.d.ts +5 -1
  45. package/dist/shared/guards.d.ts.map +1 -1
  46. package/dist/shared/guards.js +6 -1
  47. package/dist/shared/retry.d.ts +17 -0
  48. package/dist/shared/retry.d.ts.map +1 -0
  49. package/dist/shared/retry.js +27 -0
  50. package/dist/shared/schema-example.d.ts +2 -0
  51. package/dist/shared/schema-example.d.ts.map +1 -0
  52. package/dist/shared/schema-example.js +128 -0
  53. package/dist/shared/schemas.d.ts +0 -42
  54. package/dist/shared/schemas.d.ts.map +1 -1
  55. package/dist/shared/schemas.js +0 -21
  56. package/dist/shared/types.d.ts +84 -12
  57. package/dist/shared/types.d.ts.map +1 -1
  58. package/dist/shared/types.js +1 -1
  59. package/package.json +5 -7
  60. package/dist/commands/call.d.ts +0 -14
  61. package/dist/commands/call.d.ts.map +0 -1
  62. package/dist/commands/call.js +0 -51
  63. package/dist/commands/describe.d.ts +0 -4
  64. package/dist/commands/describe.d.ts.map +0 -1
  65. package/dist/commands/describe.js +0 -109
  66. package/dist/commands/info.d.ts.map +0 -1
  67. package/dist/commands/servers.d.ts +0 -13
  68. package/dist/commands/servers.d.ts.map +0 -1
  69. package/dist/commands/servers.js +0 -29
  70. package/dist/postinstall.d.ts +0 -2
  71. package/dist/postinstall.d.ts.map +0 -1
  72. package/dist/postinstall.js +0 -12
@@ -1,7 +1,9 @@
1
1
  import { Result } from "better-result";
2
2
  import { readResponseText } from "../infra/http.js";
3
+ import { ERROR_CODE } from "../shared/error-codes.js";
3
4
  import { AuthError, RemoteRequestError } from "../shared/errors.js";
4
5
  import { parseWithSchema } from "../shared/guards.js";
6
+ import { remoteRetryConfig } from "../shared/retry.js";
5
7
  import { accountMeSchema } from "../shared/schemas.js";
6
8
  const authHeader = (apiKey) => {
7
9
  return {
@@ -9,7 +11,7 @@ const authHeader = (apiKey) => {
9
11
  };
10
12
  };
11
13
  export const createAccountService = (deps) => {
12
- const fetchAccount = async (apiKey) => {
14
+ const fetchAccountOnce = async (apiKey) => {
13
15
  const responseResult = await deps.httpClient.request(`${deps.baseUrl}/api/v1/mcp-auth/me`, {
14
16
  headers: authHeader(apiKey),
15
17
  });
@@ -19,7 +21,9 @@ export const createAccountService = (deps) => {
19
21
  if (!responseResult.value.ok) {
20
22
  if (responseResult.value.status === 401) {
21
23
  return Result.err(new AuthError({
22
- message: "Authentication failed. Run `ogment login` again.",
24
+ code: ERROR_CODE.authInvalidCredentials,
25
+ message: "Authentication failed. Run `ogment auth login` again.",
26
+ suggestedCommand: "ogment auth login",
23
27
  }));
24
28
  }
25
29
  const body = await readResponseText(responseResult.value);
@@ -45,6 +49,18 @@ export const createAccountService = (deps) => {
45
49
  }
46
50
  return Result.ok(parsed.value.data);
47
51
  };
52
+ const fetchAccount = async (apiKey) => {
53
+ return Result.tryPromise({
54
+ catch: (cause) => cause,
55
+ try: async () => {
56
+ const result = await fetchAccountOnce(apiKey);
57
+ if (Result.isError(result)) {
58
+ throw result.error;
59
+ }
60
+ return result.value;
61
+ },
62
+ }, remoteRetryConfig());
63
+ };
48
64
  return {
49
65
  fetchAccount,
50
66
  listServers: async (apiKey) => {
@@ -4,22 +4,33 @@ import type { BrowserOpener } from "../infra/browser.js";
4
4
  import type { CredentialsStore } from "../infra/credentials.js";
5
5
  import type { HttpClient } from "../infra/http.js";
6
6
  import { AuthError, RemoteRequestError, UnexpectedError, ValidationError } from "../shared/errors.js";
7
- import type { LoginSuccess, LogoutSuccess } from "../shared/types.js";
7
+ import type { AuthStatusSuccess, LoginSuccess, LogoutSuccess } from "../shared/types.js";
8
8
  export interface LoginPendingInfo {
9
9
  userCode: string;
10
10
  verificationUri: string;
11
11
  }
12
- export interface LoginOptions {
13
- device: boolean;
12
+ interface BaseLoginOptions {
14
13
  nonInteractive: boolean;
14
+ }
15
+ interface DeviceLoginOptions extends BaseLoginOptions {
16
+ mode: "device";
15
17
  onPending?: (info: LoginPendingInfo) => void;
16
18
  }
19
+ interface BrowserLoginOptions extends BaseLoginOptions {
20
+ mode: "browser";
21
+ }
22
+ interface ApiKeyLoginOptions extends BaseLoginOptions {
23
+ apiKey: string;
24
+ mode: "apiKey";
25
+ }
26
+ export type LoginOptions = ApiKeyLoginOptions | BrowserLoginOptions | DeviceLoginOptions;
17
27
  export type LoginError = AuthError | RemoteRequestError | UnexpectedError | ValidationError;
18
28
  export type ResolveApiKeyError = AuthError | UnexpectedError;
19
29
  export interface AuthService {
20
30
  login(options: LoginOptions): Promise<ResultType<LoginSuccess, LoginError>>;
21
31
  logout(): Promise<ResultType<LogoutSuccess, UnexpectedError>>;
22
32
  resolveApiKey(overrideApiKey?: string): Promise<ResultType<string, ResolveApiKeyError>>;
33
+ status(overrideApiKey?: string): Promise<ResultType<AuthStatusSuccess, UnexpectedError>>;
23
34
  }
24
35
  interface AuthServiceDeps {
25
36
  baseUrl: string;
@@ -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;AAGnD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,C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UAAU,CAAC,CAAC,CAAC;IAC5E,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;IAC9D,aAAa,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACxF,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC,CAAC;CAC1F;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,YAAY,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;IACjC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1B,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;AAgTD,eAAO,MAAM,iBAAiB,GAAI,MAAM,eAAe,KAAG,WAioBzD,CAAC"}
@@ -6,8 +6,10 @@ import { Result } from "better-result";
6
6
  import { detectExecutionEnvironment } from "../infra/env.js";
7
7
  import { readResponseText } from "../infra/http.js";
8
8
  import { CLI_CLIENT_NAME, CLI_REDIRECT_HOST } from "../shared/constants.js";
9
+ import { ERROR_CODE } from "../shared/error-codes.js";
9
10
  import { AuthError, RemoteRequestError, UnexpectedError, ValidationError, } from "../shared/errors.js";
10
11
  import { parseWithSchema } from "../shared/guards.js";
12
+ import { remoteRetryConfig } from "../shared/retry.js";
11
13
  import { browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, } from "../shared/schemas.js";
12
14
  const CALLBACK_TIMEOUT_MILLISECONDS = 5 * 60 * 1000;
13
15
  const defaultSleep = async (milliseconds) => {
@@ -123,7 +125,9 @@ const waitForOAuthCallback = async (server, port) => {
123
125
  });
124
126
  response.end(errorPage(`OAuth error: ${oauthError}`));
125
127
  return Result.err(new AuthError({
128
+ code: ERROR_CODE.authInvalidCredentials,
126
129
  message: `OAuth error: ${oauthError}`,
130
+ suggestedCommand: "ogment auth login --browser",
127
131
  }));
128
132
  }
129
133
  const code = url.searchParams.get("code");
@@ -133,7 +137,9 @@ const waitForOAuthCallback = async (server, port) => {
133
137
  });
134
138
  response.end(errorPage("No authorization code received."));
135
139
  return Result.err(new AuthError({
140
+ code: ERROR_CODE.authInvalidCredentials,
136
141
  message: "No authorization code in callback",
142
+ suggestedCommand: "ogment auth login --browser",
137
143
  }));
138
144
  }
139
145
  return Result.ok({
@@ -146,18 +152,24 @@ const waitForOAuthCallback = async (server, port) => {
146
152
  catch (error) {
147
153
  if (error instanceof Error && error.name === "AbortError") {
148
154
  return Result.err(new AuthError({
155
+ code: ERROR_CODE.authInvalidCredentials,
149
156
  message: "Login timed out. No callback received within 5 minutes.",
157
+ suggestedCommand: "ogment auth login --browser",
150
158
  }));
151
159
  }
152
160
  return Result.err(new AuthError({
161
+ code: ERROR_CODE.authInvalidCredentials,
153
162
  message: "Failed while waiting for OAuth callback.",
163
+ suggestedCommand: "ogment auth login --browser",
154
164
  }));
155
165
  }
156
166
  finally {
157
167
  clearTimeout(timeout);
158
168
  }
159
169
  return Result.err(new AuthError({
170
+ code: ERROR_CODE.authInvalidCredentials,
160
171
  message: "Login timed out. No callback received within 5 minutes.",
172
+ suggestedCommand: "ogment auth login --browser",
161
173
  }));
162
174
  };
163
175
  const waitForAgentCallback = async (server, port) => {
@@ -181,7 +193,9 @@ const waitForAgentCallback = async (server, port) => {
181
193
  });
182
194
  response.end(errorPage("No exchange code received."));
183
195
  return Result.err(new AuthError({
196
+ code: ERROR_CODE.authInvalidCredentials,
184
197
  message: "No exchange code in callback",
198
+ suggestedCommand: "ogment auth login --browser",
185
199
  }));
186
200
  }
187
201
  const agentName = parsedCallback.value.agent_name ?? "CLI Agent";
@@ -198,18 +212,24 @@ const waitForAgentCallback = async (server, port) => {
198
212
  catch (error) {
199
213
  if (error instanceof Error && error.name === "AbortError") {
200
214
  return Result.err(new AuthError({
215
+ code: ERROR_CODE.authInvalidCredentials,
201
216
  message: "Agent selection timed out.",
217
+ suggestedCommand: "ogment auth login --browser",
202
218
  }));
203
219
  }
204
220
  return Result.err(new AuthError({
221
+ code: ERROR_CODE.authInvalidCredentials,
205
222
  message: "Failed while waiting for agent callback.",
223
+ suggestedCommand: "ogment auth login --browser",
206
224
  }));
207
225
  }
208
226
  finally {
209
227
  clearTimeout(timeout);
210
228
  }
211
229
  return Result.err(new AuthError({
230
+ code: ERROR_CODE.authInvalidCredentials,
212
231
  message: "Agent selection timed out.",
232
+ suggestedCommand: "ogment auth login --browser",
213
233
  }));
214
234
  };
215
235
  const deviceCodeUrl = (baseUrl) => `${baseUrl}/api/v1/mcp-auth/device/code`;
@@ -226,8 +246,21 @@ export const createAuthService = (deps) => {
226
246
  const createServerFn = deps.createServerFn ?? createServer;
227
247
  const detectEnvironment = deps.detectEnvironment ?? detectExecutionEnvironment;
228
248
  const hostnameFn = deps.hostnameFn ?? hostname;
249
+ const retryConfig = remoteRetryConfig();
250
+ const requestWithRetry = async (input, init) => {
251
+ return Result.tryPromise({
252
+ catch: (cause) => cause,
253
+ try: async () => {
254
+ const response = await deps.httpClient.request(input, init);
255
+ if (Result.isError(response)) {
256
+ throw response.error;
257
+ }
258
+ return response.value;
259
+ },
260
+ }, retryConfig);
261
+ };
229
262
  const loginWithDevice = async (options) => {
230
- const startFlowResponse = await deps.httpClient.request(deviceCodeUrl(deps.baseUrl), {
263
+ const startFlowResponse = await requestWithRetry(deviceCodeUrl(deps.baseUrl), {
231
264
  headers: {
232
265
  "Content-Type": "application/json",
233
266
  },
@@ -266,7 +299,7 @@ export const createAuthService = (deps) => {
266
299
  const interval = parsedStartPayload.value.data.interval * 1000;
267
300
  while (now() < deadline) {
268
301
  await sleep(interval);
269
- const pollResponse = await deps.httpClient.request(deviceTokenUrl(deps.baseUrl), {
302
+ const pollResponse = await requestWithRetry(deviceTokenUrl(deps.baseUrl), {
270
303
  body: JSON.stringify({
271
304
  device_code: parsedStartPayload.value.data.device_code,
272
305
  }),
@@ -280,12 +313,16 @@ export const createAuthService = (deps) => {
280
313
  }
281
314
  if (pollResponse.value.status === 410) {
282
315
  return Result.err(new AuthError({
283
- message: "Device login code expired. Run `ogment login --device` again.",
316
+ code: ERROR_CODE.authDeviceExpired,
317
+ message: "Device login code expired. Run `ogment auth login` again.",
318
+ suggestedCommand: "ogment auth login",
284
319
  }));
285
320
  }
286
321
  if (pollResponse.value.status === 404) {
287
322
  return Result.err(new AuthError({
288
- message: "Invalid device login code. Run `ogment login --device` again.",
323
+ code: ERROR_CODE.authInvalidCredentials,
324
+ message: "Invalid device login code. Run `ogment auth login` again.",
325
+ suggestedCommand: "ogment auth login",
289
326
  }));
290
327
  }
291
328
  if (!pollResponse.value.ok) {
@@ -326,7 +363,9 @@ export const createAuthService = (deps) => {
326
363
  });
327
364
  }
328
365
  return Result.err(new AuthError({
329
- message: "Device login code expired. Run `ogment login --device` again.",
366
+ code: ERROR_CODE.authDeviceExpired,
367
+ message: "Device login code expired. Run `ogment auth login` again.",
368
+ suggestedCommand: "ogment auth login",
330
369
  }));
331
370
  };
332
371
  const loginWithBrowser = async () => {
@@ -336,7 +375,7 @@ export const createAuthService = (deps) => {
336
375
  }
337
376
  const { port, server } = callbackServerResult.value;
338
377
  const redirectUri = `http://${CLI_REDIRECT_HOST}:${port}/callback`;
339
- const registerResponse = await deps.httpClient.request(oauthRegisterUrl(deps.baseUrl), {
378
+ const registerResponse = await requestWithRetry(oauthRegisterUrl(deps.baseUrl), {
340
379
  body: JSON.stringify({
341
380
  client_name: CLI_CLIENT_NAME,
342
381
  grant_types: ["authorization_code"],
@@ -406,7 +445,9 @@ export const createAuthService = (deps) => {
406
445
  oauthCallbackResult.value.response.end();
407
446
  await closeServer(server);
408
447
  return Result.err(new AuthError({
448
+ code: ERROR_CODE.authInvalidCredentials,
409
449
  message: "OAuth state mismatch - possible CSRF attack.",
450
+ suggestedCommand: "ogment auth login --browser",
410
451
  }));
411
452
  }
412
453
  const tokenBody = new URLSearchParams({
@@ -420,7 +461,7 @@ export const createAuthService = (deps) => {
420
461
  parsedClient.value.client_secret.length > 0) {
421
462
  tokenBody.set("client_secret", parsedClient.value.client_secret);
422
463
  }
423
- const tokenResponse = await deps.httpClient.request(oauthTokenUrl(deps.baseUrl), {
464
+ const tokenResponse = await requestWithRetry(oauthTokenUrl(deps.baseUrl), {
424
465
  body: tokenBody.toString(),
425
466
  headers: {
426
467
  "Content-Type": "application/x-www-form-urlencoded",
@@ -477,7 +518,7 @@ export const createAuthService = (deps) => {
477
518
  if (Result.isError(parsedExchangeRequestPayload)) {
478
519
  return parsedExchangeRequestPayload;
479
520
  }
480
- const exchangeResponse = await deps.httpClient.request(cliExchangeUrl(deps.baseUrl), {
521
+ const exchangeResponse = await requestWithRetry(cliExchangeUrl(deps.baseUrl), {
481
522
  body: JSON.stringify(parsedExchangeRequestPayload.value),
482
523
  headers: {
483
524
  "Content-Type": "application/json",
@@ -499,17 +540,24 @@ export const createAuthService = (deps) => {
499
540
  const exchangeErrorCode = parsedExchangeError.value.error;
500
541
  if (exchangeErrorCode === "expired_exchange_code") {
501
542
  return Result.err(new AuthError({
502
- message: "Browser login code expired. Run `ogment login` again.",
543
+ code: ERROR_CODE.authDeviceExpired,
544
+ message: "Browser login code expired. Run `ogment auth login --browser` again.",
545
+ suggestedCommand: "ogment auth login --browser",
503
546
  }));
504
547
  }
505
548
  if (exchangeErrorCode === "invalid_exchange_code") {
506
549
  return Result.err(new AuthError({
507
- message: "Invalid browser login code. Run `ogment login` again.",
550
+ code: ERROR_CODE.authInvalidCredentials,
551
+ message: "Invalid browser login code. Run `ogment auth login --browser` again.",
552
+ suggestedCommand: "ogment auth login --browser",
508
553
  }));
509
554
  }
510
555
  if (exchangeErrorCode === "authorization_pending") {
511
556
  return Result.err(new AuthError({
557
+ code: ERROR_CODE.authDevicePending,
512
558
  message: "Browser login authorization is still pending.",
559
+ retryable: true,
560
+ suggestedCommand: "ogment auth login --browser",
513
561
  }));
514
562
  }
515
563
  }
@@ -548,9 +596,31 @@ export const createAuthService = (deps) => {
548
596
  };
549
597
  return {
550
598
  login: async (options) => {
551
- if (options.nonInteractive && !options.device) {
599
+ if (options.mode === "apiKey" && options.apiKey.length > 0) {
600
+ const saveResult = deps.credentialsStore.save({
601
+ agentName: "CLI Agent",
602
+ apiKey: options.apiKey,
603
+ });
604
+ if (Result.isError(saveResult)) {
605
+ return saveResult;
606
+ }
607
+ return Result.ok({
608
+ agentName: "CLI Agent",
609
+ alreadyLoggedIn: false,
610
+ });
611
+ }
612
+ if (options.mode === "apiKey") {
552
613
  return Result.err(new ValidationError({
553
- message: "Use `ogment login --device` in non-interactive mode.",
614
+ code: ERROR_CODE.validationInvalidInput,
615
+ message: "Missing API key value. Provide a non-empty API key.",
616
+ suggestedCommand: "ogment auth login --api-key <key>",
617
+ }));
618
+ }
619
+ if (options.nonInteractive && options.mode === "browser") {
620
+ return Result.err(new ValidationError({
621
+ code: ERROR_CODE.validationInvalidInput,
622
+ message: "Use `ogment auth login` in non-interactive mode.",
623
+ suggestedCommand: "ogment auth login",
554
624
  }));
555
625
  }
556
626
  const stored = deps.credentialsStore.load();
@@ -563,7 +633,7 @@ export const createAuthService = (deps) => {
563
633
  alreadyLoggedIn: true,
564
634
  });
565
635
  }
566
- if (options.device) {
636
+ if (options.mode === "device") {
567
637
  return loginWithDevice(options);
568
638
  }
569
639
  return loginWithBrowser();
@@ -579,7 +649,7 @@ export const createAuthService = (deps) => {
579
649
  revoked: false,
580
650
  });
581
651
  }
582
- const revokeResult = await deps.httpClient.request(revokeUrl(deps.baseUrl), {
652
+ const revokeResult = await requestWithRetry(revokeUrl(deps.baseUrl), {
583
653
  headers: {
584
654
  Authorization: `Bearer ${stored.value.apiKey}`,
585
655
  },
@@ -610,8 +680,42 @@ export const createAuthService = (deps) => {
610
680
  return Result.ok(stored.value.apiKey);
611
681
  }
612
682
  return Result.err(new AuthError({
613
- message: "Not logged in. Run `ogment login` or set OGMENT_API_KEY.",
683
+ code: ERROR_CODE.authRequired,
684
+ message: "Not logged in. Run `ogment auth login` or set OGMENT_API_KEY.",
685
+ suggestedCommand: "ogment auth login",
614
686
  }));
615
687
  },
688
+ status: async (overrideApiKey) => {
689
+ if (typeof overrideApiKey === "string" && overrideApiKey.length > 0) {
690
+ return Result.ok({
691
+ agentName: null,
692
+ apiKeySource: "apiKeyOption",
693
+ loggedIn: true,
694
+ });
695
+ }
696
+ if (typeof deps.envApiKey === "string" && deps.envApiKey.length > 0) {
697
+ return Result.ok({
698
+ agentName: null,
699
+ apiKeySource: "env",
700
+ loggedIn: true,
701
+ });
702
+ }
703
+ const stored = deps.credentialsStore.load();
704
+ if (Result.isError(stored)) {
705
+ return stored;
706
+ }
707
+ if (stored.value === null) {
708
+ return Result.ok({
709
+ agentName: null,
710
+ apiKeySource: "none",
711
+ loggedIn: false,
712
+ });
713
+ }
714
+ return Result.ok({
715
+ agentName: stored.value.agentName ?? null,
716
+ apiKeySource: "credentialsFile",
717
+ loggedIn: true,
718
+ });
719
+ },
616
720
  };
617
721
  };
@@ -1 +1 @@
1
- {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/services/info.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD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a,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,4BAA4B,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAqFD,eAAO,MAAM,iBAAiB,GAAI,MAAM,eAAe,KAAG,WAgNzD,CAAC"}
@@ -48,9 +48,9 @@ const resolveApiKey = (apiKeyOverride, envApiKey, credentialsStore) => {
48
48
  };
49
49
  };
50
50
  const nextActionByIssueCode = {
51
- auth_failed: "Run `ogment login` to refresh credentials.",
51
+ auth_failed: "Run `ogment auth login` to refresh credentials.",
52
52
  credentials_load_failed: "Check file permissions and contents of `~/.config/ogment/credentials.json`.",
53
- no_api_key: "Run `ogment login` or set `OGMENT_API_KEY`.",
53
+ no_api_key: "Run `ogment auth login` or set `OGMENT_API_KEY`.",
54
54
  unreachable: "Verify `OGMENT_BASE_URL` and network connectivity.",
55
55
  };
56
56
  const toSummary = (issues) => {
@@ -61,7 +61,7 @@ const toSummary = (issues) => {
61
61
  nextActions.add(nextAction);
62
62
  }
63
63
  }
64
- nextActions.add("Run `ogment servers` to inspect available servers.");
64
+ nextActions.add("Run `ogment catalog` to inspect available servers.");
65
65
  return {
66
66
  issues: issues.map((issue) => issue.message),
67
67
  nextActions: [...nextActions],
@@ -172,7 +172,7 @@ export const createInfoService = (deps) => {
172
172
  if (apiKeyResolution.source === "none") {
173
173
  issues.push({
174
174
  code: "no_api_key",
175
- message: "No API key found in --apiKey, OGMENT_API_KEY, or credentials file.",
175
+ message: "No API key found in --api-key, OGMENT_API_KEY, or credentials file.",
176
176
  });
177
177
  }
178
178
  if (apiKeyResolution.source === "credentialsError" && apiKeyResolution.loadError !== null) {
@@ -221,17 +221,18 @@ export const createInfoService = (deps) => {
221
221
  },
222
222
  documentation: {
223
223
  configPrecedence: [
224
- "--apiKey option",
224
+ "--api-key option",
225
225
  "OGMENT_API_KEY environment variable",
226
226
  "~/.config/ogment/credentials.json",
227
227
  "default base URL when OGMENT_BASE_URL is unset",
228
228
  ],
229
229
  quickCommands: [
230
- "ogment info",
231
- "ogment login --device --non-interactive",
232
- "ogment servers",
233
- "ogment servers <path>",
234
- 'ogment call <serverPath> <toolName> \'{"key":"value"}\'',
230
+ "ogment status",
231
+ "ogment auth login",
232
+ "ogment catalog",
233
+ "ogment catalog <server-id>",
234
+ "ogment catalog <server-id> <tool-name>",
235
+ "ogment invoke <server-id>/<tool-name> --input '{}'",
235
236
  ],
236
237
  },
237
238
  generatedAt: new Date(now()).toISOString(),
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/services/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,C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C"}
@@ -1,8 +1,10 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client";
2
2
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
3
3
  import { Result } from "better-result";
4
+ import { ERROR_CODE } from "../shared/error-codes.js";
4
5
  import { RemoteRequestError } from "../shared/errors.js";
5
6
  import { parseWithSchema } from "../shared/guards.js";
7
+ import { remoteRetryConfig } from "../shared/retry.js";
6
8
  import { toolDefinitionSchema } from "../shared/schemas.js";
7
9
  const defaultCreateClient = (version) => {
8
10
  return new Client({
@@ -71,6 +73,7 @@ const parseToolCallContent = (result) => {
71
73
  export const createMcpService = (deps) => {
72
74
  const createClient = deps.createClient ?? (() => defaultCreateClient(deps.version));
73
75
  const createTransport = deps.createTransport ?? defaultCreateTransport;
76
+ const retryConfig = remoteRetryConfig();
74
77
  const withClient = async (target, apiKey, handler) => {
75
78
  const endpoint = `${deps.baseUrl}/api/v1/mcp/${target.orgSlug}/${target.serverPath}`;
76
79
  const url = new URL(endpoint);
@@ -84,7 +87,7 @@ export const createMcpService = (deps) => {
84
87
  try: async () => {
85
88
  await client.connect(transport);
86
89
  },
87
- });
90
+ }, retryConfig);
88
91
  if (Result.isError(connectResult)) {
89
92
  return connectResult;
90
93
  }
@@ -100,21 +103,24 @@ export const createMcpService = (deps) => {
100
103
  });
101
104
  }
102
105
  };
106
+ const withRemoteRetry = async (action, message) => {
107
+ return Result.tryPromise({
108
+ catch: (cause) => new RemoteRequestError({
109
+ body: JSON.stringify({ cause }),
110
+ message,
111
+ }),
112
+ try: action,
113
+ }, retryConfig);
114
+ };
103
115
  return {
104
116
  callTool: async (target, apiKey, toolName, args) => {
105
117
  return withClient(target, apiKey, async (client) => {
106
- const toolCallResult = await Result.tryPromise({
107
- catch: (cause) => new RemoteRequestError({
108
- body: JSON.stringify({ cause }),
109
- message: "MCP tool call failed",
110
- }),
111
- try: async () => {
112
- return client.callTool({
113
- arguments: args,
114
- name: toolName,
115
- });
116
- },
117
- });
118
+ const toolCallResult = await withRemoteRetry(async () => {
119
+ return client.callTool({
120
+ arguments: args,
121
+ name: toolName,
122
+ });
123
+ }, "MCP tool call failed");
118
124
  if (Result.isError(toolCallResult)) {
119
125
  return toolCallResult;
120
126
  }
@@ -123,21 +129,16 @@ export const createMcpService = (deps) => {
123
129
  },
124
130
  listTools: async (target, apiKey) => {
125
131
  return withClient(target, apiKey, async (client) => {
126
- const toolsResult = await Result.tryPromise({
127
- catch: (cause) => new RemoteRequestError({
128
- body: JSON.stringify({ cause }),
129
- message: "MCP tools/list failed",
130
- }),
131
- try: async () => {
132
- return client.listTools();
133
- },
134
- });
132
+ const toolsResult = await withRemoteRetry(async () => client.listTools(), "MCP tools/list failed");
135
133
  if (Result.isError(toolsResult)) {
136
134
  return toolsResult;
137
135
  }
138
136
  const parsedTools = [];
139
137
  for (const tool of toolsResult.value.tools) {
140
- const parsed = parseWithSchema(toolDefinitionSchema, tool, "MCP tool definition");
138
+ const parsed = parseWithSchema(toolDefinitionSchema, tool, "MCP tool definition", {
139
+ code: ERROR_CODE.toolInputSchemaViolation,
140
+ suggestedCommand: "ogment catalog",
141
+ });
141
142
  if (Result.isError(parsed)) {
142
143
  return parsed;
143
144
  }
@@ -4,5 +4,4 @@ export declare const DEFAULT_OGMENT_BASE_URL = "https://dashboard.ogment.ai";
4
4
  export declare const CLI_CLIENT_NAME = "Ogment CLI";
5
5
  export declare const CLI_REDIRECT_HOST = "127.0.0.1";
6
6
  export declare const VERSION: string;
7
- export declare const AGENT_SUCCESS_HINT = "Use `ogment servers` to list available servers.";
8
7
  //# 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;AAM7C,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C,eAAO,MAAM,kBAAkB,oDAAoD,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;AACrE,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAQ7C,eAAO,MAAM,OAAO,QAAsB,CAAC"}
@@ -6,4 +6,3 @@ export const CLI_CLIENT_NAME = "Ogment CLI";
6
6
  export const CLI_REDIRECT_HOST = "127.0.0.1";
7
7
  const packageJson = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
8
8
  export const VERSION = packageJson.version;
9
- export const AGENT_SUCCESS_HINT = "Use `ogment servers` to list available servers.";
@@ -0,0 +1,28 @@
1
+ export declare const ERROR_CATEGORY: {
2
+ readonly auth: "auth";
3
+ readonly authorization: "authorization";
4
+ readonly contractMismatch: "contract_mismatch";
5
+ readonly internal: "internal";
6
+ readonly notFound: "not_found";
7
+ readonly rateLimit: "rate_limit";
8
+ readonly remote: "remote";
9
+ readonly transport: "transport";
10
+ readonly validation: "validation";
11
+ };
12
+ export type ErrorCategory = (typeof ERROR_CATEGORY)[keyof typeof ERROR_CATEGORY];
13
+ export declare const ERROR_CODE: {
14
+ readonly authDeviceExpired: "AUTH_DEVICE_EXPIRED";
15
+ readonly authDevicePending: "AUTH_DEVICE_PENDING";
16
+ readonly authInvalidCredentials: "AUTH_INVALID_CREDENTIALS";
17
+ readonly authRequired: "AUTH_REQUIRED";
18
+ readonly contractVersionUnsupported: "CONTRACT_VERSION_UNSUPPORTED";
19
+ readonly internalUnexpected: "INTERNAL_UNEXPECTED";
20
+ readonly remoteRateLimited: "REMOTE_RATE_LIMITED";
21
+ readonly remoteUnavailable: "REMOTE_UNAVAILABLE";
22
+ readonly toolInputSchemaViolation: "TOOL_INPUT_SCHEMA_VIOLATION";
23
+ readonly toolNotFound: "TOOL_NOT_FOUND";
24
+ readonly transportRequestFailed: "TRANSPORT_REQUEST_FAILED";
25
+ readonly validationInvalidInput: "VALIDATION_INVALID_INPUT";
26
+ };
27
+ export type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];
28
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/shared/error-codes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEjF,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAab,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ export const ERROR_CATEGORY = {
2
+ auth: "auth",
3
+ authorization: "authorization",
4
+ contractMismatch: "contract_mismatch",
5
+ internal: "internal",
6
+ notFound: "not_found",
7
+ rateLimit: "rate_limit",
8
+ remote: "remote",
9
+ transport: "transport",
10
+ validation: "validation",
11
+ };
12
+ export const ERROR_CODE = {
13
+ authDeviceExpired: "AUTH_DEVICE_EXPIRED",
14
+ authDevicePending: "AUTH_DEVICE_PENDING",
15
+ authInvalidCredentials: "AUTH_INVALID_CREDENTIALS",
16
+ authRequired: "AUTH_REQUIRED",
17
+ contractVersionUnsupported: "CONTRACT_VERSION_UNSUPPORTED",
18
+ internalUnexpected: "INTERNAL_UNEXPECTED",
19
+ remoteRateLimited: "REMOTE_RATE_LIMITED",
20
+ remoteUnavailable: "REMOTE_UNAVAILABLE",
21
+ toolInputSchemaViolation: "TOOL_INPUT_SCHEMA_VIOLATION",
22
+ toolNotFound: "TOOL_NOT_FOUND",
23
+ transportRequestFailed: "TRANSPORT_REQUEST_FAILED",
24
+ validationInvalidInput: "VALIDATION_INVALID_INPUT",
25
+ };