@suveren/gateway 0.11.1 → 0.11.2

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.
@@ -1885,7 +1885,7 @@ var SharedState = class {
1885
1885
 
1886
1886
  // src/index.ts
1887
1887
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1888
- import { z } from "zod";
1888
+ import { z as z2 } from "zod";
1889
1889
 
1890
1890
  // src/lib/mandate-brief.ts
1891
1891
  import { getProfile } from "@hap/core";
@@ -3960,45 +3960,83 @@ ${lines.join("\n")}`
3960
3960
  };
3961
3961
  }
3962
3962
 
3963
- // src/index.ts
3964
- function jsonSchemaToZodShape(schema) {
3965
- const properties = schema.properties ?? {};
3966
- const required = new Set(schema.required ?? []);
3967
- const shape = {};
3968
- for (const [key, prop] of Object.entries(properties)) {
3969
- let zodType;
3970
- switch (prop.type) {
3971
- case "string":
3972
- if (prop.enum && Array.isArray(prop.enum)) {
3973
- zodType = z.enum(prop.enum);
3974
- } else {
3975
- zodType = z.string();
3976
- }
3977
- break;
3978
- case "number":
3979
- case "integer":
3980
- zodType = z.number();
3981
- break;
3982
- case "boolean":
3983
- zodType = z.boolean();
3984
- break;
3985
- case "array":
3986
- zodType = z.array(z.unknown());
3987
- break;
3988
- case "object":
3989
- zodType = z.record(z.unknown());
3990
- break;
3991
- default:
3992
- zodType = z.unknown();
3963
+ // src/lib/json-schema-to-zod.ts
3964
+ import { z } from "zod";
3965
+ var MAX_DEPTH = 8;
3966
+ function convert(schema, depth) {
3967
+ if (!schema || typeof schema !== "object" || depth > MAX_DEPTH) return z.unknown();
3968
+ const s = schema;
3969
+ if ("$ref" in s) return withDescription(z.unknown(), s);
3970
+ let t;
3971
+ const type = Array.isArray(s.type) ? void 0 : s.type;
3972
+ switch (type) {
3973
+ case "string": {
3974
+ if (Array.isArray(s.enum) && s.enum.length > 0 && s.enum.every((v) => typeof v === "string")) {
3975
+ t = z.enum(s.enum);
3993
3976
  break;
3977
+ }
3978
+ let str = z.string();
3979
+ if (typeof s.minLength === "number") str = str.min(s.minLength);
3980
+ if (typeof s.maxLength === "number") str = str.max(s.maxLength);
3981
+ if (typeof s.pattern === "string") {
3982
+ try {
3983
+ str = str.regex(new RegExp(s.pattern));
3984
+ } catch {
3985
+ }
3986
+ }
3987
+ t = str;
3988
+ break;
3994
3989
  }
3995
- if (typeof prop.description === "string") {
3996
- zodType = zodType.describe(prop.description);
3990
+ case "number":
3991
+ case "integer": {
3992
+ let num = z.number();
3993
+ if (type === "integer") num = num.int();
3994
+ if (typeof s.minimum === "number") num = num.min(s.minimum);
3995
+ if (typeof s.maximum === "number") num = num.max(s.maximum);
3996
+ t = num;
3997
+ break;
3998
+ }
3999
+ case "boolean":
4000
+ t = z.boolean();
4001
+ break;
4002
+ case "array": {
4003
+ let arr = z.array(s.items ? convert(s.items, depth + 1) : z.unknown());
4004
+ if (typeof s.minItems === "number") arr = arr.min(s.minItems);
4005
+ if (typeof s.maxItems === "number") arr = arr.max(s.maxItems);
4006
+ t = arr;
4007
+ break;
4008
+ }
4009
+ case "object": {
4010
+ if (s.properties && typeof s.properties === "object") {
4011
+ t = z.object(shapeOf(s, depth + 1)).passthrough();
4012
+ } else {
4013
+ t = z.record(z.unknown());
4014
+ }
4015
+ break;
3997
4016
  }
3998
- shape[key] = required.has(key) ? zodType : zodType.optional();
4017
+ default:
4018
+ t = z.unknown();
4019
+ }
4020
+ return withDescription(t, s);
4021
+ }
4022
+ function withDescription(t, s) {
4023
+ return typeof s.description === "string" ? t.describe(s.description) : t;
4024
+ }
4025
+ function shapeOf(schema, depth) {
4026
+ const properties = schema.properties ?? {};
4027
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
4028
+ const shape = {};
4029
+ for (const [key, prop] of Object.entries(properties)) {
4030
+ const t = convert(prop, depth);
4031
+ shape[key] = required.has(key) ? t : t.optional();
3999
4032
  }
4000
4033
  return shape;
4001
4034
  }
4035
+ function jsonSchemaToZodShape(schema) {
4036
+ return shapeOf(schema ?? {}, 1);
4037
+ }
4038
+
4039
+ // src/index.ts
4002
4040
  function createMcpServer(state2, integrationManager2) {
4003
4041
  const { cache } = state2;
4004
4042
  const enriched = state2.getEnrichedAuthorizations();
@@ -4016,7 +4054,7 @@ function createMcpServer(state2, integrationManager2) {
4016
4054
  {
4017
4055
  description: 'List what you are currently authorized to do. Call with no arguments for a compact overview, or with a domain (e.g., "charge") for full details including consumption, bounds, and capability map.',
4018
4056
  inputSchema: {
4019
- domain: z.string().optional().describe('Profile domain to show full details for (e.g., "charge", "deploy"). Omit for compact overview.')
4057
+ domain: z2.string().optional().describe('Profile domain to show full details for (e.g., "charge", "deploy"). Omit for compact overview.')
4020
4058
  }
4021
4059
  },
4022
4060
  listAuthorizationsHandler(state2, integrationManager2)
@@ -4026,7 +4064,7 @@ function createMcpServer(state2, integrationManager2) {
4026
4064
  {
4027
4065
  description: "Check if any attestations are waiting for your owner's approval.",
4028
4066
  inputSchema: {
4029
- domain: z.string().describe(`The owner's domain (e.g., "compliance")`)
4067
+ domain: z2.string().describe(`The owner's domain (e.g., "compliance")`)
4030
4068
  }
4031
4069
  },
4032
4070
  checkPendingHandler(cache)
@@ -4044,7 +4082,7 @@ function createMcpServer(state2, integrationManager2) {
4044
4082
  {
4045
4083
  description: "Check status of pending proposals awaiting domain owner commitment. Call with a proposal_id to check a specific proposal, or without to see all.",
4046
4084
  inputSchema: {
4047
- proposal_id: z.string().optional().describe("Specific proposal ID to check. Omit to see all.")
4085
+ proposal_id: z2.string().optional().describe("Specific proposal ID to check. Omit to see all.")
4048
4086
  }
4049
4087
  },
4050
4088
  checkPendingCommitmentsHandler(state2, integrationManager2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suveren/gateway",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Suveren gateway — local agent gateway built in compliance with the Human Agency Protocol (HAP). Runs the UI, control plane, and MCP server in one Node process.",
5
5
  "type": "module",
6
6
  "main": "server.js",