@ogment-ai/cli 0.4.2 → 0.5.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 (71) hide show
  1. package/dist/cli/commands.d.ts +38 -0
  2. package/dist/cli/commands.d.ts.map +1 -0
  3. package/dist/cli/commands.js +57 -0
  4. package/dist/cli/execute.d.ts +11 -0
  5. package/dist/cli/execute.d.ts.map +1 -0
  6. package/dist/cli/execute.js +487 -0
  7. package/dist/cli/invocations.d.ts +32 -0
  8. package/dist/cli/invocations.d.ts.map +1 -0
  9. package/dist/cli/invocations.js +1 -0
  10. package/dist/cli/parse-errors.d.ts +17 -0
  11. package/dist/cli/parse-errors.d.ts.map +1 -0
  12. package/dist/cli/parse-errors.js +184 -0
  13. package/dist/cli/program.d.ts +10 -0
  14. package/dist/cli/program.d.ts.map +1 -0
  15. package/dist/cli/program.js +183 -0
  16. package/dist/cli/run.d.ts +6 -0
  17. package/dist/cli/run.d.ts.map +1 -0
  18. package/dist/cli/run.js +83 -0
  19. package/dist/cli/runtime.d.ts +22 -0
  20. package/dist/cli/runtime.d.ts.map +1 -0
  21. package/dist/cli/runtime.js +86 -0
  22. package/dist/cli.d.ts +2 -20
  23. package/dist/cli.d.ts.map +1 -1
  24. package/dist/cli.js +2 -737
  25. package/dist/commands/catalog.d.ts +3 -1
  26. package/dist/commands/catalog.d.ts.map +1 -1
  27. package/dist/commands/catalog.js +19 -2
  28. package/dist/commands/invoke.d.ts.map +1 -1
  29. package/dist/commands/invoke.js +53 -3
  30. package/dist/infra/http.d.ts +5 -1
  31. package/dist/infra/http.d.ts.map +1 -1
  32. package/dist/infra/http.js +62 -5
  33. package/dist/output/envelope.d.ts +5 -2
  34. package/dist/output/envelope.d.ts.map +1 -1
  35. package/dist/output/envelope.js +39 -23
  36. package/dist/output/manager.d.ts +9 -3
  37. package/dist/output/manager.d.ts.map +1 -1
  38. package/dist/output/manager.js +53 -2
  39. package/dist/services/account.d.ts.map +1 -1
  40. package/dist/services/account.js +9 -16
  41. package/dist/services/auth.d.ts.map +1 -1
  42. package/dist/services/auth.js +70 -52
  43. package/dist/services/info.d.ts.map +1 -1
  44. package/dist/services/info.js +62 -0
  45. package/dist/services/mcp-error-mapping.d.ts +9 -0
  46. package/dist/services/mcp-error-mapping.d.ts.map +1 -0
  47. package/dist/services/mcp-error-mapping.js +129 -0
  48. package/dist/services/mcp.d.ts +8 -2
  49. package/dist/services/mcp.d.ts.map +1 -1
  50. package/dist/services/mcp.js +24 -14
  51. package/dist/shared/error-codes.d.ts +4 -1
  52. package/dist/shared/error-codes.d.ts.map +1 -1
  53. package/dist/shared/error-presentation.d.ts +17 -0
  54. package/dist/shared/error-presentation.d.ts.map +1 -0
  55. package/dist/shared/error-presentation.js +151 -0
  56. package/dist/shared/errors.d.ts +34 -14
  57. package/dist/shared/errors.d.ts.map +1 -1
  58. package/dist/shared/errors.js +126 -25
  59. package/dist/shared/guards.d.ts +2 -1
  60. package/dist/shared/guards.d.ts.map +1 -1
  61. package/dist/shared/guards.js +1 -3
  62. package/dist/shared/recovery.d.ts +5 -0
  63. package/dist/shared/recovery.d.ts.map +1 -0
  64. package/dist/shared/recovery.js +123 -0
  65. package/dist/shared/types.d.ts +53 -13
  66. package/dist/shared/types.d.ts.map +1 -1
  67. package/dist/shared/types.js +1 -1
  68. package/package.json +2 -2
  69. package/dist/shared/retry.d.ts +0 -17
  70. package/dist/shared/retry.d.ts.map +0 -1
  71. package/dist/shared/retry.js +0 -27
@@ -1,11 +1,14 @@
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 { createRemoteRequestErrorFromMcpCause } from "./mcp-error-mapping.js";
4
5
  import { ERROR_CODE } from "../shared/error-codes.js";
5
6
  import { RemoteRequestError } from "../shared/errors.js";
6
7
  import { parseWithSchema } from "../shared/guards.js";
7
- import { remoteRetryConfig } from "../shared/retry.js";
8
8
  import { toolDefinitionSchema } from "../shared/schemas.js";
9
+ const MCP_CONNECT_TIMEOUT_MS = 10_000;
10
+ const MCP_DISCOVERY_TIMEOUT_MS = 10_000;
11
+ const MCP_INVOKE_TIMEOUT_MS = 45_000;
9
12
  const defaultCreateClient = (version) => {
10
13
  return new Client({
11
14
  name: "ogment-cli",
@@ -73,21 +76,23 @@ const parseToolCallContent = (result) => {
73
76
  export const createMcpService = (deps) => {
74
77
  const createClient = deps.createClient ?? (() => defaultCreateClient(deps.version));
75
78
  const createTransport = deps.createTransport ?? defaultCreateTransport;
76
- const retryConfig = remoteRetryConfig();
77
79
  const withClient = async (target, apiKey, handler) => {
78
80
  const endpoint = `${deps.baseUrl}/api/v1/mcp/${target.orgSlug}/${target.serverPath}`;
79
81
  const url = new URL(endpoint);
80
82
  const transport = createTransport(url, apiKey);
81
83
  const client = createClient();
82
84
  const connectResult = await Result.tryPromise({
83
- catch: (cause) => new RemoteRequestError({
84
- body: JSON.stringify({ cause }),
85
+ catch: (cause) => createRemoteRequestErrorFromMcpCause({
86
+ cause,
85
87
  message: "Failed to connect to MCP server",
88
+ operation: "connect",
86
89
  }),
87
90
  try: async () => {
88
- await client.connect(transport);
91
+ await client.connect(transport, {
92
+ timeout: MCP_CONNECT_TIMEOUT_MS,
93
+ });
89
94
  },
90
- }, retryConfig);
95
+ });
91
96
  if (Result.isError(connectResult)) {
92
97
  return connectResult;
93
98
  }
@@ -103,24 +108,27 @@ export const createMcpService = (deps) => {
103
108
  });
104
109
  }
105
110
  };
106
- const withRemoteRetry = async (action, message) => {
111
+ const withRemoteCall = async (action, message, operation) => {
107
112
  return Result.tryPromise({
108
- catch: (cause) => new RemoteRequestError({
109
- body: JSON.stringify({ cause }),
113
+ catch: (cause) => createRemoteRequestErrorFromMcpCause({
114
+ cause,
110
115
  message,
116
+ operation,
111
117
  }),
112
118
  try: action,
113
- }, retryConfig);
119
+ });
114
120
  };
115
121
  return {
116
122
  callTool: async (target, apiKey, toolName, args) => {
117
123
  return withClient(target, apiKey, async (client) => {
118
- const toolCallResult = await withRemoteRetry(async () => {
124
+ const toolCallResult = await withRemoteCall(async () => {
119
125
  return client.callTool({
120
126
  arguments: args,
121
127
  name: toolName,
128
+ }, undefined, {
129
+ timeout: MCP_INVOKE_TIMEOUT_MS,
122
130
  });
123
- }, "MCP tool call failed");
131
+ }, "MCP tool call failed", "tools/call");
124
132
  if (Result.isError(toolCallResult)) {
125
133
  return toolCallResult;
126
134
  }
@@ -129,7 +137,9 @@ export const createMcpService = (deps) => {
129
137
  },
130
138
  listTools: async (target, apiKey) => {
131
139
  return withClient(target, apiKey, async (client) => {
132
- const toolsResult = await withRemoteRetry(async () => client.listTools(), "MCP tools/list failed");
140
+ const toolsResult = await withRemoteCall(async () => client.listTools(undefined, {
141
+ timeout: MCP_DISCOVERY_TIMEOUT_MS,
142
+ }), "MCP tools/list failed", "tools/list");
133
143
  if (Result.isError(toolsResult)) {
134
144
  return toolsResult;
135
145
  }
@@ -137,7 +147,7 @@ export const createMcpService = (deps) => {
137
147
  for (const tool of toolsResult.value.tools) {
138
148
  const parsed = parseWithSchema(toolDefinitionSchema, tool, "MCP tool definition", {
139
149
  code: ERROR_CODE.toolInputSchemaViolation,
140
- suggestedCommand: "ogment catalog",
150
+ recovery: { command: "ogment catalog" },
141
151
  });
142
152
  if (Result.isError(parsed)) {
143
153
  return parsed;
@@ -24,5 +24,8 @@ export declare const ERROR_CODE: {
24
24
  readonly transportRequestFailed: "TRANSPORT_REQUEST_FAILED";
25
25
  readonly validationInvalidInput: "VALIDATION_INVALID_INPUT";
26
26
  };
27
- export type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];
27
+ export type StaticErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];
28
+ export type HttpStatusErrorCode = `HTTP_${number}`;
29
+ export type McpNumericErrorCode = `MCP_${number}`;
30
+ export type ErrorCode = StaticErrorCode | HttpStatusErrorCode | McpNumericErrorCode;
28
31
  //# sourceMappingURL=error-codes.d.ts.map
@@ -1 +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"}
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,eAAe,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAC3E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,MAAM,EAAE,CAAC;AACnD,MAAM,MAAM,mBAAmB,GAAG,OAAO,MAAM,EAAE,CAAC;AAClD,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,mBAAmB,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type AppError } from "./errors.js";
2
+ import type { CliRuntimeErrorPayload } from "./types.js";
3
+ interface PresentAppErrorOptions {
4
+ contextDiagnostics?: Record<string, unknown>;
5
+ includeDebug: boolean;
6
+ }
7
+ export declare const presentRuntimeErrorPayload: (error: AppError, options: PresentAppErrorOptions) => CliRuntimeErrorPayload;
8
+ export declare const presentCatalogFailureError: (error: AppError, options: PresentAppErrorOptions) => {
9
+ code: string;
10
+ detail: string;
11
+ diagnostics: Record<string, unknown>;
12
+ related_codes?: string[];
13
+ retryable: boolean;
14
+ title: string;
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=error-presentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-presentation.d.ts","sourceRoot":"","sources":["../../src/shared/error-presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EAEd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,UAAU,sBAAsB;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,YAAY,EAAE,OAAO,CAAC;CACvB;AA+ID,eAAO,MAAM,0BAA0B,GACrC,OAAO,QAAQ,EACf,SAAS,sBAAsB,KAC9B,sBA2BF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,OAAO,QAAQ,EACf,SAAS,sBAAsB,KAC9B;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CAWf,CAAC"}
@@ -0,0 +1,151 @@
1
+ import { appErrorDiagnostics, appErrorMeta, appErrorTitle, formatAppError, } from "./errors.js";
2
+ const isRecord = (value) => {
3
+ return typeof value === "object" && value !== null;
4
+ };
5
+ const toHttpCode = (status) => {
6
+ return `HTTP_${status}`;
7
+ };
8
+ const toMcpCode = (code) => {
9
+ return `MCP_${code}`;
10
+ };
11
+ const sanitizeRemoteMessage = (value) => {
12
+ const trimmed = value.trim();
13
+ if (trimmed.length === 0) {
14
+ return undefined;
15
+ }
16
+ if (/^[\w]+Error$/u.test(trimmed)) {
17
+ return undefined;
18
+ }
19
+ const normalized = trimmed.replace(/^[\w]+Error:\s*/u, "").trim();
20
+ return normalized.length > 0 ? normalized : undefined;
21
+ };
22
+ const extractMessageFromRecord = (record) => {
23
+ if (typeof record["message"] === "string") {
24
+ return sanitizeRemoteMessage(record["message"]);
25
+ }
26
+ const nested = record["error"];
27
+ if (isRecord(nested) && typeof nested["message"] === "string") {
28
+ return sanitizeRemoteMessage(nested["message"]);
29
+ }
30
+ return undefined;
31
+ };
32
+ const extractMessageFromBody = (body) => {
33
+ if (typeof body !== "string" || body.length === 0) {
34
+ return undefined;
35
+ }
36
+ const parsed = (() => {
37
+ try {
38
+ return JSON.parse(body);
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ })();
44
+ if (isRecord(parsed)) {
45
+ const fromParsed = extractMessageFromRecord(parsed);
46
+ if (fromParsed !== undefined) {
47
+ return fromParsed;
48
+ }
49
+ }
50
+ return sanitizeRemoteMessage(body);
51
+ };
52
+ const extractRemoteUserMessage = (error) => {
53
+ if (error.source !== "mcp_transport_http" && error.source !== "mcp_jsonrpc") {
54
+ return undefined;
55
+ }
56
+ if (isRecord(error.raw)) {
57
+ const fromRaw = extractMessageFromRecord(error.raw);
58
+ if (fromRaw !== undefined) {
59
+ return fromRaw;
60
+ }
61
+ }
62
+ const fromBody = extractMessageFromBody(error.body);
63
+ if (fromBody !== undefined) {
64
+ return fromBody;
65
+ }
66
+ if (typeof error.mcpData === "string") {
67
+ const fromData = sanitizeRemoteMessage(error.mcpData);
68
+ if (fromData !== undefined) {
69
+ return fromData;
70
+ }
71
+ }
72
+ return undefined;
73
+ };
74
+ const resolvePrimaryCode = (error) => {
75
+ const meta = appErrorMeta(error);
76
+ if (error._tag === "RemoteRequestError") {
77
+ if (typeof error.httpStatus === "number") {
78
+ return toHttpCode(error.httpStatus);
79
+ }
80
+ if (typeof error.mcpCode === "number") {
81
+ return toMcpCode(error.mcpCode);
82
+ }
83
+ }
84
+ return String(meta.code);
85
+ };
86
+ const resolveRelatedCodes = (error, primaryCode) => {
87
+ if (error._tag !== "RemoteRequestError") {
88
+ return undefined;
89
+ }
90
+ const relatedCodes = [
91
+ ...(typeof error.httpStatus === "number" ? [toHttpCode(error.httpStatus)] : []),
92
+ ...(typeof error.mcpCode === "number" ? [toMcpCode(error.mcpCode)] : []),
93
+ ].filter((code, index, array) => {
94
+ return code !== primaryCode && array.indexOf(code) === index;
95
+ });
96
+ return relatedCodes.length > 0 ? relatedCodes : undefined;
97
+ };
98
+ const defaultDiagnostics = (error) => {
99
+ if (error._tag !== "RemoteRequestError") {
100
+ return {};
101
+ }
102
+ return {
103
+ source: error.source,
104
+ ...(error.operation === undefined ? {} : { operation: error.operation }),
105
+ };
106
+ };
107
+ const resolveDetail = (error) => {
108
+ if (error._tag === "RemoteRequestError") {
109
+ const userMessage = extractRemoteUserMessage(error);
110
+ if (userMessage !== undefined) {
111
+ return userMessage;
112
+ }
113
+ }
114
+ return formatAppError(error);
115
+ };
116
+ export const presentRuntimeErrorPayload = (error, options) => {
117
+ const meta = appErrorMeta(error);
118
+ const primaryCode = resolvePrimaryCode(error);
119
+ const relatedCodes = resolveRelatedCodes(error, primaryCode);
120
+ const diagnostics = options.includeDebug === true
121
+ ? {
122
+ tag: error._tag,
123
+ ...appErrorDiagnostics(error),
124
+ }
125
+ : {
126
+ ...defaultDiagnostics(error),
127
+ };
128
+ if (options.contextDiagnostics !== undefined) {
129
+ Object.assign(diagnostics, options.contextDiagnostics);
130
+ }
131
+ return {
132
+ category: meta.category,
133
+ code: primaryCode,
134
+ detail: resolveDetail(error),
135
+ diagnostics,
136
+ ...(relatedCodes === undefined ? {} : { related_codes: relatedCodes }),
137
+ retryable: meta.retryable,
138
+ title: appErrorTitle(error),
139
+ };
140
+ };
141
+ export const presentCatalogFailureError = (error, options) => {
142
+ const payload = presentRuntimeErrorPayload(error, options);
143
+ return {
144
+ code: payload.code,
145
+ detail: payload.detail,
146
+ diagnostics: payload.diagnostics,
147
+ ...(payload.related_codes === undefined ? {} : { related_codes: payload.related_codes }),
148
+ retryable: payload.retryable,
149
+ title: payload.title,
150
+ };
151
+ };
@@ -1,13 +1,15 @@
1
1
  import { ERROR_CODE, type ErrorCategory, type ErrorCode } from "./error-codes.js";
2
+ import { type RecoveryOverride } from "./recovery.js";
3
+ import type { CliNextAction, RemoteErrorDiagnostics, RemoteErrorSource } from "./types.js";
2
4
  type AuthErrorCode = typeof ERROR_CODE.authDeviceExpired | typeof ERROR_CODE.authDevicePending | typeof ERROR_CODE.authInvalidCredentials | typeof ERROR_CODE.authRequired;
3
- type RemoteErrorCode = typeof ERROR_CODE.remoteRateLimited | typeof ERROR_CODE.remoteUnavailable | typeof ERROR_CODE.transportRequestFailed;
5
+ type RemoteErrorCode = typeof ERROR_CODE.remoteRateLimited | typeof ERROR_CODE.remoteUnavailable | typeof ERROR_CODE.transportRequestFailed | `HTTP_${number}` | `MCP_${number}`;
4
6
  type ValidationErrorCode = typeof ERROR_CODE.toolInputSchemaViolation | typeof ERROR_CODE.validationInvalidInput;
5
7
  type ContractMismatchErrorCode = typeof ERROR_CODE.contractVersionUnsupported;
6
8
  interface BaseAppErrorFields {
7
9
  category: ErrorCategory;
8
10
  code: ErrorCode;
11
+ recovery: CliNextAction | undefined;
9
12
  retryable: boolean;
10
- suggestedCommand: string | undefined;
11
13
  }
12
14
  declare const ValidationErrorBase: import("better-result").TaggedErrorClass<"ValidationError", {
13
15
  details?: string;
@@ -17,13 +19,13 @@ interface ValidationErrorPayload {
17
19
  code?: ValidationErrorCode;
18
20
  details?: string;
19
21
  message: string;
20
- suggestedCommand?: string;
22
+ recovery?: RecoveryOverride;
21
23
  }
22
24
  export declare class ValidationError extends ValidationErrorBase implements BaseAppErrorFields {
23
25
  readonly category: "validation";
24
26
  readonly code: ValidationErrorCode;
27
+ readonly recovery: CliNextAction | undefined;
25
28
  readonly retryable = false;
26
- readonly suggestedCommand: string | undefined;
27
29
  constructor(payload: ValidationErrorPayload);
28
30
  }
29
31
  declare const AuthErrorBase: import("better-result").TaggedErrorClass<"AuthError", {
@@ -34,14 +36,14 @@ interface AuthErrorPayload {
34
36
  code?: AuthErrorCode;
35
37
  details?: string;
36
38
  message: string;
39
+ recovery?: RecoveryOverride;
37
40
  retryable?: boolean;
38
- suggestedCommand?: string;
39
41
  }
40
42
  export declare class AuthError extends AuthErrorBase implements BaseAppErrorFields {
41
43
  readonly category: "auth";
42
44
  readonly code: AuthErrorCode;
45
+ readonly recovery: CliNextAction | undefined;
43
46
  readonly retryable: boolean;
44
- readonly suggestedCommand: string | undefined;
45
47
  constructor(payload: AuthErrorPayload);
46
48
  }
47
49
  declare const NotFoundErrorBase: import("better-result").TaggedErrorClass<"NotFoundError", {
@@ -51,33 +53,48 @@ declare const NotFoundErrorBase: import("better-result").TaggedErrorClass<"NotFo
51
53
  interface NotFoundErrorPayload {
52
54
  code?: typeof ERROR_CODE.toolNotFound;
53
55
  message: string;
56
+ recovery?: RecoveryOverride;
54
57
  resource: string;
55
- suggestedCommand?: string;
56
58
  }
57
59
  export declare class NotFoundError extends NotFoundErrorBase implements BaseAppErrorFields {
58
60
  readonly category: "not_found";
59
61
  readonly code: typeof ERROR_CODE.toolNotFound;
62
+ readonly recovery: CliNextAction | undefined;
60
63
  readonly retryable = false;
61
- readonly suggestedCommand: string | undefined;
62
64
  constructor(payload: NotFoundErrorPayload);
63
65
  }
64
66
  declare const RemoteRequestErrorBase: import("better-result").TaggedErrorClass<"RemoteRequestError", {
65
67
  body?: string;
66
68
  message: string;
69
+ mcpCode?: number;
70
+ mcpData?: unknown;
71
+ operation?: string;
72
+ raw?: unknown;
73
+ source: RemoteErrorSource;
67
74
  status?: number;
68
75
  }>;
69
76
  interface RemoteRequestErrorPayload {
70
77
  body?: string;
71
78
  code?: RemoteErrorCode;
79
+ diagnostics?: Partial<RemoteErrorDiagnostics>;
80
+ httpStatus?: number;
81
+ mcpCode?: number;
82
+ mcpData?: unknown;
72
83
  message: string;
84
+ operation?: string;
85
+ raw?: unknown;
86
+ recovery?: RecoveryOverride;
87
+ retryable?: boolean;
88
+ source?: RemoteErrorSource;
73
89
  status?: number;
74
- suggestedCommand?: string;
75
90
  }
76
91
  export declare class RemoteRequestError extends RemoteRequestErrorBase implements BaseAppErrorFields {
77
92
  readonly category: ErrorCategory;
78
93
  readonly code: RemoteErrorCode;
94
+ readonly diagnostics: RemoteErrorDiagnostics;
95
+ readonly httpStatus: number | undefined;
96
+ readonly recovery: CliNextAction | undefined;
79
97
  readonly retryable: boolean;
80
- readonly suggestedCommand: string | undefined;
81
98
  constructor(payload: RemoteRequestErrorPayload);
82
99
  }
83
100
  declare const ContractMismatchErrorBase: import("better-result").TaggedErrorClass<"ContractMismatchError", {
@@ -88,13 +105,13 @@ interface ContractMismatchErrorPayload {
88
105
  code?: ContractMismatchErrorCode;
89
106
  details?: string;
90
107
  message: string;
91
- suggestedCommand?: string;
108
+ recovery?: RecoveryOverride;
92
109
  }
93
110
  export declare class ContractMismatchError extends ContractMismatchErrorBase implements BaseAppErrorFields {
94
111
  readonly category: "contract_mismatch";
95
112
  readonly code: ContractMismatchErrorCode;
113
+ readonly recovery: CliNextAction | undefined;
96
114
  readonly retryable = false;
97
- readonly suggestedCommand: string | undefined;
98
115
  constructor(payload: ContractMismatchErrorPayload);
99
116
  }
100
117
  declare const UnexpectedErrorBase: import("better-result").TaggedErrorClass<"UnexpectedError", {
@@ -105,22 +122,25 @@ interface UnexpectedErrorPayload {
105
122
  cause?: unknown;
106
123
  code?: typeof ERROR_CODE.internalUnexpected;
107
124
  message: string;
125
+ recovery?: RecoveryOverride;
108
126
  }
109
127
  export declare class UnexpectedError extends UnexpectedErrorBase implements BaseAppErrorFields {
110
128
  readonly category: "internal";
111
129
  readonly code: typeof ERROR_CODE.internalUnexpected;
130
+ readonly recovery: CliNextAction | undefined;
112
131
  readonly retryable = false;
113
- readonly suggestedCommand: undefined;
114
132
  constructor(payload: UnexpectedErrorPayload);
115
133
  }
116
134
  export type AppError = AuthError | ContractMismatchError | NotFoundError | RemoteRequestError | UnexpectedError | ValidationError;
117
135
  export interface AppErrorMeta {
118
136
  category: ErrorCategory;
119
137
  code: ErrorCode;
138
+ recovery: CliNextAction | undefined;
120
139
  retryable: boolean;
121
- suggestedCommand: string | undefined;
122
140
  }
123
141
  export declare const appErrorMeta: (error: AppError) => AppErrorMeta;
142
+ export declare const appErrorDiagnostics: (error: AppError) => Record<string, unknown>;
143
+ export declare const appErrorTitle: (error: AppError) => string;
124
144
  export declare const formatAppError: (error: AppError) => string;
125
145
  export {};
126
146
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElG,KAAK,aAAa,GACd,OAAO,UAAU,CAAC,iBAAiB,GACnC,OAAO,UAAU,CAAC,iBAAiB,GACnC,OAAO,UAAU,CAAC,sBAAsB,GACxC,OAAO,UAAU,CAAC,YAAY,CAAC;AAEnC,KAAK,eAAe,GAChB,OAAO,UAAU,CAAC,iBAAiB,GACnC,OAAO,UAAU,CAAC,iBAAiB,GACnC,OAAO,UAAU,CAAC,sBAAsB,CAAC;AAE7C,KAAK,mBAAmB,GACpB,OAAO,UAAU,CAAC,wBAAwB,GAC1C,OAAO,UAAU,CAAC,sBAAsB,CAAC;AAE7C,KAAK,yBAAyB,GAAG,OAAO,UAAU,CAAC,0BAA0B,CAAC;AAE9E,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,QAAA,MAAM,mBAAmB;cACb,MAAM;aACP,MAAM;EACb,CAAC;AAEL,UAAU,sBAAsB;IAC9B,IAAI,CAAC,EAAE,mBAAmB,CA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