@ogment-ai/cli 0.4.2 → 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.
Files changed (87) hide show
  1. package/README.md +0 -9
  2. package/dist/cli/commands.d.ts +37 -0
  3. package/dist/cli/commands.d.ts.map +1 -0
  4. package/dist/cli/commands.js +56 -0
  5. package/dist/cli/execute.d.ts +11 -0
  6. package/dist/cli/execute.d.ts.map +1 -0
  7. package/dist/cli/execute.js +468 -0
  8. package/dist/cli/invocations.d.ts +31 -0
  9. package/dist/cli/invocations.d.ts.map +1 -0
  10. package/dist/cli/invocations.js +1 -0
  11. package/dist/cli/parse-errors.d.ts +17 -0
  12. package/dist/cli/parse-errors.d.ts.map +1 -0
  13. package/dist/cli/parse-errors.js +184 -0
  14. package/dist/cli/program.d.ts +10 -0
  15. package/dist/cli/program.d.ts.map +1 -0
  16. package/dist/cli/program.js +174 -0
  17. package/dist/cli/run.d.ts +6 -0
  18. package/dist/cli/run.d.ts.map +1 -0
  19. package/dist/cli/run.js +83 -0
  20. package/dist/cli/runtime.d.ts +21 -0
  21. package/dist/cli/runtime.d.ts.map +1 -0
  22. package/dist/cli/runtime.js +80 -0
  23. package/dist/cli.d.ts +2 -20
  24. package/dist/cli.d.ts.map +1 -1
  25. package/dist/cli.js +2 -737
  26. package/dist/commands/auth.d.ts +1 -4
  27. package/dist/commands/auth.d.ts.map +1 -1
  28. package/dist/commands/auth.js +0 -8
  29. package/dist/commands/catalog.d.ts +3 -1
  30. package/dist/commands/catalog.d.ts.map +1 -1
  31. package/dist/commands/catalog.js +19 -2
  32. package/dist/commands/invoke.d.ts.map +1 -1
  33. package/dist/commands/invoke.js +53 -3
  34. package/dist/infra/credentials.d.ts.map +1 -1
  35. package/dist/infra/credentials.js +0 -7
  36. package/dist/infra/http.d.ts +5 -1
  37. package/dist/infra/http.d.ts.map +1 -1
  38. package/dist/infra/http.js +62 -5
  39. package/dist/output/envelope.d.ts +5 -2
  40. package/dist/output/envelope.d.ts.map +1 -1
  41. package/dist/output/envelope.js +39 -23
  42. package/dist/output/manager.d.ts +9 -5
  43. package/dist/output/manager.d.ts.map +1 -1
  44. package/dist/output/manager.js +52 -9
  45. package/dist/services/account.d.ts.map +1 -1
  46. package/dist/services/account.js +9 -16
  47. package/dist/services/auth.d.ts +3 -15
  48. package/dist/services/auth.d.ts.map +1 -1
  49. package/dist/services/auth.js +32 -483
  50. package/dist/services/info.d.ts.map +1 -1
  51. package/dist/services/info.js +62 -0
  52. package/dist/services/mcp-error-mapping.d.ts +9 -0
  53. package/dist/services/mcp-error-mapping.d.ts.map +1 -0
  54. package/dist/services/mcp-error-mapping.js +129 -0
  55. package/dist/services/mcp.d.ts +8 -2
  56. package/dist/services/mcp.d.ts.map +1 -1
  57. package/dist/services/mcp.js +24 -14
  58. package/dist/shared/constants.d.ts +0 -2
  59. package/dist/shared/constants.d.ts.map +1 -1
  60. package/dist/shared/constants.js +0 -2
  61. package/dist/shared/error-codes.d.ts +4 -1
  62. package/dist/shared/error-codes.d.ts.map +1 -1
  63. package/dist/shared/error-presentation.d.ts +17 -0
  64. package/dist/shared/error-presentation.d.ts.map +1 -0
  65. package/dist/shared/error-presentation.js +151 -0
  66. package/dist/shared/errors.d.ts +34 -14
  67. package/dist/shared/errors.d.ts.map +1 -1
  68. package/dist/shared/errors.js +126 -25
  69. package/dist/shared/guards.d.ts +2 -1
  70. package/dist/shared/guards.d.ts.map +1 -1
  71. package/dist/shared/guards.js +1 -3
  72. package/dist/shared/recovery.d.ts +5 -0
  73. package/dist/shared/recovery.d.ts.map +1 -0
  74. package/dist/shared/recovery.js +123 -0
  75. package/dist/shared/schemas.d.ts +2 -3
  76. package/dist/shared/schemas.d.ts.map +1 -1
  77. package/dist/shared/schemas.js +2 -3
  78. package/dist/shared/types.d.ts +53 -13
  79. package/dist/shared/types.d.ts.map +1 -1
  80. package/dist/shared/types.js +1 -1
  81. package/package.json +2 -4
  82. package/dist/infra/browser.d.ts +0 -12
  83. package/dist/infra/browser.d.ts.map +0 -1
  84. package/dist/infra/browser.js +0 -20
  85. package/dist/shared/retry.d.ts +0 -17
  86. package/dist/shared/retry.d.ts.map +0 -1
  87. package/dist/shared/retry.js +0 -27
@@ -3,7 +3,6 @@ import { readResponseText } from "../infra/http.js";
3
3
  import { ERROR_CODE } from "../shared/error-codes.js";
4
4
  import { AuthError, RemoteRequestError } from "../shared/errors.js";
5
5
  import { parseWithSchema } from "../shared/guards.js";
6
- import { remoteRetryConfig } from "../shared/retry.js";
7
6
  import { accountMeSchema } from "../shared/schemas.js";
8
7
  const authHeader = (apiKey) => {
9
8
  return {
@@ -23,20 +22,25 @@ export const createAccountService = (deps) => {
23
22
  return Result.err(new AuthError({
24
23
  code: ERROR_CODE.authInvalidCredentials,
25
24
  message: "Authentication failed. Run `ogment auth login` again.",
26
- suggestedCommand: "ogment auth login",
25
+ recovery: { command: "ogment auth login" },
27
26
  }));
28
27
  }
29
28
  const body = await readResponseText(responseResult.value);
30
29
  return Result.err(new RemoteRequestError({
31
30
  body,
31
+ httpStatus: responseResult.value.status,
32
32
  message: "Failed to fetch account details",
33
- status: responseResult.value.status,
33
+ operation: "account/fetch",
34
+ raw: body,
35
+ source: "http",
34
36
  }));
35
37
  }
36
38
  const jsonResult = await Result.tryPromise({
37
39
  catch: () => new RemoteRequestError({
40
+ httpStatus: responseResult.value.status,
38
41
  message: "Failed to parse account response JSON",
39
- status: responseResult.value.status,
42
+ operation: "account/fetch",
43
+ source: "http",
40
44
  }),
41
45
  try: async () => responseResult.value.json(),
42
46
  });
@@ -49,18 +53,7 @@ export const createAccountService = (deps) => {
49
53
  }
50
54
  return Result.ok(parsed.value.data);
51
55
  };
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
- };
56
+ const fetchAccount = async (apiKey) => fetchAccountOnce(apiKey);
64
57
  return {
65
58
  fetchAccount,
66
59
  listServers: async (apiKey) => {
@@ -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":"","s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