toolcraft 0.0.548 → 0.0.550

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.96",
101
+ "version": "0.1.97",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.548",
116
+ "version": "0.0.550",
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.548",
126
+ "version": "0.0.550",
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.96",
101
+ "version": "0.1.97",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.548",
116
+ "version": "0.0.550",
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.548",
126
+ "version": "0.0.550",
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.96",
21
+ "version": "0.1.97",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -1,46 +1,44 @@
1
1
  /** Copy credential JSON without invoking accessors or custom serialization. */
2
2
  export function copyBoundedOAuthJson(value, message) {
3
3
  const invalid = () => new Error(message);
4
- let nodes = 0;
5
- function copy(input, depth) {
6
- if (++nodes > 20_000 || depth > 64)
7
- throw invalid();
8
- if (input === null || typeof input === "boolean" || typeof input === "string")
9
- return input;
10
- if (typeof input === "number" && Number.isFinite(input))
11
- return input;
12
- if (typeof input !== "object" || input === null)
13
- throw invalid();
14
- const descriptors = Object.getOwnPropertyDescriptors(input);
15
- if (Array.isArray(input)) {
16
- const length = descriptors.length?.value;
17
- if (length > 20_000)
18
- throw invalid();
19
- const result = [];
20
- for (let index = 0; index < length; index++) {
21
- const descriptor = descriptors[String(index)];
22
- if (descriptor === undefined || !Object.hasOwn(descriptor, "value"))
4
+ const ancestors = new Set();
5
+ const root = {};
6
+ const tasks = [{ input: value, target: root, key: "value" }];
7
+ try {
8
+ while (tasks.length) {
9
+ const task = tasks.pop();
10
+ if ("leave" in task) {
11
+ ancestors.delete(task.leave);
12
+ continue;
13
+ }
14
+ const { input, target, key } = task;
15
+ let output = input;
16
+ if (input !== null && typeof input !== "boolean" && typeof input !== "string" &&
17
+ !(typeof input === "number" && Number.isFinite(input))) {
18
+ if (typeof input !== "object" || input === null || ancestors.has(input))
19
+ throw invalid();
20
+ const descriptors = Object.getOwnPropertyDescriptors(input);
21
+ const array = Array.isArray(input);
22
+ if (!array && Object.getPrototypeOf(input) !== Object.prototype && Object.getPrototypeOf(input) !== null)
23
23
  throw invalid();
24
- result.push(copy(descriptor.value, depth + 1));
24
+ output = array ? [] : {};
25
+ ancestors.add(input);
26
+ tasks.push({ leave: input });
27
+ const keys = array
28
+ ? Array.from({ length: input.length }, (_, index) => String(index))
29
+ : Object.keys(descriptors).filter(name => descriptors[name].enumerable);
30
+ for (let index = keys.length - 1; index >= 0; index--) {
31
+ const name = keys[index], descriptor = descriptors[name];
32
+ if (descriptor === undefined || !Object.hasOwn(descriptor, "value"))
33
+ throw invalid();
34
+ tasks.push({ input: descriptor.value, target: output, key: name });
35
+ }
25
36
  }
26
- return result;
37
+ Object.defineProperty(target, key, { value: output, enumerable: true, configurable: true, writable: true });
27
38
  }
28
- if (Object.getPrototypeOf(input) !== Object.prototype && Object.getPrototypeOf(input) !== null)
29
- throw invalid();
30
- return Object.fromEntries(Object.entries(descriptors).filter(([, descriptor]) => descriptor.enumerable).map(([key, descriptor]) => {
31
- if (!Object.hasOwn(descriptor, "value"))
32
- throw invalid();
33
- return [key, copy(descriptor.value, depth + 1)];
34
- }));
35
- }
36
- let result;
37
- try {
38
- result = copy(value, 0);
39
+ return root.value;
39
40
  }
40
41
  catch {
41
42
  throw invalid();
42
43
  }
43
- if (Buffer.byteLength(JSON.stringify(result), "utf8") > 64 * 1024)
44
- throw invalid();
45
- return result;
46
44
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.96",
3
+ "version": "0.1.97",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -216,59 +216,71 @@ function isJsonValue(value, options = {}) {
216
216
  const maxDepth = options.maxDepth ?? 64;
217
217
  if (maxNodes !== Infinity && (!Number.isSafeInteger(maxNodes) || maxNodes < 1))
218
218
  throw new Error("maxNodes must be a positive safe integer");
219
- if (!Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 256)
220
- throw new Error("maxDepth must be an integer between 0 and 256");
219
+ if (maxDepth !== Infinity && (!Number.isSafeInteger(maxDepth) || maxDepth < 0))
220
+ throw new Error("maxDepth must be a nonnegative safe integer");
221
221
  const ancestors = /* @__PURE__ */ new Set();
222
+ const stack = [];
223
+ function* properties(item2) {
224
+ if (Array.isArray(item2)) {
225
+ for (let index = 0; index < item2.length; index++)
226
+ yield Object.getOwnPropertyDescriptor(item2, String(index));
227
+ } else
228
+ for (const key2 in item2) {
229
+ const property = Object.getOwnPropertyDescriptor(item2, key2);
230
+ if (property !== void 0)
231
+ yield property;
232
+ }
233
+ }
222
234
  let nodes = 0;
223
- const visit = (item, depth) => {
235
+ let item = value, depth = 0;
236
+ while (true) {
224
237
  if (++nodes > maxNodes || depth > maxDepth)
225
238
  return false;
226
- if (item === null || typeof item === "string" || typeof item === "boolean")
227
- return true;
228
- if (typeof item === "number")
229
- return Number.isFinite(item);
230
- if (typeof item !== "object" || ancestors.has(item))
231
- return false;
232
- if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype && Object.getPrototypeOf(item) !== null)
233
- return false;
234
- let hookOwner = item;
235
- let prototypeDepth = 0;
236
- while (hookOwner !== null) {
237
- if (++prototypeDepth > 64)
238
- return false;
239
- const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
240
- if (serializationHook !== void 0) {
241
- if (!("value" in serializationHook) || typeof serializationHook.value === "function")
239
+ if (item !== null && typeof item !== "string" && typeof item !== "boolean") {
240
+ if (typeof item === "number") {
241
+ if (!Number.isFinite(item))
242
242
  return false;
243
- break;
244
- }
245
- hookOwner = Object.getPrototypeOf(hookOwner);
246
- }
247
- ancestors.add(item);
248
- let valid = true;
249
- if (Array.isArray(item)) {
250
- if (item.length > maxNodes)
251
- valid = false;
252
- else
253
- for (let index = 0; index < item.length; index++) {
254
- const property = Object.getOwnPropertyDescriptor(item, String(index));
255
- if (property === void 0 || !("value" in property) || !visit(property.value, depth + 1)) {
256
- valid = false;
243
+ } else {
244
+ if (typeof item !== "object" || ancestors.has(item))
245
+ return false;
246
+ if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype && Object.getPrototypeOf(item) !== null)
247
+ return false;
248
+ let hookOwner = item;
249
+ let prototypeDepth = 0;
250
+ while (hookOwner !== null) {
251
+ if (++prototypeDepth > 64)
252
+ return false;
253
+ const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
254
+ if (serializationHook !== void 0) {
255
+ if (!("value" in serializationHook) || typeof serializationHook.value === "function")
256
+ return false;
257
257
  break;
258
258
  }
259
+ hookOwner = Object.getPrototypeOf(hookOwner);
259
260
  }
260
- } else
261
- for (const key2 in item) {
262
- const property = Object.getOwnPropertyDescriptor(item, key2);
263
- if (property !== void 0 && (!("value" in property) || !visit(property.value, depth + 1))) {
264
- valid = false;
265
- break;
266
- }
261
+ if (Array.isArray(item) && item.length > maxNodes)
262
+ return false;
263
+ ancestors.add(item);
264
+ stack.push({ owner: item, children: properties(item), depth });
267
265
  }
268
- ancestors.delete(item);
269
- return valid;
270
- };
271
- return visit(value, 0);
266
+ }
267
+ let next;
268
+ while (stack.length) {
269
+ const frame = stack[stack.length - 1];
270
+ next = frame.children.next();
271
+ if (!next.done) {
272
+ if (next.value === void 0 || !("value" in next.value))
273
+ return false;
274
+ item = next.value.value;
275
+ depth = frame.depth + 1;
276
+ break;
277
+ }
278
+ ancestors.delete(frame.owner);
279
+ stack.pop();
280
+ }
281
+ if (!stack.length)
282
+ return true;
283
+ }
272
284
  }
273
285
 
274
286
  // ../toolcraft-schema/dist/json-schema/utils.js
@@ -3516,47 +3528,42 @@ async function waitForOAuthOperation(operation, signal) {
3516
3528
  // ../mcp-oauth/dist/client/bounded-json.js
3517
3529
  function copyBoundedOAuthJson(value, message) {
3518
3530
  const invalid = () => new Error(message);
3519
- let nodes = 0;
3520
- function copy(input, depth) {
3521
- if (++nodes > 2e4 || depth > 64)
3522
- throw invalid();
3523
- if (input === null || typeof input === "boolean" || typeof input === "string")
3524
- return input;
3525
- if (typeof input === "number" && Number.isFinite(input))
3526
- return input;
3527
- if (typeof input !== "object" || input === null)
3528
- throw invalid();
3529
- const descriptors = Object.getOwnPropertyDescriptors(input);
3530
- if (Array.isArray(input)) {
3531
- const length = descriptors.length?.value;
3532
- if (length > 2e4)
3533
- throw invalid();
3534
- const result2 = [];
3535
- for (let index = 0; index < length; index++) {
3536
- const descriptor = descriptors[String(index)];
3537
- if (descriptor === void 0 || !Object.hasOwn(descriptor, "value"))
3531
+ const ancestors = /* @__PURE__ */ new Set();
3532
+ const root = {};
3533
+ const tasks = [{ input: value, target: root, key: "value" }];
3534
+ try {
3535
+ while (tasks.length) {
3536
+ const task = tasks.pop();
3537
+ if ("leave" in task) {
3538
+ ancestors.delete(task.leave);
3539
+ continue;
3540
+ }
3541
+ const { input, target, key: key2 } = task;
3542
+ let output = input;
3543
+ if (input !== null && typeof input !== "boolean" && typeof input !== "string" && !(typeof input === "number" && Number.isFinite(input))) {
3544
+ if (typeof input !== "object" || input === null || ancestors.has(input))
3538
3545
  throw invalid();
3539
- result2.push(copy(descriptor.value, depth + 1));
3546
+ const descriptors = Object.getOwnPropertyDescriptors(input);
3547
+ const array = Array.isArray(input);
3548
+ if (!array && Object.getPrototypeOf(input) !== Object.prototype && Object.getPrototypeOf(input) !== null)
3549
+ throw invalid();
3550
+ output = array ? [] : {};
3551
+ ancestors.add(input);
3552
+ tasks.push({ leave: input });
3553
+ const keys = array ? Array.from({ length: input.length }, (_, index) => String(index)) : Object.keys(descriptors).filter((name) => descriptors[name].enumerable);
3554
+ for (let index = keys.length - 1; index >= 0; index--) {
3555
+ const name = keys[index], descriptor = descriptors[name];
3556
+ if (descriptor === void 0 || !Object.hasOwn(descriptor, "value"))
3557
+ throw invalid();
3558
+ tasks.push({ input: descriptor.value, target: output, key: name });
3559
+ }
3540
3560
  }
3541
- return result2;
3561
+ Object.defineProperty(target, key2, { value: output, enumerable: true, configurable: true, writable: true });
3542
3562
  }
3543
- if (Object.getPrototypeOf(input) !== Object.prototype && Object.getPrototypeOf(input) !== null)
3544
- throw invalid();
3545
- return Object.fromEntries(Object.entries(descriptors).filter(([, descriptor]) => descriptor.enumerable).map(([key2, descriptor]) => {
3546
- if (!Object.hasOwn(descriptor, "value"))
3547
- throw invalid();
3548
- return [key2, copy(descriptor.value, depth + 1)];
3549
- }));
3550
- }
3551
- let result;
3552
- try {
3553
- result = copy(value, 0);
3563
+ return root.value;
3554
3564
  } catch {
3555
3565
  throw invalid();
3556
3566
  }
3557
- if (Buffer.byteLength(JSON.stringify(result), "utf8") > 64 * 1024)
3558
- throw invalid();
3559
- return result;
3560
3567
  }
3561
3568
 
3562
3569
  // ../mcp-oauth/dist/client/loopback-authorization.js
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.548",
11
+ "version": "0.0.550",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -10,59 +10,72 @@ export function isJsonValue(value, options = {}) {
10
10
  const maxDepth = options.maxDepth ?? 64;
11
11
  if (maxNodes !== Infinity && (!Number.isSafeInteger(maxNodes) || maxNodes < 1))
12
12
  throw new Error("maxNodes must be a positive safe integer");
13
- if (!Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 256)
14
- throw new Error("maxDepth must be an integer between 0 and 256");
13
+ if (maxDepth !== Infinity && (!Number.isSafeInteger(maxDepth) || maxDepth < 0))
14
+ throw new Error("maxDepth must be a nonnegative safe integer");
15
15
  const ancestors = new Set();
16
+ const stack = [];
17
+ function* properties(item) {
18
+ if (Array.isArray(item)) {
19
+ for (let index = 0; index < item.length; index++)
20
+ yield Object.getOwnPropertyDescriptor(item, String(index));
21
+ }
22
+ else
23
+ for (const key in item) {
24
+ const property = Object.getOwnPropertyDescriptor(item, key);
25
+ if (property !== undefined)
26
+ yield property;
27
+ }
28
+ }
16
29
  let nodes = 0;
17
- const visit = (item, depth) => {
30
+ let item = value, depth = 0;
31
+ while (true) {
18
32
  if (++nodes > maxNodes || depth > maxDepth)
19
33
  return false;
20
- if (item === null || typeof item === "string" || typeof item === "boolean")
21
- return true;
22
- if (typeof item === "number")
23
- return Number.isFinite(item);
24
- if (typeof item !== "object" || ancestors.has(item))
25
- return false;
26
- if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype &&
27
- Object.getPrototypeOf(item) !== null)
28
- return false;
29
- let hookOwner = item;
30
- let prototypeDepth = 0;
31
- while (hookOwner !== null) {
32
- if (++prototypeDepth > 64)
33
- return false;
34
- const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
35
- if (serializationHook !== undefined) {
36
- if (!("value" in serializationHook) || typeof serializationHook.value === "function")
34
+ if (item !== null && typeof item !== "string" && typeof item !== "boolean") {
35
+ if (typeof item === "number") {
36
+ if (!Number.isFinite(item))
37
37
  return false;
38
- break;
39
38
  }
40
- hookOwner = Object.getPrototypeOf(hookOwner);
41
- }
42
- ancestors.add(item);
43
- let valid = true;
44
- if (Array.isArray(item)) {
45
- if (item.length > maxNodes)
46
- valid = false;
47
- else
48
- for (let index = 0; index < item.length; index++) {
49
- const property = Object.getOwnPropertyDescriptor(item, String(index));
50
- if (property === undefined || !("value" in property) || !visit(property.value, depth + 1)) {
51
- valid = false;
39
+ else {
40
+ if (typeof item !== "object" || ancestors.has(item))
41
+ return false;
42
+ if (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype &&
43
+ Object.getPrototypeOf(item) !== null)
44
+ return false;
45
+ let hookOwner = item;
46
+ let prototypeDepth = 0;
47
+ while (hookOwner !== null) {
48
+ if (++prototypeDepth > 64)
49
+ return false;
50
+ const serializationHook = Object.getOwnPropertyDescriptor(hookOwner, "toJSON");
51
+ if (serializationHook !== undefined) {
52
+ if (!("value" in serializationHook) || typeof serializationHook.value === "function")
53
+ return false;
52
54
  break;
53
55
  }
56
+ hookOwner = Object.getPrototypeOf(hookOwner);
54
57
  }
58
+ if (Array.isArray(item) && item.length > maxNodes)
59
+ return false;
60
+ ancestors.add(item);
61
+ stack.push({ owner: item, children: properties(item), depth });
62
+ }
55
63
  }
56
- else
57
- for (const key in item) {
58
- const property = Object.getOwnPropertyDescriptor(item, key);
59
- if (property !== undefined && (!("value" in property) || !visit(property.value, depth + 1))) {
60
- valid = false;
61
- break;
62
- }
64
+ let next;
65
+ while (stack.length) {
66
+ const frame = stack[stack.length - 1];
67
+ next = frame.children.next();
68
+ if (!next.done) {
69
+ if (next.value === undefined || !("value" in next.value))
70
+ return false;
71
+ item = next.value.value;
72
+ depth = frame.depth + 1;
73
+ break;
63
74
  }
64
- ancestors.delete(item);
65
- return valid;
66
- };
67
- return visit(value, 0);
75
+ ancestors.delete(frame.owner);
76
+ stack.pop();
77
+ }
78
+ if (!stack.length)
79
+ return true;
80
+ }
68
81
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.548",
3
+ "version": "0.0.550",
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.548",
3
+ "version": "0.0.550",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -162,7 +162,7 @@
162
162
  "yaml"
163
163
  ],
164
164
  "optionalDependencies": {
165
- "toolcraft-schema": "0.0.548",
165
+ "toolcraft-schema": "0.0.550",
166
166
  "toolcraft-design": "*",
167
167
  "@poe-code/frontmatter": "*",
168
168
  "@poe-code/agent-mcp-config": "*",