@sidecar-ai/cli 0.1.0-alpha.15 → 0.1.0-alpha.16

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/dist/index.js CHANGED
@@ -532,9 +532,18 @@ function typeToJsonSchemaInner(type) {
532
532
  if (type.isUnion()) {
533
533
  const parts = type.getUnionTypes().filter((part) => !part.isUndefined());
534
534
  if (parts.every(isLiteralType)) {
535
- return { enum: parts.map((part) => literalValue(part)) };
535
+ return { enum: [...new Set(parts.map((part) => literalValue(part)))] };
536
536
  }
537
- return { anyOf: parts.map((part) => typeToJsonSchema(part)) };
537
+ const schemas = deduplicateSchemas(
538
+ parts.map((part) => typeToJsonSchema(part))
539
+ );
540
+ if (schemas.length === 1) {
541
+ return schemas[0];
542
+ }
543
+ return {
544
+ ...schemas.every((schema) => schema.type === "object") ? { type: "object" } : {},
545
+ anyOf: schemas
546
+ };
538
547
  }
539
548
  const properties = type.getProperties();
540
549
  const indexType = type.getStringIndexType() ?? type.getNumberIndexType();
@@ -549,6 +558,37 @@ function typeToJsonSchemaInner(type) {
549
558
  }
550
559
  return {};
551
560
  }
561
+ function deduplicateSchemas(schemas) {
562
+ const seen = /* @__PURE__ */ new Set();
563
+ return schemas.filter((schema) => {
564
+ const key = schemaComparisonKey(schema);
565
+ if (seen.has(key)) {
566
+ return false;
567
+ }
568
+ seen.add(key);
569
+ return true;
570
+ });
571
+ }
572
+ function schemaComparisonKey(schema) {
573
+ return JSON.stringify(canonicalSchemaValue(schema));
574
+ }
575
+ function canonicalSchemaValue(value, keyword) {
576
+ if (Array.isArray(value)) {
577
+ const values = value.map((item) => canonicalSchemaValue(item));
578
+ if (keyword === "allOf" || keyword === "anyOf" || keyword === "enum" || keyword === "oneOf" || keyword === "required" || keyword === "type") {
579
+ return values.sort(
580
+ (left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right))
581
+ );
582
+ }
583
+ return values;
584
+ }
585
+ if (value && typeof value === "object") {
586
+ return Object.fromEntries(
587
+ Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, canonicalSchemaValue(entry, key)])
588
+ );
589
+ }
590
+ return value;
591
+ }
552
592
  function objectTypeToSchema(properties, indexType) {
553
593
  const schemaProperties = {};
554
594
  const required = [];
@@ -3934,7 +3974,11 @@ import { randomUUID } from "crypto";
3934
3974
  import { JSONRPC_VERSION } from "@modelcontextprotocol/sdk/types.js";
3935
3975
 
3936
3976
  // packages/server/src/index.ts
3937
- import { JSONRPC_VERSION as JSONRPC_VERSION2 } from "@modelcontextprotocol/sdk/types.js";
3977
+ import {
3978
+ JSONRPC_VERSION as JSONRPC_VERSION2,
3979
+ LATEST_PROTOCOL_VERSION,
3980
+ SUPPORTED_PROTOCOL_VERSIONS
3981
+ } from "@modelcontextprotocol/sdk/types.js";
3938
3982
  var CODE_MODE_CALLBACK_TOKEN_TTL_MS = 5 * 60 * 1e3;
3939
3983
 
3940
3984
  // packages/cli/src/dev-harness.ts