@ogment-ai/cli 0.5.0 → 0.7.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 (111) hide show
  1. package/dist/cli.js +21382 -4
  2. package/dist/cli.js.map +1 -0
  3. package/package.json +46 -55
  4. package/README.md +0 -143
  5. package/dist/cli/commands.d.ts +0 -38
  6. package/dist/cli/commands.d.ts.map +0 -1
  7. package/dist/cli/commands.js +0 -57
  8. package/dist/cli/execute.d.ts +0 -11
  9. package/dist/cli/execute.d.ts.map +0 -1
  10. package/dist/cli/execute.js +0 -487
  11. package/dist/cli/invocations.d.ts +0 -32
  12. package/dist/cli/invocations.d.ts.map +0 -1
  13. package/dist/cli/invocations.js +0 -1
  14. package/dist/cli/parse-errors.d.ts +0 -17
  15. package/dist/cli/parse-errors.d.ts.map +0 -1
  16. package/dist/cli/parse-errors.js +0 -184
  17. package/dist/cli/program.d.ts +0 -10
  18. package/dist/cli/program.d.ts.map +0 -1
  19. package/dist/cli/program.js +0 -183
  20. package/dist/cli/run.d.ts +0 -6
  21. package/dist/cli/run.d.ts.map +0 -1
  22. package/dist/cli/run.js +0 -83
  23. package/dist/cli/runtime.d.ts +0 -22
  24. package/dist/cli/runtime.d.ts.map +0 -1
  25. package/dist/cli/runtime.js +0 -86
  26. package/dist/cli.d.ts +0 -4
  27. package/dist/cli.d.ts.map +0 -1
  28. package/dist/commands/auth.d.ts +0 -22
  29. package/dist/commands/auth.d.ts.map +0 -1
  30. package/dist/commands/auth.js +0 -29
  31. package/dist/commands/catalog.d.ts +0 -31
  32. package/dist/commands/catalog.d.ts.map +0 -1
  33. package/dist/commands/catalog.js +0 -167
  34. package/dist/commands/context.d.ts +0 -15
  35. package/dist/commands/context.d.ts.map +0 -1
  36. package/dist/commands/context.js +0 -1
  37. package/dist/commands/invoke.d.ts +0 -17
  38. package/dist/commands/invoke.d.ts.map +0 -1
  39. package/dist/commands/invoke.js +0 -173
  40. package/dist/commands/server-context.d.ts +0 -14
  41. package/dist/commands/server-context.d.ts.map +0 -1
  42. package/dist/commands/server-context.js +0 -26
  43. package/dist/commands/status.d.ts +0 -12
  44. package/dist/commands/status.d.ts.map +0 -1
  45. package/dist/commands/status.js +0 -5
  46. package/dist/index.d.ts +0 -4
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js +0 -3
  49. package/dist/infra/browser.d.ts +0 -12
  50. package/dist/infra/browser.d.ts.map +0 -1
  51. package/dist/infra/browser.js +0 -20
  52. package/dist/infra/credentials.d.ts +0 -22
  53. package/dist/infra/credentials.d.ts.map +0 -1
  54. package/dist/infra/credentials.js +0 -81
  55. package/dist/infra/env.d.ts +0 -15
  56. package/dist/infra/env.d.ts.map +0 -1
  57. package/dist/infra/env.js +0 -100
  58. package/dist/infra/http.d.ts +0 -16
  59. package/dist/infra/http.d.ts.map +0 -1
  60. package/dist/infra/http.js +0 -84
  61. package/dist/output/envelope.d.ts +0 -22
  62. package/dist/output/envelope.d.ts.map +0 -1
  63. package/dist/output/envelope.js +0 -67
  64. package/dist/output/manager.d.ts +0 -49
  65. package/dist/output/manager.d.ts.map +0 -1
  66. package/dist/output/manager.js +0 -128
  67. package/dist/services/account.d.ts +0 -16
  68. package/dist/services/account.d.ts.map +0 -1
  69. package/dist/services/account.js +0 -75
  70. package/dist/services/auth.d.ts +0 -49
  71. package/dist/services/auth.d.ts.map +0 -1
  72. package/dist/services/auth.js +0 -739
  73. package/dist/services/info.d.ts +0 -24
  74. package/dist/services/info.d.ts.map +0 -1
  75. package/dist/services/info.js +0 -316
  76. package/dist/services/mcp-error-mapping.d.ts +0 -9
  77. package/dist/services/mcp-error-mapping.d.ts.map +0 -1
  78. package/dist/services/mcp-error-mapping.js +0 -129
  79. package/dist/services/mcp.d.ts +0 -39
  80. package/dist/services/mcp.d.ts.map +0 -1
  81. package/dist/services/mcp.js +0 -169
  82. package/dist/shared/constants.d.ts +0 -7
  83. package/dist/shared/constants.d.ts.map +0 -1
  84. package/dist/shared/constants.js +0 -8
  85. package/dist/shared/error-codes.d.ts +0 -31
  86. package/dist/shared/error-codes.d.ts.map +0 -1
  87. package/dist/shared/error-codes.js +0 -25
  88. package/dist/shared/error-presentation.d.ts +0 -17
  89. package/dist/shared/error-presentation.d.ts.map +0 -1
  90. package/dist/shared/error-presentation.js +0 -151
  91. package/dist/shared/errors.d.ts +0 -146
  92. package/dist/shared/errors.d.ts.map +0 -1
  93. package/dist/shared/errors.js +0 -233
  94. package/dist/shared/exit-codes.d.ts +0 -15
  95. package/dist/shared/exit-codes.d.ts.map +0 -1
  96. package/dist/shared/exit-codes.js +0 -44
  97. package/dist/shared/guards.d.ts +0 -11
  98. package/dist/shared/guards.d.ts.map +0 -1
  99. package/dist/shared/guards.js +0 -29
  100. package/dist/shared/recovery.d.ts +0 -5
  101. package/dist/shared/recovery.d.ts.map +0 -1
  102. package/dist/shared/recovery.js +0 -123
  103. package/dist/shared/schema-example.d.ts +0 -3
  104. package/dist/shared/schema-example.d.ts.map +0 -1
  105. package/dist/shared/schema-example.js +0 -105
  106. package/dist/shared/schemas.d.ts +0 -15
  107. package/dist/shared/schemas.d.ts.map +0 -1
  108. package/dist/shared/schemas.js +0 -15
  109. package/dist/shared/types.d.ts +0 -225
  110. package/dist/shared/types.d.ts.map +0 -1
  111. package/dist/shared/types.js +0 -1
@@ -1,233 +0,0 @@
1
- import { TaggedError } from "better-result";
2
- import { ERROR_CATEGORY, ERROR_CODE } from "./error-codes.js";
3
- import { normalizeRecovery } from "./recovery.js";
4
- const ValidationErrorBase = TaggedError("ValidationError")();
5
- export class ValidationError extends ValidationErrorBase {
6
- category = ERROR_CATEGORY.validation;
7
- code;
8
- recovery;
9
- retryable = false;
10
- constructor(payload) {
11
- super({
12
- message: payload.message,
13
- ...(payload.details === undefined ? {} : { details: payload.details }),
14
- });
15
- this.code = payload.code ?? ERROR_CODE.validationInvalidInput;
16
- this.recovery = normalizeRecovery(this.code, payload.recovery);
17
- }
18
- }
19
- const AuthErrorBase = TaggedError("AuthError")();
20
- export class AuthError extends AuthErrorBase {
21
- category = ERROR_CATEGORY.auth;
22
- code;
23
- recovery;
24
- retryable;
25
- constructor(payload) {
26
- super({
27
- message: payload.message,
28
- ...(payload.details === undefined ? {} : { details: payload.details }),
29
- });
30
- this.code = payload.code ?? ERROR_CODE.authRequired;
31
- this.recovery = normalizeRecovery(this.code, payload.recovery);
32
- this.retryable = payload.retryable ?? this.code === ERROR_CODE.authDeviceExpired;
33
- }
34
- }
35
- const NotFoundErrorBase = TaggedError("NotFoundError")();
36
- export class NotFoundError extends NotFoundErrorBase {
37
- category = ERROR_CATEGORY.notFound;
38
- code;
39
- recovery;
40
- retryable = false;
41
- constructor(payload) {
42
- super({
43
- message: payload.message,
44
- resource: payload.resource,
45
- });
46
- this.code = payload.code ?? ERROR_CODE.toolNotFound;
47
- this.recovery = normalizeRecovery(this.code, payload.recovery);
48
- }
49
- }
50
- const RemoteRequestErrorBase = TaggedError("RemoteRequestError")();
51
- const parseHttpCode = (code) => {
52
- if (!code.startsWith("HTTP_")) {
53
- return undefined;
54
- }
55
- const parsed = Number.parseInt(code.slice("HTTP_".length), 10);
56
- if (!Number.isFinite(parsed)) {
57
- return undefined;
58
- }
59
- return parsed;
60
- };
61
- const resolveRemoteErrorCode = (payload, diagnostics) => {
62
- if (payload.code !== undefined) {
63
- return payload.code;
64
- }
65
- if (typeof diagnostics.httpStatus === "number") {
66
- return `HTTP_${diagnostics.httpStatus}`;
67
- }
68
- if (typeof diagnostics.mcpCode === "number") {
69
- return `MCP_${diagnostics.mcpCode}`;
70
- }
71
- return ERROR_CODE.transportRequestFailed;
72
- };
73
- const resolveRemoteDiagnostics = (payload) => {
74
- const source = payload.source ?? payload.diagnostics?.source ?? "network";
75
- return {
76
- httpStatus: payload.httpStatus ?? payload.status ?? payload.diagnostics?.httpStatus,
77
- mcpCode: payload.mcpCode ?? payload.diagnostics?.mcpCode,
78
- mcpData: payload.mcpData ?? payload.diagnostics?.mcpData,
79
- operation: payload.operation ?? payload.diagnostics?.operation,
80
- raw: payload.raw ?? payload.diagnostics?.raw,
81
- source,
82
- };
83
- };
84
- const resolveRetryableRemoteError = (diagnostics, code) => {
85
- const httpStatus = diagnostics.httpStatus ?? parseHttpCode(code);
86
- if (typeof httpStatus === "number") {
87
- return httpStatus === 429 || httpStatus >= 500;
88
- }
89
- if (typeof diagnostics.mcpCode === "number") {
90
- return diagnostics.mcpCode === -32_001;
91
- }
92
- return diagnostics.source === "network";
93
- };
94
- const resolveRemoteCategory = (code, diagnostics) => {
95
- const httpStatus = diagnostics.httpStatus ?? parseHttpCode(code);
96
- if (code === ERROR_CODE.remoteRateLimited || httpStatus === 429) {
97
- return ERROR_CATEGORY.rateLimit;
98
- }
99
- return ERROR_CATEGORY.remote;
100
- };
101
- export class RemoteRequestError extends RemoteRequestErrorBase {
102
- category;
103
- code;
104
- diagnostics;
105
- httpStatus;
106
- recovery;
107
- retryable;
108
- constructor(payload) {
109
- const diagnostics = resolveRemoteDiagnostics(payload);
110
- const code = resolveRemoteErrorCode(payload, diagnostics);
111
- const status = diagnostics.httpStatus;
112
- super({
113
- message: payload.message,
114
- ...(payload.body === undefined ? {} : { body: payload.body }),
115
- ...(status === undefined ? {} : { status }),
116
- source: diagnostics.source,
117
- ...(diagnostics.mcpCode === undefined ? {} : { mcpCode: diagnostics.mcpCode }),
118
- ...(diagnostics.mcpData === undefined ? {} : { mcpData: diagnostics.mcpData }),
119
- ...(diagnostics.operation === undefined ? {} : { operation: diagnostics.operation }),
120
- ...(diagnostics.raw === undefined ? {} : { raw: diagnostics.raw }),
121
- });
122
- this.code = code;
123
- this.category = resolveRemoteCategory(code, diagnostics);
124
- this.diagnostics = diagnostics;
125
- this.httpStatus = diagnostics.httpStatus;
126
- this.recovery = normalizeRecovery(this.code, payload.recovery);
127
- this.retryable = payload.retryable ?? resolveRetryableRemoteError(diagnostics, code);
128
- }
129
- }
130
- const ContractMismatchErrorBase = TaggedError("ContractMismatchError")();
131
- export class ContractMismatchError extends ContractMismatchErrorBase {
132
- category = ERROR_CATEGORY.contractMismatch;
133
- code;
134
- recovery;
135
- retryable = false;
136
- constructor(payload) {
137
- super({
138
- message: payload.message,
139
- ...(payload.details === undefined ? {} : { details: payload.details }),
140
- });
141
- this.code = payload.code ?? ERROR_CODE.contractVersionUnsupported;
142
- this.recovery = normalizeRecovery(this.code, payload.recovery);
143
- }
144
- }
145
- const UnexpectedErrorBase = TaggedError("UnexpectedError")();
146
- export class UnexpectedError extends UnexpectedErrorBase {
147
- category = ERROR_CATEGORY.internal;
148
- code;
149
- recovery;
150
- retryable = false;
151
- constructor(payload) {
152
- super({
153
- message: payload.message,
154
- ...(payload.cause === undefined ? {} : { cause: payload.cause }),
155
- });
156
- this.code = payload.code ?? ERROR_CODE.internalUnexpected;
157
- this.recovery = normalizeRecovery(this.code, payload.recovery);
158
- }
159
- }
160
- const withIfDefined = (base, key, value) => {
161
- if (value === undefined) {
162
- return base;
163
- }
164
- return {
165
- ...base,
166
- [key]: value,
167
- };
168
- };
169
- const hasDetails = (error) => {
170
- return error._tag === "AuthError" || error._tag === "ValidationError";
171
- };
172
- export const appErrorMeta = (error) => {
173
- return {
174
- category: error.category,
175
- code: error.code,
176
- recovery: error.recovery,
177
- retryable: error.retryable,
178
- };
179
- };
180
- export const appErrorDiagnostics = (error) => {
181
- if (error._tag === "RemoteRequestError") {
182
- let diagnostics = {
183
- source: error.source,
184
- };
185
- diagnostics = withIfDefined(diagnostics, "httpStatus", error.httpStatus);
186
- diagnostics = withIfDefined(diagnostics, "mcpCode", error.mcpCode);
187
- diagnostics = withIfDefined(diagnostics, "mcpData", error.mcpData);
188
- diagnostics = withIfDefined(diagnostics, "operation", error.operation);
189
- diagnostics = withIfDefined(diagnostics, "raw", error.raw);
190
- diagnostics = withIfDefined(diagnostics, "body", error.body);
191
- return diagnostics;
192
- }
193
- if (error._tag === "NotFoundError") {
194
- return {
195
- resource: error.resource,
196
- };
197
- }
198
- if (error._tag === "UnexpectedError") {
199
- if (error.cause === undefined) {
200
- return {};
201
- }
202
- return {
203
- cause: error.cause,
204
- };
205
- }
206
- if (hasDetails(error) && typeof error.details === "string" && error.details.length > 0) {
207
- return {
208
- details: error.details,
209
- };
210
- }
211
- return {};
212
- };
213
- export const appErrorTitle = (error) => {
214
- if (error._tag === "UnexpectedError") {
215
- return "Unexpected CLI error";
216
- }
217
- if (error._tag === "ContractMismatchError") {
218
- return "Contract version unsupported";
219
- }
220
- return error.message;
221
- };
222
- export const formatAppError = (error) => {
223
- if (error._tag === "NotFoundError") {
224
- return `${error.message} (${error.resource})`;
225
- }
226
- if (error._tag === "RemoteRequestError" && typeof error.httpStatus === "number") {
227
- return `${error.message} (status ${error.httpStatus})`;
228
- }
229
- if (hasDetails(error) && typeof error.details === "string" && error.details.length > 0) {
230
- return `${error.message}: ${error.details}`;
231
- }
232
- return error.message;
233
- };
@@ -1,15 +0,0 @@
1
- import type { AppError } from "./errors.js";
2
- export declare const EXIT_CODE: {
3
- readonly authFailed: 4;
4
- readonly authRequired: 3;
5
- readonly contractMismatch: 8;
6
- readonly internal: 9;
7
- readonly notFound: 5;
8
- readonly rateLimit: 6;
9
- readonly remote: 7;
10
- readonly success: 0;
11
- readonly validation: 2;
12
- };
13
- export type ExitCode = (typeof EXIT_CODE)[keyof typeof EXIT_CODE];
14
- export declare const exitCodeForError: (error: AppError) => ExitCode;
15
- //# sourceMappingURL=exit-codes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exit-codes.d.ts","sourceRoot":"","sources":["../../src/shared/exit-codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,SAAS;;;;;;;;;;CAUZ,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAElE,eAAO,MAAM,gBAAgB,GAAI,OAAO,QAAQ,KAAG,QA+BlD,CAAC"}
@@ -1,44 +0,0 @@
1
- import { ERROR_CATEGORY, ERROR_CODE } from "./error-codes.js";
2
- import { appErrorMeta } from "./errors.js";
3
- export const EXIT_CODE = {
4
- authFailed: 4,
5
- authRequired: 3,
6
- contractMismatch: 8,
7
- internal: 9,
8
- notFound: 5,
9
- rateLimit: 6,
10
- remote: 7,
11
- success: 0,
12
- validation: 2,
13
- };
14
- export const exitCodeForError = (error) => {
15
- const { category, code } = appErrorMeta(error);
16
- switch (category) {
17
- case ERROR_CATEGORY.auth: {
18
- if (code === ERROR_CODE.authRequired) {
19
- return EXIT_CODE.authRequired;
20
- }
21
- return EXIT_CODE.authFailed;
22
- }
23
- case ERROR_CATEGORY.notFound: {
24
- return EXIT_CODE.notFound;
25
- }
26
- case ERROR_CATEGORY.rateLimit: {
27
- return EXIT_CODE.rateLimit;
28
- }
29
- case ERROR_CATEGORY.remote:
30
- case ERROR_CATEGORY.transport:
31
- case ERROR_CATEGORY.authorization: {
32
- return EXIT_CODE.remote;
33
- }
34
- case ERROR_CATEGORY.contractMismatch: {
35
- return EXIT_CODE.contractMismatch;
36
- }
37
- case ERROR_CATEGORY.validation: {
38
- return EXIT_CODE.validation;
39
- }
40
- case ERROR_CATEGORY.internal: {
41
- return EXIT_CODE.internal;
42
- }
43
- }
44
- };
@@ -1,11 +0,0 @@
1
- import type { Result as ResultType } from "better-result";
2
- import type { ZodTypeAny } from "zod";
3
- import { z } from "zod";
4
- import { ERROR_CODE } from "./error-codes.js";
5
- import { ValidationError } from "./errors.js";
6
- import type { RecoveryOverride } from "./recovery.js";
7
- export declare const parseWithSchema: <TSchema extends ZodTypeAny>(schema: TSchema, payload: unknown, context: string, options?: {
8
- code?: typeof ERROR_CODE.toolInputSchemaViolation | typeof ERROR_CODE.validationInvalidInput;
9
- recovery?: RecoveryOverride;
10
- }) => ResultType<z.infer<TSchema>, ValidationError>;
11
- //# sourceMappingURL=guards.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/shared/guards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAoBtD,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,UAAU,EACxD,QAAQ,OAAO,EACf,SAAS,OAAO,EAChB,SAAS,MAAM,EACf,UAAS;IACP,IAAI,CAAC,EAAE,OAAO,UAAU,CAAC,wBAAwB,GAAG,OAAO,UAAU,CAAC,sBAAsB,CAAC;IAC7F,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACxB,KACL,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,eAAe,CAe9C,CAAC"}
@@ -1,29 +0,0 @@
1
- import { Result } from "better-result";
2
- import { z } from "zod";
3
- import { ERROR_CODE } from "./error-codes.js";
4
- import { ValidationError } from "./errors.js";
5
- const formatIssues = (issues) => {
6
- return issues
7
- .map((issue) => {
8
- if (issue.path.length === 0) {
9
- return issue.message;
10
- }
11
- const path = issue.path
12
- .filter((value) => typeof value === "number" || typeof value === "string")
13
- .join(".");
14
- return `${path}: ${issue.message}`;
15
- })
16
- .join("; ");
17
- };
18
- export const parseWithSchema = (schema, payload, context, options = {}) => {
19
- const parsed = schema.safeParse(payload);
20
- if (!parsed.success) {
21
- return Result.err(new ValidationError({
22
- details: formatIssues(parsed.error.issues),
23
- message: `Invalid ${context}`,
24
- ...(options.code === undefined ? {} : { code: options.code }),
25
- ...(options.recovery === undefined ? {} : { recovery: options.recovery }),
26
- }));
27
- }
28
- return Result.ok(parsed.data);
29
- };
@@ -1,5 +0,0 @@
1
- import { type ErrorCode } from "./error-codes.js";
2
- import type { CliNextAction } from "./types.js";
3
- export type RecoveryOverride = Partial<CliNextAction>;
4
- export declare const normalizeRecovery: (code: ErrorCode, override?: RecoveryOverride) => CliNextAction | undefined;
5
- //# sourceMappingURL=recovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../src/shared/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AA0HtD,eAAO,MAAM,iBAAiB,GAC5B,MAAM,SAAS,EACf,WAAW,gBAAgB,KAC1B,aAAa,GAAG,SAkBlB,CAAC"}
@@ -1,123 +0,0 @@
1
- import { ERROR_CODE } from "./error-codes.js";
2
- const defaultRecoveryByCode = {
3
- [ERROR_CODE.authDeviceExpired]: {
4
- command: "ogment auth login",
5
- reason: "Device code expired; restart login to continue.",
6
- title: "Restart login",
7
- when: "immediate",
8
- },
9
- [ERROR_CODE.authDevicePending]: {
10
- command: "ogment auth status",
11
- reason: "Authorization is pending; check whether credentials are now available.",
12
- title: "Check auth status",
13
- when: "immediate",
14
- },
15
- [ERROR_CODE.authInvalidCredentials]: {
16
- command: "ogment auth logout",
17
- reason: "Credentials are invalid; clear local state before re-authenticating.",
18
- title: "Reset auth state",
19
- when: "immediate",
20
- },
21
- [ERROR_CODE.authRequired]: {
22
- command: "ogment auth login",
23
- reason: "Authentication is required before catalog or invoke commands can run.",
24
- title: "Authenticate",
25
- when: "immediate",
26
- },
27
- [ERROR_CODE.contractVersionUnsupported]: {
28
- command: "ogment --version",
29
- reason: "Contract mismatch detected; verify CLI version and upgrade before retrying.",
30
- title: "Inspect CLI version",
31
- when: "immediate",
32
- },
33
- [ERROR_CODE.internalUnexpected]: {
34
- command: "ogment status",
35
- reason: "Unexpected failure detected; run diagnostics before retrying the workflow.",
36
- title: "Inspect diagnostics",
37
- when: "immediate",
38
- },
39
- [ERROR_CODE.remoteRateLimited]: {
40
- command: "ogment status",
41
- reason: "Remote rate limit detected; check diagnostics before retrying.",
42
- title: "Inspect diagnostics",
43
- when: "immediate",
44
- },
45
- [ERROR_CODE.remoteUnavailable]: {
46
- command: "ogment status",
47
- reason: "Remote service is unavailable; check connectivity and endpoint health.",
48
- title: "Inspect diagnostics",
49
- when: "immediate",
50
- },
51
- [ERROR_CODE.toolInputSchemaViolation]: {
52
- command: "ogment catalog",
53
- reason: "Tool contract did not validate; inspect available servers and tool metadata.",
54
- title: "Inspect catalog",
55
- when: "immediate",
56
- },
57
- [ERROR_CODE.toolNotFound]: {
58
- command: "ogment catalog",
59
- reason: "Requested tool could not be found; rediscover servers and tools.",
60
- title: "Rediscover tools",
61
- when: "immediate",
62
- },
63
- [ERROR_CODE.transportRequestFailed]: {
64
- command: "ogment status",
65
- reason: "Transport request failed; inspect connectivity diagnostics.",
66
- title: "Inspect diagnostics",
67
- when: "immediate",
68
- },
69
- [ERROR_CODE.validationInvalidInput]: {
70
- command: "ogment --help",
71
- reason: "Input validation failed; inspect canonical command syntax.",
72
- title: "Show command help",
73
- when: "immediate",
74
- },
75
- };
76
- const dynamicRecoveryForCode = (code) => {
77
- if (code.startsWith("HTTP_")) {
78
- return {
79
- command: "ogment status",
80
- reason: `HTTP error ${code} detected; inspect diagnostics and remote connectivity.`,
81
- title: "Inspect diagnostics",
82
- when: "immediate",
83
- };
84
- }
85
- if (code.startsWith("MCP_")) {
86
- return {
87
- command: "ogment status",
88
- reason: `MCP error ${code} detected; inspect diagnostics and remote server state.`,
89
- title: "Inspect diagnostics",
90
- when: "immediate",
91
- };
92
- }
93
- return undefined;
94
- };
95
- const hasPlaceholderTokens = (command) => {
96
- return command.includes("<") || command.includes(">");
97
- };
98
- const sanitizedCommand = (command) => {
99
- if (typeof command !== "string") {
100
- return undefined;
101
- }
102
- if (hasPlaceholderTokens(command)) {
103
- return undefined;
104
- }
105
- return command;
106
- };
107
- export const normalizeRecovery = (code, override) => {
108
- const fallback = defaultRecoveryByCode[code] ?? dynamicRecoveryForCode(code);
109
- if (fallback === undefined) {
110
- return undefined;
111
- }
112
- const overrideCommand = sanitizedCommand(override?.command);
113
- const command = overrideCommand ?? fallback.command;
114
- const usesCustomCommand = overrideCommand !== undefined && overrideCommand !== fallback.command;
115
- return {
116
- command,
117
- id: override?.id ?? `recover_${code.toLowerCase()}`,
118
- reason: override?.reason ??
119
- (usesCustomCommand ? `Suggested recovery for error ${code}.` : fallback.reason),
120
- title: override?.title ?? (usesCustomCommand ? "Run suggested command" : fallback.title),
121
- when: override?.when ?? fallback.when,
122
- };
123
- };
@@ -1,3 +0,0 @@
1
- export declare const EXAMPLE_PLACEHOLDER = " ... ";
2
- export declare const buildJsonSchemaExample: (schema: Record<string, unknown>) => unknown;
3
- //# sourceMappingURL=schema-example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-example.d.ts","sourceRoot":"","sources":["../../src/shared/schema-example.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,UAAU,CAAC;AA8H3C,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAExE,CAAC"}
@@ -1,105 +0,0 @@
1
- const MAX_EXAMPLE_DEPTH = 6;
2
- export const EXAMPLE_PLACEHOLDER = " ... ";
3
- const isRecord = (value) => {
4
- return typeof value === "object" && value !== null && !Array.isArray(value);
5
- };
6
- const asStringArray = (value) => {
7
- if (!Array.isArray(value)) {
8
- return [];
9
- }
10
- return value.filter((item) => typeof item === "string");
11
- };
12
- const firstKnown = (value) => {
13
- if (Array.isArray(value) && value.length > 0) {
14
- return value[0];
15
- }
16
- return undefined;
17
- };
18
- const deriveType = (schema) => {
19
- const typeValue = schema["type"];
20
- if (typeof typeValue === "string") {
21
- return typeValue;
22
- }
23
- if (Array.isArray(typeValue)) {
24
- const firstType = typeValue.find((entry) => typeof entry === "string");
25
- return firstType;
26
- }
27
- if (isRecord(schema["properties"])) {
28
- return "object";
29
- }
30
- if (schema["items"] !== undefined) {
31
- return "array";
32
- }
33
- return undefined;
34
- };
35
- const baseScalarExample = (typeName) => {
36
- switch (typeName) {
37
- case "string": {
38
- return EXAMPLE_PLACEHOLDER;
39
- }
40
- case "integer": {
41
- return EXAMPLE_PLACEHOLDER;
42
- }
43
- case "number": {
44
- return EXAMPLE_PLACEHOLDER;
45
- }
46
- case "boolean": {
47
- return EXAMPLE_PLACEHOLDER;
48
- }
49
- case "null": {
50
- return EXAMPLE_PLACEHOLDER;
51
- }
52
- default: {
53
- return EXAMPLE_PLACEHOLDER;
54
- }
55
- }
56
- };
57
- const buildExample = (value, depth) => {
58
- if (!isRecord(value)) {
59
- return {};
60
- }
61
- if (depth > MAX_EXAMPLE_DEPTH) {
62
- return {};
63
- }
64
- const oneOfCandidate = firstKnown(value["oneOf"]);
65
- if (oneOfCandidate !== undefined) {
66
- return buildExample(oneOfCandidate, depth + 1);
67
- }
68
- const anyOfCandidate = firstKnown(value["anyOf"]);
69
- if (anyOfCandidate !== undefined) {
70
- return buildExample(anyOfCandidate, depth + 1);
71
- }
72
- const allOfCandidate = firstKnown(value["allOf"]);
73
- if (allOfCandidate !== undefined) {
74
- return buildExample(allOfCandidate, depth + 1);
75
- }
76
- const typeName = deriveType(value);
77
- if (typeName === "object") {
78
- const result = {};
79
- const properties = isRecord(value["properties"]) ? value["properties"] : {};
80
- const required = asStringArray(value["required"]);
81
- for (const propertyName of required) {
82
- const propertySchema = properties[propertyName];
83
- if (propertySchema !== undefined) {
84
- result[propertyName] = buildExample(propertySchema, depth + 1);
85
- }
86
- }
87
- if (required.length === 0 && isRecord(value["additionalProperties"])) {
88
- result["example"] = buildExample(value["additionalProperties"], depth + 1);
89
- }
90
- return result;
91
- }
92
- if (typeName === "array") {
93
- if (value["items"] === undefined) {
94
- return [EXAMPLE_PLACEHOLDER];
95
- }
96
- return [buildExample(value["items"], depth + 1)];
97
- }
98
- if (typeName === undefined) {
99
- return depth === 0 ? {} : EXAMPLE_PLACEHOLDER;
100
- }
101
- return baseScalarExample(typeName);
102
- };
103
- export const buildJsonSchemaExample = (schema) => {
104
- return buildExample(schema, 0);
105
- };
@@ -1,15 +0,0 @@
1
- import { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema } from "@ogment-ai/cli-contract/v1";
2
- import { z } from "zod";
3
- export { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, };
4
- export declare const credentialsFileSchema: z.ZodObject<{
5
- accessToken: z.ZodOptional<z.ZodString>;
6
- agentName: z.ZodOptional<z.ZodString>;
7
- apiKey: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>;
9
- export declare const toolDefinitionSchema: z.ZodObject<{
10
- description: z.ZodOptional<z.ZodString>;
11
- inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
12
- name: z.ZodString;
13
- outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
14
- }, z.core.$strip>;
15
- //# sourceMappingURL=schemas.d.ts.map
@@ -1 +0,0 @@
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,15 +0,0 @@
1
- import { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, } from "@ogment-ai/cli-contract/v1";
2
- import { z } from "zod";
3
- export { accountMeSchema, browserAgentCallbackSchema, cliExchangeErrorSchema, cliExchangeRequestSchema, cliExchangeSuccessSchema, deviceCodeStartSchema, deviceTokenApprovedSchema, oauthClientRegistrationSchema, oauthTokenSchema, orgServerSchema, organizationSchema, };
4
- const jsonObjectSchema = z.record(z.string(), z.unknown());
5
- export const credentialsFileSchema = z.object({
6
- accessToken: z.string().min(1).optional(),
7
- agentName: z.string().optional(),
8
- apiKey: z.string().min(1).optional(),
9
- });
10
- export const toolDefinitionSchema = z.object({
11
- description: z.string().optional(),
12
- inputSchema: jsonObjectSchema,
13
- name: z.string(),
14
- outputSchema: jsonObjectSchema.optional(),
15
- });