@ogment-ai/cli 0.6.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 (108) hide show
  1. package/dist/cli.js +21382 -4
  2. package/dist/cli.js.map +1 -0
  3. package/package.json +46 -53
  4. package/README.md +0 -134
  5. package/dist/cli/commands.d.ts +0 -37
  6. package/dist/cli/commands.d.ts.map +0 -1
  7. package/dist/cli/commands.js +0 -56
  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 -468
  11. package/dist/cli/invocations.d.ts +0 -31
  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 -174
  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 -21
  24. package/dist/cli/runtime.d.ts.map +0 -1
  25. package/dist/cli/runtime.js +0 -80
  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 -19
  29. package/dist/commands/auth.d.ts.map +0 -1
  30. package/dist/commands/auth.js +0 -21
  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/credentials.d.ts +0 -22
  50. package/dist/infra/credentials.d.ts.map +0 -1
  51. package/dist/infra/credentials.js +0 -74
  52. package/dist/infra/env.d.ts +0 -15
  53. package/dist/infra/env.d.ts.map +0 -1
  54. package/dist/infra/env.js +0 -100
  55. package/dist/infra/http.d.ts +0 -16
  56. package/dist/infra/http.d.ts.map +0 -1
  57. package/dist/infra/http.js +0 -84
  58. package/dist/output/envelope.d.ts +0 -22
  59. package/dist/output/envelope.d.ts.map +0 -1
  60. package/dist/output/envelope.js +0 -67
  61. package/dist/output/manager.d.ts +0 -47
  62. package/dist/output/manager.d.ts.map +0 -1
  63. package/dist/output/manager.js +0 -120
  64. package/dist/services/account.d.ts +0 -16
  65. package/dist/services/account.d.ts.map +0 -1
  66. package/dist/services/account.js +0 -75
  67. package/dist/services/auth.d.ts +0 -37
  68. package/dist/services/auth.d.ts.map +0 -1
  69. package/dist/services/auth.js +0 -270
  70. package/dist/services/info.d.ts +0 -24
  71. package/dist/services/info.d.ts.map +0 -1
  72. package/dist/services/info.js +0 -316
  73. package/dist/services/mcp-error-mapping.d.ts +0 -9
  74. package/dist/services/mcp-error-mapping.d.ts.map +0 -1
  75. package/dist/services/mcp-error-mapping.js +0 -129
  76. package/dist/services/mcp.d.ts +0 -39
  77. package/dist/services/mcp.d.ts.map +0 -1
  78. package/dist/services/mcp.js +0 -169
  79. package/dist/shared/constants.d.ts +0 -5
  80. package/dist/shared/constants.d.ts.map +0 -1
  81. package/dist/shared/constants.js +0 -6
  82. package/dist/shared/error-codes.d.ts +0 -31
  83. package/dist/shared/error-codes.d.ts.map +0 -1
  84. package/dist/shared/error-codes.js +0 -25
  85. package/dist/shared/error-presentation.d.ts +0 -17
  86. package/dist/shared/error-presentation.d.ts.map +0 -1
  87. package/dist/shared/error-presentation.js +0 -151
  88. package/dist/shared/errors.d.ts +0 -146
  89. package/dist/shared/errors.d.ts.map +0 -1
  90. package/dist/shared/errors.js +0 -233
  91. package/dist/shared/exit-codes.d.ts +0 -15
  92. package/dist/shared/exit-codes.d.ts.map +0 -1
  93. package/dist/shared/exit-codes.js +0 -44
  94. package/dist/shared/guards.d.ts +0 -11
  95. package/dist/shared/guards.d.ts.map +0 -1
  96. package/dist/shared/guards.js +0 -29
  97. package/dist/shared/recovery.d.ts +0 -5
  98. package/dist/shared/recovery.d.ts.map +0 -1
  99. package/dist/shared/recovery.js +0 -123
  100. package/dist/shared/schema-example.d.ts +0 -3
  101. package/dist/shared/schema-example.d.ts.map +0 -1
  102. package/dist/shared/schema-example.js +0 -105
  103. package/dist/shared/schemas.d.ts +0 -14
  104. package/dist/shared/schemas.d.ts.map +0 -1
  105. package/dist/shared/schemas.js +0 -14
  106. package/dist/shared/types.d.ts +0 -225
  107. package/dist/shared/types.d.ts.map +0 -1
  108. package/dist/shared/types.js +0 -1
@@ -1,184 +0,0 @@
1
- import { cliCommands } from "./commands.js";
2
- const usageLinePattern = /^Usage:\s+ogment(?:\s+(.*))?$/;
3
- const scopeFromUsageLine = (line) => {
4
- const match = usageLinePattern.exec(line);
5
- if (match === null) {
6
- return null;
7
- }
8
- const suffix = match[1]?.trim();
9
- if (suffix === undefined || suffix.length === 0) {
10
- return null;
11
- }
12
- const scopeTokens = [];
13
- const tokens = suffix.split(/\s+/);
14
- for (const token of tokens) {
15
- if (token.startsWith("[") || token.startsWith("<") || token.startsWith("-")) {
16
- break;
17
- }
18
- scopeTokens.push(token);
19
- }
20
- if (scopeTokens.length === 0) {
21
- return null;
22
- }
23
- return scopeTokens.join(" ");
24
- };
25
- const scopeFromOutput = (output) => {
26
- const lines = output.split(/\r?\n/);
27
- for (const line of lines) {
28
- const scope = scopeFromUsageLine(line.trim());
29
- if (scope !== null) {
30
- return scope;
31
- }
32
- }
33
- return null;
34
- };
35
- const inferCommandScope = (parseState) => {
36
- const stderrScope = scopeFromOutput(parseState.stderrChunks.join(""));
37
- if (stderrScope !== null) {
38
- return stderrScope;
39
- }
40
- return scopeFromOutput(parseState.stdoutChunks.join(""));
41
- };
42
- const detailForParseError = (error, scope) => {
43
- if (error.message !== "(outputHelp)") {
44
- return error.message;
45
- }
46
- if (scope === null) {
47
- return "Missing or incomplete command.";
48
- }
49
- return `Missing or incomplete command for \`${scope}\`.`;
50
- };
51
- const nextActionForParseError = (scope, helpCommand) => {
52
- return {
53
- command: helpCommand,
54
- id: "recover_cli_parse_error",
55
- reason: scope === null
56
- ? "Input parsing failed; inspect canonical command syntax."
57
- : `Input parsing failed for \`${scope}\`; inspect command syntax.`,
58
- title: "Show command help",
59
- when: "immediate",
60
- };
61
- };
62
- const parseActionsForScope = (scope, helpCommand, helpAction) => {
63
- if (scope === "auth") {
64
- return [
65
- {
66
- command: cliCommands.auth.login(),
67
- id: "auth_login",
68
- reason: "Authenticate with device flow.",
69
- title: "Auth login",
70
- when: "immediate",
71
- },
72
- {
73
- command: cliCommands.auth.status(),
74
- id: "auth_status",
75
- reason: "Check current local authentication state.",
76
- title: "Auth status",
77
- when: "immediate",
78
- },
79
- helpAction,
80
- ];
81
- }
82
- if (scope === "catalog") {
83
- return [
84
- {
85
- command: cliCommands.catalog.command(),
86
- id: "catalog_summary",
87
- reason: "List available servers and follow progressive discovery.",
88
- title: "Catalog servers",
89
- when: "immediate",
90
- },
91
- helpAction,
92
- ];
93
- }
94
- if (scope === "invoke") {
95
- return [
96
- {
97
- command: cliCommands.catalog.command(),
98
- id: "invoke_prepare",
99
- reason: "Discover servers and tools before invoking a target command.",
100
- title: "Discover tools",
101
- when: "immediate",
102
- },
103
- helpAction,
104
- ];
105
- }
106
- if (scope === null) {
107
- return [helpAction];
108
- }
109
- if (helpCommand === "ogment --help") {
110
- return [helpAction];
111
- }
112
- return [helpAction];
113
- };
114
- const parseErrorKind = (error) => {
115
- switch (error.code) {
116
- case "commander.missingArgument": {
117
- return "missing_argument";
118
- }
119
- case "commander.optionMissingArgument":
120
- case "commander.missingMandatoryOptionValue": {
121
- return "missing_option_value";
122
- }
123
- case "commander.help": {
124
- return "missing_subcommand";
125
- }
126
- case "commander.invalidArgument": {
127
- return "invalid_argument";
128
- }
129
- case "commander.conflictingOption": {
130
- return "conflicting_option";
131
- }
132
- case "commander.excessArguments": {
133
- return "excess_arguments";
134
- }
135
- case "commander.unknownCommand": {
136
- return "unknown_command";
137
- }
138
- case "commander.unknownOption": {
139
- return "unknown_option";
140
- }
141
- default: {
142
- return "other";
143
- }
144
- }
145
- };
146
- const parseHelpText = (parseState) => {
147
- const stderr = parseState.stderrChunks.join("");
148
- if (stderr.length > 0) {
149
- return stderr;
150
- }
151
- const stdout = parseState.stdoutChunks.join("");
152
- return stdout.length > 0 ? stdout : null;
153
- };
154
- export const createCommanderParseState = () => {
155
- return {
156
- stderrChunks: [],
157
- stdoutChunks: [],
158
- };
159
- };
160
- export const toParseCliError = (error, parseState, options = {}) => {
161
- const scope = inferCommandScope(parseState);
162
- const helpCommand = cliCommands.helpForScope(scope);
163
- const helpAction = nextActionForParseError(scope, helpCommand);
164
- return {
165
- nextActions: parseActionsForScope(scope, helpCommand, helpAction),
166
- payload: {
167
- category: "parse",
168
- code: "CLI_PARSE_ERROR",
169
- detail: detailForParseError(error, scope),
170
- diagnostics: {
171
- kind: parseErrorKind(error),
172
- scope,
173
- ...(options.includeDebug === true
174
- ? {
175
- helpText: parseHelpText(parseState),
176
- parserCode: error.code,
177
- }
178
- : {}),
179
- },
180
- retryable: false,
181
- title: "CLI parse error",
182
- },
183
- };
184
- };
@@ -1,10 +0,0 @@
1
- import { Command } from "commander";
2
- import type { CliInvocation } from "./invocations.js";
3
- import type { CommanderParseState } from "./parse-errors.js";
4
- import { type Runtime } from "./runtime.js";
5
- export interface ProgramCreationResult {
6
- program: Command;
7
- readInvocation: () => CliInvocation | null;
8
- }
9
- export declare const createProgram: (runtime: Runtime, parseState: CommanderParseState) => ProgramCreationResult;
10
- //# sourceMappingURL=program.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgC,MAAM,WAAW,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAA2C,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CAC5C;AA0BD,eAAO,MAAM,aAAa,GACxB,SAAS,OAAO,EAChB,YAAY,mBAAmB,KAC9B,qBAsLF,CAAC"}
@@ -1,174 +0,0 @@
1
- import { Command, InvalidArgumentError, Option } from "commander";
2
- import { APP_DESCRIPTION, APP_NAME, VERSION } from "../shared/constants.js";
3
- import { asGlobalOptions, mapGlobalOutputOptions } from "./runtime.js";
4
- const positiveIntegerPattern = /^\d+$/;
5
- const parseCatalogLimitOption = (value) => {
6
- if (!positiveIntegerPattern.test(value)) {
7
- throw new InvalidArgumentError("Expected a positive integer.");
8
- }
9
- const parsed = Number.parseInt(value, 10);
10
- if (!Number.isSafeInteger(parsed) || parsed < 1) {
11
- throw new InvalidArgumentError("Expected a positive integer.");
12
- }
13
- return parsed;
14
- };
15
- const parseInvokeTarget = (value) => {
16
- const separatorIndex = value.lastIndexOf("/");
17
- if (separatorIndex <= 0 || separatorIndex >= value.length - 1 || /\s/.test(value)) {
18
- throw new InvalidArgumentError("Expected <server-id>/<tool-name>.");
19
- }
20
- return value;
21
- };
22
- export const createProgram = (runtime, parseState) => {
23
- const program = new Command();
24
- let invocation = null;
25
- const setInvocation = (next) => {
26
- invocation = next;
27
- };
28
- program.exitOverride();
29
- program.configureOutput({
30
- writeErr: (chunk) => {
31
- parseState.stderrChunks.push(chunk);
32
- if (runtime.output.mode === "human") {
33
- runtime.output.writeStderr(chunk);
34
- }
35
- },
36
- writeOut: (chunk) => {
37
- parseState.stdoutChunks.push(chunk);
38
- runtime.output.writeStdout(chunk);
39
- },
40
- });
41
- program.configureHelp({
42
- showGlobalOptions: true,
43
- sortOptions: true,
44
- sortSubcommands: true,
45
- });
46
- program.showHelpAfterError();
47
- program.showSuggestionAfterError();
48
- program.helpCommand("help [command]", "Display help for a command");
49
- program.addHelpText("after", ({ error }) => {
50
- if (error) {
51
- return "";
52
- }
53
- return [
54
- "",
55
- "Examples:",
56
- " $ ogment auth login",
57
- " $ ogment catalog billing create_invoice --example",
58
- " $ ogment invoke billing/create_invoice --input '{\"amount\":100}'",
59
- "",
60
- "Run `ogment help <command>` for command-specific usage.",
61
- ].join("\n");
62
- });
63
- program
64
- .name(APP_NAME)
65
- .description(APP_DESCRIPTION)
66
- .version(VERSION)
67
- .optionsGroup("Connection Options:")
68
- .option("--api-key <key>", "API key override")
69
- .optionsGroup("Output Options:")
70
- .option("--debug", "Include debug metadata and diagnostics in JSON output")
71
- .option("--human", "Render output for humans")
72
- .option("--quiet", "Suppress non-essential output")
73
- .optionsGroup("Automation Options:")
74
- .option("--yes", "Assume yes for any confirmation")
75
- .hook("preAction", (thisCommand) => {
76
- const options = asGlobalOptions(thisCommand);
77
- runtime.output.configure(mapGlobalOutputOptions(options));
78
- runtime.context.apiKeyOverride = options.apiKey;
79
- });
80
- const authCommand = program
81
- .command("auth")
82
- .summary("Authenticate, inspect auth state, and logout")
83
- .description("Authentication workflows")
84
- .helpGroup("Authentication Commands:")
85
- .helpCommand("help [command]", "Display help for auth commands")
86
- .addHelpText("after", ({ error }) => {
87
- if (error) {
88
- return "";
89
- }
90
- return ["", "Examples:", " $ ogment auth login", " $ ogment auth status"].join("\n");
91
- });
92
- authCommand
93
- .command("login")
94
- .summary("Login with device flow (default)")
95
- .description("Authenticate with Ogment using device flow (recommended)")
96
- .action((_, command) => {
97
- const { apiKey } = asGlobalOptions(command);
98
- setInvocation({
99
- apiKey,
100
- kind: "auth_login",
101
- });
102
- });
103
- authCommand
104
- .command("status")
105
- .summary("Show current auth state")
106
- .description("Show local authentication status")
107
- .action(() => {
108
- setInvocation({
109
- kind: "auth_status",
110
- });
111
- });
112
- authCommand
113
- .command("logout")
114
- .summary("Delete local credentials and revoke token")
115
- .description("Revoke token and delete local credentials")
116
- .action(() => {
117
- setInvocation({
118
- kind: "auth_logout",
119
- });
120
- });
121
- program
122
- .command("catalog [serverId] [toolName]")
123
- .summary("Discover servers and inspect tools")
124
- .description("Discover servers and tools with progressive disclosure")
125
- .helpGroup("Discovery Commands:")
126
- .addOption(new Option("--cursor <cursor>", "Pagination cursor (catalog summary only)").conflicts("example"))
127
- .addOption(new Option("--limit <limit>", "Maximum servers to return (catalog summary only)")
128
- .argParser(parseCatalogLimitOption)
129
- .conflicts("example"))
130
- .addOption(new Option("--example", "Include a generated example input payload (tool details only)").conflicts(["cursor", "limit"]))
131
- .action((serverId, toolName, options) => {
132
- setInvocation({
133
- cursor: options.cursor,
134
- example: options.example === true,
135
- kind: "catalog",
136
- limit: options.limit,
137
- serverId,
138
- toolName,
139
- });
140
- });
141
- program
142
- .command("invoke")
143
- .summary("Invoke a tool by <server-id>/<tool-name>")
144
- .description("Invoke a tool using <server-id>/<tool-name>")
145
- .helpGroup("Execution Commands:")
146
- .argument("<target>", "Target tool in the form <server-id>/<tool-name>", parseInvokeTarget)
147
- .option("--input <value>", "Input payload: inline JSON object, @path, or - for stdin")
148
- .action((target, options) => {
149
- setInvocation({
150
- input: options.input,
151
- kind: "invoke",
152
- target,
153
- });
154
- });
155
- program
156
- .command("status")
157
- .summary("Show runtime diagnostics")
158
- .description("Show runtime configuration and connectivity diagnostics")
159
- .helpGroup("Diagnostics Commands:")
160
- .action(() => {
161
- setInvocation({
162
- kind: "status",
163
- });
164
- });
165
- program.action(() => {
166
- setInvocation({
167
- kind: "root",
168
- });
169
- });
170
- return {
171
- program,
172
- readInvocation: () => invocation,
173
- };
174
- };
package/dist/cli/run.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { type ExitCode } from "../shared/exit-codes.js";
2
- import { type Runtime } from "./runtime.js";
3
- export declare const runCli: (argv?: readonly string[], runtime?: Runtime) => Promise<ExitCode>;
4
- export declare const executeCli: () => Promise<void>;
5
- export declare const shouldExecuteCli: (importMetaUrl: string, argv1: string | undefined) => boolean;
6
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAoB,MAAM,yBAAyB,CAAC;AAIrF,OAAO,EAA6C,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAmBvF,eAAO,MAAM,MAAM,GACjB,OAAM,SAAS,MAAM,EAA0B,EAC/C,UAAS,OAAyB,KACjC,OAAO,CAAC,QAAQ,CAgDlB,CAAC;AAEF,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,IAAI,CAG/C,CAAC;AAMF,eAAO,MAAM,gBAAgB,GAAI,eAAe,MAAM,EAAE,OAAO,MAAM,GAAG,SAAS,KAAG,OAYnF,CAAC"}
package/dist/cli/run.js DELETED
@@ -1,83 +0,0 @@
1
- import { realpathSync } from "node:fs";
2
- import { fileURLToPath, pathToFileURL } from "node:url";
3
- import { CommanderError } from "commander";
4
- import { EXIT_CODE, exitCodeForError } from "../shared/exit-codes.js";
5
- import { executeInvocation, CliExitError, normalizeCliRuntimeError } from "./execute.js";
6
- import { createCommanderParseState, toParseCliError } from "./parse-errors.js";
7
- import { createProgram } from "./program.js";
8
- import { createRuntime, parseOutputOptionsFromArgv } from "./runtime.js";
9
- const normalizeCliArgv = (argv) => {
10
- if (argv[0] === "--") {
11
- return argv.slice(1);
12
- }
13
- return argv;
14
- };
15
- const commandFromArgv = (argv) => {
16
- const normalized = normalizeCliArgv(argv);
17
- if (normalized.length === 0) {
18
- return "ogment";
19
- }
20
- return `ogment ${normalized.join(" ")}`;
21
- };
22
- export const runCli = async (argv = process.argv.slice(2), runtime = createRuntime()) => {
23
- const normalizedArgv = normalizeCliArgv(argv);
24
- runtime.output.configure(parseOutputOptionsFromArgv(normalizedArgv));
25
- const parseState = createCommanderParseState();
26
- const { program, readInvocation } = createProgram(runtime, parseState);
27
- try {
28
- await program.parseAsync(normalizedArgv, { from: "user" });
29
- const invocation = readInvocation();
30
- if (invocation !== null) {
31
- await executeInvocation(runtime, invocation);
32
- }
33
- return EXIT_CODE.success;
34
- }
35
- catch (error) {
36
- if (error instanceof CliExitError) {
37
- return error.exitCode;
38
- }
39
- if (error instanceof CommanderError) {
40
- if (error.exitCode === EXIT_CODE.success) {
41
- return EXIT_CODE.success;
42
- }
43
- if (runtime.output.mode === "human") {
44
- return EXIT_CODE.validation;
45
- }
46
- const parseError = toParseCliError(error, parseState, {
47
- includeDebug: runtime.output.debug,
48
- });
49
- runtime.output.parseError(parseError.payload, {
50
- command: commandFromArgv(argv),
51
- entity: null,
52
- nextActions: parseError.nextActions,
53
- });
54
- return EXIT_CODE.validation;
55
- }
56
- const normalized = normalizeCliRuntimeError(error);
57
- runtime.output.error(normalized, {
58
- command: commandFromArgv(argv),
59
- entity: null,
60
- });
61
- return exitCodeForError(normalized);
62
- }
63
- };
64
- export const executeCli = async () => {
65
- const code = await runCli();
66
- process.exitCode = code;
67
- };
68
- const toCanonicalFileHref = (path) => {
69
- return pathToFileURL(realpathSync(path)).href;
70
- };
71
- export const shouldExecuteCli = (importMetaUrl, argv1) => {
72
- if (argv1 === undefined) {
73
- return false;
74
- }
75
- try {
76
- const invokedFileHref = toCanonicalFileHref(argv1);
77
- const moduleFileHref = toCanonicalFileHref(fileURLToPath(importMetaUrl));
78
- return invokedFileHref === moduleFileHref;
79
- }
80
- catch {
81
- return false;
82
- }
83
- };
@@ -1,21 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { CommandContext } from "../commands/context.js";
3
- import { OutputManager, type OutputInitOptions } from "../output/manager.js";
4
- import { type InfoService } from "../services/info.js";
5
- export interface GlobalCliOptions {
6
- apiKey: string | undefined;
7
- debug: boolean | undefined;
8
- human: boolean | undefined;
9
- quiet: boolean | undefined;
10
- yes: boolean | undefined;
11
- }
12
- export interface Runtime {
13
- context: CommandContext;
14
- infoService?: InfoService;
15
- output: OutputManager;
16
- }
17
- export declare const createRuntime: () => Runtime;
18
- export declare const asGlobalOptions: (command: Command) => GlobalCliOptions;
19
- export declare const mapGlobalOutputOptions: (options: GlobalCliOptions) => OutputInitOptions;
20
- export declare const parseOutputOptionsFromArgv: (argv: readonly string[]) => OutputInitOptions;
21
- //# sourceMappingURL=runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/cli/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,wBAAwB,CAAC;AAI9E,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG1E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,QAAO,OA+ChC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,KAAG,gBAgBlD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,gBAAgB,KAAG,iBAOlE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,iBASpE,CAAC"}
@@ -1,80 +0,0 @@
1
- import { createFileCredentialsStore } from "../infra/credentials.js";
2
- import { createRuntimeConfig } from "../infra/env.js";
3
- import { createHttpClient } from "../infra/http.js";
4
- import { OutputManager } from "../output/manager.js";
5
- import { createAccountService } from "../services/account.js";
6
- import { createAuthService } from "../services/auth.js";
7
- import { createInfoService } from "../services/info.js";
8
- import { createMcpService } from "../services/mcp.js";
9
- export const createRuntime = () => {
10
- const runtimeConfig = createRuntimeConfig();
11
- const output = new OutputManager();
12
- const credentialsStore = createFileCredentialsStore({
13
- configDir: runtimeConfig.configDir,
14
- credentialsPath: runtimeConfig.credentialsPath,
15
- });
16
- const httpClient = createHttpClient();
17
- const services = {
18
- account: createAccountService({
19
- baseUrl: runtimeConfig.baseUrl,
20
- httpClient,
21
- }),
22
- auth: createAuthService({
23
- baseUrl: runtimeConfig.baseUrl,
24
- credentialsStore,
25
- envApiKey: runtimeConfig.envApiKey,
26
- httpClient,
27
- }),
28
- mcp: createMcpService({
29
- baseUrl: runtimeConfig.baseUrl,
30
- version: runtimeConfig.version,
31
- }),
32
- };
33
- const infoService = createInfoService({
34
- accountService: services.account,
35
- baseUrl: runtimeConfig.baseUrl,
36
- baseUrlSource: runtimeConfig.baseUrlSource,
37
- configDir: runtimeConfig.configDir,
38
- credentialsPath: runtimeConfig.credentialsPath,
39
- credentialsStore,
40
- envApiKey: runtimeConfig.envApiKey,
41
- httpClient,
42
- version: runtimeConfig.version,
43
- });
44
- return {
45
- context: {
46
- apiKeyOverride: undefined,
47
- output,
48
- services,
49
- },
50
- infoService,
51
- output,
52
- };
53
- };
54
- export const asGlobalOptions = (command) => {
55
- const options = command.optsWithGlobals();
56
- return {
57
- apiKey: options.apiKey,
58
- debug: options.debug,
59
- human: options.human,
60
- quiet: options.quiet,
61
- yes: options.yes,
62
- };
63
- };
64
- export const mapGlobalOutputOptions = (options) => {
65
- return {
66
- debug: options.debug,
67
- human: options.human,
68
- quiet: options.quiet,
69
- yes: options.yes,
70
- };
71
- };
72
- export const parseOutputOptionsFromArgv = (argv) => {
73
- const hasFlag = (flag) => argv.includes(flag);
74
- return {
75
- debug: hasFlag("--debug"),
76
- human: hasFlag("--human"),
77
- quiet: hasFlag("--quiet"),
78
- yes: hasFlag("--yes"),
79
- };
80
- };
package/dist/cli.d.ts DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { executeCli, runCli, shouldExecuteCli } from "./cli/run.js";
3
- export { executeCli, runCli, shouldExecuteCli };
4
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,19 +0,0 @@
1
- import type { Result as ResultType } from "better-result";
2
- import type { LoginPendingInfo, LoginError } from "../services/auth.js";
3
- import type { UnexpectedError } from "../shared/errors.js";
4
- import type { AuthStatusSuccess, LoginSuccess, LogoutSuccess } from "../shared/types.js";
5
- import type { CommandContext } from "./context.js";
6
- interface DeviceAuthLoginCommandOptions {
7
- mode: "device";
8
- onPending?: (info: LoginPendingInfo) => void;
9
- }
10
- interface ApiKeyAuthLoginCommandOptions {
11
- apiKey: string;
12
- mode: "apiKey";
13
- }
14
- export type AuthLoginCommandOptions = ApiKeyAuthLoginCommandOptions | DeviceAuthLoginCommandOptions;
15
- export declare const runAuthLoginCommand: (context: CommandContext, options: AuthLoginCommandOptions) => Promise<ResultType<LoginSuccess, LoginError>>;
16
- export declare const runAuthStatusCommand: (context: CommandContext) => Promise<ResultType<AuthStatusSuccess, UnexpectedError>>;
17
- export declare const runAuthLogoutCommand: (context: CommandContext) => Promise<ResultType<LogoutSuccess, UnexpectedError>>;
18
- export {};
19
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,UAAU,6BAA6B;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9C;AAED,UAAU,6BAA6B;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAEpG,eAAO,MAAM,mBAAmB,GAC9B,SAAS,cAAc,EACvB,SAAS,uBAAuB,KAC/B,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAgB9C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,cAAc,KACtB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAExD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,cAAc,KACtB,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAEpD,CAAC"}
@@ -1,21 +0,0 @@
1
- export const runAuthLoginCommand = async (context, options) => {
2
- const loginOptions = (() => {
3
- if (options.mode === "apiKey") {
4
- return {
5
- apiKey: options.apiKey,
6
- mode: "apiKey",
7
- };
8
- }
9
- return {
10
- mode: "device",
11
- ...(options.onPending === undefined ? {} : { onPending: options.onPending }),
12
- };
13
- })();
14
- return context.services.auth.login(loginOptions);
15
- };
16
- export const runAuthStatusCommand = async (context) => {
17
- return context.services.auth.status(context.apiKeyOverride);
18
- };
19
- export const runAuthLogoutCommand = async (context) => {
20
- return context.services.auth.logout();
21
- };
@@ -1,31 +0,0 @@
1
- import type { Result as ResultType } from "better-result";
2
- import type { McpServiceError } from "../services/mcp.js";
3
- import { NotFoundError, ValidationError } from "../shared/errors.js";
4
- import type { CatalogServerFailure, CatalogSummarySuccess, CatalogToolDetailsSuccess, CatalogToolsSuccess } from "../shared/types.js";
5
- import type { CommandContext } from "./context.js";
6
- import { type ResolveServerStateError } from "./server-context.js";
7
- export interface CatalogCommandOptions {
8
- cursor?: string | undefined;
9
- includeDebug?: boolean | undefined;
10
- limit?: number | undefined;
11
- serverId?: string | undefined;
12
- }
13
- export interface CatalogToolsCommandOptions {
14
- serverId: string;
15
- }
16
- export interface CatalogToolDetailsCommandOptions {
17
- serverId: string;
18
- toolName: string;
19
- }
20
- export interface CatalogSummaryPage {
21
- failures: CatalogServerFailure[];
22
- nextCursor: string | null;
23
- servers: CatalogSummarySuccess["servers"];
24
- }
25
- export type CatalogCommandError = McpServiceError | NotFoundError | ResolveServerStateError | ValidationError;
26
- export type CatalogToolsCommandError = McpServiceError | NotFoundError | ResolveServerStateError;
27
- export type CatalogToolDetailsCommandError = McpServiceError | NotFoundError | ResolveServerStateError;
28
- export declare const runCatalogCommand: (context: CommandContext, options: CatalogCommandOptions) => Promise<ResultType<CatalogSummaryPage, CatalogCommandError>>;
29
- export declare const runCatalogToolsCommand: (context: CommandContext, options: CatalogToolsCommandOptions) => Promise<ResultType<CatalogToolsSuccess, CatalogToolsCommandError>>;
30
- export declare const runCatalogToolDetailsCommand: (context: CommandContext, options: CatalogToolDetailsCommandOptions) => Promise<ResultType<CatalogToolDetailsSuccess, CatalogToolDetailsCommandError>>;
31
- //# sourceMappingURL=catalog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/commands/catalog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AA0B7B,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;CAC3C;AAED,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,aAAa,GACb,uBAAuB,GACvB,eAAe,CAAC;AAEpB,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG,aAAa,GAAG,uBAAuB,CAAC;AAEjG,MAAM,MAAM,8BAA8B,GACtC,eAAe,GACf,aAAa,GACb,uBAAuB,CAAC;AA+D5B,eAAO,MAAM,iBAAiB,GAC5B,SAAS,cAAc,EACvB,SAAS,qBAAqB,KAC7B,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAmF7D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,EACvB,SAAS,0BAA0B,KAClC,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAoBnE,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,SAAS,cAAc,EACvB,SAAS,gCAAgC,KACxC,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,8BAA8B,CAAC,CAiC/E,CAAC"}