@ogment-ai/cli 0.3.5 → 0.4.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 +72 -76
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +521 -247
- package/dist/commands/auth.d.ts +22 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +29 -0
- package/dist/commands/catalog.d.ts +29 -0
- package/dist/commands/catalog.d.ts.map +1 -0
- package/dist/commands/catalog.js +151 -0
- package/dist/commands/invoke.d.ts +17 -0
- package/dist/commands/invoke.d.ts.map +1 -0
- package/dist/commands/invoke.js +123 -0
- package/dist/commands/{info.d.ts → status.d.ts} +4 -4
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/{info.js → status.js} +1 -1
- package/dist/output/envelope.d.ts +19 -0
- package/dist/output/envelope.d.ts.map +1 -0
- package/dist/output/envelope.js +51 -0
- package/dist/output/manager.d.ts +16 -3
- package/dist/output/manager.d.ts.map +1 -1
- package/dist/output/manager.js +27 -29
- package/dist/services/account.d.ts.map +1 -1
- package/dist/services/account.js +18 -2
- package/dist/services/auth.d.ts +14 -3
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +119 -15
- package/dist/services/info.d.ts.map +1 -1
- package/dist/services/info.js +11 -10
- package/dist/services/mcp.d.ts.map +1 -1
- package/dist/services/mcp.js +24 -23
- package/dist/shared/constants.d.ts +0 -1
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +0 -1
- package/dist/shared/error-codes.d.ts +28 -0
- package/dist/shared/error-codes.d.ts.map +1 -0
- package/dist/shared/error-codes.js +25 -0
- package/dist/shared/errors.d.ts +100 -9
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +101 -0
- package/dist/shared/exit-codes.d.ts +8 -5
- package/dist/shared/exit-codes.d.ts.map +1 -1
- package/dist/shared/exit-codes.js +31 -14
- package/dist/shared/guards.d.ts +5 -1
- package/dist/shared/guards.d.ts.map +1 -1
- package/dist/shared/guards.js +6 -1
- package/dist/shared/retry.d.ts +17 -0
- package/dist/shared/retry.d.ts.map +1 -0
- package/dist/shared/retry.js +27 -0
- package/dist/shared/schema-example.d.ts +2 -0
- package/dist/shared/schema-example.d.ts.map +1 -0
- package/dist/shared/schema-example.js +128 -0
- package/dist/shared/schemas.d.ts +0 -42
- package/dist/shared/schemas.d.ts.map +1 -1
- package/dist/shared/schemas.js +0 -21
- package/dist/shared/types.d.ts +84 -12
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +1 -1
- package/package.json +5 -7
- package/dist/commands/call.d.ts +0 -14
- package/dist/commands/call.d.ts.map +0 -1
- package/dist/commands/call.js +0 -51
- package/dist/commands/describe.d.ts +0 -4
- package/dist/commands/describe.d.ts.map +0 -1
- package/dist/commands/describe.js +0 -109
- package/dist/commands/info.d.ts.map +0 -1
- package/dist/commands/servers.d.ts +0 -13
- package/dist/commands/servers.d.ts.map +0 -1
- package/dist/commands/servers.js +0 -29
- package/dist/postinstall.d.ts +0 -2
- package/dist/postinstall.d.ts.map +0 -1
- package/dist/postinstall.js +0 -12
|
@@ -0,0 +1,22 @@
|
|
|
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 BrowserAuthLoginCommandOptions {
|
|
11
|
+
mode: "browser";
|
|
12
|
+
}
|
|
13
|
+
interface ApiKeyAuthLoginCommandOptions {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
mode: "apiKey";
|
|
16
|
+
}
|
|
17
|
+
export type AuthLoginCommandOptions = ApiKeyAuthLoginCommandOptions | BrowserAuthLoginCommandOptions | DeviceAuthLoginCommandOptions;
|
|
18
|
+
export declare const runAuthLoginCommand: (context: CommandContext, options: AuthLoginCommandOptions) => Promise<ResultType<LoginSuccess, LoginError>>;
|
|
19
|
+
export declare const runAuthStatusCommand: (context: CommandContext) => Promise<ResultType<AuthStatusSuccess, UnexpectedError>>;
|
|
20
|
+
export declare const runAuthLogoutCommand: (context: CommandContext) => Promise<ResultType<LogoutSuccess, UnexpectedError>>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,8BAA8B;IACtC,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,UAAU,6BAA6B;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAC/B,6BAA6B,GAC7B,8BAA8B,GAC9B,6BAA6B,CAAC;AAElC,eAAO,MAAM,mBAAmB,GAC9B,SAAS,cAAc,EACvB,SAAS,uBAAuB,KAC/B,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAyB9C,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
nonInteractive: context.output.nonInteractive,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (options.mode === "browser") {
|
|
11
|
+
return {
|
|
12
|
+
mode: "browser",
|
|
13
|
+
nonInteractive: context.output.nonInteractive,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
mode: "device",
|
|
18
|
+
nonInteractive: context.output.nonInteractive,
|
|
19
|
+
...(options.onPending === undefined ? {} : { onPending: options.onPending }),
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
return context.services.auth.login(loginOptions);
|
|
23
|
+
};
|
|
24
|
+
export const runAuthStatusCommand = async (context) => {
|
|
25
|
+
return context.services.auth.status(context.apiKeyOverride);
|
|
26
|
+
};
|
|
27
|
+
export const runAuthLogoutCommand = async (context) => {
|
|
28
|
+
return context.services.auth.logout();
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { 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
|
+
limit?: number | undefined;
|
|
10
|
+
serverId?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface CatalogToolsCommandOptions {
|
|
13
|
+
serverId: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CatalogToolDetailsCommandOptions {
|
|
16
|
+
serverId: string;
|
|
17
|
+
toolName: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CatalogSummaryPage {
|
|
20
|
+
nextCursor: string | null;
|
|
21
|
+
servers: CatalogSummarySuccess["servers"];
|
|
22
|
+
}
|
|
23
|
+
export type CatalogCommandError = McpServiceError | NotFoundError | ResolveServerStateError | ValidationError;
|
|
24
|
+
export type CatalogToolsCommandError = McpServiceError | NotFoundError | ResolveServerStateError;
|
|
25
|
+
export type CatalogToolDetailsCommandError = McpServiceError | NotFoundError | ResolveServerStateError;
|
|
26
|
+
export declare const runCatalogCommand: (context: CommandContext, options: CatalogCommandOptions) => Promise<ResultType<CatalogSummaryPage, CatalogCommandError>>;
|
|
27
|
+
export declare const runCatalogToolsCommand: (context: CommandContext, options: CatalogToolsCommandOptions) => Promise<ResultType<CatalogToolsSuccess, CatalogToolsCommandError>>;
|
|
28
|
+
export declare const runCatalogToolDetailsCommand: (context: CommandContext, options: CatalogToolDetailsCommandOptions) => Promise<ResultType<CatalogToolDetailsSuccess, CatalogToolDetailsCommandError>>;
|
|
29
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAE1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAEV,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;AA2B7B,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,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,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;AAiD5B,eAAO,MAAM,iBAAiB,GAC5B,SAAS,cAAc,EACvB,SAAS,qBAAqB,KAC7B,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAqE7D,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"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Result } from "better-result";
|
|
2
|
+
import { ERROR_CODE } from "../shared/error-codes.js";
|
|
3
|
+
import { NotFoundError, ValidationError } from "../shared/errors.js";
|
|
4
|
+
import { findServerByPath, resolveServerState, } from "./server-context.js";
|
|
5
|
+
const toServerSummary = (server, toolCount) => {
|
|
6
|
+
return {
|
|
7
|
+
capabilities: [],
|
|
8
|
+
description: server.description,
|
|
9
|
+
name: server.name,
|
|
10
|
+
orgSlug: server.orgSlug,
|
|
11
|
+
serverId: server.path,
|
|
12
|
+
toolCount,
|
|
13
|
+
version: null,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const toToolSummaries = (tools) => {
|
|
17
|
+
return tools.map((tool) => {
|
|
18
|
+
return {
|
|
19
|
+
description: tool.description,
|
|
20
|
+
inputSchemaRef: tool.inputSchema["$id"] ?? null,
|
|
21
|
+
name: tool.name,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const listServerTools = async (context, apiKey, server) => {
|
|
26
|
+
return context.services.mcp.listTools({
|
|
27
|
+
orgSlug: server.orgSlug,
|
|
28
|
+
serverPath: server.path,
|
|
29
|
+
}, apiKey);
|
|
30
|
+
};
|
|
31
|
+
const TOOL_COUNT_CONCURRENCY = 4;
|
|
32
|
+
const mapWithConcurrency = async (items, concurrency, mapItem) => {
|
|
33
|
+
if (items.length === 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const results = Array.from({ length: items.length });
|
|
37
|
+
let nextIndex = 0;
|
|
38
|
+
const worker = async () => {
|
|
39
|
+
while (true) {
|
|
40
|
+
const currentIndex = nextIndex;
|
|
41
|
+
nextIndex += 1;
|
|
42
|
+
if (currentIndex >= items.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
results[currentIndex] = await mapItem(items[currentIndex], currentIndex);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const workerCount = Math.min(concurrency, items.length);
|
|
49
|
+
await Promise.all(Array.from({ length: workerCount }, async () => worker()));
|
|
50
|
+
return results;
|
|
51
|
+
};
|
|
52
|
+
export const runCatalogCommand = async (context, options) => {
|
|
53
|
+
const stateResult = await resolveServerState(context);
|
|
54
|
+
if (Result.isError(stateResult)) {
|
|
55
|
+
return stateResult;
|
|
56
|
+
}
|
|
57
|
+
let targetServers = stateResult.value.servers;
|
|
58
|
+
if (options.serverId !== undefined) {
|
|
59
|
+
const serverResult = findServerByPath(stateResult.value.servers, options.serverId);
|
|
60
|
+
if (Result.isError(serverResult)) {
|
|
61
|
+
return serverResult;
|
|
62
|
+
}
|
|
63
|
+
targetServers = [serverResult.value];
|
|
64
|
+
}
|
|
65
|
+
const serverSummaries = await mapWithConcurrency(targetServers, TOOL_COUNT_CONCURRENCY, async (server) => {
|
|
66
|
+
const toolsResult = await listServerTools(context, stateResult.value.apiKey, server);
|
|
67
|
+
return {
|
|
68
|
+
server,
|
|
69
|
+
toolsResult,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const summaries = [];
|
|
73
|
+
for (const serverSummary of serverSummaries) {
|
|
74
|
+
if (Result.isError(serverSummary.toolsResult)) {
|
|
75
|
+
return serverSummary.toolsResult;
|
|
76
|
+
}
|
|
77
|
+
summaries.push(toServerSummary(serverSummary.server, serverSummary.toolsResult.value.length));
|
|
78
|
+
}
|
|
79
|
+
if (options.serverId !== undefined) {
|
|
80
|
+
return Result.ok({
|
|
81
|
+
nextCursor: null,
|
|
82
|
+
servers: summaries,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const limit = Math.max(1, options.limit ?? 20);
|
|
86
|
+
let startIndex = 0;
|
|
87
|
+
if (options.cursor !== undefined) {
|
|
88
|
+
const cursorIndex = summaries.findIndex((server) => server.serverId === options.cursor);
|
|
89
|
+
if (cursorIndex === -1) {
|
|
90
|
+
return Result.err(new ValidationError({
|
|
91
|
+
code: ERROR_CODE.validationInvalidInput,
|
|
92
|
+
message: `Invalid --cursor value: "${options.cursor}"`,
|
|
93
|
+
suggestedCommand: "ogment catalog",
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
startIndex = cursorIndex + 1;
|
|
97
|
+
}
|
|
98
|
+
const servers = summaries.slice(startIndex, startIndex + limit);
|
|
99
|
+
const hasMore = startIndex + limit < summaries.length;
|
|
100
|
+
const nextCursor = hasMore ? (servers.at(-1)?.serverId ?? null) : null;
|
|
101
|
+
return Result.ok({
|
|
102
|
+
nextCursor,
|
|
103
|
+
servers,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export const runCatalogToolsCommand = async (context, options) => {
|
|
107
|
+
const stateResult = await resolveServerState(context);
|
|
108
|
+
if (Result.isError(stateResult)) {
|
|
109
|
+
return stateResult;
|
|
110
|
+
}
|
|
111
|
+
const serverResult = findServerByPath(stateResult.value.servers, options.serverId);
|
|
112
|
+
if (Result.isError(serverResult)) {
|
|
113
|
+
return serverResult;
|
|
114
|
+
}
|
|
115
|
+
const toolsResult = await listServerTools(context, stateResult.value.apiKey, serverResult.value);
|
|
116
|
+
if (Result.isError(toolsResult)) {
|
|
117
|
+
return toolsResult;
|
|
118
|
+
}
|
|
119
|
+
return Result.ok({
|
|
120
|
+
server: toServerSummary(serverResult.value, toolsResult.value.length),
|
|
121
|
+
tools: toToolSummaries(toolsResult.value),
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
export const runCatalogToolDetailsCommand = async (context, options) => {
|
|
125
|
+
const stateResult = await resolveServerState(context);
|
|
126
|
+
if (Result.isError(stateResult)) {
|
|
127
|
+
return stateResult;
|
|
128
|
+
}
|
|
129
|
+
const serverResult = findServerByPath(stateResult.value.servers, options.serverId);
|
|
130
|
+
if (Result.isError(serverResult)) {
|
|
131
|
+
return serverResult;
|
|
132
|
+
}
|
|
133
|
+
const toolsResult = await listServerTools(context, stateResult.value.apiKey, serverResult.value);
|
|
134
|
+
if (Result.isError(toolsResult)) {
|
|
135
|
+
return toolsResult;
|
|
136
|
+
}
|
|
137
|
+
const tool = toolsResult.value.find((item) => item.name === options.toolName);
|
|
138
|
+
if (tool === undefined) {
|
|
139
|
+
return Result.err(new NotFoundError({
|
|
140
|
+
message: `Tool "${options.toolName}" not found`,
|
|
141
|
+
resource: options.toolName,
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
return Result.ok({
|
|
145
|
+
description: tool.description,
|
|
146
|
+
inputSchema: tool.inputSchema,
|
|
147
|
+
name: tool.name,
|
|
148
|
+
outputSchema: tool.outputSchema ?? null,
|
|
149
|
+
server: toServerSummary(serverResult.value, toolsResult.value.length),
|
|
150
|
+
});
|
|
151
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Result as ResultType } from "better-result";
|
|
2
|
+
import type { McpServiceError } from "../services/mcp.js";
|
|
3
|
+
import { NotFoundError, UnexpectedError, ValidationError } from "../shared/errors.js";
|
|
4
|
+
import type { InvokeSuccess } from "../shared/types.js";
|
|
5
|
+
import type { CommandContext } from "./context.js";
|
|
6
|
+
import { type ResolveServerStateError } from "./server-context.js";
|
|
7
|
+
export interface InvokeCommandOptions {
|
|
8
|
+
input: string | undefined;
|
|
9
|
+
target: string;
|
|
10
|
+
}
|
|
11
|
+
interface InvokeCommandDeps {
|
|
12
|
+
readStdin?: () => Promise<ResultType<string, UnexpectedError>>;
|
|
13
|
+
}
|
|
14
|
+
export type InvokeCommandError = McpServiceError | NotFoundError | ResolveServerStateError | UnexpectedError | ValidationError;
|
|
15
|
+
export declare const runInvokeCommand: (context: CommandContext, options: InvokeCommandOptions, deps?: InvokeCommandDeps) => Promise<ResultType<InvokeSuccess, InvokeCommandError>>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/commands/invoke.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;CAChE;AAED,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,eAAe,CAAC;AAgIpB,eAAO,MAAM,gBAAgB,GAC3B,SAAS,cAAc,EACvB,SAAS,oBAAoB,EAC7B,OAAM,iBAAsB,KAC3B,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAwCvD,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
|
+
import { NotFoundError, UnexpectedError, ValidationError } from "../shared/errors.js";
|
|
4
|
+
import { findServerByPath, resolveServerState, } from "./server-context.js";
|
|
5
|
+
const parseTarget = (target) => {
|
|
6
|
+
const separatorIndex = target.lastIndexOf("/");
|
|
7
|
+
if (separatorIndex <= 0 || separatorIndex >= target.length - 1) {
|
|
8
|
+
return Result.err(new ValidationError({
|
|
9
|
+
details: target,
|
|
10
|
+
message: "Invoke target must be in format <server-id>/<tool-name>",
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
const serverId = target.slice(0, separatorIndex);
|
|
14
|
+
const toolName = target.slice(separatorIndex + 1);
|
|
15
|
+
return Result.ok({
|
|
16
|
+
serverId,
|
|
17
|
+
toolName,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const parseInputObject = (raw, context) => {
|
|
21
|
+
const parsed = Result.try({
|
|
22
|
+
catch: () => new ValidationError({
|
|
23
|
+
details: raw,
|
|
24
|
+
message: `Invalid JSON in ${context}`,
|
|
25
|
+
}),
|
|
26
|
+
try: () => JSON.parse(raw),
|
|
27
|
+
});
|
|
28
|
+
if (Result.isError(parsed)) {
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
if (typeof parsed.value !== "object" || parsed.value === null || Array.isArray(parsed.value)) {
|
|
32
|
+
return Result.err(new ValidationError({
|
|
33
|
+
message: "Invoke input must be a JSON object",
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
return Result.ok(parsed.value);
|
|
37
|
+
};
|
|
38
|
+
const readStdin = async () => {
|
|
39
|
+
return Result.tryPromise({
|
|
40
|
+
catch: (cause) => new UnexpectedError({
|
|
41
|
+
cause,
|
|
42
|
+
message: "Failed to read stdin",
|
|
43
|
+
}),
|
|
44
|
+
try: async () => {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
let data = "";
|
|
47
|
+
process.stdin.setEncoding("utf8");
|
|
48
|
+
process.stdin.on("data", (chunk) => {
|
|
49
|
+
data += chunk.toString();
|
|
50
|
+
});
|
|
51
|
+
process.stdin.on("end", () => {
|
|
52
|
+
resolve(data);
|
|
53
|
+
});
|
|
54
|
+
process.stdin.on("error", (error) => {
|
|
55
|
+
reject(error);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const parseInvokeArgs = async (options, deps) => {
|
|
62
|
+
if (options.input === undefined) {
|
|
63
|
+
return Result.ok({});
|
|
64
|
+
}
|
|
65
|
+
if (options.input === "-") {
|
|
66
|
+
const stdinResult = await (deps.readStdin ?? readStdin)();
|
|
67
|
+
if (Result.isError(stdinResult)) {
|
|
68
|
+
return stdinResult;
|
|
69
|
+
}
|
|
70
|
+
return parseInputObject(stdinResult.value, "--input (-)");
|
|
71
|
+
}
|
|
72
|
+
if (options.input.startsWith("@")) {
|
|
73
|
+
const inputFile = options.input.slice(1);
|
|
74
|
+
if (inputFile.length === 0) {
|
|
75
|
+
return Result.err(new ValidationError({
|
|
76
|
+
details: options.input,
|
|
77
|
+
message: "Invalid --input value. Use @<path>, -, or an inline JSON object.",
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
const fileReadResult = await Result.tryPromise({
|
|
81
|
+
catch: (cause) => new UnexpectedError({
|
|
82
|
+
cause,
|
|
83
|
+
message: `Failed to read input file: ${inputFile}`,
|
|
84
|
+
}),
|
|
85
|
+
try: async () => readFile(inputFile, "utf8"),
|
|
86
|
+
});
|
|
87
|
+
if (Result.isError(fileReadResult)) {
|
|
88
|
+
return fileReadResult;
|
|
89
|
+
}
|
|
90
|
+
return parseInputObject(fileReadResult.value, "--input (@file)");
|
|
91
|
+
}
|
|
92
|
+
return parseInputObject(options.input, "--input");
|
|
93
|
+
};
|
|
94
|
+
export const runInvokeCommand = async (context, options, deps = {}) => {
|
|
95
|
+
const targetResult = parseTarget(options.target);
|
|
96
|
+
if (Result.isError(targetResult)) {
|
|
97
|
+
return targetResult;
|
|
98
|
+
}
|
|
99
|
+
const argsResult = await parseInvokeArgs(options, deps);
|
|
100
|
+
if (Result.isError(argsResult)) {
|
|
101
|
+
return argsResult;
|
|
102
|
+
}
|
|
103
|
+
const stateResult = await resolveServerState(context);
|
|
104
|
+
if (Result.isError(stateResult)) {
|
|
105
|
+
return stateResult;
|
|
106
|
+
}
|
|
107
|
+
const serverResult = findServerByPath(stateResult.value.servers, targetResult.value.serverId);
|
|
108
|
+
if (Result.isError(serverResult)) {
|
|
109
|
+
return serverResult;
|
|
110
|
+
}
|
|
111
|
+
const callResult = await context.services.mcp.callTool({
|
|
112
|
+
orgSlug: serverResult.value.orgSlug,
|
|
113
|
+
serverPath: serverResult.value.path,
|
|
114
|
+
}, stateResult.value.apiKey, targetResult.value.toolName, argsResult.value);
|
|
115
|
+
if (Result.isError(callResult)) {
|
|
116
|
+
return callResult;
|
|
117
|
+
}
|
|
118
|
+
return Result.ok({
|
|
119
|
+
result: callResult.value.structuredContent,
|
|
120
|
+
serverId: targetResult.value.serverId,
|
|
121
|
+
toolName: targetResult.value.toolName,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Result as ResultType } from "better-result";
|
|
2
2
|
import type { InfoService } from "../services/info.js";
|
|
3
3
|
import type { InfoPayload } from "../shared/types.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface StatusCommandOptions {
|
|
5
5
|
apiKeyOverride: string | undefined;
|
|
6
6
|
}
|
|
7
|
-
interface
|
|
7
|
+
interface RunStatusCommandDeps {
|
|
8
8
|
infoService: InfoService;
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const runStatusCommand: (options: StatusCommandOptions, deps: RunStatusCommandDeps) => Promise<ResultType<InfoPayload, never>>;
|
|
11
11
|
export {};
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,GAC3B,SAAS,oBAAoB,EAC7B,MAAM,oBAAoB,KACzB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAGxC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppError } from "../shared/errors.js";
|
|
2
|
+
import { type CliErrorEnvelope, type CliNextAction, type CliPaginationMeta, type CliSuccessEnvelope } from "../shared/types.js";
|
|
3
|
+
export interface EnvelopeContext {
|
|
4
|
+
command: string;
|
|
5
|
+
entity?: Record<string, unknown> | null;
|
|
6
|
+
nextActions?: CliNextAction[];
|
|
7
|
+
pagination?: CliPaginationMeta | null;
|
|
8
|
+
}
|
|
9
|
+
interface EnvelopeBuilderDeps {
|
|
10
|
+
createRequestId?: () => string;
|
|
11
|
+
now?: () => Date;
|
|
12
|
+
}
|
|
13
|
+
export interface EnvelopeBuilder {
|
|
14
|
+
error: (error: AppError, context: EnvelopeContext) => CliErrorEnvelope;
|
|
15
|
+
success: <T>(data: T, context: EnvelopeContext) => CliSuccessEnvelope<T>;
|
|
16
|
+
}
|
|
17
|
+
export declare const createEnvelopeBuilder: (deps?: EnvelopeBuilderDeps) => EnvelopeBuilder;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/output/envelope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACvC;AAED,UAAU,mBAAmB;IAC3B,eAAe,CAAC,EAAE,MAAM,MAAM,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,KAAK,gBAAgB,CAAC;IACvE,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAC1E;AAED,eAAO,MAAM,qBAAqB,GAAI,OAAM,mBAAwB,KAAG,eAkDtE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { appErrorMeta, formatAppError } from "../shared/errors.js";
|
|
3
|
+
import { CLI_CONTRACT_VERSION, } from "../shared/types.js";
|
|
4
|
+
export const createEnvelopeBuilder = (deps = {}) => {
|
|
5
|
+
const createRequestId = deps.createRequestId ?? randomUUID;
|
|
6
|
+
const now = deps.now ?? (() => new Date());
|
|
7
|
+
const toMeta = (context) => {
|
|
8
|
+
return {
|
|
9
|
+
command: context.command,
|
|
10
|
+
entity: context.entity ?? null,
|
|
11
|
+
pagination: context.pagination ?? null,
|
|
12
|
+
requestId: createRequestId(),
|
|
13
|
+
timestamp: now().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
error: (error, context) => {
|
|
18
|
+
const meta = appErrorMeta(error);
|
|
19
|
+
return {
|
|
20
|
+
data: null,
|
|
21
|
+
error: {
|
|
22
|
+
category: meta.category,
|
|
23
|
+
code: meta.code,
|
|
24
|
+
detail: formatAppError(error),
|
|
25
|
+
diagnostics: {
|
|
26
|
+
tag: error._tag,
|
|
27
|
+
},
|
|
28
|
+
docsUrl: null,
|
|
29
|
+
retryAfterMs: null,
|
|
30
|
+
retryable: meta.retryable,
|
|
31
|
+
suggestedCommand: meta.suggestedCommand ?? null,
|
|
32
|
+
title: error.message,
|
|
33
|
+
},
|
|
34
|
+
meta: toMeta(context),
|
|
35
|
+
next_actions: context.nextActions ?? [],
|
|
36
|
+
ok: false,
|
|
37
|
+
version: CLI_CONTRACT_VERSION,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
success: (data, context) => {
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
error: null,
|
|
44
|
+
meta: toMeta(context),
|
|
45
|
+
next_actions: context.nextActions ?? [],
|
|
46
|
+
ok: true,
|
|
47
|
+
version: CLI_CONTRACT_VERSION,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
};
|
package/dist/output/manager.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { AppError } from "../shared/errors.js";
|
|
2
|
+
import type { CliErrorEnvelope, CliNextAction, CliPaginationMeta } from "../shared/types.js";
|
|
2
3
|
export type OutputMode = "human" | "json" | "quiet";
|
|
3
4
|
export interface OutputInitOptions {
|
|
4
|
-
|
|
5
|
+
human: boolean | undefined;
|
|
6
|
+
json?: boolean | undefined;
|
|
5
7
|
nonInteractive: boolean | undefined;
|
|
6
8
|
quiet: boolean | undefined;
|
|
7
9
|
yes: boolean | undefined;
|
|
@@ -10,21 +12,32 @@ interface WritableLike {
|
|
|
10
12
|
write(chunk: string): boolean;
|
|
11
13
|
}
|
|
12
14
|
interface OutputManagerDeps {
|
|
15
|
+
createRequestId?: () => string;
|
|
13
16
|
isTty?: boolean;
|
|
14
17
|
noColor?: boolean;
|
|
18
|
+
now?: () => Date;
|
|
15
19
|
stderr?: WritableLike;
|
|
16
20
|
stdout?: WritableLike;
|
|
17
21
|
}
|
|
22
|
+
interface EnvelopeOptions {
|
|
23
|
+
command: string;
|
|
24
|
+
entity?: Record<string, unknown> | null;
|
|
25
|
+
nextActions?: CliNextAction[];
|
|
26
|
+
pagination?: CliPaginationMeta | null;
|
|
27
|
+
}
|
|
28
|
+
interface SuccessOptions extends EnvelopeOptions {
|
|
29
|
+
humanMessage?: string;
|
|
30
|
+
}
|
|
18
31
|
export declare class OutputManager {
|
|
19
32
|
#private;
|
|
20
33
|
constructor(deps?: OutputManagerDeps);
|
|
21
34
|
configure(options: OutputInitOptions): void;
|
|
22
35
|
get mode(): OutputMode;
|
|
23
36
|
get nonInteractive(): boolean;
|
|
24
|
-
error(error: AppError):
|
|
37
|
+
error(error: AppError, options: EnvelopeOptions): CliErrorEnvelope;
|
|
25
38
|
info(message: string): void;
|
|
26
39
|
json(value: unknown): void;
|
|
27
|
-
success(data:
|
|
40
|
+
success<T>(data: T, options: SuccessOptions): void;
|
|
28
41
|
}
|
|
29
42
|
export {};
|
|
30
43
|
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/output/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/output/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG7F,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1B;AAED,UAAU,YAAY;IACpB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAED,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACvC;AAED,UAAU,cAAe,SAAQ,eAAe;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,qBAAa,aAAa;;gBAQL,IAAI,GAAE,iBAAsB;IAWxC,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAalD,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED,IAAW,cAAc,IAAI,OAAO,CAEnC;IAEM,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB;IAgBlE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ3B,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI1B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;CAmB1D"}
|
package/dist/output/manager.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { createEnvelopeBuilder } from "./envelope.js";
|
|
1
2
|
const toJson = (value) => {
|
|
2
3
|
return `${JSON.stringify(value, null, 2)}\n`;
|
|
3
4
|
};
|
|
4
5
|
export class OutputManager {
|
|
6
|
+
#envelopeBuilder;
|
|
5
7
|
#isTty;
|
|
6
8
|
#mode;
|
|
7
9
|
#nonInteractive = false;
|
|
@@ -11,16 +13,22 @@ export class OutputManager {
|
|
|
11
13
|
this.#isTty = deps.isTty ?? Boolean(process.stdout.isTTY);
|
|
12
14
|
this.#stderr = deps.stderr ?? process.stderr;
|
|
13
15
|
this.#stdout = deps.stdout ?? process.stdout;
|
|
14
|
-
|
|
15
|
-
this.#
|
|
16
|
+
this.#mode = "json";
|
|
17
|
+
this.#envelopeBuilder = createEnvelopeBuilder({
|
|
18
|
+
...(deps.createRequestId === undefined ? {} : { createRequestId: deps.createRequestId }),
|
|
19
|
+
...(deps.now === undefined ? {} : { now: deps.now }),
|
|
20
|
+
});
|
|
16
21
|
}
|
|
17
22
|
configure(options) {
|
|
18
|
-
if (options.
|
|
19
|
-
this.#mode = "json";
|
|
20
|
-
}
|
|
21
|
-
else if (options.quiet === true) {
|
|
23
|
+
if (options.quiet === true) {
|
|
22
24
|
this.#mode = "quiet";
|
|
23
25
|
}
|
|
26
|
+
else if (options.human === true && options.json !== true) {
|
|
27
|
+
this.#mode = "human";
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.#mode = "json";
|
|
31
|
+
}
|
|
24
32
|
this.#nonInteractive =
|
|
25
33
|
options.nonInteractive === true || options.yes === true || this.#isTty === false;
|
|
26
34
|
}
|
|
@@ -30,23 +38,17 @@ export class OutputManager {
|
|
|
30
38
|
get nonInteractive() {
|
|
31
39
|
return this.#nonInteractive;
|
|
32
40
|
}
|
|
33
|
-
error(error) {
|
|
34
|
-
const
|
|
35
|
-
error: {
|
|
36
|
-
details: "details" in error ? error.details : undefined,
|
|
37
|
-
message: error.message,
|
|
38
|
-
type: error._tag,
|
|
39
|
-
},
|
|
40
|
-
status: "error",
|
|
41
|
-
};
|
|
41
|
+
error(error, options) {
|
|
42
|
+
const envelope = this.#envelopeBuilder.error(error, options);
|
|
42
43
|
if (this.#mode === "json") {
|
|
43
|
-
this.#stdout.write(toJson(
|
|
44
|
-
return;
|
|
44
|
+
this.#stdout.write(toJson(envelope));
|
|
45
|
+
return envelope;
|
|
45
46
|
}
|
|
46
47
|
if (this.#mode === "quiet") {
|
|
47
|
-
return;
|
|
48
|
+
return envelope;
|
|
48
49
|
}
|
|
49
|
-
this.#stderr.write(`${error.
|
|
50
|
+
this.#stderr.write(`${envelope.error.code}: ${envelope.error.detail}\n`);
|
|
51
|
+
return envelope;
|
|
50
52
|
}
|
|
51
53
|
info(message) {
|
|
52
54
|
if (this.#mode !== "human") {
|
|
@@ -57,23 +59,19 @@ export class OutputManager {
|
|
|
57
59
|
json(value) {
|
|
58
60
|
this.#stdout.write(toJson(value));
|
|
59
61
|
}
|
|
60
|
-
success(data,
|
|
62
|
+
success(data, options) {
|
|
63
|
+
const envelope = this.#envelopeBuilder.success(data, options);
|
|
61
64
|
if (this.#mode === "json") {
|
|
62
|
-
this.#stdout.write(toJson(
|
|
63
|
-
data,
|
|
64
|
-
status: "success",
|
|
65
|
-
}));
|
|
65
|
+
this.#stdout.write(toJson(envelope));
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (this.#mode === "quiet") {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
if (typeof humanMessage === "string" && humanMessage.length > 0) {
|
|
72
|
-
this.#stdout.write(`${humanMessage}\n`);
|
|
71
|
+
if (typeof options.humanMessage === "string" && options.humanMessage.length > 0) {
|
|
72
|
+
this.#stdout.write(`${options.humanMessage}\n`);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
this.#stdout.write(`${data}\n`);
|
|
77
|
-
}
|
|
75
|
+
this.#stdout.write(toJson(data));
|
|
78
76
|
}
|
|
79
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/services/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/services/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI1F,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAEjF,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;CACtF;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAQD,eAAO,MAAM,oBAAoB,GAAI,MAAM,kBAAkB,KAAG,cA8F/D,CAAC"}
|