@ibm/ibmi-mcp-server 0.4.5 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/config/index.d.ts +20 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +95 -0
- package/dist/config/index.js.map +1 -1
- package/dist/ibmi-mcp-server/schemas/config.d.ts +58 -0
- package/dist/ibmi-mcp-server/schemas/config.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/schemas/config.js +35 -0
- package/dist/ibmi-mcp-server/schemas/config.js.map +1 -1
- package/dist/ibmi-mcp-server/services/authenticatedPoolManager.d.ts +19 -1
- package/dist/ibmi-mcp-server/services/authenticatedPoolManager.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/services/authenticatedPoolManager.js +30 -2
- package/dist/ibmi-mcp-server/services/authenticatedPoolManager.js.map +1 -1
- package/dist/ibmi-mcp-server/services/baseConnectionPool.d.ts +6 -2
- package/dist/ibmi-mcp-server/services/baseConnectionPool.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/services/baseConnectionPool.js +68 -8
- package/dist/ibmi-mcp-server/services/baseConnectionPool.js.map +1 -1
- package/dist/ibmi-mcp-server/services/connectionPool.d.ts +4 -2
- package/dist/ibmi-mcp-server/services/connectionPool.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/services/connectionPool.js +6 -3
- package/dist/ibmi-mcp-server/services/connectionPool.js.map +1 -1
- package/dist/ibmi-mcp-server/services/sourceManager.d.ts +19 -1
- package/dist/ibmi-mcp-server/services/sourceManager.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/services/sourceManager.js +31 -2
- package/dist/ibmi-mcp-server/services/sourceManager.js.map +1 -1
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts +1 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js +17 -3
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js.map +1 -1
- package/dist/ibmi-mcp-server/tools/index.d.ts +1 -0
- package/dist/ibmi-mcp-server/tools/index.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js +42 -4
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js.map +1 -1
- package/dist/public/context.d.ts +5 -0
- package/dist/public/context.d.ts.map +1 -0
- package/dist/public/context.js +5 -0
- package/dist/public/context.js.map +1 -0
- package/dist/public/formatting.d.ts +5 -0
- package/dist/public/formatting.d.ts.map +1 -0
- package/dist/public/formatting.js +5 -0
- package/dist/public/formatting.js.map +1 -0
- package/dist/public/services.d.ts +8 -0
- package/dist/public/services.d.ts.map +1 -0
- package/dist/public/services.js +8 -0
- package/dist/public/services.js.map +1 -0
- package/dist/public/tools.d.ts +16 -0
- package/dist/public/tools.d.ts.map +1 -0
- package/dist/public/tools.js +15 -0
- package/dist/public/tools.js.map +1 -0
- package/package.json +20 -17
- package/dist/cli/commands/columns.d.ts +0 -7
- package/dist/cli/commands/columns.d.ts.map +0 -1
- package/dist/cli/commands/columns.js +0 -29
- package/dist/cli/commands/columns.js.map +0 -1
- package/dist/cli/commands/completion.d.ts +0 -10
- package/dist/cli/commands/completion.d.ts.map +0 -1
- package/dist/cli/commands/completion.js +0 -247
- package/dist/cli/commands/completion.js.map +0 -1
- package/dist/cli/commands/config.d.ts +0 -11
- package/dist/cli/commands/config.d.ts.map +0 -1
- package/dist/cli/commands/config.js +0 -124
- package/dist/cli/commands/config.js.map +0 -1
- package/dist/cli/commands/describe.d.ts +0 -9
- package/dist/cli/commands/describe.d.ts.map +0 -1
- package/dist/cli/commands/describe.js +0 -82
- package/dist/cli/commands/describe.js.map +0 -1
- package/dist/cli/commands/related.d.ts +0 -7
- package/dist/cli/commands/related.d.ts.map +0 -1
- package/dist/cli/commands/related.js +0 -32
- package/dist/cli/commands/related.js.map +0 -1
- package/dist/cli/commands/schemas.d.ts +0 -7
- package/dist/cli/commands/schemas.d.ts.map +0 -1
- package/dist/cli/commands/schemas.js +0 -49
- package/dist/cli/commands/schemas.js.map +0 -1
- package/dist/cli/commands/sql.d.ts +0 -8
- package/dist/cli/commands/sql.d.ts.map +0 -1
- package/dist/cli/commands/sql.js +0 -187
- package/dist/cli/commands/sql.js.map +0 -1
- package/dist/cli/commands/system.d.ts +0 -11
- package/dist/cli/commands/system.d.ts.map +0 -1
- package/dist/cli/commands/system.js +0 -263
- package/dist/cli/commands/system.js.map +0 -1
- package/dist/cli/commands/tables.d.ts +0 -7
- package/dist/cli/commands/tables.d.ts.map +0 -1
- package/dist/cli/commands/tables.js +0 -48
- package/dist/cli/commands/tables.js.map +0 -1
- package/dist/cli/commands/tool.d.ts +0 -18
- package/dist/cli/commands/tool.d.ts.map +0 -1
- package/dist/cli/commands/tool.js +0 -194
- package/dist/cli/commands/tool.js.map +0 -1
- package/dist/cli/commands/tools-list.d.ts +0 -20
- package/dist/cli/commands/tools-list.d.ts.map +0 -1
- package/dist/cli/commands/tools-list.js +0 -209
- package/dist/cli/commands/tools-list.js.map +0 -1
- package/dist/cli/commands/validate.d.ts +0 -7
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/commands/validate.js +0 -77
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/config/credentials.d.ts +0 -21
- package/dist/cli/config/credentials.d.ts.map +0 -1
- package/dist/cli/config/credentials.js +0 -96
- package/dist/cli/config/credentials.js.map +0 -1
- package/dist/cli/config/index.d.ts +0 -11
- package/dist/cli/config/index.d.ts.map +0 -1
- package/dist/cli/config/index.js +0 -9
- package/dist/cli/config/index.js.map +0 -1
- package/dist/cli/config/loader.d.ts +0 -52
- package/dist/cli/config/loader.d.ts.map +0 -1
- package/dist/cli/config/loader.js +0 -237
- package/dist/cli/config/loader.js.map +0 -1
- package/dist/cli/config/resolver.d.ts +0 -31
- package/dist/cli/config/resolver.d.ts.map +0 -1
- package/dist/cli/config/resolver.js +0 -115
- package/dist/cli/config/resolver.js.map +0 -1
- package/dist/cli/config/schema.d.ts +0 -128
- package/dist/cli/config/schema.d.ts.map +0 -1
- package/dist/cli/config/schema.js +0 -37
- package/dist/cli/config/schema.js.map +0 -1
- package/dist/cli/config/types.d.ts +0 -59
- package/dist/cli/config/types.d.ts.map +0 -1
- package/dist/cli/config/types.js +0 -6
- package/dist/cli/config/types.js.map +0 -1
- package/dist/cli/formatters/output.d.ts +0 -70
- package/dist/cli/formatters/output.d.ts.map +0 -1
- package/dist/cli/formatters/output.js +0 -279
- package/dist/cli/formatters/output.js.map +0 -1
- package/dist/cli/index.d.ts +0 -13
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -102
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/utils/command-helpers.d.ts +0 -47
- package/dist/cli/utils/command-helpers.d.ts.map +0 -1
- package/dist/cli/utils/command-helpers.js +0 -211
- package/dist/cli/utils/command-helpers.js.map +0 -1
- package/dist/cli/utils/connection.d.ts +0 -20
- package/dist/cli/utils/connection.d.ts.map +0 -1
- package/dist/cli/utils/connection.js +0 -37
- package/dist/cli/utils/connection.js.map +0 -1
- package/dist/cli/utils/exit-codes.d.ts +0 -48
- package/dist/cli/utils/exit-codes.d.ts.map +0 -1
- package/dist/cli/utils/exit-codes.js +0 -111
- package/dist/cli/utils/exit-codes.js.map +0 -1
- package/dist/cli/utils/multi-connection.d.ts +0 -26
- package/dist/cli/utils/multi-connection.d.ts.map +0 -1
- package/dist/cli/utils/multi-connection.js +0 -72
- package/dist/cli/utils/multi-connection.js.map +0 -1
- package/dist/cli/utils/yaml-loader.d.ts +0 -69
- package/dist/cli/utils/yaml-loader.d.ts.map +0 -1
- package/dist/cli/utils/yaml-loader.js +0 -135
- package/dist/cli/utils/yaml-loader.js.map +0 -1
- package/dist/cli/utils/yaml-to-commander.d.ts +0 -26
- package/dist/cli/utils/yaml-to-commander.d.ts.map +0 -1
- package/dist/cli/utils/yaml-to-commander.js +0 -156
- package/dist/cli/utils/yaml-to-commander.js.map +0 -1
package/dist/cli/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Entry point for the IBM i CLI (`ibmi`).
|
|
4
|
-
* Provides a human-friendly and agent-friendly command-line interface to IBM i systems,
|
|
5
|
-
* reusing the same tool infrastructure as the MCP server.
|
|
6
|
-
* @module cli/index
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from "commander";
|
|
9
|
-
import { readFileSync } from "fs";
|
|
10
|
-
import path from "path";
|
|
11
|
-
import { fileURLToPath } from "url";
|
|
12
|
-
import { registerConfigCommand } from "./commands/config.js";
|
|
13
|
-
import { registerSystemCommand } from "./commands/system.js";
|
|
14
|
-
import { registerSchemasCommand } from "./commands/schemas.js";
|
|
15
|
-
import { registerTablesCommand } from "./commands/tables.js";
|
|
16
|
-
import { registerColumnsCommand } from "./commands/columns.js";
|
|
17
|
-
import { registerRelatedCommand } from "./commands/related.js";
|
|
18
|
-
import { registerValidateCommand } from "./commands/validate.js";
|
|
19
|
-
import { registerDescribeCommand } from "./commands/describe.js";
|
|
20
|
-
import { registerSqlCommand } from "./commands/sql.js";
|
|
21
|
-
import { registerToolCommand } from "./commands/tool.js";
|
|
22
|
-
import { registerToolsCommand, registerToolsetsCommand } from "./commands/tools-list.js";
|
|
23
|
-
import { registerCompletionCommand } from "./commands/completion.js";
|
|
24
|
-
/**
|
|
25
|
-
* Load version from package.json.
|
|
26
|
-
*/
|
|
27
|
-
function getVersion() {
|
|
28
|
-
try {
|
|
29
|
-
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
-
// Walk up to find package.json (handles both src/ and dist/)
|
|
31
|
-
let dir = currentDir;
|
|
32
|
-
for (let i = 0; i < 5; i++) {
|
|
33
|
-
try {
|
|
34
|
-
const pkg = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf-8"));
|
|
35
|
-
if (pkg.name === "@ibm/ibmi-mcp-server") {
|
|
36
|
-
return pkg.version;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// Continue searching
|
|
41
|
-
}
|
|
42
|
-
dir = path.dirname(dir);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Fallback
|
|
47
|
-
}
|
|
48
|
-
return "0.0.0";
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create and configure the CLI program.
|
|
52
|
-
*/
|
|
53
|
-
export function createProgram() {
|
|
54
|
-
const program = new Command();
|
|
55
|
-
program
|
|
56
|
-
.name("ibmi")
|
|
57
|
-
.description("IBM i command-line interface — query, explore, and manage IBM i systems")
|
|
58
|
-
.version(getVersion(), "-v, --version")
|
|
59
|
-
.option("--system <name>", "Target system name (overrides IBMI_SYSTEM and config default)")
|
|
60
|
-
.option("--format <type>", "Output format: table, json, csv, markdown", undefined)
|
|
61
|
-
.option("--raw", "Output as JSON (shorthand for --format json)")
|
|
62
|
-
.option("--no-color", "Disable colored output")
|
|
63
|
-
.option("--tools <path>", "Path to YAML tool file(s) or directory (comma-separated)")
|
|
64
|
-
.option("--stream", "Stream results as NDJSON (one JSON object per line)")
|
|
65
|
-
.option("--watch <seconds>", "Re-run command at interval (seconds)")
|
|
66
|
-
.option("--output <path>", "Write output to file instead of stdout");
|
|
67
|
-
// Register command groups
|
|
68
|
-
registerConfigCommand(program);
|
|
69
|
-
registerSystemCommand(program);
|
|
70
|
-
registerSchemasCommand(program);
|
|
71
|
-
registerTablesCommand(program);
|
|
72
|
-
registerColumnsCommand(program);
|
|
73
|
-
registerRelatedCommand(program);
|
|
74
|
-
registerValidateCommand(program);
|
|
75
|
-
registerDescribeCommand(program);
|
|
76
|
-
registerSqlCommand(program);
|
|
77
|
-
registerToolCommand(program);
|
|
78
|
-
registerToolsCommand(program);
|
|
79
|
-
registerToolsetsCommand(program);
|
|
80
|
-
registerCompletionCommand(program);
|
|
81
|
-
// Add a helpful message for when no command is given
|
|
82
|
-
program.action(() => {
|
|
83
|
-
program.outputHelp();
|
|
84
|
-
});
|
|
85
|
-
return program;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Main entry point.
|
|
89
|
-
*/
|
|
90
|
-
async function main() {
|
|
91
|
-
const program = createProgram();
|
|
92
|
-
try {
|
|
93
|
-
await program.parseAsync(process.argv);
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
// Commander handles most errors, but catch anything unexpected
|
|
97
|
-
process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
98
|
-
process.exitCode = 1; // Top-level catch uses code 1 (general)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
main();
|
|
102
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAA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CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,+DAA+D;QAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC/D,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,wCAAwC;IAChE,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Shared utilities for CLI command implementations.
|
|
3
|
-
* Provides the `withConnection` wrapper that handles the full lifecycle
|
|
4
|
-
* of system resolution, connection setup, execution, rendering, and cleanup.
|
|
5
|
-
*
|
|
6
|
-
* @module cli/utils/command-helpers
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from "commander";
|
|
9
|
-
import type { OutputFormat, ResolvedSystem } from "../config/types.js";
|
|
10
|
-
import type { RequestContext } from "../../utils/internal/requestContext.js";
|
|
11
|
-
import { type OutputMeta } from "../formatters/output.js";
|
|
12
|
-
/**
|
|
13
|
-
* Get the effective output format from parent command options and config.
|
|
14
|
-
*
|
|
15
|
-
* Priority: --raw → --format → config format → TTY auto-detect.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getFormat(cmd: Command): OutputFormat;
|
|
18
|
-
/**
|
|
19
|
-
* Check if --stream mode is enabled.
|
|
20
|
-
*/
|
|
21
|
-
export declare function isStreaming(cmd: Command): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Create a minimal RequestContext for CLI tool execution.
|
|
24
|
-
* Avoids importing the full server utils (which would trigger OpenTelemetry).
|
|
25
|
-
*/
|
|
26
|
-
export declare function createCliContext(toolName: string): RequestContext;
|
|
27
|
-
/** Result shape expected from command actions. */
|
|
28
|
-
export interface CommandResult {
|
|
29
|
-
data: Record<string, unknown>[];
|
|
30
|
-
meta?: Partial<OutputMeta>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Standard command action wrapper.
|
|
34
|
-
*
|
|
35
|
-
* Handles the full lifecycle:
|
|
36
|
-
* 1. Resolve target system from --system flag / env / config
|
|
37
|
-
* 2. Connect (set env vars for IBMiConnectionPool)
|
|
38
|
-
* 3. Run the action callback
|
|
39
|
-
* 4. Render output in the requested format (or NDJSON if --stream)
|
|
40
|
-
* 5. Cleanup (close pool) in finally block
|
|
41
|
-
* 6. Set semantic exit code on error
|
|
42
|
-
*
|
|
43
|
-
* When --watch <seconds> is set, the connect-execute-render cycle repeats
|
|
44
|
-
* at the given interval until Ctrl+C is received.
|
|
45
|
-
*/
|
|
46
|
-
export declare function withConnection(cmd: Command, toolName: string, action: (resolved: ResolvedSystem, ctx: RequestContext) => Promise<CommandResult>): Promise<void>;
|
|
47
|
-
//# sourceMappingURL=command-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/command-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAK7E,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAapD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAOjE;AAED,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CACN,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,aAAa,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsDf"}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Shared utilities for CLI command implementations.
|
|
3
|
-
* Provides the `withConnection` wrapper that handles the full lifecycle
|
|
4
|
-
* of system resolution, connection setup, execution, rendering, and cleanup.
|
|
5
|
-
*
|
|
6
|
-
* @module cli/utils/command-helpers
|
|
7
|
-
*/
|
|
8
|
-
import { loadConfig } from "../config/loader.js";
|
|
9
|
-
import { resolveSystem } from "../config/resolver.js";
|
|
10
|
-
import { connectSystem } from "./connection.js";
|
|
11
|
-
import { classifyError } from "./exit-codes.js";
|
|
12
|
-
import { detectFormat, renderOutput, renderNdjson, renderError, setOutputFile, finalizeOutput, } from "../formatters/output.js";
|
|
13
|
-
/**
|
|
14
|
-
* Get the effective output format from parent command options and config.
|
|
15
|
-
*
|
|
16
|
-
* Priority: --raw → --format → config format → TTY auto-detect.
|
|
17
|
-
*/
|
|
18
|
-
export function getFormat(cmd) {
|
|
19
|
-
const opts = cmd.optsWithGlobals();
|
|
20
|
-
let configFormat;
|
|
21
|
-
try {
|
|
22
|
-
configFormat = loadConfig().format;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// Config may not exist — fall through to auto-detect
|
|
26
|
-
}
|
|
27
|
-
return detectFormat(opts["format"], opts["raw"], configFormat);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Check if --stream mode is enabled.
|
|
31
|
-
*/
|
|
32
|
-
export function isStreaming(cmd) {
|
|
33
|
-
const opts = cmd.optsWithGlobals();
|
|
34
|
-
return opts["stream"] === true;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a minimal RequestContext for CLI tool execution.
|
|
38
|
-
* Avoids importing the full server utils (which would trigger OpenTelemetry).
|
|
39
|
-
*/
|
|
40
|
-
export function createCliContext(toolName) {
|
|
41
|
-
return {
|
|
42
|
-
requestId: `cli-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
43
|
-
timestamp: new Date().toISOString(),
|
|
44
|
-
operation: "CliToolExecution",
|
|
45
|
-
toolName,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Standard command action wrapper.
|
|
50
|
-
*
|
|
51
|
-
* Handles the full lifecycle:
|
|
52
|
-
* 1. Resolve target system from --system flag / env / config
|
|
53
|
-
* 2. Connect (set env vars for IBMiConnectionPool)
|
|
54
|
-
* 3. Run the action callback
|
|
55
|
-
* 4. Render output in the requested format (or NDJSON if --stream)
|
|
56
|
-
* 5. Cleanup (close pool) in finally block
|
|
57
|
-
* 6. Set semantic exit code on error
|
|
58
|
-
*
|
|
59
|
-
* When --watch <seconds> is set, the connect-execute-render cycle repeats
|
|
60
|
-
* at the given interval until Ctrl+C is received.
|
|
61
|
-
*/
|
|
62
|
-
export async function withConnection(cmd, toolName, action) {
|
|
63
|
-
const format = getFormat(cmd);
|
|
64
|
-
const stream = isStreaming(cmd);
|
|
65
|
-
const opts = cmd.optsWithGlobals();
|
|
66
|
-
const outputPath = opts["output"];
|
|
67
|
-
const watchInterval = opts["watch"] ? parseInt(opts["watch"], 10) : undefined;
|
|
68
|
-
if (outputPath) {
|
|
69
|
-
setOutputFile(outputPath);
|
|
70
|
-
}
|
|
71
|
-
if (watchInterval && watchInterval > 0) {
|
|
72
|
-
try {
|
|
73
|
-
await runWithWatch(cmd, toolName, action, format, stream, watchInterval);
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
if (outputPath)
|
|
77
|
-
finalizeOutput();
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
let cleanup;
|
|
82
|
-
let resolved;
|
|
83
|
-
try {
|
|
84
|
-
resolved = resolveSystem(opts["system"]);
|
|
85
|
-
cleanup = await connectSystem(resolved);
|
|
86
|
-
const ctx = createCliContext(toolName);
|
|
87
|
-
const startTime = Date.now();
|
|
88
|
-
const result = await action(resolved, ctx);
|
|
89
|
-
const elapsedMs = Date.now() - startTime;
|
|
90
|
-
// NDJSON streaming: one JSON object per line, no envelope
|
|
91
|
-
if (stream && format === "json") {
|
|
92
|
-
renderNdjson(result.data);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
renderOutput(result.data, format, {
|
|
96
|
-
rowCount: result.data.length,
|
|
97
|
-
elapsedMs,
|
|
98
|
-
system: resolved,
|
|
99
|
-
command: toolName,
|
|
100
|
-
...result.meta,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
105
|
-
const classified = classifyError(error);
|
|
106
|
-
renderError(error, format, resolved, classified.errorCode);
|
|
107
|
-
process.exitCode = classified.exitCode;
|
|
108
|
-
}
|
|
109
|
-
finally {
|
|
110
|
-
if (cleanup)
|
|
111
|
-
await cleanup();
|
|
112
|
-
if (outputPath)
|
|
113
|
-
finalizeOutput();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Strip sensitive flags (e.g. --password) from argv before displaying.
|
|
118
|
-
*/
|
|
119
|
-
function sanitizeArgsForDisplay(args) {
|
|
120
|
-
const sensitiveFlags = ["--password"];
|
|
121
|
-
const sanitized = [];
|
|
122
|
-
for (let i = 0; i < args.length; i++) {
|
|
123
|
-
const arg = args[i];
|
|
124
|
-
if (sensitiveFlags.some((f) => arg === f || arg.startsWith(`${f}=`))) {
|
|
125
|
-
if (!arg.includes("="))
|
|
126
|
-
i++; // skip next arg (the value)
|
|
127
|
-
sanitized.push("--password ****");
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
sanitized.push(arg);
|
|
131
|
-
}
|
|
132
|
-
return sanitized.join(" ");
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Run a command repeatedly at the specified interval.
|
|
136
|
-
* Clears the screen between runs in table/markdown/csv mode (not JSON/NDJSON,
|
|
137
|
-
* which are intended for piping). Shows a timestamp header on stderr.
|
|
138
|
-
* Ctrl+C exits cleanly.
|
|
139
|
-
*/
|
|
140
|
-
async function runWithWatch(cmd, toolName, action, format, stream, intervalSeconds) {
|
|
141
|
-
let running = true;
|
|
142
|
-
// Primary SIGINT handler to stop the loop
|
|
143
|
-
const handler = () => {
|
|
144
|
-
running = false;
|
|
145
|
-
};
|
|
146
|
-
process.on("SIGINT", handler);
|
|
147
|
-
try {
|
|
148
|
-
while (running) {
|
|
149
|
-
// Clear screen for human-readable formats; leave JSON/NDJSON clean for piping
|
|
150
|
-
if (format !== "json") {
|
|
151
|
-
process.stdout.write("\x1b[2J\x1b[H");
|
|
152
|
-
}
|
|
153
|
-
// Show timestamp header so the user knows when the last refresh happened
|
|
154
|
-
const now = new Date().toLocaleString();
|
|
155
|
-
const args = sanitizeArgsForDisplay(process.argv.slice(2));
|
|
156
|
-
process.stderr.write(`Every ${intervalSeconds}s: ibmi ${args} ${now}\n\n`);
|
|
157
|
-
// Run one connect-execute-render cycle
|
|
158
|
-
let cleanup;
|
|
159
|
-
try {
|
|
160
|
-
const opts = cmd.optsWithGlobals();
|
|
161
|
-
const resolved = resolveSystem(opts["system"]);
|
|
162
|
-
cleanup = await connectSystem(resolved);
|
|
163
|
-
const ctx = createCliContext(toolName);
|
|
164
|
-
const startTime = Date.now();
|
|
165
|
-
const result = await action(resolved, ctx);
|
|
166
|
-
const elapsedMs = Date.now() - startTime;
|
|
167
|
-
if (stream && format === "json") {
|
|
168
|
-
renderNdjson(result.data);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
renderOutput(result.data, format, {
|
|
172
|
-
rowCount: result.data.length,
|
|
173
|
-
elapsedMs,
|
|
174
|
-
system: resolved,
|
|
175
|
-
command: toolName,
|
|
176
|
-
...result.meta,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
catch (err) {
|
|
181
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
182
|
-
const classified = classifyError(error);
|
|
183
|
-
renderError(error, format, undefined, classified.errorCode);
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
186
|
-
if (cleanup)
|
|
187
|
-
await cleanup();
|
|
188
|
-
}
|
|
189
|
-
// Wait for the interval, but allow SIGINT to break out immediately
|
|
190
|
-
if (running) {
|
|
191
|
-
await new Promise((resolve) => {
|
|
192
|
-
const timer = setTimeout(resolve, intervalSeconds * 1000);
|
|
193
|
-
const sigHandler = () => {
|
|
194
|
-
clearTimeout(timer);
|
|
195
|
-
running = false;
|
|
196
|
-
resolve();
|
|
197
|
-
};
|
|
198
|
-
process.once("SIGINT", sigHandler);
|
|
199
|
-
// Remove the per-iteration handler once the timer fires naturally
|
|
200
|
-
setTimeout(() => {
|
|
201
|
-
process.removeListener("SIGINT", sigHandler);
|
|
202
|
-
}, intervalSeconds * 1000 + 10);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
finally {
|
|
208
|
-
process.removeListener("SIGINT", handler);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
//# sourceMappingURL=command-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|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OAAO;oBAAE,MAAM,OAAO,EAAE,CAAC;YAC/B,CAAC;YAED,mEAAmE;YACnE,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAClC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC,CAAC;oBAC1D,MAAM,UAAU,GAAG,GAAG,EAAE;wBACtB,YAAY,CAAC,KAAK,CAAC,CAAC;wBACpB,OAAO,GAAG,KAAK,CAAC;wBAChB,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;oBACnC,kEAAkE;oBAClE,UAAU,CAAC,GAAG,EAAE;wBACd,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;oBAC/C,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;gBAClC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Connection bridge for the IBM i CLI.
|
|
3
|
-
* Maps resolved system config into DB2i_* environment variables that
|
|
4
|
-
* IBMiConnectionPool reads via the global config singleton.
|
|
5
|
-
*
|
|
6
|
-
* Must be called BEFORE dynamic-importing any tool modules, since
|
|
7
|
-
* the server's config/index.ts evaluates env vars at import time.
|
|
8
|
-
*
|
|
9
|
-
* @module cli/utils/connection
|
|
10
|
-
*/
|
|
11
|
-
import type { ResolvedSystem } from "../config/types.js";
|
|
12
|
-
/**
|
|
13
|
-
* Set DB2i_* environment variables from resolved system config and
|
|
14
|
-
* return a cleanup function to close the connection pool.
|
|
15
|
-
*
|
|
16
|
-
* Call this before dynamically importing tool modules so the global
|
|
17
|
-
* config singleton picks up the correct credentials.
|
|
18
|
-
*/
|
|
19
|
-
export declare function connectSystem(resolved: ResolvedSystem): Promise<() => Promise<void>>;
|
|
20
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CA2B9B"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Connection bridge for the IBM i CLI.
|
|
3
|
-
* Maps resolved system config into DB2i_* environment variables that
|
|
4
|
-
* IBMiConnectionPool reads via the global config singleton.
|
|
5
|
-
*
|
|
6
|
-
* Must be called BEFORE dynamic-importing any tool modules, since
|
|
7
|
-
* the server's config/index.ts evaluates env vars at import time.
|
|
8
|
-
*
|
|
9
|
-
* @module cli/utils/connection
|
|
10
|
-
*/
|
|
11
|
-
import { resolvePassword } from "../config/credentials.js";
|
|
12
|
-
/**
|
|
13
|
-
* Set DB2i_* environment variables from resolved system config and
|
|
14
|
-
* return a cleanup function to close the connection pool.
|
|
15
|
-
*
|
|
16
|
-
* Call this before dynamically importing tool modules so the global
|
|
17
|
-
* config singleton picks up the correct credentials.
|
|
18
|
-
*/
|
|
19
|
-
export async function connectSystem(resolved) {
|
|
20
|
-
const password = await resolvePassword(resolved.name, resolved.config.password, resolved.config.user, resolved.config.host);
|
|
21
|
-
// Set env vars for IBMiConnectionPool (reads from global config singleton)
|
|
22
|
-
process.env.DB2i_HOST = resolved.config.host;
|
|
23
|
-
process.env.DB2i_USER = resolved.config.user;
|
|
24
|
-
process.env.DB2i_PASS = password;
|
|
25
|
-
process.env.DB2i_IGNORE_UNAUTHORIZED = String(resolved.config.ignoreUnauthorized);
|
|
26
|
-
// Return cleanup function
|
|
27
|
-
return async () => {
|
|
28
|
-
try {
|
|
29
|
-
const { IBMiConnectionPool } = await import("../../ibmi-mcp-server/services/connectionPool.js");
|
|
30
|
-
await IBMiConnectionPool.close();
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
// Ignore cleanup errors
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/cli/utils/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAwB;IAExB,MAAM,QAAQ,GAAG,MAAM,eAAe,CACpC,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,MAAM,CAAC,QAAQ,EACxB,QAAQ,CAAC,MAAM,CAAC,IAAI,EACpB,QAAQ,CAAC,MAAM,CAAC,IAAI,CACrB,CAAC;IAEF,2EAA2E;IAC3E,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,MAAM,CAC3C,QAAQ,CAAC,MAAM,CAAC,kBAAkB,CACnC,CAAC;IAEF,0BAA0B;IAC1B,OAAO,KAAK,IAAI,EAAE;QAChB,IAAI,CAAC;YACH,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CACzC,kDAAkD,CACnD,CAAC;YACF,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI exit codes and error classification.
|
|
3
|
-
* Provides semantic exit codes for agent and script consumption.
|
|
4
|
-
* @module cli/utils/exit-codes
|
|
5
|
-
*/
|
|
6
|
-
/** CLI exit codes for different error categories. */
|
|
7
|
-
export declare const ExitCode: {
|
|
8
|
-
/** Command completed successfully. */
|
|
9
|
-
readonly SUCCESS: 0;
|
|
10
|
-
/** General error (connection failure, unexpected error). */
|
|
11
|
-
readonly GENERAL: 1;
|
|
12
|
-
/** Invalid arguments or usage error. */
|
|
13
|
-
readonly USAGE: 2;
|
|
14
|
-
/** Query execution error (SQL error). */
|
|
15
|
-
readonly QUERY: 3;
|
|
16
|
-
/** Security violation (read-only system, forbidden keyword). */
|
|
17
|
-
readonly SECURITY: 4;
|
|
18
|
-
/** Authentication failure (bad credentials, missing password). */
|
|
19
|
-
readonly AUTH: 5;
|
|
20
|
-
};
|
|
21
|
-
export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];
|
|
22
|
-
/** Error code strings for structured JSON error output. */
|
|
23
|
-
export declare const ErrorCode: {
|
|
24
|
-
readonly GENERAL_ERROR: "GENERAL_ERROR";
|
|
25
|
-
readonly USAGE_ERROR: "USAGE_ERROR";
|
|
26
|
-
readonly CONNECTION_ERROR: "CONNECTION_ERROR";
|
|
27
|
-
readonly QUERY_ERROR: "QUERY_ERROR";
|
|
28
|
-
readonly SQL_ERROR: "SQL_ERROR";
|
|
29
|
-
readonly SECURITY_VIOLATION: "SECURITY_VIOLATION";
|
|
30
|
-
readonly AUTH_FAILURE: "AUTH_FAILURE";
|
|
31
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
32
|
-
readonly TIMEOUT: "TIMEOUT";
|
|
33
|
-
};
|
|
34
|
-
export type ErrorCodeValue = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
35
|
-
/** Classified error with exit code and error code. */
|
|
36
|
-
export interface ClassifiedError {
|
|
37
|
-
exitCode: ExitCodeValue;
|
|
38
|
-
errorCode: ErrorCodeValue;
|
|
39
|
-
message: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Classify an error into an exit code and error code based on its message and type.
|
|
43
|
-
*
|
|
44
|
-
* Pattern matching is intentionally broad — we check common patterns from
|
|
45
|
-
* Mapepire, SqlSecurityValidator, and our own error messages.
|
|
46
|
-
*/
|
|
47
|
-
export declare function classifyError(error: Error): ClassifiedError;
|
|
48
|
-
//# sourceMappingURL=exit-codes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-codes.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,qDAAqD;AACrD,eAAO,MAAM,QAAQ;IACnB,sCAAsC;;IAEtC,4DAA4D;;IAE5D,wCAAwC;;IAExC,yCAAyC;;IAEzC,gEAAgE;;IAEhE,kEAAkE;;CAE1D,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAErE,2DAA2D;AAC3D,eAAO,MAAM,SAAS;;;;;;;;;;CAUZ,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAExE,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAuF3D"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI exit codes and error classification.
|
|
3
|
-
* Provides semantic exit codes for agent and script consumption.
|
|
4
|
-
* @module cli/utils/exit-codes
|
|
5
|
-
*/
|
|
6
|
-
/** CLI exit codes for different error categories. */
|
|
7
|
-
export const ExitCode = {
|
|
8
|
-
/** Command completed successfully. */
|
|
9
|
-
SUCCESS: 0,
|
|
10
|
-
/** General error (connection failure, unexpected error). */
|
|
11
|
-
GENERAL: 1,
|
|
12
|
-
/** Invalid arguments or usage error. */
|
|
13
|
-
USAGE: 2,
|
|
14
|
-
/** Query execution error (SQL error). */
|
|
15
|
-
QUERY: 3,
|
|
16
|
-
/** Security violation (read-only system, forbidden keyword). */
|
|
17
|
-
SECURITY: 4,
|
|
18
|
-
/** Authentication failure (bad credentials, missing password). */
|
|
19
|
-
AUTH: 5,
|
|
20
|
-
};
|
|
21
|
-
/** Error code strings for structured JSON error output. */
|
|
22
|
-
export const ErrorCode = {
|
|
23
|
-
GENERAL_ERROR: "GENERAL_ERROR",
|
|
24
|
-
USAGE_ERROR: "USAGE_ERROR",
|
|
25
|
-
CONNECTION_ERROR: "CONNECTION_ERROR",
|
|
26
|
-
QUERY_ERROR: "QUERY_ERROR",
|
|
27
|
-
SQL_ERROR: "SQL_ERROR",
|
|
28
|
-
SECURITY_VIOLATION: "SECURITY_VIOLATION",
|
|
29
|
-
AUTH_FAILURE: "AUTH_FAILURE",
|
|
30
|
-
NOT_FOUND: "NOT_FOUND",
|
|
31
|
-
TIMEOUT: "TIMEOUT",
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Classify an error into an exit code and error code based on its message and type.
|
|
35
|
-
*
|
|
36
|
-
* Pattern matching is intentionally broad — we check common patterns from
|
|
37
|
-
* Mapepire, SqlSecurityValidator, and our own error messages.
|
|
38
|
-
*/
|
|
39
|
-
export function classifyError(error) {
|
|
40
|
-
const msg = error.message.toLowerCase();
|
|
41
|
-
// Authentication failures
|
|
42
|
-
if (msg.includes("authentication") ||
|
|
43
|
-
msg.includes("unauthorized") ||
|
|
44
|
-
msg.includes("credentials") ||
|
|
45
|
-
msg.includes("password") ||
|
|
46
|
-
msg.includes("login failed") ||
|
|
47
|
-
msg.includes("auth")) {
|
|
48
|
-
return {
|
|
49
|
-
exitCode: ExitCode.AUTH,
|
|
50
|
-
errorCode: ErrorCode.AUTH_FAILURE,
|
|
51
|
-
message: error.message,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// Security violations
|
|
55
|
-
if (msg.includes("read-only") ||
|
|
56
|
-
msg.includes("readonly") ||
|
|
57
|
-
msg.includes("security") ||
|
|
58
|
-
msg.includes("forbidden") ||
|
|
59
|
-
msg.includes("blocked") ||
|
|
60
|
-
msg.includes("not allowed") ||
|
|
61
|
-
msg.includes("mutation")) {
|
|
62
|
-
return {
|
|
63
|
-
exitCode: ExitCode.SECURITY,
|
|
64
|
-
errorCode: ErrorCode.SECURITY_VIOLATION,
|
|
65
|
-
message: error.message,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// SQL / query execution errors
|
|
69
|
-
if (msg.includes("sql") ||
|
|
70
|
-
msg.includes("query") ||
|
|
71
|
-
msg.includes("sqlcode") ||
|
|
72
|
-
msg.includes("sqlstate") ||
|
|
73
|
-
msg.includes("execute") ||
|
|
74
|
-
msg.includes("syntax error")) {
|
|
75
|
-
return {
|
|
76
|
-
exitCode: ExitCode.QUERY,
|
|
77
|
-
errorCode: ErrorCode.SQL_ERROR,
|
|
78
|
-
message: error.message,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
// Connection errors
|
|
82
|
-
if (msg.includes("connect") ||
|
|
83
|
-
msg.includes("econnrefused") ||
|
|
84
|
-
msg.includes("enotfound") ||
|
|
85
|
-
msg.includes("timeout") ||
|
|
86
|
-
msg.includes("timed out") ||
|
|
87
|
-
msg.includes("socket")) {
|
|
88
|
-
return {
|
|
89
|
-
exitCode: ExitCode.GENERAL,
|
|
90
|
-
errorCode: ErrorCode.CONNECTION_ERROR,
|
|
91
|
-
message: error.message,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
// Not found
|
|
95
|
-
if (msg.includes("not found") ||
|
|
96
|
-
msg.includes("does not exist") ||
|
|
97
|
-
msg.includes("no such")) {
|
|
98
|
-
return {
|
|
99
|
-
exitCode: ExitCode.GENERAL,
|
|
100
|
-
errorCode: ErrorCode.NOT_FOUND,
|
|
101
|
-
message: error.message,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
// Default: general error
|
|
105
|
-
return {
|
|
106
|
-
exitCode: ExitCode.GENERAL,
|
|
107
|
-
errorCode: ErrorCode.GENERAL_ERROR,
|
|
108
|
-
message: error.message,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=exit-codes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../../../src/cli/utils/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,qDAAqD;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,sCAAsC;IACtC,OAAO,EAAE,CAAC;IACV,4DAA4D;IAC5D,OAAO,EAAE,CAAC;IACV,wCAAwC;IACxC,KAAK,EAAE,CAAC;IACR,yCAAyC;IACzC,KAAK,EAAE,CAAC;IACR,gEAAgE;IAChE,QAAQ,EAAE,CAAC;IACX,kEAAkE;IAClE,IAAI,EAAE,CAAC;CACC,CAAC;AAIX,2DAA2D;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,kBAAkB,EAAE,oBAAoB;IACxC,YAAY,EAAE,cAAc;IAC5B,S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0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Multi-system parallel execution for the IBM i CLI.
|
|
3
|
-
* Creates a temporary SourceManager to run queries against multiple
|
|
4
|
-
* systems in parallel using independent connection pools.
|
|
5
|
-
* @module cli/utils/multi-connection
|
|
6
|
-
*/
|
|
7
|
-
import type { ResolvedSystem } from "../config/types.js";
|
|
8
|
-
import type { RequestContext } from "../../utils/internal/requestContext.js";
|
|
9
|
-
import { type CommandResult } from "./command-helpers.js";
|
|
10
|
-
/** Result from a single system in a multi-system execution. */
|
|
11
|
-
export interface MultiSystemResult {
|
|
12
|
-
system: string;
|
|
13
|
-
host: string;
|
|
14
|
-
data: Record<string, unknown>[];
|
|
15
|
-
rowCount: number;
|
|
16
|
-
elapsedMs: number;
|
|
17
|
-
error?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Execute an action against multiple systems in parallel using SourceManager.
|
|
21
|
-
*
|
|
22
|
-
* Creates a temporary SourceManager instance with one pool per system,
|
|
23
|
-
* fans out the action via Promise.allSettled, and cleans up all pools.
|
|
24
|
-
*/
|
|
25
|
-
export declare function executeMultiSystem(systems: ResolvedSystem[], action: (sourceName: string, mgr: InstanceType<typeof import("../../ibmi-mcp-server/services/sourceManager.js").SourceManager>, ctx: RequestContext) => Promise<CommandResult>): Promise<MultiSystemResult[]>;
|
|
26
|
-
//# sourceMappingURL=multi-connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multi-connection.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/multi-connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,cAAc,EAAE,EACzB,MAAM,EAAE,CACN,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,YAAY,CAAC,cAAc,iDAAiD,EAAE,aAAa,CAAC,EACjG,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,aAAa,CAAC,GAC1B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAsE9B"}
|