@cliniq360/ondc-cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +34 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/forms.d.ts +3 -0
- package/dist/commands/forms.d.ts.map +1 -0
- package/dist/commands/forms.js +133 -0
- package/dist/commands/forms.js.map +1 -0
- package/dist/commands/journey.d.ts +3 -0
- package/dist/commands/journey.d.ts.map +1 -0
- package/dist/commands/journey.js +31 -0
- package/dist/commands/journey.js.map +1 -0
- package/dist/commands/offers.d.ts +3 -0
- package/dist/commands/offers.d.ts.map +1 -0
- package/dist/commands/offers.js +37 -0
- package/dist/commands/offers.js.map +1 -0
- package/dist/commands/orders.d.ts +3 -0
- package/dist/commands/orders.d.ts.map +1 -0
- package/dist/commands/orders.js +74 -0
- package/dist/commands/orders.js.map +1 -0
- package/dist/commands/policy.d.ts +3 -0
- package/dist/commands/policy.d.ts.map +1 -0
- package/dist/commands/policy.js +67 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/tools.d.ts +3 -0
- package/dist/commands/tools.d.ts.map +1 -0
- package/dist/commands/tools.js +71 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/commands/workflow.d.ts +3 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +116 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +44 -0
- package/dist/config.js.map +1 -0
- package/dist/input.d.ts +10 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +54 -0
- package/dist/input.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +69 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp-client.d.ts +7 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +58 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/output.d.ts +11 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +117 -0
- package/dist/output.js.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +75 -0
- package/dist/prompts.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { shouldUseJson } from "../config.js";
|
|
3
|
+
import { callTool } from "../mcp-client.js";
|
|
4
|
+
import { outputToolCallResult } from "../output.js";
|
|
5
|
+
async function confirmAction(message) {
|
|
6
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
7
|
+
const answer = await new Promise((resolve) => rl.question(message, resolve));
|
|
8
|
+
rl.close();
|
|
9
|
+
return answer.trim().toLowerCase() === "y";
|
|
10
|
+
}
|
|
11
|
+
export function registerPolicy(program) {
|
|
12
|
+
const policy = program
|
|
13
|
+
.command("policy")
|
|
14
|
+
.description("Cancellation and outbound policy-notification helpers.");
|
|
15
|
+
policy
|
|
16
|
+
.command("cancellation-terms")
|
|
17
|
+
.requiredOption("--order-id <order_id>", "Issued insurance order ID")
|
|
18
|
+
.option("--json", "Output as JSON")
|
|
19
|
+
.description("Fetch available cancellation terms and reason IDs.")
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
const result = await callTool("get-insurance-cancellation-terms", {
|
|
22
|
+
order_id: opts.orderId,
|
|
23
|
+
});
|
|
24
|
+
outputToolCallResult(result, shouldUseJson(opts.json));
|
|
25
|
+
});
|
|
26
|
+
policy
|
|
27
|
+
.command("cancel")
|
|
28
|
+
.requiredOption("--txn-id <txn_id>", "Insurance transaction ID")
|
|
29
|
+
.requiredOption("--offer-item-id <offer_item_id>", "Selected offer item ID")
|
|
30
|
+
.requiredOption("--reason-id <cancellation_reason_id>", "Cancellation reason ID")
|
|
31
|
+
.requiredOption("--notes <cancellation_notes>", "Short cancellation note")
|
|
32
|
+
.option("-y, --yes", "Skip confirmation")
|
|
33
|
+
.option("--json", "Output as JSON")
|
|
34
|
+
.description("Cancel an issued policy.")
|
|
35
|
+
.action(async (opts) => {
|
|
36
|
+
if (!opts.yes) {
|
|
37
|
+
const confirmed = await confirmAction("Cancel this insurance order? This action is destructive (y/N): ");
|
|
38
|
+
if (!confirmed) {
|
|
39
|
+
console.log("Aborted.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const result = await callTool("cancel-insurance-order", {
|
|
44
|
+
txn_id: opts.txnId,
|
|
45
|
+
offer_item_id: opts.offerItemId,
|
|
46
|
+
cancellation_reason_id: opts.reasonId,
|
|
47
|
+
cancellation_notes: opts.notes,
|
|
48
|
+
});
|
|
49
|
+
outputToolCallResult(result, shouldUseJson(opts.json));
|
|
50
|
+
});
|
|
51
|
+
policy
|
|
52
|
+
.command("notify")
|
|
53
|
+
.requiredOption("--order-id <order_id>", "Insurance order ID")
|
|
54
|
+
.requiredOption("--channel <channel>", "WHATSAPP or SMS")
|
|
55
|
+
.requiredOption("--mobile-number <mobile_number>", "Destination mobile number")
|
|
56
|
+
.option("--json", "Output as JSON")
|
|
57
|
+
.description("Send the order summary or policy document via SMS or WhatsApp.")
|
|
58
|
+
.action(async (opts) => {
|
|
59
|
+
const result = await callTool("send-insurance-notification", {
|
|
60
|
+
order_id: opts.orderId,
|
|
61
|
+
channel: opts.channel,
|
|
62
|
+
mobile_number: opts.mobileNumber,
|
|
63
|
+
});
|
|
64
|
+
outputToolCallResult(result, shouldUseJson(opts.json));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/commands/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EA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MAAM,GAAG,MAAM,QAAQ,CAAC,6BAA6B,EAAE;YAC3D,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,IAAI,CAAC,YAAY;SACjC,CAAC,CAAC;QAEH,oBAAoB,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqFpD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { shouldUseJson } from "../config.js";
|
|
2
|
+
import { requireJsonObjectInput } from "../input.js";
|
|
3
|
+
import { callTool, getTool, listTools } from "../mcp-client.js";
|
|
4
|
+
import { outputDetail, outputJson, outputTable, outputToolCallResult, schemaPropertyRows, toolListRows, } from "../output.js";
|
|
5
|
+
export function registerTools(program) {
|
|
6
|
+
const tools = program
|
|
7
|
+
.command("tools")
|
|
8
|
+
.description("Inspect and call ONDC MCP tools directly.");
|
|
9
|
+
tools
|
|
10
|
+
.command("list")
|
|
11
|
+
.option("--json", "Output as JSON")
|
|
12
|
+
.description("List all tools exposed by the configured ONDC MCP server.")
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
const toolDefinitions = await listTools();
|
|
15
|
+
if (shouldUseJson(opts.json)) {
|
|
16
|
+
outputJson({ tools: toolDefinitions });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
outputTable([
|
|
20
|
+
["name", "Name"],
|
|
21
|
+
["title", "Title"],
|
|
22
|
+
["read_only", "Read Only"],
|
|
23
|
+
["destructive", "Destructive"],
|
|
24
|
+
], toolListRows(toolDefinitions), "ONDC MCP Tools");
|
|
25
|
+
});
|
|
26
|
+
tools
|
|
27
|
+
.command("inspect")
|
|
28
|
+
.argument("<name>", "Tool name")
|
|
29
|
+
.option("--json", "Output as JSON")
|
|
30
|
+
.description("Show metadata and input schema for a tool.")
|
|
31
|
+
.action(async (name, opts) => {
|
|
32
|
+
const tool = await getTool(name);
|
|
33
|
+
if (!tool) {
|
|
34
|
+
console.error(`Error: Tool '${name}' not found.`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
if (shouldUseJson(opts.json)) {
|
|
38
|
+
outputJson(tool);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
outputDetail({
|
|
42
|
+
name: tool.name,
|
|
43
|
+
title: tool.title || "",
|
|
44
|
+
description: tool.description || "",
|
|
45
|
+
}, `Tool: ${tool.name}`);
|
|
46
|
+
const rows = schemaPropertyRows(tool);
|
|
47
|
+
if (!rows.length) {
|
|
48
|
+
console.log("No input parameters.\n");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
outputTable([
|
|
52
|
+
["name", "Field"],
|
|
53
|
+
["required", "Required"],
|
|
54
|
+
["type", "Type"],
|
|
55
|
+
["description", "Description"],
|
|
56
|
+
], rows, "Input Schema");
|
|
57
|
+
});
|
|
58
|
+
tools
|
|
59
|
+
.command("call")
|
|
60
|
+
.argument("<name>", "Tool name")
|
|
61
|
+
.option("--input <json>", "Inline JSON object with tool arguments")
|
|
62
|
+
.option("--file <path>", "Read tool arguments from a JSON file")
|
|
63
|
+
.option("--json", "Output as JSON")
|
|
64
|
+
.description("Call any tool with raw JSON arguments.")
|
|
65
|
+
.action(async (name, opts) => {
|
|
66
|
+
const payload = await requireJsonObjectInput(opts, "tool arguments");
|
|
67
|
+
const result = await callTool(name, payload);
|
|
68
|
+
outputToolCallResult(result, shouldUseJson(opts.json));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -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/D,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,WAAW,CAAC,wCAAwC,CAAC;SACrD,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAI,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7C,oBAAoB,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgEpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsFvD"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { outputJson, outputTable } from "../output.js";
|
|
3
|
+
import { INSURANCE_WORKFLOW_TEMPLATE } from "../prompts.js";
|
|
4
|
+
import { shouldUseJson } from "../config.js";
|
|
5
|
+
const WORKFLOWS = [
|
|
6
|
+
{
|
|
7
|
+
name: "quote-purchase",
|
|
8
|
+
title: "Quote To Purchase",
|
|
9
|
+
description: "Recommended end-to-end flow for quote discovery, KYC, payment, and policy issuance.",
|
|
10
|
+
steps: [
|
|
11
|
+
"journey start",
|
|
12
|
+
"forms applicant or forms family",
|
|
13
|
+
"journey trigger-search",
|
|
14
|
+
"offers list",
|
|
15
|
+
"offers select",
|
|
16
|
+
"orders form-url --form-type KYC",
|
|
17
|
+
"orders transaction-status",
|
|
18
|
+
"orders init",
|
|
19
|
+
"forms buyer",
|
|
20
|
+
"orders init",
|
|
21
|
+
"forms nominee",
|
|
22
|
+
"orders form-url --form-type PAYMENT",
|
|
23
|
+
"orders transaction-status",
|
|
24
|
+
"orders confirm",
|
|
25
|
+
"orders status",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "post-purchase",
|
|
30
|
+
title: "Post Purchase",
|
|
31
|
+
description: "Recommended flow for policy review, cancellation checks, cancellation, and outbound notifications.",
|
|
32
|
+
steps: [
|
|
33
|
+
"orders status",
|
|
34
|
+
"policy cancellation-terms",
|
|
35
|
+
"policy cancel",
|
|
36
|
+
"policy notify",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
function printWorkflow(workflow) {
|
|
41
|
+
console.log(chalk.bold(`\n${workflow.title}`));
|
|
42
|
+
console.log(workflow.description);
|
|
43
|
+
console.log();
|
|
44
|
+
workflow.steps.forEach((step, index) => {
|
|
45
|
+
console.log(`${chalk.cyan(`${index + 1}.`)} ${step}`);
|
|
46
|
+
});
|
|
47
|
+
console.log();
|
|
48
|
+
}
|
|
49
|
+
export function registerWorkflow(program) {
|
|
50
|
+
const workflow = program
|
|
51
|
+
.command("workflow")
|
|
52
|
+
.description("Show recommended ONDC insurance tool sequences and the strict AI workflow prompt.");
|
|
53
|
+
workflow
|
|
54
|
+
.command("prompt")
|
|
55
|
+
.option("--json", "Output as JSON")
|
|
56
|
+
.description("Print the strict insurance AI workflow prompt (INSURANCE_WORKFLOW_TEMPLATE).")
|
|
57
|
+
.action((opts) => {
|
|
58
|
+
if (shouldUseJson(opts.json)) {
|
|
59
|
+
outputJson({
|
|
60
|
+
name: "insurance-workflow",
|
|
61
|
+
symbol: "INSURANCE_WORKFLOW_TEMPLATE",
|
|
62
|
+
prompt: INSURANCE_WORKFLOW_TEMPLATE,
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
console.log(chalk.bold("\nINSURANCE_WORKFLOW_TEMPLATE\n"));
|
|
67
|
+
console.log(INSURANCE_WORKFLOW_TEMPLATE);
|
|
68
|
+
console.log();
|
|
69
|
+
});
|
|
70
|
+
workflow
|
|
71
|
+
.command("list")
|
|
72
|
+
.option("--json", "Output as JSON")
|
|
73
|
+
.description("List built-in workflow guides.")
|
|
74
|
+
.action((opts) => {
|
|
75
|
+
if (shouldUseJson(opts.json)) {
|
|
76
|
+
outputJson({ workflows: WORKFLOWS });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
outputTable([
|
|
80
|
+
["name", "Name"],
|
|
81
|
+
["title", "Title"],
|
|
82
|
+
["description", "Description"],
|
|
83
|
+
], WORKFLOWS, "Workflow Guides");
|
|
84
|
+
});
|
|
85
|
+
for (const guide of WORKFLOWS) {
|
|
86
|
+
workflow
|
|
87
|
+
.command(guide.name)
|
|
88
|
+
.option("--json", "Output as JSON")
|
|
89
|
+
.description(guide.description)
|
|
90
|
+
.action((opts) => {
|
|
91
|
+
if (shouldUseJson(opts.json)) {
|
|
92
|
+
outputJson(guide);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
printWorkflow(guide);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
workflow
|
|
99
|
+
.command("show")
|
|
100
|
+
.argument("<name>", "Workflow name")
|
|
101
|
+
.option("--json", "Output as JSON")
|
|
102
|
+
.description("Show a workflow by name.")
|
|
103
|
+
.action((name, opts) => {
|
|
104
|
+
const guide = WORKFLOWS.find((workflowGuide) => workflowGuide.name === name);
|
|
105
|
+
if (!guide) {
|
|
106
|
+
console.error(`Error: Unknown workflow '${name}'.`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
if (shouldUseJson(opts.json)) {
|
|
110
|
+
outputJson(guide);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
printWorkflow(guide);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../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|
+
export declare const OUTPUT_FORMATS: readonly ["pretty", "json"];
|
|
4
|
+
export type OutputFormat = (typeof OUTPUT_FORMATS)[number];
|
|
5
|
+
export declare const ENV_FILE_PATH: string;
|
|
6
|
+
export declare function getMcpUrl(): string;
|
|
7
|
+
export declare function getOutputFormat(): OutputFormat;
|
|
8
|
+
export declare function setOutputFormat(format: OutputFormat): void;
|
|
9
|
+
export declare function getConfigPath(): string;
|
|
10
|
+
export declare function getEnvFilePath(): string;
|
|
11
|
+
export declare function getMcpUrlSource(): string;
|
|
12
|
+
export declare function shouldUseJson(flag?: boolean): boolean;
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAC1C,eAAO,MAAM,cAAc,6BAA8B,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAG3D,eAAO,MAAM,aAAa,QAA+B,CAAC;AAiB1D,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE1D;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAIxC;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAErD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import Conf from "conf";
|
|
4
|
+
import { config as loadEnv } from "dotenv";
|
|
5
|
+
export const DEFAULT_MCP_URL = "https://ondc.eigi.ai/mcp";
|
|
6
|
+
export const ENV_MCP_URL = "ONDC_MCP_URL";
|
|
7
|
+
export const OUTPUT_FORMATS = ["pretty", "json"];
|
|
8
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
export const ENV_FILE_PATH = resolve(packageRoot, ".env");
|
|
10
|
+
const envLoadResult = loadEnv({ path: ENV_FILE_PATH, quiet: true });
|
|
11
|
+
const config = new Conf({
|
|
12
|
+
projectName: "ondc-cli",
|
|
13
|
+
schema: {
|
|
14
|
+
output_format: {
|
|
15
|
+
type: "string",
|
|
16
|
+
enum: [...OUTPUT_FORMATS],
|
|
17
|
+
default: "pretty",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export function getMcpUrl() {
|
|
22
|
+
return process.env[ENV_MCP_URL] || DEFAULT_MCP_URL;
|
|
23
|
+
}
|
|
24
|
+
export function getOutputFormat() {
|
|
25
|
+
return config.get("output_format") || "pretty";
|
|
26
|
+
}
|
|
27
|
+
export function setOutputFormat(format) {
|
|
28
|
+
config.set("output_format", format);
|
|
29
|
+
}
|
|
30
|
+
export function getConfigPath() {
|
|
31
|
+
return config.path;
|
|
32
|
+
}
|
|
33
|
+
export function getEnvFilePath() {
|
|
34
|
+
return ENV_FILE_PATH;
|
|
35
|
+
}
|
|
36
|
+
export function getMcpUrlSource() {
|
|
37
|
+
return envLoadResult.parsed?.[ENV_MCP_URL]
|
|
38
|
+
? ENV_FILE_PATH
|
|
39
|
+
: "hardcoded default";
|
|
40
|
+
}
|
|
41
|
+
export function shouldUseJson(flag) {
|
|
42
|
+
return flag === true || getOutputFormat() === "json";
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,O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IAC3B,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC;QACxC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,OAAO,IAAI,KAAK,IAAI,IAAI,eAAe,EAAE,KAAK,MAAM,CAAC;AACvD,CAAC"}
|
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type JsonInputOptions = {
|
|
2
|
+
input?: string;
|
|
3
|
+
file?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function pickDefined(values: Record<string, unknown>): Record<string, unknown>;
|
|
6
|
+
export declare function parseJsonValue(value: string, label: string): unknown;
|
|
7
|
+
export declare function parseJsonObject(value: string, label: string): Record<string, unknown>;
|
|
8
|
+
export declare function loadJsonObjectInput(options: JsonInputOptions, label: string): Promise<Record<string, unknown>>;
|
|
9
|
+
export declare function requireJsonObjectInput(options: JsonInputOptions, label: string): Promise<Record<string, unknown>>;
|
|
10
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpE;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAUD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiBlC;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAMlC"}
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
function fail(message) {
|
|
3
|
+
console.error(`Error: ${message}`);
|
|
4
|
+
process.exit(1);
|
|
5
|
+
}
|
|
6
|
+
export function pickDefined(values) {
|
|
7
|
+
return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
|
|
8
|
+
}
|
|
9
|
+
export function parseJsonValue(value, label) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(value);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
15
|
+
return fail(`Invalid ${label}: ${detail}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function parseJsonObject(value, label) {
|
|
19
|
+
const parsed = parseJsonValue(value, label);
|
|
20
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
21
|
+
return fail(`${label} must be a JSON object.`);
|
|
22
|
+
}
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
async function readStdin() {
|
|
26
|
+
const chunks = [];
|
|
27
|
+
for await (const chunk of process.stdin) {
|
|
28
|
+
chunks.push(String(chunk));
|
|
29
|
+
}
|
|
30
|
+
return chunks.join("");
|
|
31
|
+
}
|
|
32
|
+
export async function loadJsonObjectInput(options, label) {
|
|
33
|
+
if (options.input) {
|
|
34
|
+
return parseJsonObject(options.input, label);
|
|
35
|
+
}
|
|
36
|
+
if (options.file) {
|
|
37
|
+
return parseJsonObject(readFileSync(options.file, "utf-8"), label);
|
|
38
|
+
}
|
|
39
|
+
if (!process.stdin.isTTY) {
|
|
40
|
+
const stdin = (await readStdin()).trim();
|
|
41
|
+
if (stdin) {
|
|
42
|
+
return parseJsonObject(stdin, label);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
export async function requireJsonObjectInput(options, label) {
|
|
48
|
+
const payload = await loadJsonObjectInput(options, label);
|
|
49
|
+
if (Object.keys(payload).length === 0) {
|
|
50
|
+
fail(`Provide ${label} via --input, --file, or piped stdin.`);
|
|
51
|
+
}
|
|
52
|
+
return payload;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAOD,MAAM,UAAU,WAAW,CACzB,MAA+B;IAE/B,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAClE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,KAAa;IACzD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAA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AAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAyB,EACzB,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1D,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,WAAW,KAAK,uCAAuC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { registerConfig } from "./commands/config.js";
|
|
5
|
+
import { registerForms } from "./commands/forms.js";
|
|
6
|
+
import { registerJourney } from "./commands/journey.js";
|
|
7
|
+
import { registerOffers } from "./commands/offers.js";
|
|
8
|
+
import { registerOrders } from "./commands/orders.js";
|
|
9
|
+
import { registerPolicy } from "./commands/policy.js";
|
|
10
|
+
import { registerTools } from "./commands/tools.js";
|
|
11
|
+
import { registerWorkflow } from "./commands/workflow.js";
|
|
12
|
+
const panelBackground = chalk.bgHex("#242424");
|
|
13
|
+
const panelAccent = chalk.hex("#d7875f");
|
|
14
|
+
const panelAccentBright = chalk.hex("#f0a178");
|
|
15
|
+
const panelTitle = chalk.hex("#e18b67");
|
|
16
|
+
const panelMeta = chalk.hex("#7aa2d6");
|
|
17
|
+
const panelTagline = chalk.hex("#d5cfbf");
|
|
18
|
+
const panelWidth = 64;
|
|
19
|
+
function panelLine(content = "") {
|
|
20
|
+
return panelBackground(` ${content.padEnd(panelWidth)} `);
|
|
21
|
+
}
|
|
22
|
+
const bannerArt = [
|
|
23
|
+
" ██████ █ ██ ██████ ██████ ",
|
|
24
|
+
"██ ██ ██ ██ ██ ██ ██ ",
|
|
25
|
+
"██ ██ █ █ ██ ██ ██ ██ ",
|
|
26
|
+
"██ ██ █ ███ ██ ██ ██ ",
|
|
27
|
+
" ██████ █ ██ ██████ ██████ ",
|
|
28
|
+
];
|
|
29
|
+
const banner = [
|
|
30
|
+
"",
|
|
31
|
+
panelLine(`${panelAccent("●")} ${panelAccentBright("●")} ${chalk.green("●")}`),
|
|
32
|
+
panelLine(),
|
|
33
|
+
...bannerArt.map((line) => panelLine(` ${panelTitle.bold(line)}`)),
|
|
34
|
+
panelLine(),
|
|
35
|
+
panelLine(` ${panelMeta("Insurance MCP CLI")}`),
|
|
36
|
+
panelLine(` ${panelTagline("powered by eigi")}`),
|
|
37
|
+
"",
|
|
38
|
+
].join("\n");
|
|
39
|
+
const program = new Command();
|
|
40
|
+
program
|
|
41
|
+
.name("ondc")
|
|
42
|
+
.description("Official CLI for the ONDC insurance MCP workflow.")
|
|
43
|
+
.version("0.1.0");
|
|
44
|
+
program.addHelpText("beforeAll", `${banner}\n`);
|
|
45
|
+
program.addHelpText("after", "\nStrict instruction before executing tools:\n" +
|
|
46
|
+
" Read: ondc workflow prompt\n" +
|
|
47
|
+
" This contains the mandatory sequence, stop conditions, and txn-status checks.\n\n" +
|
|
48
|
+
"Quick start:\n" +
|
|
49
|
+
" 1. Default MCP URL is https://ondc.eigi.ai/mcp\n" +
|
|
50
|
+
" Edit .env only if you need a different endpoint\n" +
|
|
51
|
+
" 2. ondc workflow prompt\n" +
|
|
52
|
+
" 3. ondc workflow quote-purchase\n" +
|
|
53
|
+
" 4. ondc tools list\n\n" +
|
|
54
|
+
"Useful commands:\n" +
|
|
55
|
+
" ondc config show\n" +
|
|
56
|
+
" ondc journey start\n" +
|
|
57
|
+
" ondc forms applicant --help\n" +
|
|
58
|
+
" ondc offers list --txn-id <TXN_ID>\n" +
|
|
59
|
+
" ondc tools inspect list-insurance-offers\n");
|
|
60
|
+
registerJourney(program);
|
|
61
|
+
registerForms(program);
|
|
62
|
+
registerOffers(program);
|
|
63
|
+
registerOrders(program);
|
|
64
|
+
registerPolicy(program);
|
|
65
|
+
registerWorkflow(program);
|
|
66
|
+
registerTools(program);
|
|
67
|
+
registerConfig(program);
|
|
68
|
+
program.parse();
|
|
69
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzC,MAA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pB,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC;AAEhD,OAAO,CAAC,WAAW,CACjB,OAAO,EACP,gDAAgD;IAC9C,gCAAgC;IAChC,qFAAqF;IACrF,gBAAgB;IAChB,oDAAoD;IACpD,wDAAwD;IACxD,6BAA6B;IAC7B,qCAAqC;IACrC,0BAA0B;IAC1B,oBAAoB;IACpB,sBAAsB;IACtB,wBAAwB;IACxB,iCAAiC;IACjC,wCAAwC;IACxC,8CAA8C,CACjD,CAAC;AAEF,eAAe,CAAC,OAAO,CAAC,CAAC;AACzB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC1B,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,cAAc,CAAC,OAAO,CAAC,CAAC;AAExB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export declare function withClient<T>(handler: (client: Client) => Promise<T>): Promise<T>;
|
|
4
|
+
export declare function listTools(): Promise<Tool[]>;
|
|
5
|
+
export declare function getTool(name: string): Promise<Tool | undefined>;
|
|
6
|
+
export declare function callTool(name: string, args: Record<string, unknown>): Promise<CallToolResult>;
|
|
7
|
+
//# sourceMappingURL=mcp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../src/mcp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AA0C/E,wBAAsB,UAAU,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACtC,OAAO,CAAC,CAAC,CAAC,CAWZ;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAKjD;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAGrE;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC,CAKzB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
|
+
import { getMcpUrl } from "./config.js";
|
|
4
|
+
const IMPLEMENTATION = {
|
|
5
|
+
name: "ondc-cli",
|
|
6
|
+
version: "0.1.0",
|
|
7
|
+
};
|
|
8
|
+
function fail(message) {
|
|
9
|
+
console.error(`Error: ${message}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
function getServerUrl() {
|
|
13
|
+
try {
|
|
14
|
+
return new URL(getMcpUrl());
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return fail(`Invalid MCP URL '${getMcpUrl()}'.`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getErrorMessage(error) {
|
|
21
|
+
if (error instanceof Error && error.message) {
|
|
22
|
+
return error.message;
|
|
23
|
+
}
|
|
24
|
+
return String(error);
|
|
25
|
+
}
|
|
26
|
+
async function createClient() {
|
|
27
|
+
const transport = new StreamableHTTPClientTransport(getServerUrl());
|
|
28
|
+
const client = new Client(IMPLEMENTATION, { capabilities: {} });
|
|
29
|
+
await client.connect(transport);
|
|
30
|
+
return { client, transport };
|
|
31
|
+
}
|
|
32
|
+
export async function withClient(handler) {
|
|
33
|
+
const { client, transport } = await createClient();
|
|
34
|
+
try {
|
|
35
|
+
return await handler(client);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
fail(getErrorMessage(error));
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await client.close().catch(() => undefined);
|
|
42
|
+
await transport.close().catch(() => undefined);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function listTools() {
|
|
46
|
+
return withClient(async (client) => {
|
|
47
|
+
const response = await client.listTools();
|
|
48
|
+
return response.tools;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export async function getTool(name) {
|
|
52
|
+
const tools = await listTools();
|
|
53
|
+
return tools.find((tool) => tool.name === name);
|
|
54
|
+
}
|
|
55
|
+
export async function callTool(name, args) {
|
|
56
|
+
return withClient(async (client) => (await client.callTool({ name, arguments: args })));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=mcp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../src/mcp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAGnG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,OAAO;CACjB,CAAC;AAEF,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,OAAO,IAAI,G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K,EAAE,MAAM,EAAE,EAAE;QACjC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1C,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,MAAM,SAAS,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ,IAA6B;IAE7B,OAAO,UAAU,CACf,KAAK,EAAE,MAAM,EAAE,EAAE,CACf,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAmB,CACvE,CAAC;AACJ,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
type ColumnDef = [key: string, label: string];
|
|
3
|
+
export declare function outputJson(data: unknown): void;
|
|
4
|
+
export declare function outputTable(columns: ColumnDef[], rows: Record<string, unknown>[], title?: string): void;
|
|
5
|
+
export declare function outputDetail(data: Record<string, unknown>, title?: string): void;
|
|
6
|
+
export declare function outputPretty(data: unknown): void;
|
|
7
|
+
export declare function outputToolCallResult(result: CallToolResult, asJson: boolean): void;
|
|
8
|
+
export declare function toolListRows(tools: Tool[]): Record<string, unknown>[];
|
|
9
|
+
export declare function schemaPropertyRows(tool: Tool): Record<string, unknown>[];
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/E,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAoB9C,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,EAAE,EACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAgBN;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAUN;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAOhD;AA0CD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAYlF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAWrE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiBxE"}
|