toolcraft 0.0.307 → 0.0.308

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/composition.json CHANGED
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.22",
101
+ "version": "0.1.23",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.307",
116
+ "version": "0.0.308",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.307",
126
+ "version": "0.0.308",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.22",
101
+ "version": "0.1.23",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.307",
116
+ "version": "0.0.308",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.307",
126
+ "version": "0.0.308",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.22",
21
+ "version": "0.1.23",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -152,11 +152,17 @@ var HttpResponseMessages = class {
152
152
  };
153
153
 
154
154
  // ../toolcraft-schema/dist/json.js
155
- function isJsonValue(value) {
155
+ function isJsonValue(value, options = {}) {
156
+ const maxNodes = options.maxNodes ?? 1e4;
157
+ const maxDepth = options.maxDepth ?? 64;
158
+ if (!Number.isSafeInteger(maxNodes) || maxNodes < 1)
159
+ throw new Error("maxNodes must be a positive safe integer");
160
+ if (!Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 256)
161
+ throw new Error("maxDepth must be an integer between 0 and 256");
156
162
  const ancestors = /* @__PURE__ */ new Set();
157
163
  let nodes = 0;
158
164
  const visit = (item, depth) => {
159
- if (++nodes > 1e4 || depth > 64)
165
+ if (++nodes > maxNodes || depth > maxDepth)
160
166
  return false;
161
167
  if (item === null || typeof item === "string" || typeof item === "boolean")
162
168
  return true;
@@ -182,7 +188,7 @@ function isJsonValue(value) {
182
188
  ancestors.add(item);
183
189
  let valid = true;
184
190
  if (Array.isArray(item)) {
185
- if (item.length > 1e4)
191
+ if (item.length > maxNodes)
186
192
  valid = false;
187
193
  else
188
194
  for (let index = 0; index < item.length; index++) {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.307",
11
+ "version": "0.0.308",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -94,6 +94,13 @@ validate the complete object to enforce branch-dependent and combined constraint
94
94
  Both functions accept a `registry` for external schema documents without network
95
95
  fetching.
96
96
 
97
+ `isJsonValue(value, options)` checks JSON data without invoking getters or
98
+ serialization hooks. It rejects cycles, sparse arrays, non-finite numbers and
99
+ non-JSON prototypes. Defaults bound the tree to 10,000 nodes and depth 64.
100
+ Use `maxNodes` for larger bounded documents, or `maxDepth` (0–256) to choose a
101
+ depth budget. Shared objects count once for each occurrence in the JSON tree;
102
+ options never change other calls' budgets.
103
+
97
104
  ## Environment Variables
98
105
 
99
106
  This package exposes no environment variables.
@@ -182,6 +182,7 @@ export declare function toJsonSchema(schema: AnySchema): JsonSchema;
182
182
  export declare function toJsonSchemaDocument(schema: AnySchema, options?: JsonSchemaDocumentOptions): JsonSchemaDocument;
183
183
  export { Json, OneOf, RecordBuilder as Record, Union, isPlainRecord, validate };
184
184
  export { isJsonValue } from "./json.js";
185
+ export type { JsonValueValidationOptions } from "./json.js";
185
186
  export { cloneDefaultValue } from "./clone-default.js";
186
187
  export { unicodeLength } from "./json-schema/utils.js";
187
188
  export { compileJsonSchema, formatIssues } from "./json-schema/index.js";
@@ -9,5 +9,9 @@ export interface JsonValueSchema extends SchemaBase<"json", JsonValue> {
9
9
  readonly enum?: readonly JsonValue[];
10
10
  }
11
11
  export declare function Json(options?: Omit<JsonValueSchema, "kind">): JsonValueSchema;
12
- export declare function isJsonValue(value: unknown): boolean;
12
+ export interface JsonValueValidationOptions {
13
+ readonly maxNodes?: number;
14
+ readonly maxDepth?: number;
15
+ }
16
+ export declare function isJsonValue(value: unknown, options?: JsonValueValidationOptions): boolean;
13
17
  export {};
@@ -4,11 +4,17 @@ export function Json(options = {}) {
4
4
  ...options,
5
5
  };
6
6
  }
7
- export function isJsonValue(value) {
7
+ export function isJsonValue(value, options = {}) {
8
+ const maxNodes = options.maxNodes ?? 10_000;
9
+ const maxDepth = options.maxDepth ?? 64;
10
+ if (!Number.isSafeInteger(maxNodes) || maxNodes < 1)
11
+ throw new Error("maxNodes must be a positive safe integer");
12
+ if (!Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 256)
13
+ throw new Error("maxDepth must be an integer between 0 and 256");
8
14
  const ancestors = new Set();
9
15
  let nodes = 0;
10
16
  const visit = (item, depth) => {
11
- if (++nodes > 10_000 || depth > 64)
17
+ if (++nodes > maxNodes || depth > maxDepth)
12
18
  return false;
13
19
  if (item === null || typeof item === "string" || typeof item === "boolean")
14
20
  return true;
@@ -35,7 +41,7 @@ export function isJsonValue(value) {
35
41
  ancestors.add(item);
36
42
  let valid = true;
37
43
  if (Array.isArray(item)) {
38
- if (item.length > 10_000)
44
+ if (item.length > maxNodes)
39
45
  valid = false;
40
46
  else
41
47
  for (let index = 0; index < item.length; index++) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.307",
3
+ "version": "0.0.308",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.307",
3
+ "version": "0.0.308",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.307",
161
+ "toolcraft-schema": "0.0.308",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",