@solidcommerce/mcp-server 2.0.0-alpha.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/README.md +74 -0
- package/bin/solidcommerce-mcp.js +8 -0
- package/dist/audit/auditClient.d.ts +51 -0
- package/dist/audit/auditClient.d.ts.map +1 -0
- package/dist/audit/auditClient.js +93 -0
- package/dist/audit/auditClient.js.map +1 -0
- package/dist/auth/apiKey.d.ts +44 -0
- package/dist/auth/apiKey.d.ts.map +1 -0
- package/dist/auth/apiKey.js +80 -0
- package/dist/auth/apiKey.js.map +1 -0
- package/dist/auth/oauth.d.ts +108 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +300 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/generator/fromOpenApi.d.ts +54 -0
- package/dist/generator/fromOpenApi.d.ts.map +1 -0
- package/dist/generator/fromOpenApi.js +411 -0
- package/dist/generator/fromOpenApi.js.map +1 -0
- package/dist/generator/schemaToZod.d.ts +81 -0
- package/dist/generator/schemaToZod.d.ts.map +1 -0
- package/dist/generator/schemaToZod.js +277 -0
- package/dist/generator/schemaToZod.js.map +1 -0
- package/dist/generator/scopeInference.d.ts +26 -0
- package/dist/generator/scopeInference.d.ts.map +1 -0
- package/dist/generator/scopeInference.js +91 -0
- package/dist/generator/scopeInference.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/server/buildServer.d.ts +35 -0
- package/dist/server/buildServer.d.ts.map +1 -0
- package/dist/server/buildServer.js +104 -0
- package/dist/server/buildServer.js.map +1 -0
- package/dist/server/dispatcher.d.ts +14 -0
- package/dist/server/dispatcher.d.ts.map +1 -0
- package/dist/server/dispatcher.js +190 -0
- package/dist/server/dispatcher.js.map +1 -0
- package/dist/session.d.ts +9 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +11 -0
- package/dist/session.js.map +1 -0
- package/dist/telemetry/hostName.d.ts +26 -0
- package/dist/telemetry/hostName.d.ts.map +1 -0
- package/dist/telemetry/hostName.js +80 -0
- package/dist/telemetry/hostName.js.map +1 -0
- package/dist/tools/contract.d.ts +125 -0
- package/dist/tools/contract.d.ts.map +1 -0
- package/dist/tools/contract.js +101 -0
- package/dist/tools/contract.js.map +1 -0
- package/dist/tools/foundation/catalog_amazon_items_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_amazon_items_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_amazon_items_list.js +47 -0
- package/dist/tools/foundation/catalog_amazon_items_list.js.map +1 -0
- package/dist/tools/foundation/catalog_attribute_filters_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_attribute_filters_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_attribute_filters_list.js +47 -0
- package/dist/tools/foundation/catalog_attribute_filters_list.js.map +1 -0
- package/dist/tools/foundation/catalog_attribute_tags_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_attribute_tags_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_attribute_tags_list.js +47 -0
- package/dist/tools/foundation/catalog_attribute_tags_list.js.map +1 -0
- package/dist/tools/foundation/catalog_attributes_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_attributes_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_attributes_list.js +57 -0
- package/dist/tools/foundation/catalog_attributes_list.js.map +1 -0
- package/dist/tools/foundation/catalog_column_views_default_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_column_views_default_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_column_views_default_list.js +47 -0
- package/dist/tools/foundation/catalog_column_views_default_list.js.map +1 -0
- package/dist/tools/foundation/catalog_column_views_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_column_views_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_column_views_list.js +47 -0
- package/dist/tools/foundation/catalog_column_views_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_categories_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_categories_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_categories_list.js +56 -0
- package/dist/tools/foundation/catalog_ebay_categories_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_category_specifics_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_category_specifics_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_category_specifics_list.js +56 -0
- package/dist/tools/foundation/catalog_ebay_category_specifics_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_listing_templates_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_listing_templates_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_listing_templates_list.js +47 -0
- package/dist/tools/foundation/catalog_ebay_listing_templates_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_product_search_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_product_search_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_product_search_list.js +56 -0
- package/dist/tools/foundation/catalog_ebay_product_search_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_template_fields_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_template_fields_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_template_fields_list.js +47 -0
- package/dist/tools/foundation/catalog_ebay_template_fields_list.js.map +1 -0
- package/dist/tools/foundation/catalog_ebay_variation_groups_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_ebay_variation_groups_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_ebay_variation_groups_list.js +56 -0
- package/dist/tools/foundation/catalog_ebay_variation_groups_list.js.map +1 -0
- package/dist/tools/foundation/catalog_inventory_sources_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_inventory_sources_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_inventory_sources_list.js +47 -0
- package/dist/tools/foundation/catalog_inventory_sources_list.js.map +1 -0
- package/dist/tools/foundation/catalog_listing_rules_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_listing_rules_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_listing_rules_list.js +47 -0
- package/dist/tools/foundation/catalog_listing_rules_list.js.map +1 -0
- package/dist/tools/foundation/catalog_listing_templates_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_listing_templates_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_listing_templates_list.js +47 -0
- package/dist/tools/foundation/catalog_listing_templates_list.js.map +1 -0
- package/dist/tools/foundation/catalog_manufacturers_all_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_manufacturers_all_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_manufacturers_all_list.js +47 -0
- package/dist/tools/foundation/catalog_manufacturers_all_list.js.map +1 -0
- package/dist/tools/foundation/catalog_manufacturers_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_manufacturers_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_manufacturers_list.js +47 -0
- package/dist/tools/foundation/catalog_manufacturers_list.js.map +1 -0
- package/dist/tools/foundation/catalog_market_lists_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_market_lists_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_market_lists_list.js +47 -0
- package/dist/tools/foundation/catalog_market_lists_list.js.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_filters_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_product_usage_filters_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_filters_list.js +47 -0
- package/dist/tools/foundation/catalog_product_usage_filters_list.js.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_product_usage_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_list.js +61 -0
- package/dist/tools/foundation/catalog_product_usage_list.js.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_totals_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_product_usage_totals_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_product_usage_totals_list.js +58 -0
- package/dist/tools/foundation/catalog_product_usage_totals_list.js.map +1 -0
- package/dist/tools/foundation/catalog_products_generate_sku_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_products_generate_sku_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_products_generate_sku_list.js +47 -0
- package/dist/tools/foundation/catalog_products_generate_sku_list.js.map +1 -0
- package/dist/tools/foundation/catalog_products_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_products_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_products_list.js +60 -0
- package/dist/tools/foundation/catalog_products_list.js.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_channels_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_taxonomy_channels_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_channels_list.js +47 -0
- package/dist/tools/foundation/catalog_taxonomy_channels_list.js.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_mappings_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_taxonomy_mappings_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_mappings_list.js +56 -0
- package/dist/tools/foundation/catalog_taxonomy_mappings_list.js.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_product_values_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_taxonomy_product_values_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_taxonomy_product_values_list.js +57 -0
- package/dist/tools/foundation/catalog_taxonomy_product_values_list.js.map +1 -0
- package/dist/tools/foundation/catalog_tree_list.d.ts +4 -0
- package/dist/tools/foundation/catalog_tree_list.d.ts.map +1 -0
- package/dist/tools/foundation/catalog_tree_list.js +47 -0
- package/dist/tools/foundation/catalog_tree_list.js.map +1 -0
- package/dist/tools/foundation/crm_customers_list.d.ts +4 -0
- package/dist/tools/foundation/crm_customers_list.d.ts.map +1 -0
- package/dist/tools/foundation/crm_customers_list.js +59 -0
- package/dist/tools/foundation/crm_customers_list.js.map +1 -0
- package/dist/tools/foundation/fulfillment_manifests_list.d.ts +4 -0
- package/dist/tools/foundation/fulfillment_manifests_list.d.ts.map +1 -0
- package/dist/tools/foundation/fulfillment_manifests_list.js +47 -0
- package/dist/tools/foundation/fulfillment_manifests_list.js.map +1 -0
- package/dist/tools/foundation/fulfillment_ship_now_addresses_list.d.ts +4 -0
- package/dist/tools/foundation/fulfillment_ship_now_addresses_list.d.ts.map +1 -0
- package/dist/tools/foundation/fulfillment_ship_now_addresses_list.js +47 -0
- package/dist/tools/foundation/fulfillment_ship_now_addresses_list.js.map +1 -0
- package/dist/tools/foundation/fulfillment_ship_now_dictionaries_list.d.ts +4 -0
- package/dist/tools/foundation/fulfillment_ship_now_dictionaries_list.d.ts.map +1 -0
- package/dist/tools/foundation/fulfillment_ship_now_dictionaries_list.js +56 -0
- package/dist/tools/foundation/fulfillment_ship_now_dictionaries_list.js.map +1 -0
- package/dist/tools/foundation/index.d.ts +8 -0
- package/dist/tools/foundation/index.d.ts.map +1 -0
- package/dist/tools/foundation/index.js +93 -0
- package/dist/tools/foundation/index.js.map +1 -0
- package/dist/tools/foundation/inventory_alert_rules_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_alert_rules_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_alert_rules_list.js +47 -0
- package/dist/tools/foundation/inventory_alert_rules_list.js.map +1 -0
- package/dist/tools/foundation/inventory_alert_settings_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_alert_settings_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_alert_settings_list.js +47 -0
- package/dist/tools/foundation/inventory_alert_settings_list.js.map +1 -0
- package/dist/tools/foundation/inventory_analytics_alert_count_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_analytics_alert_count_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_analytics_alert_count_list.js +47 -0
- package/dist/tools/foundation/inventory_analytics_alert_count_list.js.map +1 -0
- package/dist/tools/foundation/inventory_rules_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_rules_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_rules_list.js +47 -0
- package/dist/tools/foundation/inventory_rules_list.js.map +1 -0
- package/dist/tools/foundation/inventory_rules_periods_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_rules_periods_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_rules_periods_list.js +47 -0
- package/dist/tools/foundation/inventory_rules_periods_list.js.map +1 -0
- package/dist/tools/foundation/inventory_seasonal_factors_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_seasonal_factors_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_seasonal_factors_list.js +47 -0
- package/dist/tools/foundation/inventory_seasonal_factors_list.js.map +1 -0
- package/dist/tools/foundation/inventory_warehouses_list.d.ts +4 -0
- package/dist/tools/foundation/inventory_warehouses_list.d.ts.map +1 -0
- package/dist/tools/foundation/inventory_warehouses_list.js +47 -0
- package/dist/tools/foundation/inventory_warehouses_list.js.map +1 -0
- package/dist/tools/foundation/listings_dictionary_marketplace_locales_list.d.ts +4 -0
- package/dist/tools/foundation/listings_dictionary_marketplace_locales_list.d.ts.map +1 -0
- package/dist/tools/foundation/listings_dictionary_marketplace_locales_list.js +56 -0
- package/dist/tools/foundation/listings_dictionary_marketplace_locales_list.js.map +1 -0
- package/dist/tools/foundation/listings_dictionary_marketplaces_list.d.ts +4 -0
- package/dist/tools/foundation/listings_dictionary_marketplaces_list.d.ts.map +1 -0
- package/dist/tools/foundation/listings_dictionary_marketplaces_list.js +47 -0
- package/dist/tools/foundation/listings_dictionary_marketplaces_list.js.map +1 -0
- package/dist/tools/tasks/bulk_update_prices.d.ts +4 -0
- package/dist/tools/tasks/bulk_update_prices.d.ts.map +1 -0
- package/dist/tools/tasks/bulk_update_prices.js +96 -0
- package/dist/tools/tasks/bulk_update_prices.js.map +1 -0
- package/dist/tools/tasks/cancel_order_with_reason.d.ts +4 -0
- package/dist/tools/tasks/cancel_order_with_reason.d.ts.map +1 -0
- package/dist/tools/tasks/cancel_order_with_reason.js +117 -0
- package/dist/tools/tasks/cancel_order_with_reason.js.map +1 -0
- package/dist/tools/tasks/check_listing_health.d.ts +4 -0
- package/dist/tools/tasks/check_listing_health.d.ts.map +1 -0
- package/dist/tools/tasks/check_listing_health.js +123 -0
- package/dist/tools/tasks/check_listing_health.js.map +1 -0
- package/dist/tools/tasks/create_and_submit_purchase_order.d.ts +4 -0
- package/dist/tools/tasks/create_and_submit_purchase_order.d.ts.map +1 -0
- package/dist/tools/tasks/create_and_submit_purchase_order.js +142 -0
- package/dist/tools/tasks/create_and_submit_purchase_order.js.map +1 -0
- package/dist/tools/tasks/find_product_by_sku.d.ts +4 -0
- package/dist/tools/tasks/find_product_by_sku.d.ts.map +1 -0
- package/dist/tools/tasks/find_product_by_sku.js +68 -0
- package/dist/tools/tasks/find_product_by_sku.js.map +1 -0
- package/dist/tools/tasks/fulfill_order.d.ts +4 -0
- package/dist/tools/tasks/fulfill_order.d.ts.map +1 -0
- package/dist/tools/tasks/fulfill_order.js +121 -0
- package/dist/tools/tasks/fulfill_order.js.map +1 -0
- package/dist/tools/tasks/get_inventory_across_warehouses.d.ts +4 -0
- package/dist/tools/tasks/get_inventory_across_warehouses.d.ts.map +1 -0
- package/dist/tools/tasks/get_inventory_across_warehouses.js +118 -0
- package/dist/tools/tasks/get_inventory_across_warehouses.js.map +1 -0
- package/dist/tools/tasks/index.d.ts +14 -0
- package/dist/tools/tasks/index.d.ts.map +1 -0
- package/dist/tools/tasks/index.js +32 -0
- package/dist/tools/tasks/index.js.map +1 -0
- package/dist/tools/tasks/publish_product_to_channels.d.ts +4 -0
- package/dist/tools/tasks/publish_product_to_channels.d.ts.map +1 -0
- package/dist/tools/tasks/publish_product_to_channels.js +109 -0
- package/dist/tools/tasks/publish_product_to_channels.js.map +1 -0
- package/dist/tools/tasks/reply_to_buyer_message.d.ts +4 -0
- package/dist/tools/tasks/reply_to_buyer_message.d.ts.map +1 -0
- package/dist/tools/tasks/reply_to_buyer_message.js +72 -0
- package/dist/tools/tasks/reply_to_buyer_message.js.map +1 -0
- package/dist/tools/tasks/reprice_listing.d.ts +4 -0
- package/dist/tools/tasks/reprice_listing.d.ts.map +1 -0
- package/dist/tools/tasks/reprice_listing.js +74 -0
- package/dist/tools/tasks/reprice_listing.js.map +1 -0
- package/dist/transports/stdio.d.ts +12 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +30 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/transports/streamableHttp.d.ts +33 -0
- package/dist/transports/streamableHttp.d.ts.map +1 -0
- package/dist/transports/streamableHttp.js +237 -0
- package/dist/transports/streamableHttp.js.map +1 -0
- package/package.json +47 -0
- package/vendor/openapi.snapshot.json +19887 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// src/generator/fromOpenApi.ts
|
|
3
|
+
// Wave: W6 — Stream A
|
|
4
|
+
//
|
|
5
|
+
// Reads vendor/openapi.snapshot.json (171 paths × 244 schemas, 238 ops),
|
|
6
|
+
// emits ≤40 foundation tools using the heuristic from the wave brief:
|
|
7
|
+
//
|
|
8
|
+
// Tier 1 — every GET with zero required path parameters ("list" endpoints).
|
|
9
|
+
// Naming: synthesized from path (since the W4 snapshot does not
|
|
10
|
+
// populate operationId — see snapshot meta). Required scope:
|
|
11
|
+
// x-required-scope > x-required-scopes[0] > x-scopes[0] > inferred.
|
|
12
|
+
// Tier 2 — top POSTs whose path matches one of the 10 task-tool composition
|
|
13
|
+
// targets (catalog/products, listings, orders, vendors/...,
|
|
14
|
+
// crm, inventory, platform/webhooks, fulfillment).
|
|
15
|
+
// Tier 3 — fill remaining slots with other write operations,
|
|
16
|
+
// alphabetical by synthesized name.
|
|
17
|
+
// Hard cap: 40 — if tier 1 alone exceeds, take the first 40 (alphabetical).
|
|
18
|
+
//
|
|
19
|
+
// Outputs:
|
|
20
|
+
// - In-memory: `generate()` returns FoundationTool[] (used by tests).
|
|
21
|
+
// - On disk: `regenerate()` writes one .ts file per tool under
|
|
22
|
+
// src/tools/foundation/<tool_name>.ts, plus an index.ts
|
|
23
|
+
// re-export. Wired via `npm run regen-foundation-tools`.
|
|
24
|
+
//
|
|
25
|
+
// Stream A invariant: tool names are stable & unique. The dispatcher
|
|
26
|
+
// (Stream C) uses them as MCP tool identifiers, so renames are breaking.
|
|
27
|
+
// =============================================================================
|
|
28
|
+
import { readFileSync, writeFileSync, mkdirSync, rmSync, existsSync } from "node:fs";
|
|
29
|
+
import { dirname, resolve, join } from "node:path";
|
|
30
|
+
import { fileURLToPath } from "node:url";
|
|
31
|
+
import { buildToolInputSchema, } from "./schemaToZod.js";
|
|
32
|
+
import { resolveRequiredScope } from "./scopeInference.js";
|
|
33
|
+
const HTTP_METHODS = ["get", "post", "put", "patch", "delete"];
|
|
34
|
+
const COMPOSITION_TARGETS = [
|
|
35
|
+
// Order = priority. Longest-prefix wins, so more specific entries first.
|
|
36
|
+
"catalog/products",
|
|
37
|
+
"platform/webhooks",
|
|
38
|
+
"vendors/po-sources",
|
|
39
|
+
"vendors",
|
|
40
|
+
"listings",
|
|
41
|
+
"orders",
|
|
42
|
+
"crm/customers",
|
|
43
|
+
"crm",
|
|
44
|
+
"inventory",
|
|
45
|
+
"fulfillment",
|
|
46
|
+
];
|
|
47
|
+
/** Hard cap from the wave brief — keeps us under Claude's tool token budget. */
|
|
48
|
+
export const MAX_FOUNDATION_TOOLS = 40;
|
|
49
|
+
// -----------------------------------------------------------------------------
|
|
50
|
+
// Path utilities
|
|
51
|
+
// -----------------------------------------------------------------------------
|
|
52
|
+
const PATH_PARAM_RE = /\{([^}]+)\}/g;
|
|
53
|
+
function pathHasBraces(path) {
|
|
54
|
+
return path.includes("{");
|
|
55
|
+
}
|
|
56
|
+
/** Extract path-parameter names from a template, in declared order. */
|
|
57
|
+
function _extractPathParams(path) {
|
|
58
|
+
const names = [];
|
|
59
|
+
for (const match of path.matchAll(PATH_PARAM_RE)) {
|
|
60
|
+
names.push(match[1]);
|
|
61
|
+
}
|
|
62
|
+
return names;
|
|
63
|
+
}
|
|
64
|
+
void _extractPathParams; // exported indirectly via tests in W6.1; kept for symmetry
|
|
65
|
+
/** Path tokens after `/v1/` excluding empty segments. */
|
|
66
|
+
function pathTokens(path) {
|
|
67
|
+
return path
|
|
68
|
+
.replace(/^\/+/, "")
|
|
69
|
+
.replace(/^v1\//, "")
|
|
70
|
+
.split("/")
|
|
71
|
+
.filter((t) => t.length > 0);
|
|
72
|
+
}
|
|
73
|
+
function snakeToken(token) {
|
|
74
|
+
return token.replace(/[^A-Za-z0-9]+/g, "_").toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Synthesize a stable MCP tool name from a (path, method) operation.
|
|
78
|
+
* Why we don't use operationId: the W4 frozen snapshot omits operationId
|
|
79
|
+
* everywhere — sampled 238/238 ops in vendor/openapi.snapshot.json.
|
|
80
|
+
*/
|
|
81
|
+
export function synthesizeToolName(path, method) {
|
|
82
|
+
const parts = [];
|
|
83
|
+
for (const tok of pathTokens(path)) {
|
|
84
|
+
if (tok.startsWith("{") && tok.endsWith("}")) {
|
|
85
|
+
parts.push("by_" + snakeToken(tok.slice(1, -1)));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
parts.push(snakeToken(tok));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const verb = methodToVerb(method, pathHasBraces(path));
|
|
92
|
+
parts.push(verb);
|
|
93
|
+
return parts.join("_");
|
|
94
|
+
}
|
|
95
|
+
function methodToVerb(method, hasBraces) {
|
|
96
|
+
switch (method) {
|
|
97
|
+
case "get":
|
|
98
|
+
return hasBraces ? "get" : "list";
|
|
99
|
+
case "post":
|
|
100
|
+
return "create";
|
|
101
|
+
case "put":
|
|
102
|
+
return "replace";
|
|
103
|
+
case "patch":
|
|
104
|
+
return "update";
|
|
105
|
+
case "delete":
|
|
106
|
+
return "delete";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Highest matching composition-target prefix length, or 0. */
|
|
110
|
+
function compositionScore(path) {
|
|
111
|
+
const stripped = path.replace(/^\/+/, "").replace(/^v1\//, "");
|
|
112
|
+
let best = 0;
|
|
113
|
+
for (const target of COMPOSITION_TARGETS) {
|
|
114
|
+
if (stripped.startsWith(target)) {
|
|
115
|
+
if (target.length > best)
|
|
116
|
+
best = target.length;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return best;
|
|
120
|
+
}
|
|
121
|
+
function isTier1(ctx) {
|
|
122
|
+
if (ctx.method !== "get")
|
|
123
|
+
return false;
|
|
124
|
+
if (pathHasBraces(ctx.path))
|
|
125
|
+
return false;
|
|
126
|
+
// Defensive: if the operation/pathItem still declares a required path param
|
|
127
|
+
// (without a brace in the template), we still treat it as non-list.
|
|
128
|
+
const all = [...(ctx.operation.parameters ?? []), ...ctx.pathLevelParams];
|
|
129
|
+
for (const p of all) {
|
|
130
|
+
if (p.in === "path" && p.required === true)
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
function tier2Score(ctx) {
|
|
136
|
+
if (ctx.method !== "post")
|
|
137
|
+
return 0;
|
|
138
|
+
return compositionScore(ctx.path);
|
|
139
|
+
}
|
|
140
|
+
function isTier3Candidate(ctx) {
|
|
141
|
+
return ctx.method === "post" || ctx.method === "put" || ctx.method === "patch";
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Pure entry: read snapshot, run heuristic, return FoundationTool[].
|
|
145
|
+
* Does NOT touch the filesystem under src/tools/foundation/.
|
|
146
|
+
*/
|
|
147
|
+
export function generate(options = {}) {
|
|
148
|
+
const snapshotPath = options.snapshotPath ?? defaultSnapshotPath();
|
|
149
|
+
const cap = options.maxTools ?? MAX_FOUNDATION_TOOLS;
|
|
150
|
+
const doc = loadDoc(snapshotPath);
|
|
151
|
+
const allOps = [];
|
|
152
|
+
for (const [path, item] of Object.entries(doc.paths)) {
|
|
153
|
+
if (!item || typeof item !== "object")
|
|
154
|
+
continue;
|
|
155
|
+
const pathLevelParams = (item.parameters ?? []);
|
|
156
|
+
for (const method of HTTP_METHODS) {
|
|
157
|
+
const op = item[method];
|
|
158
|
+
if (!op)
|
|
159
|
+
continue;
|
|
160
|
+
allOps.push({ path, method, operation: op, pathLevelParams });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Tier 1
|
|
164
|
+
const tier1 = allOps
|
|
165
|
+
.filter(isTier1)
|
|
166
|
+
.map((c) => ({ ctx: c, name: synthesizeToolName(c.path, c.method) }))
|
|
167
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
168
|
+
// Tier 2 — only POSTs hitting composition targets, ranked by score desc, name asc.
|
|
169
|
+
const tier2 = allOps
|
|
170
|
+
.map((c) => ({ ctx: c, score: tier2Score(c), name: synthesizeToolName(c.path, c.method) }))
|
|
171
|
+
.filter((e) => e.score > 0)
|
|
172
|
+
.sort((a, b) => (b.score - a.score) || a.name.localeCompare(b.name));
|
|
173
|
+
// Tier 3 — POST/PUT/PATCH not yet selected, alphabetical.
|
|
174
|
+
const tier3 = allOps
|
|
175
|
+
.filter(isTier3Candidate)
|
|
176
|
+
.map((c) => ({ ctx: c, name: synthesizeToolName(c.path, c.method) }))
|
|
177
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
178
|
+
// Compose the final selection.
|
|
179
|
+
const selected = [];
|
|
180
|
+
const seen = new Set();
|
|
181
|
+
const components = (doc.components?.schemas ?? {});
|
|
182
|
+
const schemaCtx = { components: components };
|
|
183
|
+
const pushIfRoom = (name, ctx, tier) => {
|
|
184
|
+
if (selected.length >= cap)
|
|
185
|
+
return;
|
|
186
|
+
if (seen.has(name))
|
|
187
|
+
return;
|
|
188
|
+
seen.add(name);
|
|
189
|
+
selected.push(buildFoundationTool(name, ctx, tier, schemaCtx));
|
|
190
|
+
};
|
|
191
|
+
for (const e of tier1)
|
|
192
|
+
pushIfRoom(e.name, e.ctx, "tier1");
|
|
193
|
+
for (const e of tier2)
|
|
194
|
+
pushIfRoom(e.name, e.ctx, "tier2");
|
|
195
|
+
for (const e of tier3)
|
|
196
|
+
pushIfRoom(e.name, e.ctx, "tier3");
|
|
197
|
+
return selected;
|
|
198
|
+
}
|
|
199
|
+
function buildFoundationTool(name, ctx, tier, schemaCtx) {
|
|
200
|
+
const params = [
|
|
201
|
+
...ctx.pathLevelParams,
|
|
202
|
+
...(ctx.operation.parameters ?? []),
|
|
203
|
+
];
|
|
204
|
+
// The two generator modules each declare their own structural shapes for the
|
|
205
|
+
// OpenAPI types — schemaToZod's view types `schema` as the richer
|
|
206
|
+
// OpenApiSchema while ours keeps it `unknown` so we can stay tolerant of
|
|
207
|
+
// unsupported features. The shapes are runtime-compatible; bridge with a cast.
|
|
208
|
+
const { source, shape } = buildToolInputSchema(params, (ctx.operation.requestBody ?? null), schemaCtx);
|
|
209
|
+
const description = (ctx.operation.summary ??
|
|
210
|
+
ctx.operation.description ??
|
|
211
|
+
`${ctx.method.toUpperCase()} ${ctx.path}`).trim();
|
|
212
|
+
const required_scope = resolveRequiredScope(ctx.operation, ctx.path, ctx.method);
|
|
213
|
+
const httpMethod = ctx.method.toUpperCase();
|
|
214
|
+
return {
|
|
215
|
+
name,
|
|
216
|
+
description,
|
|
217
|
+
required_scope,
|
|
218
|
+
inputSchemaSource: source,
|
|
219
|
+
httpMethod,
|
|
220
|
+
path: ctx.path,
|
|
221
|
+
operationId: ctx.operation.operationId ?? name,
|
|
222
|
+
tier,
|
|
223
|
+
hasBody: shape.hasBody,
|
|
224
|
+
pathParamNames: shape.pathParamNames,
|
|
225
|
+
queryParamNames: shape.queryParamNames,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
// -----------------------------------------------------------------------------
|
|
229
|
+
// Snapshot loader
|
|
230
|
+
// -----------------------------------------------------------------------------
|
|
231
|
+
function defaultSnapshotPath() {
|
|
232
|
+
// src/generator/fromOpenApi.ts → ../../vendor/openapi.snapshot.json
|
|
233
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
234
|
+
return resolve(here, "../../vendor/openapi.snapshot.json");
|
|
235
|
+
}
|
|
236
|
+
function loadDoc(snapshotPath) {
|
|
237
|
+
const raw = readFileSync(snapshotPath, "utf8");
|
|
238
|
+
const parsed = JSON.parse(raw);
|
|
239
|
+
if (!parsed.paths || typeof parsed.paths !== "object") {
|
|
240
|
+
throw new Error("openapi snapshot: missing `paths`");
|
|
241
|
+
}
|
|
242
|
+
return parsed;
|
|
243
|
+
}
|
|
244
|
+
// -----------------------------------------------------------------------------
|
|
245
|
+
// File emission
|
|
246
|
+
// -----------------------------------------------------------------------------
|
|
247
|
+
const FOUNDATION_HEADER = `// =============================================================================
|
|
248
|
+
// AUTO-GENERATED — DO NOT EDIT BY HAND.
|
|
249
|
+
// Regenerate via: npm run regen-foundation-tools
|
|
250
|
+
// Source: vendor/openapi.snapshot.json (W4 frozen).
|
|
251
|
+
// =============================================================================
|
|
252
|
+
`;
|
|
253
|
+
function renderToolFile(tool) {
|
|
254
|
+
const safeDescription = JSON.stringify(tool.description);
|
|
255
|
+
// Render handle() body: pack {path, query, body} from parsed args, dispatch,
|
|
256
|
+
// map errors. We use `client.raw[METHOD]` indexing because it's invariant
|
|
257
|
+
// across the synthesized tools. The cast widens openapi-fetch's narrowly-typed
|
|
258
|
+
// path key (a literal union) to plain string — necessary because we hold the
|
|
259
|
+
// path as data, not as a literal.
|
|
260
|
+
const argsExtraction = [];
|
|
261
|
+
if (tool.pathParamNames.length > 0) {
|
|
262
|
+
argsExtraction.push(" path: parsed.path");
|
|
263
|
+
}
|
|
264
|
+
if (tool.queryParamNames.length > 0) {
|
|
265
|
+
argsExtraction.push(" query: parsed.query");
|
|
266
|
+
}
|
|
267
|
+
const paramsBlock = argsExtraction.length === 0
|
|
268
|
+
? ""
|
|
269
|
+
: `\n const requestParams = {\n${argsExtraction.join(",\n")},\n };`;
|
|
270
|
+
const optsLines = [];
|
|
271
|
+
if (argsExtraction.length > 0)
|
|
272
|
+
optsLines.push(" params: requestParams");
|
|
273
|
+
if (tool.hasBody)
|
|
274
|
+
optsLines.push(" body: parsed.body");
|
|
275
|
+
const optsBlock = optsLines.length === 0 ? "{}" : `{\n${optsLines.join(",\n")},\n }`;
|
|
276
|
+
return `${FOUNDATION_HEADER}
|
|
277
|
+
// Tier: ${tool.tier} HTTP: ${tool.httpMethod} ${tool.path}
|
|
278
|
+
import { z } from "zod";
|
|
279
|
+
|
|
280
|
+
import {
|
|
281
|
+
mapSdkErrorToToolResult,
|
|
282
|
+
type ToolContext,
|
|
283
|
+
type ToolModule,
|
|
284
|
+
type ToolResult,
|
|
285
|
+
} from "../contract.js";
|
|
286
|
+
|
|
287
|
+
const inputSchema = ${tool.inputSchemaSource};
|
|
288
|
+
|
|
289
|
+
type Args = z.infer<typeof inputSchema>;
|
|
290
|
+
|
|
291
|
+
async function handle(args: unknown, ctx: ToolContext): Promise<ToolResult> {
|
|
292
|
+
let parsed: Args;
|
|
293
|
+
try {
|
|
294
|
+
parsed = inputSchema.parse(args) as Args;
|
|
295
|
+
} catch (err) {
|
|
296
|
+
return mapSdkErrorToToolResult(err);
|
|
297
|
+
}
|
|
298
|
+
void parsed; // referenced below when the operation declares params/body.
|
|
299
|
+
try {${paramsBlock}
|
|
300
|
+
// openapi-fetch: client.raw[METHOD](pathTemplate, opts) → { data, error, response }
|
|
301
|
+
// We cast \`raw\` to a permissive shape; the path template is data-driven
|
|
302
|
+
// here, not a literal, so the SDK's narrow Path union doesn't apply.
|
|
303
|
+
type FetchFn = (
|
|
304
|
+
path: string,
|
|
305
|
+
init?: { params?: unknown; body?: unknown },
|
|
306
|
+
) => Promise<{ data?: unknown; error?: unknown; response: Response }>;
|
|
307
|
+
const raw = ctx.client.raw as unknown as Record<string, FetchFn>;
|
|
308
|
+
const fn = raw["${tool.httpMethod}"];
|
|
309
|
+
if (typeof fn !== "function") {
|
|
310
|
+
return mapSdkErrorToToolResult(
|
|
311
|
+
new Error("SDK client missing method ${tool.httpMethod}"),
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
const result = await fn(${JSON.stringify(tool.path)}, ${optsBlock});
|
|
315
|
+
if (result.error !== undefined && result.error !== null) {
|
|
316
|
+
return mapSdkErrorToToolResult(result.error);
|
|
317
|
+
}
|
|
318
|
+
return { content: [{ type: "json", json: result.data ?? null }] };
|
|
319
|
+
} catch (err) {
|
|
320
|
+
return mapSdkErrorToToolResult(err);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const tool: ToolModule = {
|
|
325
|
+
name: ${JSON.stringify(tool.name)},
|
|
326
|
+
kind: "foundation",
|
|
327
|
+
description: ${safeDescription},
|
|
328
|
+
required_scope: ${JSON.stringify(tool.required_scope)},
|
|
329
|
+
// HTTP verb → Claude UI annotation. GET → readOnlyHint; write verbs →
|
|
330
|
+
// destructiveHint. Enforced by test/tools/annotations.test.ts.
|
|
331
|
+
${tool.httpMethod === "GET" ? "readOnlyHint: true" : "destructiveHint: true"},
|
|
332
|
+
inputSchema,
|
|
333
|
+
handle,
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export default tool;
|
|
337
|
+
`;
|
|
338
|
+
}
|
|
339
|
+
function renderIndex(tools) {
|
|
340
|
+
// Sort imports alphabetically for deterministic output.
|
|
341
|
+
const sorted = [...tools].sort((a, b) => a.name.localeCompare(b.name));
|
|
342
|
+
const imports = sorted
|
|
343
|
+
.map((t, i) => `import tool_${i} from "./${t.name}.js";`)
|
|
344
|
+
.join("\n");
|
|
345
|
+
const arrayBody = sorted.map((_, i) => ` tool_${i}`).join(",\n");
|
|
346
|
+
return `${FOUNDATION_HEADER}
|
|
347
|
+
import type { ToolModule } from "../contract.js";
|
|
348
|
+
|
|
349
|
+
${imports}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* The full set of OpenAPI-derived foundation tools, ordered alphabetically
|
|
353
|
+
* by tool name. Stream C imports this and registers every entry with the
|
|
354
|
+
* MCP server's tools/list response.
|
|
355
|
+
*/
|
|
356
|
+
export const foundationTools: ReadonlyArray<ToolModule> = [
|
|
357
|
+
${arrayBody},
|
|
358
|
+
];
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Write tool files + index to disk. Idempotent: clears the output directory
|
|
363
|
+
* first so stale tools from previous runs don't linger.
|
|
364
|
+
*
|
|
365
|
+
* Returns the list of FoundationTool produced, identical to what `generate()`
|
|
366
|
+
* would have returned for the same options.
|
|
367
|
+
*/
|
|
368
|
+
export function regenerate(options = {}) {
|
|
369
|
+
const tools = generate(options);
|
|
370
|
+
const outDir = defaultFoundationDir();
|
|
371
|
+
if (existsSync(outDir)) {
|
|
372
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
373
|
+
}
|
|
374
|
+
mkdirSync(outDir, { recursive: true });
|
|
375
|
+
for (const tool of tools) {
|
|
376
|
+
const filePath = join(outDir, `${tool.name}.ts`);
|
|
377
|
+
writeFileSync(filePath, renderToolFile(tool), "utf8");
|
|
378
|
+
}
|
|
379
|
+
writeFileSync(join(outDir, "index.ts"), renderIndex(tools), "utf8");
|
|
380
|
+
return tools;
|
|
381
|
+
}
|
|
382
|
+
function defaultFoundationDir() {
|
|
383
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
384
|
+
return resolve(here, "../tools/foundation");
|
|
385
|
+
}
|
|
386
|
+
// -----------------------------------------------------------------------------
|
|
387
|
+
// CLI entry — `npm run regen-foundation-tools`
|
|
388
|
+
// -----------------------------------------------------------------------------
|
|
389
|
+
const isDirectInvocation = (() => {
|
|
390
|
+
try {
|
|
391
|
+
const entry = process.argv[1];
|
|
392
|
+
if (!entry)
|
|
393
|
+
return false;
|
|
394
|
+
// Compare absolute paths: import.meta.url is `file://...`, argv[1] is fs path.
|
|
395
|
+
const here = fileURLToPath(import.meta.url);
|
|
396
|
+
const entryAbs = resolve(entry);
|
|
397
|
+
return here === entryAbs;
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
})();
|
|
403
|
+
if (isDirectInvocation) {
|
|
404
|
+
const tools = regenerate();
|
|
405
|
+
const tierCount = { tier1: 0, tier2: 0, tier3: 0 };
|
|
406
|
+
for (const t of tools)
|
|
407
|
+
tierCount[t.tier] += 1;
|
|
408
|
+
// eslint-disable-next-line no-console
|
|
409
|
+
console.log(`[w6/foundation] emitted ${tools.length} tools — tier1=${tierCount.tier1} tier2=${tierCount.tier2} tier3=${tierCount.tier3}`);
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=fromOpenApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromOpenApi.js","sourceRoot":"","sources":["../../src/generator/fromOpenApi.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+BAA+B;AAC/B,sBAAsB;AACtB,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,wEAAwE;AACxE,+EAA+E;AAC/E,8EAA8E;AAC9E,uEAAuE;AACvE,8DAA8D;AAC9D,+DAA+D;AAC/D,+CAA+C;AAC/C,8EAA8E;AAC9E,EAAE;AACF,WAAW;AACX,wEAAwE;AACxE,mEAAmE;AACnE,uEAAuE;AACvE,wEAAwE;AACxE,EAAE;AACF,qEAAqE;AACrE,yEAAyE;AACzE,gFAAgF;AAEhF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,E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AAE,CAAC;IAC3B,MAAM,SAAS,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAA0B,CAAC;IAC3E,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,sCAAsC;IACtC,OAAO,CAAC,GAAG,CACT,2BAA2B,KAAK,CAAC,MAAM,kBAAkB,SAAS,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,EAAE,CAC7H,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
interface OpenApiSchema {
|
|
2
|
+
readonly type?: string;
|
|
3
|
+
readonly format?: string;
|
|
4
|
+
readonly enum?: ReadonlyArray<unknown>;
|
|
5
|
+
readonly items?: OpenApiSchema;
|
|
6
|
+
readonly properties?: Readonly<Record<string, OpenApiSchema>>;
|
|
7
|
+
readonly required?: ReadonlyArray<string>;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly nullable?: boolean;
|
|
10
|
+
readonly $ref?: string;
|
|
11
|
+
readonly oneOf?: ReadonlyArray<OpenApiSchema>;
|
|
12
|
+
readonly anyOf?: ReadonlyArray<OpenApiSchema>;
|
|
13
|
+
readonly allOf?: ReadonlyArray<OpenApiSchema>;
|
|
14
|
+
readonly default?: unknown;
|
|
15
|
+
}
|
|
16
|
+
interface OpenApiParameter {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly in: "path" | "query" | "header" | "cookie";
|
|
19
|
+
readonly required?: boolean;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly schema?: OpenApiSchema;
|
|
22
|
+
}
|
|
23
|
+
interface OpenApiRequestBody {
|
|
24
|
+
readonly required?: boolean;
|
|
25
|
+
readonly description?: string;
|
|
26
|
+
readonly content?: Readonly<Record<string, {
|
|
27
|
+
readonly schema?: OpenApiSchema;
|
|
28
|
+
}>>;
|
|
29
|
+
}
|
|
30
|
+
export interface SchemaContext {
|
|
31
|
+
/** All component schemas, keyed by name. Used to resolve `$ref`. */
|
|
32
|
+
readonly components: Readonly<Record<string, OpenApiSchema>>;
|
|
33
|
+
/** Cycle guard — if we re-enter the same $ref, we emit `z.unknown()`. */
|
|
34
|
+
readonly visiting?: ReadonlyArray<string>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Emit a Zod source-code expression for a single OpenAPI schema.
|
|
38
|
+
* Returns just the expression — no leading whitespace, no trailing semicolon.
|
|
39
|
+
*
|
|
40
|
+
* `nullable` and `optional` modifiers are NOT applied here — callers (notably
|
|
41
|
+
* `objectFromProperties`) decide per-field whether to chain `.optional()` /
|
|
42
|
+
* `.nullable()` based on the parent's `required[]` array.
|
|
43
|
+
*/
|
|
44
|
+
export declare function schemaToZodSource(schema: OpenApiSchema | undefined, ctx: SchemaContext): string;
|
|
45
|
+
export interface ToolParameterShape {
|
|
46
|
+
/** Source code for `z.object({ ... })` covering path params. */
|
|
47
|
+
readonly pathExpr: string | null;
|
|
48
|
+
/** Source code for `z.object({ ... })` covering query params. */
|
|
49
|
+
readonly queryExpr: string | null;
|
|
50
|
+
/** Source code for the request body Zod expression. May already be optional. */
|
|
51
|
+
readonly bodyExpr: string | null;
|
|
52
|
+
/** True if the operation declares a request body. */
|
|
53
|
+
readonly hasBody: boolean;
|
|
54
|
+
/** Whether the body is required. */
|
|
55
|
+
readonly bodyRequired: boolean;
|
|
56
|
+
/** Whether at least one query param is required. */
|
|
57
|
+
readonly hasRequiredQuery: boolean;
|
|
58
|
+
/** Path parameter names, in declared order. */
|
|
59
|
+
readonly pathParamNames: ReadonlyArray<string>;
|
|
60
|
+
/** Query parameter names. */
|
|
61
|
+
readonly queryParamNames: ReadonlyArray<string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Build the per-tool inputSchema source. Output shape is always:
|
|
65
|
+
*
|
|
66
|
+
* z.object({
|
|
67
|
+
* path?: z.object({ ... }), // only if op has any path params
|
|
68
|
+
* query?: z.object({ ... }), // only if op has any query params
|
|
69
|
+
* body?: <body schema>, // only if op declares a requestBody
|
|
70
|
+
* })
|
|
71
|
+
*
|
|
72
|
+
* `.optional()` is chained on `path` only when ALL path params are
|
|
73
|
+
* non-required (rare); on `query` when no query param is required;
|
|
74
|
+
* on `body` when the requestBody is not declared as required.
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildToolInputSchema(parameters: ReadonlyArray<OpenApiParameter>, requestBody: OpenApiRequestBody | null, ctx: SchemaContext): {
|
|
77
|
+
source: string;
|
|
78
|
+
shape: ToolParameterShape;
|
|
79
|
+
};
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=schemaToZod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaToZod.d.ts","sourceRoot":"","sources":["../../src/generator/schemaToZod.ts"],"names":[],"mappings":"AA2BA,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC9C,Q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